On this page
btcGetPublicKey
Bitcoin: get public key
Returns the public key derived from the specified path. Use showOnOneKey to request confirmation on the device.
const result = await HardwareSDK.btcGetPublicKey(connectId, deviceId, params);Params
Single public key
path- requiredstring | Array<number>SDK minimum length is1. read moreshowOnOneKey- optionalbooleanWhether to display the public key on the device. Defaults totrue.coin- optionalstringdetermines network definition specified in coins.json file. Coinshortcut,nameorlabelcan be used. Ifcoinis not set API will try to get network definition frompath.scriptType- optional InputScriptType, address script type
Multiple public keys
bundle- array of objects withpath,coinfields
Example
Return the public key for fifth bitcoin account:
HardwareSDK.btcGetPublicKey(connectId, deviceId, {
path: "m/49'/0'/4'",
coin: "btc"
});Return a bundle of public keys for multiple bitcoin accounts:
HardwareSDK.btcGetPublicKey(connectId, deviceId, {
bundle: [
{ path: "m/49'/0'/0'" }, // account 1
{ path: "m/49'/0'/1'" }, // account 2
{ path: "m/49'/0'/2'" } // account 3
]
});Result
Single-public-key response
{
success: true,
payload: {
path: string, // serialized BIP32 path
xpub: string, // xpub in legacy format
xpubSegwit?: string, // optional for segwit accounts: xpub in segwit format
root_fingerprint?: number,
node: {
depth: number,
fingerprint: number,
child_num: number,
chain_code: string,
public_key: string,
},
}
}Read more about BIP32 serialization format
Batch public-key response
{
success: true,
payload: [
{ path, xpub, xpubSegwit, root_fingerprint, node }, // account 1
{ path, xpub, xpubSegwit, root_fingerprint, node }, // account 2
{ path, xpub, xpubSegwit, root_fingerprint, node } // account 3
]
}Error
{
success: false,
payload: {
error: string, // error message
code?: string | number // error code
}
}Last updated on