How to use the @shapeshiftoss/hdwallet-core.addressNListToBIP32 function in @shapeshiftoss/hdwallet-core

To help you get started, we’ve selected a few @shapeshiftoss/hdwallet-core 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 shapeshift / hdwallet / packages / hdwallet-portis / src / portis.ts View on Github external
this.portisCallInProgress = new Promise( async (resolve, reject) => {
      try {
          await this.portisCallInProgress
      } catch (e) {
          console.error(e)
      }
      for (let i = 0; i < msg.length; i++) {
        const { addressNList, coin } = msg[i];
        const bitcoinSlip44 = 0x80000000 + slip44ByCoin('Bitcoin')
        // TODO we really shouldnt be every using the "bitcoin" string parameter but is here for now to make it work with their btc address on their portis wallet.
        const portisResult = await this.portis.getExtendedPublicKey(addressNListToBIP32(addressNList), addressNList[1] === bitcoinSlip44 ? 'Bitcoin' : '')
        const { result, error } = portisResult
        if(error)
          reject(error)
        publicKeys.push({ xpub: result })
      }
      resolve(publicKeys)
    })
    return this.portisCallInProgress
github shapeshift / hdwallet / packages / hdwallet-trezor / src / ethereum.ts View on Github external
export async function ethGetAddress (transport: TrezorTransport, msg: ETHGetAddress): Promise {
  console.assert(!msg.showDisplay || !!msg.address,
    "HDWalletTrezor::ethGetAddress: expected address is required for showDisplay")
  let args: any = {
    path: addressNListToBIP32(msg.addressNList),
    showOnTrezor: msg.showDisplay !== false,
  }
  if (msg.address)
    args.address = msg.address
  let res = await transport.call('ethereumGetAddress', args)
  handleError(transport, res, "Could not get ETH address from Trezor")
  return res.payload.address
}
github shapeshift / hdwallet / packages / hdwallet-keepkey / src / keepkey.ts View on Github external
function describeUTXOPath (path: BIP32Path, coin: Coin, scriptType: BTCInputScriptType): PathDescription {
  let pathStr = addressNListToBIP32(path)
  let unknown: PathDescription = {
    verbose: pathStr,
    coin,
    scriptType,
    isKnown: false
  }

  if (!Btc.btcSupportsCoin(coin))
    return unknown

  if (!Btc.btcSupportsScriptType(coin, scriptType))
    return unknown

  if (path.length !== 3 && path.length !== 5)
    return unknown
github shapeshift / hdwallet / packages / hdwallet-portis / src / bitcoin.ts View on Github external
export async function btcGetAddress (msg: BTCGetAddress, portis: any): Promise {

  if(!msg.addressNList.length)
    throw new Error('Empty addressNList')

  const scriptType = msg.scriptType
  const purpose = msg.addressNList[0]

  const hardPath = hardenedPath(msg.addressNList)
  const hardPathString = addressNListToBIP32(hardPath)

  const { result: xpub } = await portis.getExtendedPublicKey(hardPathString, "Bitcoin")

  const relPath = relativePath(msg.addressNList)
  const relPathString = addressNListToBIP32(relPath).substr(2)

  const args = { pubkey: fromBase58(xpub).derivePath(relPathString).publicKey }

  let result
  switch (scriptType) {
    case BTCInputScriptType.SpendAddress:
      result = payments.p2pkh(args)
      break
    case BTCInputScriptType.SpendWitness:
      result = payments.p2wpkh(args)
      break
github shapeshift / hdwallet / packages / hdwallet-ledger / src / ledger.ts View on Github external
function describeUTXOPath (path: core.BIP32Path, coin: core.Coin, scriptType: core.BTCInputScriptType) {
  let pathStr = core.addressNListToBIP32(path)
  let unknown: core.PathDescription = {
    verbose: pathStr,
    coin,
    scriptType,
    isKnown: false
  }

  if (!btc.btcSupportsCoin(coin))
    return unknown

  if (!btc.btcSupportsScriptType(coin, scriptType))
    return unknown

  if (path.length !== 3 && path.length !== 5)
    return unknown
github shapeshift / hdwallet / packages / hdwallet-ledger / src / bitcoin.ts View on Github external
export async function btcGetAddress (transport: LedgerTransport, msg: BTCGetAddress): Promise {
  const bip32path = addressNListToBIP32(msg.addressNList)
  const opts = {
    verify: !!msg.showDisplay,
    format: translateScriptType(msg.scriptType)
  }

  const res = await transport.call('Btc', 'getWalletPublicKey', bip32path, opts)
  handleError(res, transport, 'Unable to obtain BTC address from device')

  return res.payload.bitcoinAddress
}
github shapeshift / hdwallet / packages / hdwallet-trezor / src / trezor.ts View on Github external
function describeUTXOPath (path: BIP32Path, coin: Coin, scriptType: BTCInputScriptType) {
  let pathStr = addressNListToBIP32(path)
  let unknown: PathDescription = {
    verbose: pathStr,
    coin,
    scriptType,
    isKnown: false
  }

  if (!Btc.btcSupportsCoin(coin))
    return unknown

  if (!Btc.btcSupportsScriptType(coin, scriptType))
    return unknown

  if (path.length !== 3 && path.length !== 5)
    return unknown
github shapeshift / hdwallet / packages / hdwallet-keepkey / src / keepkey.ts View on Github external
function describeCosmosPath (path: BIP32Path): PathDescription {
  let pathStr = addressNListToBIP32(path)
  let unknown: PathDescription = {
    verbose: pathStr,
    coin: 'Atom',
    isKnown: false
  }

  if (path.length != 5) {
    return unknown
  }

  if (path[0] != 0x80000000 + 44) {
    return unknown
  }

  if (path[1] != 0x80000000 + slip44ByCoin('Atom')) {
    return unknown
github shapeshift / hdwallet / packages / hdwallet-metamask / src / metamask.ts View on Github external
function describeETHPath (path: BIP32Path): PathDescription {
  let pathStr = addressNListToBIP32(path)
  let unknown: PathDescription = {
    verbose: pathStr,
    coin: 'Ethereum',
    isKnown: false
  }

  if (path.length !== 5)
    return unknown

  if (path[0] !== 0x80000000 + 44)
    return unknown

  if (path[1] !== 0x80000000 + slip44ByCoin('Ethereum'))
    return unknown

  if ((path[2] & 0x80000000) >>> 0 !== 0x80000000)