How to use the unchained-bitcoin.MULTISIG_ADDRESS_TYPES.P2SH_P2WSH function in unchained-bitcoin

To help you get started, we’ve selected a few unchained-bitcoin 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 unchained-capital / unchained-wallets / src / trezor.js View on Github external
}

/**
 * Retrieve Trezor format for network constant
 * @param {string} network - bitcoin network
 * @private
 * @returns {string} Trezor format of bitcoin network
 */
function coin(network) {
  return (network === NETWORKS.MAINNET ? "Bitcoin" : "Testnet");
}

const addressScriptTypes = {
  [MULTISIG_ADDRESS_TYPES.P2WSH]: 'SPENDWITNESS',
  [MULTISIG_ADDRESS_TYPES.P2SH]: 'SPENDMULTISIG',
  [MULTISIG_ADDRESS_TYPES.P2SH_P2WSH]: 'SPENDP2SHWITNESS',
}
function trezorInput(input, bip32Path) {
  const requiredSigners = multisigRequiredSigners(input.multisig);
  const addressType = multisigAddressType(input.multisig)
  const spendType = addressScriptTypes[addressType]
  return {
    script_type: spendType,
    multisig: {
      m: requiredSigners,
      pubkeys: multisigPublicKeys(input.multisig).map((publicKey) => trezorPublicKey(publicKey)),
      signatures: Array(requiredSigners).fill(''),
    },
    prev_hash: input.txid,
    prev_index: input.index,
    address_n: bip32PathToSequence(bip32Path),
    amount: input.amountSats.toString()