Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@samouraiwallet/bip47

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@samouraiwallet/bip47

A set of utilities for working with BIP47 and bitcoinjs-lib

  • 0.8.0
  • npm
  • Socket score

Version published
Weekly downloads
49
increased by44.12%
Maintainers
1
Weekly downloads
 
Created
Source

@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

You need to provide your own implementation of secp256k1 elliptic curve. tiny-secp256k1 is recommended but you can use any other which has the same API.

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.

Examples

Mainnet

import * as ecc from 'tiny-secp256k1';
import {BIP47Factory} from '@samouraiwallet/bip47';

const bip47 = BIP47Factory(ecc);

const aliceB58PCode = 'PM8TJTLJbPRGxSbc8EJi42Wrr6QbNSaSSVJ5Y3E4pbCYiTHUskHg13935Ubb7q8tx9GVbh2UuRnBc3WSyJHhUrw8KhprKnn9eDznYGieTzFcwQRya4GA';
const bobSeed = '87eaaac5a539ab028df44d9110defbef3797ddb805ca309f61a69ff96dbaa7ab5b24038cf029edec5235d933110f0aea8aeecf939ed14fc20730bba71e4b1110';

const alicePcode = bip47.fromBase58(aliceB58PCode);
const bobPcode = bip47.fromSeed(Buffer.from(bobSeed, 'hex'), 0);

const bobNotifPrivKey = bobPcode.getNotificationPrivateKey();

const alicePaymentAddr1 = alicePcode.getPaymentAddress(bobNotifPrivKey, 0, 'p2pkh'); // derive P2PKH payment address
const alicePaymentAddr2 = alicePcode.getPaymentAddress(bobNotifPrivKey, 1, 'p2wpkh'); // derive P2WPKH payment address

Testnet

import * as ecc from 'tiny-secp256k1';
import {BIP47Factory, utils} from '@samouraiwallet/bip47';

const networks = utils.networks;

const bip47 = BIP47Factory(ecc);

const b58PCode = 'PM8TJS2JxQ5ztXUpBBRnpTbcUXbUHy2T1abfrb3KkAAtMEGNbey4oumH7Hc578WgQJhPjBxteQ5GHHToTYHE3A1w6p7tU6KSoFmWBVbFGjKPisZDbP97';

const alicePcode = bip47.fromBase58(b58PCode, networks.testnet);
const aliceNotifAddr = alicePcode.getNotificationAddress();

Keywords

FAQs

Package last updated on 15 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc