@samouraiwallet/bip47
A set of utilities for working with BIP47 and bitcoinjs-lib.
This library uses ES Modules. Node.js v14 or later is required.
Source code was written in Typescript. Type definitions are included in the published bundle.
Usage
All necessary documentation of usage is provided via test files.
Using in browser
You will need webpack/browserify to bundle this library and it's dependencies to be able to use it in browser
environment.
Since tiny-secp256k1
is a WASM library, it will require such bundler to be able to load WASM code.
Please consult the docs of a bundler that you use for further information.
For example current webpack will require you to set { experiments: { asyncWebAssembly: true }}
in your config.
Mainnet
import {PaymentCode} from '@samouraiwallet/bip47';
const b58PCode = 'PM8TJS2JxQ5ztXUpBBRnpTbcUXbUHy2T1abfrb3KkAAtMEGNbey4oumH7Hc578WgQJhPjBxteQ5GHHToTYHE3A1w6p7tU6KSoFmWBVbFGjKPisZDbP97';
const pcode = PaymentCode.fromBase58(b58PCode);
const notifAddr = pcode.getNotificationAddress();
const myPrivKey0 = Buffer.from('8d6a8ecd8ee5e0042ad0cb56e3a971c760b5145c3917a8e7beaf0ed92d7a520c', 'hex');
const paymentAddr1 = pcode.getPaymentAddress(myPrivKey0, 1);
const paymentAddr2 = pcode.getPaymentAddress(myPrivKey0, 2);
Testnet
import {PaymentCode, utils} from '@samouraiwallet/bip47';
const networks = utils.networks;
const b58PCode = 'PM8TJS2JxQ5ztXUpBBRnpTbcUXbUHy2T1abfrb3KkAAtMEGNbey4oumH7Hc578WgQJhPjBxteQ5GHHToTYHE3A1w6p7tU6KSoFmWBVbFGjKPisZDbP97';
const pcode = PaymentCode.fromBase58(b58PCode, networks.testnet);
const notifAddr = pcode.getNotificationAddress();