How to use the @shapeshiftoss/hdwallet-core.BTCInputScriptType.SpendP2SHWitness 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 / bitcoin.ts View on Github external
export function verifyScriptTypePurpose(scriptType: BTCInputScriptType, purpose: number): boolean {
  return (
      (purpose === 0x80000000 + 44 && scriptType === BTCInputScriptType.SpendAddress ) ||
      (purpose === 0x80000000 + 49 && scriptType === BTCInputScriptType.SpendP2SHWitness ) ||
      (purpose === 0x80000000 + 84 && scriptType === BTCInputScriptType.SpendWitness )
  )
}
github shapeshift / hdwallet / packages / hdwallet-keepkey / src / bitcoin.ts View on Github external
function segwitAccount (coin: Coin, slip44: number, accountIdx: number): BTCAccountPath {
  return {
    coin,
    scriptType: BTCInputScriptType.SpendP2SHWitness,
    addressNList: [ 0x80000000 + 49, 0x80000000 + slip44, 0x80000000 + accountIdx ]
  }
}
github shapeshift / hdwallet / packages / hdwallet-portis / src / bitcoin.ts View on Github external
return unknown

  if (purpose === 44 && scriptType !== BTCInputScriptType.SpendAddress)
    return unknown

  if (purpose === 49 && scriptType !== BTCInputScriptType.SpendP2SHWitness)
    return unknown

  if (purpose === 84 && scriptType !== BTCInputScriptType.SpendWitness)
    return unknown

  let wholeAccount = path.length === 3

  let script = {
    [BTCInputScriptType.SpendAddress]: ['Legacy'],
    [BTCInputScriptType.SpendP2SHWitness]: [],
    [BTCInputScriptType.SpendWitness]: ['Segwit Native']
  }[scriptType]

  let isPrefork = false
  if (path[1] !== 0x80000000 + slip44ByCoin(coin)) {
    switch (coin) {
    case 'BitcoinCash':
    case 'BitcoinGold': {
      if (path[1] === 0x80000000 + slip44ByCoin('Bitcoin')) {
        isPrefork = true
        break
      }
      return unknown
    }
    case 'BitcoinSV': {
      if (path[1] === 0x80000000 + slip44ByCoin('Bitcoin') ||
github shapeshift / hdwallet / packages / hdwallet-trezor / src / bitcoin.ts View on Github external
export function btcGetAccountPaths (msg: BTCGetAccountPaths): Array {
  const slip44 = slip44ByCoin(msg.coin)
  const bip44 = {
    coin: msg.coin,
    scriptType: BTCInputScriptType.SpendAddress,
    addressNList: [ 0x80000000 + 44, 0x80000000 + slip44, 0x80000000 + msg.accountIdx ]
  }
  const bip49 = {
    coin: msg.coin,
    scriptType: BTCInputScriptType.SpendP2SHWitness,
    addressNList: [ 0x80000000 + 49, 0x80000000 + slip44, 0x80000000 + msg.accountIdx ]
  }
  const bip84 = {
    coin: msg.coin,
    scriptType: BTCInputScriptType.SpendWitness,
    addressNList: [ 0x80000000 + 84, 0x80000000 + slip44, 0x80000000 + msg.accountIdx ]
  }

  let paths: Array

  if (segwitCoins.includes(msg.coin))
    paths = [ bip49, bip44, bip84 ]
  else
    paths = [ bip44 ]

  if (msg.scriptType !== undefined)
github shapeshift / hdwallet / packages / hdwallet-trezor / src / trezor.ts View on Github external
return res.payload.map((result, i) => {
      const scriptType = msg[i].scriptType
      switch (scriptType) {
      case BTCInputScriptType.SpendP2SHWitness:
      case BTCInputScriptType.SpendWitness:
        return {
          xpub: result.xpubSegwit
        }
      case BTCInputScriptType.SpendAddress:
      default:
        return {
          xpub: result.xpub
        }
      }
    })
  }
github shapeshift / hdwallet / packages / hdwallet-ledger / src / bitcoin.ts View on Github external
export async function btcSupportsScriptType (coin: Coin, scriptType: BTCInputScriptType): Promise {
  const supported = {
    Bitcoin: [
      BTCInputScriptType.SpendAddress,
      BTCInputScriptType.SpendWitness,
      BTCInputScriptType.SpendP2SHWitness
    ],
    BitcoinCash: [
      BTCInputScriptType.SpendAddress
    ]
  }

  return !!supported[coin] && supported[coin].includes(scriptType)
}
github shapeshift / hdwallet / integration / src / wallets / keepkey.ts View on Github external
expect(paths).toEqual([{
      "addressNList": [
        2147483692,
        2147483650,
        2147483651,
      ],
      "scriptType": BTCInputScriptType.SpendAddress,
      'coin': 'Litecoin',
    }, {
      "addressNList": [
        2147483697,
        2147483650,
        2147483651,
      ],
      "scriptType": BTCInputScriptType.SpendP2SHWitness,
      'coin': 'Litecoin',
    }, {
      "addressNList": [
        2147483732,
        2147483650,
        2147483651,
      ],
      "scriptType": BTCInputScriptType.SpendWitness,
      'coin': 'Litecoin',
    }])
  })
github shapeshift / hdwallet / packages / hdwallet-portis / src / bitcoin.ts View on Github external
export function segwitAccount (coin: Coin, slip44: number, accountIdx: number): BTCAccountPath {
  return {
    coin,
    scriptType: BTCInputScriptType.SpendP2SHWitness,
    addressNList: [ 0x80000000 + 49, 0x80000000 + slip44, 0x80000000 + accountIdx ]
  }
}
github shapeshift / hdwallet / packages / hdwallet-keepkey / src / keepkey.ts View on Github external
return unknown

  if (purpose === 44 && scriptType !== BTCInputScriptType.SpendAddress)
    return unknown

  if (purpose === 49 && scriptType !== BTCInputScriptType.SpendP2SHWitness)
    return unknown

  if (purpose === 84 && scriptType !== BTCInputScriptType.SpendWitness)
    return unknown

  let wholeAccount = path.length === 3

  let script = {
    [BTCInputScriptType.SpendAddress]: ['Legacy'],
    [BTCInputScriptType.SpendP2SHWitness]: [],
    [BTCInputScriptType.SpendWitness]: ['Segwit Native']
  }[scriptType]

  let isPrefork = false
  if (path[1] !== 0x80000000 + slip44ByCoin(coin)) {
    switch (coin) {
    case 'BitcoinCash':
    case 'BitcoinGold': {
      if (path[1] === 0x80000000 + slip44ByCoin('Bitcoin')) {
        isPrefork = true
        break
      }
      return unknown
    }
    case 'BitcoinSV': {
      if (path[1] === 0x80000000 + slip44ByCoin('Bitcoin') ||