How to use the @shapeshiftoss/hdwallet-core.BTCInputScriptType.SpendWitness 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 / integration / src / bitcoin / bitcoin.ts View on Github external
test('btcGetAccountPaths()', async () => {
      await each([
        ['Bitcoin',     0, undefined],
        ['Bitcoin',     1, BTCInputScriptType.SpendAddress],
        ['Bitcoin',     3, BTCInputScriptType.SpendP2SHWitness],
        ['Bitcoin',     2, BTCInputScriptType.SpendWitness],
        ['Litecoin',    1, BTCInputScriptType.SpendAddress],
        ['Litecoin',    1, BTCInputScriptType.SpendP2SHWitness],
        ['Dash',        0, BTCInputScriptType.SpendAddress],
        ['Dogecoin',    0, BTCInputScriptType.SpendAddress],
        ['BitcoinCash', 0, BTCInputScriptType.SpendAddress],
        ['BitcoinGold', 0, BTCInputScriptType.SpendAddress],
      ], async (args) => {
        let coin = args[0] as Coin
        let accountIdx = args[1] as number
        let scriptType = args[2] as BTCInputScriptType
        if (!wallet) return
        if (!await wallet.btcSupportsCoin(coin))
          return
        expect(await info.btcSupportsCoin(coin)).toBeTruthy()
        if (!await wallet.btcSupportsScriptType(coin, scriptType))
          return
github shapeshift / hdwallet / packages / hdwallet-portis / src / bitcoin.ts View on Github external
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') ||
          path[1] === 0x80000000 + slip44ByCoin('BitcoinCash')) {
github shapeshift / hdwallet / packages / hdwallet-keepkey / src / utils.ts View on Github external
export function translateInputScriptType (scriptType: BTCInputScriptType): any {
  switch (scriptType) {
  case BTCInputScriptType.CashAddr:
  case BTCInputScriptType.SpendAddress:
    return InputScriptType.SPENDADDRESS
  case BTCInputScriptType.SpendMultisig:
    return InputScriptType.SPENDMULTISIG
  case BTCInputScriptType.SpendP2SHWitness:
    return InputScriptType.SPENDP2SHWITNESS
  case BTCInputScriptType.SpendWitness:
    return InputScriptType.SPENDWITNESS
  }
  throw new Error('unhandled InputSriptType enum: ' + scriptType)
}
github shapeshift / hdwallet / integration / src / wallets / trezor.ts View on Github external
'coin': 'Litecoin',
    }, {
      "addressNList": [
        2147483692,
        2147483650,
        2147483651,
      ],
      "scriptType": BTCInputScriptType.SpendAddress,
      'coin': 'Litecoin',
    }, {
      "addressNList": [
        2147483732,
        2147483650,
        2147483651,
      ],
      "scriptType": BTCInputScriptType.SpendWitness,
      'coin': 'Litecoin',
    }])
  })
github shapeshift / hdwallet / packages / hdwallet-trezor / src / trezor.ts View on Github external
if (purpose === 49 && scriptType !== BTCInputScriptType.SpendP2SHWitness)
    return unknown

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

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

  let wholeAccount = path.length === 3

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

  switch (coin) {
  case 'Bitcoin':
  case 'Litecoin':
  case 'BitcoinGold':
  case 'Testnet':
    break;
  default:
    script = ''
  }

  let accountIdx = path[2] & 0x7fffffff

  if (wholeAccount) {
    return {
github shapeshift / hdwallet / packages / hdwallet-keepkey / src / bitcoin.ts View on Github external
function segwitNativeAccount (coin: Coin, slip44: number, accountIdx: number): BTCAccountPath {
  return {
    coin,
    scriptType: BTCInputScriptType.SpendWitness,
    addressNList: [ 0x80000000 + 84, 0x80000000 + slip44, 0x80000000 + accountIdx ]
  }
}
github shapeshift / hdwallet / packages / hdwallet-portis / src / bitcoin.ts View on Github external
if ((path[0] & 0x80000000) >>> 0 !== 0x80000000)
    return unknown

  let purpose = path[0] & 0x7fffffff

  if (![44, 49, 84].includes(purpose))
    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')) {
github shapeshift / hdwallet / integration / src / wallets / keepkey.ts View on Github external
'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-trezor / src / bitcoin.ts View on Github external
export async function btcSupportsScriptType (coin: Coin, scriptType: BTCInputScriptType): Promise {
  if (translateCoin(coin) === undefined)
    return false
  if (!segwitCoins.includes(coin) && scriptType === BTCInputScriptType.SpendP2SHWitness)
    return false
  if (!segwitCoins.includes(coin) && scriptType === BTCInputScriptType.SpendWitness)
    return false
  return true
}
github shapeshift / hdwallet / integration / src / wallets / ledger.ts View on Github external
'coin': 'Litecoin',
    }, {
      "addressNList": [
        2147483692,
        2147483650,
        2147483651,
      ],
      "scriptType": BTCInputScriptType.SpendAddress,
      'coin': 'Litecoin',
    }, {
      "addressNList": [
        2147483732,
        2147483650,
        2147483651,
      ],
      "scriptType": BTCInputScriptType.SpendWitness,
      'coin': 'Litecoin',
    }])
  })