Members
(constant) DIRECT_KEYSTORES :string
Enumeration of keystores which support direct interactions.
Type:
- string
(constant) INDIRECT_KEYSTORES :string
Enumeration of keystores which support indirect interactions.
Type:
- string
(constant) KEYSTORES :Array.<string>
Enumeration of supported keystores.
Type:
- Array.<string>
(constant) VERSION :string
Current unchained-wallets version.
Type:
- string
Methods
ConfigAdapter(KEYSTORE, jsonConfig) → {ColdcardMultisigWalletConfig|UnsupportedInteraction}
Return a class for creating a multisig config file for a given keystore or coordinator.
Parameters:
Name | Type | Description |
---|---|---|
KEYSTORE |
string | keystore to use |
jsonConfig |
string | JSON wallet configuration file e.g. from Caravan |
Returns:
- A class that can translate to shape of config to match the specified keystore/coordinator requirements
- Type
- ColdcardMultisigWalletConfig | UnsupportedInteraction
ConfirmMultisigAddress(options) → {module:interaction.KeystoreInteraction}
Return an interaction class for confirming a multisig address with
the given keystore
.
The multisig
parameter is a Multisig
object from
unchained-bitcoin
.
bip32Path
is the BIP32 path for the publiic key in the address on
this device.
publicKey
optional, is the public key expected to be at bip32Path
.
Supported keystores: Trezor
Parameters:
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | options argument Properties
|
Returns:
keystore-specific interaction instance
Example
import {
generateMultisigFromHex, TESTNET, P2SH,
} from "unchained-bitcoin";
import {
ConfirmMultisigAddress,
multisigPublicKeys,
trezorPublicKey,
TREZOR} from "unchained-wallets";
const redeemScript = "5...ae";
const multisig = generateMultisigFromHex(TESTNET, P2SH, redeemScript);
const interaction = ConfirmMultisigAddress({
keystore: TREZOR,
network: TESTNET,
multisig,
bip32Path: "m/45'/1'/0'/0/0",
});
await interaction.run();
With publicKey:
const redeemScript = "5...ae";
const multisig = generateMultisigFromHex(TESTNET, P2SH, redeemScript);
const publicKey = trezorPublicKey(multisigPublicKeys(this.multisig)[2])
const interaction = ConfirmMultisigAddress({
keystore: TREZOR,
publicKey,
network: TESTNET,
multisig,
bip32Path: "m/45'/1'/0'/0/0",
});
await interaction.run();
ExportExtendedPublicKey(options) → {module:interaction.KeystoreInteraction}
Return an interaction class for exporting an extended public key
from the given keystore
for the given bip32Path
and network
.
Supported keystores: Trezor, Hermit, Ledger
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | options argument Properties
|
Returns:
keystore-specific interaction instance
Example
import {MAINNET} from "unchained-bitcoin";
import {ExportExtendedPublicKey, TREZOR, HERMIT} from "unchained-wallets";
// Works similarly for Ledger
const interaction = ExportExtendedPublicKey({keystore: TREZOR, network: MAINNET, bip32Path: "m/45'/0'/0'/0/0"});
const xpub = await interaction.run();
ExportPublicKey(options) → {module:interaction.KeystoreInteraction}
Return an interaction class for exporting a public key from the
given keystore
for the given bip32Path
and network
.
Supported keystores: Trezor, Ledger, Hermit
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | options argument Properties
|
Returns:
keystore-specific interaction instance
Example
import {MAINNET} from "unchained-bitcoin";
import {ExportPublicKey, TREZOR, HERMIT} from "unchained-wallets";
// Works similarly for Ledger
const interaction = ExportPublicKey({keystore: TREZOR, network: MAINNET, bip32Path: "m/45'/0'/0'/0/0"});
const publicKey = await interaction.run();
GetMetadata(options) → {module:interaction.KeystoreInteraction}
Return an interaction class for obtaining metadata from the given
keystore
.
Supported keystores: Trezor, Ledger
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
options |
Object | options argument Properties
|
Returns:
keystore-specific interaction instance
Example
import {GetMetadata, TREZOR} from "unchained-wallets";
// Works similarly for Ledger.
const interaction = GetMetadata({keystore: TREZOR});
const metadata = await interaction.run();
SignMultisigTransaction(options) → {module:interaction.KeystoreInteraction}
Return an interaction class for signing a multisig transaction with
the given keystore
.
The inputs are objects which have txid
, index
, and a multisig
object, the last which is a Multisig
object from
unchained-bitcoin
.
The outputs are objects which have address
and amountSats
(an
integer).
bip32Paths
is an array of BIP32 paths for the public keys on this
device, one for each input.
Supported keystores: Trezor, Ledger, Hermit
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | options argument Properties
|
Returns:
keystore-specific interaction instance
Example
import {
generateMultisigFromHex, TESTNET, P2SH,
} from "unchained-bitcoin";
import {SignMultisigTransaction, TREZOR} 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 = SignMultisigTransaction({
keystore: TREZOR, // works the same for Ledger
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]