How to use the @shapeshiftoss/hdwallet-core.slip44ByCoin 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-keepkey / src / keepkey.ts View on Github external
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')) {
        isPrefork = true
        break
      }
      return unknown
github shapeshift / hdwallet / packages / hdwallet-keepkey / src / ethereum.ts View on Github external
export function ethGetAccountPaths (msg: ETHGetAccountPath): Array {
  return [{
    addressNList: [ 0x80000000 + 44, 0x80000000 + slip44ByCoin(msg.coin), 0x80000000 + msg.accountIdx, 0, 0 ],
    hardenedPath: [ 0x80000000 + 44, 0x80000000 + slip44ByCoin(msg.coin), 0x80000000 + msg.accountIdx ],
    relPath: [ 0, 0 ],
    description: "KeepKey"
  }]
}
github shapeshift / hdwallet / packages / hdwallet-ledger / src / ledger.ts View on Github external
function describeETHPath (path: core.BIP32Path): core.PathDescription {
  let pathStr = core.addressNListToBIP32(path)
  let unknown: core.PathDescription = {
    verbose: pathStr,
    coin: 'Ethereum',
    isKnown: false
  }

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

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

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

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

  let accountIdx
  if (path.length === 5) {
    if (path[3] !== 0)
      return unknown

    if (path[4] !== 0)
      return unknown

    accountIdx = (path[2] & 0x7fffffff) >>> 0
  } else if (path.length === 4) {
    if (path[2] !== 0x80000000)
github shapeshift / hdwallet / packages / hdwallet-keepkey / src / keepkey.ts View on Github external
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
  }

  if ((path[2] & 0x80000000) !== 0x80000000) {
    return unknown
  }

  if (path[3] !== 0 || path[4] !== 0) {
    return unknown
  }

  let index = path[2] & 0x7fffffff
  return {
    verbose: `Cosmos Account #${index}`,
    accountIdx: index,
    wholeAccount: true,
github shapeshift / hdwallet / packages / hdwallet-trezor / src / trezor.ts View on Github external
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

  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;
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 ]
  }
github shapeshift / hdwallet / packages / hdwallet-ledger / src / ledger.ts View on Github external
let purpose = path[0] & 0x7fffffff

  if (![44, 49, 84].includes(purpose))
    return unknown

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

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

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

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

  let wholeAccount = path.length === 3

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

  switch (coin) {
  case 'Bitcoin':
  case 'Litecoin':
  case 'BitcoinGold':
  case 'Testnet':
    break;
github shapeshift / hdwallet / packages / hdwallet-keepkey / src / keepkey.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)
    return unknown

  if (path[3] != 0)
    return unknown

  if (path[4] != 0)
    return unknown

  let index = path[2] & 0x7fffffff
  return {
    verbose: `Ethereum Account #${index}`,
    accountIdx: index,
    wholeAccount: true,