This Typescript module provides an implementation of a Bitcoin address derivation algorithm for depositing BTC to the ckBTC minter on the Internet Computer.
The module derives SegWit (P2WPKH) Bitcoin addresses for depositing BTC into a ckBTC minter using an extended public key (xpub). It follows the BIP32 key derivation standard.
- BIP32 hierarchical deterministic (HD) key derivation
- SegWit (P2WPKH) Bitcoin address generation
- Computing deposit addresses for ICRC-1 accounts
npm install @research-ag/ckbtc-address-js --save
import { Minter, CKBTC_MINTER_MAINNET_XPUBKEY } from "@research-ag/ckbtc-address-js";
let minter = new Minter(CKBTC_MINTER_MAINNET_XPUBKEY);
Note: CKBTC_MINTER_MAINNET_XPUBKEY
is a key for mainnet ckBTC minter
For a given ICRC-1 account:
let account = {
owner: Principal.fromText("<owner-principal>"),
subaccount: null,
};
let depositAddress = minter.depositAddr(account);
Alternatively, using a function-based approach:
let depositAddressFunc = minter.depositAddrFunc(Principal.fromText("<owner-principal>"));
let btcAddress = depositAddressFunc(null); // Passing optional subaccount
Run the module tests:
npm run test
The package consists of:
- Implements BIP32 key derivation.
- Provides functions for deriving child keys and computing Bitcoin addresses.
- Implements the
Minter
class. - Computes deposit addresses based on the derived keys.
This project is licensed under the MIT License.