Skip to main content

btcGetPublicKey

Bitcoin: get public key

Retrieves the BIP32 extended public key derived from the given BIP32 path. The user is asked to confirm the export on Ukey Wallet.

const result = await HardwareSDK.btcGetPublicKey(connectId, deviceId, params);

Params

Optional common params

Exporting single public key

  • path - required string | Array<number> minimum length is 1. read more
  • showOnUKey - optional boolean determines whether the public key will be displayed on the device. Default is true.
  • coin - optional string determines the network definition specified in the coins.json file. Coin shortcut, name, or label can be used. If coin is not set, the API will try to get the network definition from path.
  • scriptType - optional InputScriptType address script type

Exporting bundle of public keys

  • bundle - Array of objects with path and coin fields

Example

Return the public key of the fourth bitcoin account:

HardwareSDK.btcGetPublicKey(connectId, deviceId, {
path: "m/49'/0'/3'",
coin: "btc",
});

Return a bundle of public keys for multiple bitcoin accounts:

HardwareSDK.btcGetPublicKey(connectId, deviceId, {
bundle: [
{ path: "m/49'/0'/7'" }, // account 8
{ path: "m/49'/0'/8'" }, // account 9
{ path: "m/49'/0'/9'" }, // account 10
],
});

Result

Result with only one public key

{
success: true,
payload: {
path: Array<number>, // hardened path
xpub: string, // xpub in legacy format
xpubSegwit?: string, // optional for segwit accounts: xpub in segwit format
chainCode: string, // BIP32 serialization format
childNum: number, // BIP32 serialization format
publicKey: string, // BIP32 serialization format
fingerprint: number, // BIP32 serialization format
depth: number, // BIP32 serialization format
}
}

Read more about BIP32 serialization format

Result with a bundle of public keys in the same order as the request

{
success: true,
payload: [
{ path, serializedPath, xpub, xpubSegwit?, chainCode, childNum, publicKey, fingerprint, depth }, // account 8
{ path, serializedPath, xpub, xpubSegwit?, chainCode, childNum, publicKey, fingerprint, depth }, // account 9
{ path, serializedPath, xpub, xpubSegwit?, chainCode, childNum, publicKey, fingerprint, depth } // account 10
]
}

Error

{
success: false,
payload: {
error: string, // error message
code: number // error code
}
}