How to use the bitcoinjs-lib.HDNode.fromBase58 function in bitcoinjs-lib

To help you get started, we’ve selected a few bitcoinjs-lib 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 flow-typed / flow-typed / definitions / npm / bitcoinjs-lib_v2.x.x / test_bitcoinjs-lib_v2.x.x.js View on Github external
(new HDNode(pair): HDNode);

var bitcoinNetwork = {
  messagePrefix: '\x18Bitcoin Signed Message:\n',
  bip32: {
    public: 0x0488b21e,
    private: 0x0488ade4
  },
  pubKeyHash: 0x00,
  scriptHash: 0x05,
  wif: 0x80,
  dustThreshold: 546
};

(HDNode.fromBase58('xpub123'): HDNode);
(HDNode.fromBase58('xpub123', bitcoinNetwork): HDNode);

// $ExpectError
(HDNode.fromBase58(new Buffer(1)): HDNode);

(HDNode.fromBase58('xpub123', bitcoinNetwork).getAddress(): string);

var t: Transaction = Transaction.fromHex('1234');
var input = {
  script: new Buffer(1),
  hash: new Buffer(1),
  index: 1,
  sequence: 1
};

t.ins.push(input);
github flow-typed / flow-typed / definitions / npm / bitcoinjs-lib_v2.x.x / test_bitcoinjs-lib_v2.x.x.js View on Github external
messagePrefix: '\x18Bitcoin Signed Message:\n',
  bip32: {
    public: 0x0488b21e,
    private: 0x0488ade4
  },
  pubKeyHash: 0x00,
  scriptHash: 0x05,
  wif: 0x80,
  dustThreshold: 546
};

(HDNode.fromBase58('xpub123'): HDNode);
(HDNode.fromBase58('xpub123', bitcoinNetwork): HDNode);

// $ExpectError
(HDNode.fromBase58(new Buffer(1)): HDNode);

(HDNode.fromBase58('xpub123', bitcoinNetwork).getAddress(): string);

var t: Transaction = Transaction.fromHex('1234');
var input = {
  script: new Buffer(1),
  hash: new Buffer(1),
  index: 1,
  sequence: 1
};

t.ins.push(input);

// $ExpectError
t.addInput(input);
github flow-typed / flow-typed / definitions / npm / bitcoinjs-lib_v2.x.x / test_bitcoinjs-lib_v2.x.x.js View on Github external
public: 0x0488b21e,
    private: 0x0488ade4
  },
  pubKeyHash: 0x00,
  scriptHash: 0x05,
  wif: 0x80,
  dustThreshold: 546
};

(HDNode.fromBase58('xpub123'): HDNode);
(HDNode.fromBase58('xpub123', bitcoinNetwork): HDNode);

// $ExpectError
(HDNode.fromBase58(new Buffer(1)): HDNode);

(HDNode.fromBase58('xpub123', bitcoinNetwork).getAddress(): string);

var t: Transaction = Transaction.fromHex('1234');
var input = {
  script: new Buffer(1),
  hash: new Buffer(1),
  index: 1,
  sequence: 1
};

t.ins.push(input);

// $ExpectError
t.addInput(input);

t.addInput(new Buffer(1), 1);
github flow-typed / flow-typed / definitions / npm / bitcoinjs-lib_v2.x.x / test_bitcoinjs-lib_v2.x.x.js View on Github external
// $ExpectError
(new HDNode(pair): HDNode);

var bitcoinNetwork = {
  messagePrefix: '\x18Bitcoin Signed Message:\n',
  bip32: {
    public: 0x0488b21e,
    private: 0x0488ade4
  },
  pubKeyHash: 0x00,
  scriptHash: 0x05,
  wif: 0x80,
  dustThreshold: 546
};

(HDNode.fromBase58('xpub123'): HDNode);
(HDNode.fromBase58('xpub123', bitcoinNetwork): HDNode);

// $ExpectError
(HDNode.fromBase58(new Buffer(1)): HDNode);

(HDNode.fromBase58('xpub123', bitcoinNetwork).getAddress(): string);

var t: Transaction = Transaction.fromHex('1234');
var input = {
  script: new Buffer(1),
  hash: new Buffer(1),
  index: 1,
  sequence: 1
};

t.ins.push(input);
github blockstack / blockstack-browser / app / js / auth / components / AuthModal.js View on Github external
// Get keypair corresponding to the current user identity
      const profileSigningKeypair = identityKeypairs[identityIndex]
      const identity = localIdentities[identityIndex]

      let blockchainId = null
      if (decodedCoreSessionToken) {
        blockchainId = decodedCoreSessionToken.payload.blockchain_id
      } else {
        blockchainId = this.state.blockchainId
      }

      const profile = identity.profile
      const privateKey = profileSigningKeypair.key
      const appsNodeKey = profileSigningKeypair.appsNodeKey
      const salt = profileSigningKeypair.salt
      const appsNode = new AppsNode(HDNode.fromBase58(appsNodeKey), salt)
      const appPrivateKey = appsNode.getAppNode(appDomain).getAppPrivateKey()

      const gaiaBucketAddress = nextProps.identityKeypairs[0].address
      const profileUrlBase = `https://gaia.blockstack.org/hub/${gaiaBucketAddress}`
      let profileUrl = `${profileUrlBase}/${identityIndex}/profile.json`

      if (identity.zoneFile && identity.zoneFile.length > 0) {
        const profileUrlFromZonefile = getTokenFileUrlFromZoneFile(identity.zoneFile)
        if (profileUrlFromZonefile !== null && profileUrlFromZonefile !== undefined) {
          profileUrl = profileUrlFromZonefile
        }
      }

      // Add app storage bucket URL to profile if publish_data scope is requested
      if (this.state.scopes.publishData) {
        let apps = {}
github blockstack / blockstack-browser / app / js / auth / index.js View on Github external
// Get keypair corresponding to the current user identity
      const profileSigningKeypair = identityKeypairs[identityIndex]
      const identity = localIdentities[identityIndex]

      let blockchainId = null
      if (decodedCoreSessionToken) {
        blockchainId = decodedCoreSessionToken.payload.blockchain_id
      } else {
        blockchainId = this.state.blockchainId
      }

      const profile = identity.profile
      const privateKey = profileSigningKeypair.key
      const appsNodeKey = profileSigningKeypair.appsNodeKey
      const salt = profileSigningKeypair.salt
      const appsNode = new AppsNode(HDNode.fromBase58(appsNodeKey), salt)
      const appPrivateKey = appsNode.getAppNode(appDomain).getAppPrivateKey()

      let profileUrlPromise

      if (identity.zoneFile && identity.zoneFile.length > 0) {
        const zoneFileJson = parseZoneFile(identity.zoneFile)
        const profileUrlFromZonefile = getTokenFileUrlFromZoneFile(zoneFileJson)
        if (
          profileUrlFromZonefile !== null &&
          profileUrlFromZonefile !== undefined
        ) {
          profileUrlPromise = Promise.resolve(profileUrlFromZonefile)
        }
      }

      const gaiaBucketAddress = nextProps.identityKeypairs[0].address
github identity-com / credential-commons / src / services / MiniCryptoManagerImpl.js View on Github external
sign(keyName, hexHash) {
    const privateKey = this.KEY_STORAGE[keyName];
    const keyPair = HDNode.fromBase58(privateKey);

    const hash = Buffer.from(hexHash, 'hex');
    const signature = keyPair.sign(hash);
    const hexSignature = signature.toDER().toString('hex');

    // keys are volatile in this impl, removes
    delete this.KEY_STORAGE[keyName];

    return hexSignature;
  }
github identity-com / credential-commons / src / services / MiniCryptoManagerImpl.js View on Github external
installKey(keyName, key) {
    try {
      // Test if key is a valid HDNode key
      HDNode.fromBase58(key);
      this.KEY_STORAGE[keyName] = key;
    } catch (err) {
      throw new Error(`Invalid key format: ${err.message}`);
    }
  }
github identity-com / credential-commons / src / services / MiniCryptoManagerImpl.js View on Github external
verify(keyName, hexHash, hexSignature) {
    const key = this.KEY_STORAGE[keyName];
    const keyPair = HDNode.fromBase58(key);

    const hash = Buffer.from(hexHash, 'hex');
    const signature = Buffer.from(hexSignature, 'hex');
    const ecSignature = ECSignature.fromDER(signature);

    // keys are volatile in this impl, removes
    delete this.KEY_STORAGE[keyName];

    return keyPair.verify(hash, ecSignature);
  }
}
github blockstack / blockstack-browser / app / js / account / store / account / reducer.js View on Github external
coreWallet: Object.assign({}, state.coreWallet, {
          balance: action.coreWalletBalance
        })
      })
    case types.UPDATE_BACKUP_PHRASE:
      return Object.assign({}, state, {
        encryptedBackupPhrase: action.encryptedBackupPhrase
      })
    case types.NEW_BITCOIN_ADDRESS:
      return Object.assign({}, state, {
        bitcoinAccount: {
          publicKeychain: state.bitcoinAccount.publicKeychain,
          addresses: [
            ...state.bitcoinAccount.addresses,
            getBitcoinAddressNode(
              HDNode.fromBase58(state.bitcoinAccount.publicKeychain),
              state.bitcoinAccount.addressIndex + 1
            ).getAddress()
          ],
          addressIndex: state.bitcoinAccount.addressIndex + 1,
          balances: state.bitcoinAccount.balances
        }
      })
    case types.UPDATE_BALANCES:
      return Object.assign({}, state, {
        bitcoinAccount: {
          publicKeychain: state.bitcoinAccount.publicKeychain,
          addresses: state.bitcoinAccount.addresses,
          balances: action.balances
        }
      })
    case types.BUILD_TRANSACTION: