How to use the bitcore.Address function in bitcore

To help you get started, we’ve selected a few bitcore examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AltCoinExchange / altcoin-atomic-trading-platform / legacy / btcatomicswap / dist / contract / build-contract.js View on Github external
return regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            PK = PrivateKey.fromWIF(privateKey);
            refundAddr = PK.toPublicKey().toAddress(_config.configuration.network);
            themAddr = new Address(them);
            contract = (0, _atomicSwapContract.atomicSwapContract)(refundAddr.toJSON().hash, themAddr.toJSON().hash, lockTime, secretHash);
            contractP2SH = _addressUtil.AddressUtil.NewAddressScriptHash(contract.toHex(), _config.configuration.network);
            contractP2SHPkScript = Script.buildScriptHashOut(contractP2SH);
            contractTx = new Transaction();
            value = Math.round(amount * 100000000);
            // console.log(value);

            output = Transaction.Output({
              script: contractP2SHPkScript,
              satoshis: value
            });

            contractTx.addOutput(output);

            _context.next = 12;
            return (0, _fundTransaction.fundTransaction)(refundAddr, contractTx);
github moneybutton / yours-core / lib / contentstore.js View on Github external
ContentStore.prototype.getContentByUserAddress = q.promised(function getContentByUserAddress (userAddress) {
  // construct Address even if already in string form to validate
  userAddress = (new bitcore.Address(userAddress)).toString()

  return Content.fromObjects(
    this._queryForContent({'owner_address': userAddress})
  )
})
github bitpay / bitcore-node / test / services / address / index.unit.js View on Github external
it('should unsubscribe from all addresses if no addresses are specified', function() {
      var am = new AddressService({node: mocknode});
      var emitter = new EventEmitter();
      var emitter2 = new EventEmitter();
      var address1 = bitcore.Address('1KiW1A4dx1oRgLHtDtBjcunUGkYtFgZ1W');
      var hashHex1 = address1.hashBuffer.toString('hex');
      var address2 = bitcore.Address('1DzjESe6SLmAKVPLFMj6Sx1sWki3qt5i8N');
      var hashHex2 = address2.hashBuffer.toString('hex');
      am.subscriptions['address/balance'][hashHex1] = [emitter, emitter2];
      am.subscriptions['address/balance'][hashHex2] = [emitter2, emitter];
      am.unsubscribe('address/balance', emitter);
      am.subscriptions['address/balance'][hashHex1].should.deep.equal([emitter2]);
      am.subscriptions['address/balance'][hashHex2].should.deep.equal([emitter2]);
    });
  });
github bitpay / bitcore-node / test / services / address / index.unit.js View on Github external
it('will emit a balance if there is a subscriber', function(done) {
      var am = new AddressService({node: mocknode});
      var emitter = new EventEmitter();
      var address = bitcore.Address('1DzjESe6SLmAKVPLFMj6Sx1sWki3qt5i8N');
      am.subscriptions['address/balance'][address.hashBuffer.toString('hex')] = [emitter];
      var block = {};
      var balance = 1000;
      am.getBalance = sinon.stub().callsArgWith(2, null, balance);
      emitter.on('address/balance', function(a, bal, b) {
        a.toString().should.equal('1DzjESe6SLmAKVPLFMj6Sx1sWki3qt5i8N');
        bal.should.equal(balance);
        b.should.equal(block);
        done();
      });
      am.balanceEventHandler(block, {
        hashHex: address.hashBuffer.toString('hex'),
        hashBuffer: address.hashBuffer,
        addressType: address.type
      });
    });
github bitpay / bitcore-node / test / services / address / index.unit.js View on Github external
it('will add emitters to the subscribers array (transaction)', function() {
      var am = new AddressService({node: mocknode});
      var emitter = new EventEmitter();

      var address = bitcore.Address('1DzjESe6SLmAKVPLFMj6Sx1sWki3qt5i8N');
      var name = 'address/transaction';
      am.subscribe(name, emitter, [address]);
      am.subscriptions['address/transaction'][address.hashBuffer.toString('hex')]
        .should.deep.equal([emitter]);

      var address2 = bitcore.Address('1KiW1A4dx1oRgLHtDtBjcunUGkYtFgZ1W');
      am.subscribe(name, emitter, [address2]);
      am.subscriptions['address/transaction'][address2.hashBuffer.toString('hex')]
        .should.deep.equal([emitter]);

      var emitter2 = new EventEmitter();
      am.subscribe(name, emitter2, [address]);
      am.subscriptions['address/transaction'][address.hashBuffer.toString('hex')]
        .should.deep.equal([emitter, emitter2]);
    });
    it('will add an emitter to the subscribers array (balance)', function() {
github bitpay / bitcore-node / test / services / address / index.unit.js View on Github external
describe('#getOutputs', function() {
    var am;
    var address = '1KiW1A4dx1oRgLHtDtBjcunUGkYtFgZ1W';
    var hashHex = bitcore.Address('1KiW1A4dx1oRgLHtDtBjcunUGkYtFgZ1W').hashBuffer.toString('hex');
    var db = {
      tip: {
        __height: 1
      }
    };
    var testnode = {
      services: {
        db: db,
        bitcoind: {
          on: sinon.stub()
        }
      }
    };
    var options = {
      queryMempool: true
    };
github bitpay / bitcore-channel / examples / refund.js View on Github external
network: 'testnet'
})

var Consumer = require('../lib/Consumer');

var con = new Consumer({network: 'testnet', serverPublicKey: proKey, refundAddress: 'mqB4k1cqzfojmoa7PzyMSksM17gUpSTe6n', commitmentKey: conKey, fundingKey: fundingKey});
con.fundingAddress.toString();
con.commitmentTx.getAddress().toString()


var Refund = require('../lib/transactions/Refund');

var opts = {
  multisigOut: {"address":"2NGPp3oYGmpFokw4ZWux2jJU39i8zwfmTK5","txid":"17bb6b3f8f90a3aa7abd2ee4c3db7bc95a01bc9acd6cd919b2ac8eac367cfc7a","vout":1,"ts":1416181250,"scriptPubKey":"a914fdeaa734587dfed0090c98fbf1bf8730009ddda887","amount":0.009,"confirmationsFromCache":false},
  amount: 100000,
  refundAddress: new bitcore.Address('mrCHmWgn54hJNty2srFF4XLmkey5GnCv5m'),
  network: 'testnet',
  pubKeys: con.commitmentTx.pubkeys,
  lockTime: 1
}
var e = new Refund(opts);

var conWalletKey = new bitcore.WalletKey({
  privKey: conKey,
  network: bitcore.networks['testnet']
});

var proWalletKey = new bitcore.WalletKey({
  privKey: proKey,
  network: bitcore.networks['testnet']
});
github streamium / streamium / views / provider.html View on Github external
function checkValidAddress() {
        bitcore = require('bitcore');
        var address = new bitcore.Address($('#address').val());
        ADDRESS_VALID = address.isValid();

        $('#address').siblings('span').toggleClass('hide', false);

        var colorClass = ADDRESS_VALID ? 'has-success' : 'has-error';
        var iconClass = ADDRESS_VALID ? 'glyphicon-ok' : 'glyphicon-remove';

        $('#address').parent().removeClass('has-success').removeClass('has-error');
        $('#address').parent().addClass(colorClass);

        $('#address').siblings('span').toggleClass('hide', false);
        $('#address').siblings('span').removeClass('glyphicon-ok').removeClass('glyphicon-remove');
        $('#address').siblings('span').addClass(iconClass);

        checkFormValid();
      }