Class: TrezorSignMultisigTransaction

trezor.TrezorSignMultisigTransaction(options)

Returns a signature for a bitcoin transaction with inputs from one or many multisig addresses.

  • inputs is an array of UTXO objects from unchained-bitcoin
  • outputs is an array of TransactionOutput objects from unchained-bitcoin
  • bip32Paths is an array of (string) BIP32 paths, one for each input, identifying the path on this device to sign that input with

Constructor

new TrezorSignMultisigTransaction(options)

Parameters:
Name Type Description
options object

options argument

Properties
Name Type Attributes Description
network string

bitcoin network

inputs Array.<UTXO>

inputs for the transaction

outputs Array.<TransactionOutput>

outputs for the transaction

bip32Paths Array.<string>

BIP32 paths on this device to sign with, one per each input

psbt string <optional>

PSBT string encoded in base64

keyDetails object <optional>

Signing Key Details (Fingerprint + bip32 prefix)

returnSignatureArray boolean <optional>

return an array of signatures instead of a signed PSBT (useful for test suite)

Source:
Example
import {
  generateMultisigFromHex, TESTNET, P2SH,
} from "unchained-bitcoin";
import {TrezorSignMultisigTransaction} from "unchained-wallets";
const redeemScript = "5...ae";
const inputs = [
  {
    txid: "8d276c76b3550b145e44d35c5833bae175e0351b4a5c57dc1740387e78f57b11",
    index: 1,
    multisig: generateMultisigFromHex(TESTNET, P2SH, redeemScript),
    amountSats: '1234000'
  },
  // other inputs...
];
const outputs = [
  {
    amountSats: '1299659',
    address: "2NGHod7V2TAAXC1iUdNmc6R8UUd4TVTuBmp"
  },
  // other outputs...
];
const interaction = new TrezorSignMultisigTransaction({
  network: TESTNET,
  inputs,
  outputs,
  bip32Paths: ["m/45'/0'/0'/0", // add more, 1 per input],
});
const signature = await interaction.run();
console.log(signatures);
// ["ababab...", // 1 per input]

Extends

Methods

connectParams() → {Array.<function(), Object>}

Overrides:
Source:
Returns:

TrezorConnect parameters

Type
Array.<function(), Object>

messages() → {Array.<module:interaction.Message>}

Adds messages describing the signing flow.

Overrides:
Source:
Returns:

messages for this interaction

Type
Array.<module:interaction.Message>

parse() → {void}

Throws an error.

Overrides:
Source:
Throws:

An error since this is a direct interaction.

Returns:
Type
void

parsePayload(payload) → {Array.<string>|string}

Parses the signature(s) out of the response payload.

Ensures each input's signature hasa a trailing ...01 SIGHASH_ALL byte.

Parameters:
Name Type Description
payload Object

the original payload from the device response

Overrides:
Source:
Returns:

array of input signatures, one per input or signed psbt with signatures inserted

Type
Array.<string> | string

request() → {void}

Throws an error.

Overrides:
Source:
Throws:

An error since this is a direct interaction.

Returns:
Type
void

(async) run() → {Promise}

Awaits the call of this.method, passing in the output of this.params().

If the call returns but is unsuccessful (result.success) is false, will throw the returned error message. If some other error is thrown, it will not be caught.

Otherwise it returns the result of passing result.payload to this.parsePayload.

Overrides:
Source:
Returns:

handles the work of calling TrezorConnect

Type
Promise