Constructor
new LedgerSignMultisigTransaction(options)
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | options argument Properties
|
Example
import {
generateMultisigFromHex, TESTNET, P2SH,
} from "unchained-bitcoin";
import {LedgerSignMultisigTransaction} 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 LedgerSignMultisigTransaction({
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
closeTransport() → {Promise}
Close the Transport to free the interface (E.g. could be used in another tab now that the interaction is over)
The way the pubkey/xpub/fingerprints are grabbed makes this a little tricky. Instead of re-writing how that works, let's just add a way to explicitly close the transport.
- Overrides:
- Source:
Returns:
- promise to close the transport
- Type
- Promise
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
request() → {void}
Throws an error.
- Overrides:
- Source:
Throws:
An error since this is a direct interaction.
Returns:
- Type
- void
run() → {Array.<string>|string}
See https://github.com/LedgerHQ/ledgerjs/tree/master/packages/hw-app-btc#signp2shtransaction.
Input signatures produced will always have a trailing ...01
SIGHASH_ALL
byte.
- Overrides:
- Source:
Returns:
array of input signatures, one per input or PSBT in Base64
- Type
- Array.<string> | string
withApp(callback) → {Promise}
Can be called by a subclass during its run()
method.
Creates a transport layer connection, initializes a bitcoin app
object, and passes control to the callback
function, with the
app API as the first argument to the function and the transport
API as the second.
See the Ledger API for general information or the bitcoin app API for examples of API calls.
Parameters:
Name | Type | Description |
---|---|---|
callback |
function |
|
- Overrides:
- Source:
Returns:
does the work of setting up an app instance (and transport connection)
- Type
- Promise
Example
async run() {
return await this.withApp(async (app, transport) => {
return app.doSomething(); // Not a real Ledger bitcoin app API call
});
}
(async) withTransport(callback) → {Promise}
Can be called by a subclass during its run()
method.
Creates a transport layer connection and passes control to the
callback
function, with the transport API as the first argument
to the function.
See the Ledger API for general information or a specific transport API for examples of API calls.
Parameters:
Name | Type | Description |
---|---|---|
callback |
function |
|
- Overrides:
- Source:
Returns:
does the work of setting up a transport connection
- Type
- Promise
Example
async run() {
return await this.withTransport(async (transport) => {
return transport.doSomething(); // Not a real Ledger transport API call
});
}