btcGetAddress
Bitcoin: get address
Display the requested address derived from the given BIP32 path on the device and return it to the caller. The user is asked to confirm the export on Ukey Wallet.
const result = await HardwareSDK.btcGetAddress(connectId, deviceId, params);
Params
Exporting single address
path- requiredstring | Array<number>minimum length is 3. read moreshowOnUKey- optionalbooleandetermines whether the address will be displayed on the device. Default istrue.coin- optionalstringdetermines the network definition specified in the coins.json file. Coinshortcut,name, orlabelcan be used. Ifcoinis not set, the API will try to get the network definition frompath.multisig- optionalMultisigRedeemScriptTyperedeem script information (multisig addresses only)scriptType- optionalInputScriptTypeaddress script type
Exporting bundle of addresses
bundle-Arrayof objects withpath,showOnUKey, andcoinfields
Get different types of addresses
Different BTC address types require different derivation path parameters.
| Type | Path | Eg. |
|---|---|---|
| Legacy BIP44 | m/44'/0'/x'/x/x | It starts with a "1" and consists of 26 to 35 characters |
| Nested SegWit BIP49 | m/49'/0'/x'/x/x | It starts with a "3" and consists of 26 to 35 characters |
| Native SegWit BIP84 | m/84'/0'/x'/x/x | Start with "bc1" or "tb1" and consist of 41 to 62 characters |
| Taproot BIP86 | m/86'/0'/x'/x/x | It starts with "bc1" and consists of 41 to 62 characters |
Example
Display the second address of the first bitcoin account:
HardwareSDK.btcGetAddress(connectId, deviceId, {
path: "m/49'/0'/0'/0/1",
coin: "btc",
});
Return a bundle of addresses from the first bitcoin account without displaying them on the device:
HardwareSDK.btcGetAddress(connectId, deviceId, {
bundle: [
{ path: "m/49'/0'/0'/0/3", showOnUKey: false }, // address 4
{ path: "m/49'/0'/0'/0/4", showOnUKey: false }, // address 5
{ path: "m/49'/0'/0'/0/5", showOnUKey: false }, // address 6
],
});
Result
Result with only one address
{
success: true,
payload: {
address: string, // displayed address
path: Array<number> // hardened path
}
}
Result with a bundle of addresses in the same order as the request
{
success: true,
payload: [
{ address: string, path: Array<number> }, // address 4
{ address: string, path: Array<number> }, // address 5
{ address: string, path: Array<number> }, // address 6
]
}
Error
{
success: false,
payload: {
error: string, // error message
code: number // error code
}
}