Pubkeys
Get a Bitcoin Legacy Address with KeepKey SDK
This example demonstrates how to retrieve a Bitcoin legacy address (P2PKH) from your KeepKey device using the KeepKey SDK.
Example Code
// 1. Initialize the SDK (make sure your config is set)
const sdk = await KeepKeySdk.create(config);
// 2. Define parameters for a Bitcoin legacy address (BIP44: m/44'/0'/0'/0/0)
const addressParams = {
address_n: [
0x80000000 + 44, // BIP44 purpose (legacy)
0x80000000 + 0, // Coin type: Bitcoin
0x80000000 + 0, // Account 0
0, // External chain
0 // Address index 0
],
coin: "Bitcoin", // Coin name
script_type: "p2pkh", // Legacy address (P2PKH)
show_display: false // Set true to verify on device
};
// 3. Request the address from the device
const { address } = await sdk.address.utxoGetAddress(addressParams);
console.log("Bitcoin Legacy Address:", address);
Parameter Explanations
- address_n: Array representing the BIP44 path. The example uses
m/44'/0'/0'/0/0
(first Bitcoin legacy address). - coin: Coin name as recognized by the SDK (e.g., “Bitcoin”).
- script_type: Use
"p2pkh"
for legacy addresses. - show_display: If
true
, the KeepKey will prompt you to confirm the address on the device (blocking call).
Try it Live
1. Convert BIP32 Path to AddressNList
Use this tool to convert a BIP32 path (like m/44'/0'/0'/0/0
) to the address_n
parameter format needed by the SDK. Select a common Bitcoin path or enter a custom one.
Bitcoin Derivation Paths
Bitcoin uses different derivation path standards for different address types:
Path Standard | Example Path | Address Format | Script Type |
---|---|---|---|
BIP44 Legacy | m/44'/0'/0'/0/0 | Legacy P2PKH (1... addresses) | p2pkh |
BIP49 SegWit-Compatible | m/49'/0'/0'/0/0 | Nested SegWit P2SH-P2WPKH (3... addresses) | p2sh-p2wpkh |
BIP84 Native SegWit | m/84'/0'/0'/0/0 | Native SegWit address format (starts with bc1q) | p2wpkh |
Path format explanation:
- purpose' - Hardened purpose field (44, 49, 84, 86)
- coin_type' - Hardened coin type (0 for Bitcoin)
- account' - Hardened account number (0 for first account)
- change - 0 for receiving addresses, 1 for change addresses
- address_index - Index of the address (0, 1, 2, ...)
The apostrophe (') indicates a hardened derivation, which adds 2^31 (0x80000000) to the index.
Bitcoin Derivation Path Converter
BIP44 Legacy
m/44'/0'/0'/0/0
BIP49 SegWit-Compatible
m/49'/0'/0'/0/0
BIP84 Native SegWit
m/84'/0'/0'/0/0
Format: m/purpose'/coin_type'/account'/change/address_index
Select the script type that matches your derivation path purpose
[]
2. Test with Your KeepKey Device
Bitcoin Legacy Address Playground
Edit the JSON above to experiment with different address parameters. Click Get Bitcoin Address to derive an address using the KeepKey SDK.
Use the playground below to edit the input parameters and test retrieving a Bitcoin legacy address from your KeepKey device. Modify the JSON, click “Test on KeepKey”, and see the live output below.
Last updated on