# @spsina/bip47

> bip47 utility functions

Latest version **1.0.1** (published 2022-03-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install @spsina/bip47
pnpm add @spsina/bip47
yarn add @spsina/bip47
bun add @spsina/bip47
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2022-03-26 |
| First published | 2022-03-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=6.0.0 |
| Dependencies | 7 |
| Unpacked size | 23 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 21 |
| Author | Sina Parvizi |
| Maintainers | spsina |
| Keywords | bitcoin, bitcoinjs, bitcoinjs-lib, paynyms, payment-codes, bip47, bip-47 |

## Links

- npm: https://www.npmjs.com/package/@spsina/bip47
- Repository: https://github.com/spsina/bip47
- Homepage: https://github.com/spsina/bip47#readme
- Issues: https://github.com/spsina/bip47/issues
- npm.io page: https://npm.io/package/@spsina/bip47

## Dependencies (7)

- [bip32](https://npm.io/package/bip32.md) ^3.0.1
- [bip39](https://npm.io/package/bip39.md) ^3.0.4
- [ecpair](https://npm.io/package/ecpair.md) ^2.0.1
- [bs58check](https://npm.io/package/bs58check.md) ^2.1.1
- [create-hmac](https://npm.io/package/create-hmac.md) ^1.1.7
- [bitcoinjs-lib](https://npm.io/package/bitcoinjs-lib.md) ^6.0.1
- [tiny-secp256k1](https://npm.io/package/tiny-secp256k1.md) ^2.2.1

## Recent versions

- 1.0.1 (latest) — 2022-03-26
- 1.0.0 — 2022-03-25

## README

# BIP-47 Reusable Payment Codes

A [BIP47](https://github.com/bitcoin/bips/blob/master/bip-0047.mediawiki) compatible library written in TypeScript with transpiled JavaScript committed to git.

## Examples
typescript

```typescript
import ECPairFactory from 'ecpair';
import * as ecc from 'tiny-secp256k1';
import BIP47Factory from '.';
// You must wrap a tiny-secp256k1 compatible implementation
const ECPair = ECPairFactory(ecc);

const aliceSeedPhrase = 'response seminar brave tip suit recall often sound stick owner lottery motion';
const bobSeedPhrase = 'reward upper indicate eight swift arch injury crystal super wrestle already dentist';
const bobPaymentCode = 'PM8TJS2JxQ5ztXUpBBRnpTbcUXbUHy2T1abfrb3KkAAtMEGNbey4oumH7Hc578WgQJhPjBxteQ5GHHToTYHE3A1w6p7tU6KSoFmWBVbFGjKPisZDbP97';

// alice private bip47
const aliceBip47 = BIP47Factory(ecc).fromBip39Seed(aliceSeedPhrase);

// base58 payment code
const alicePaymentCode = aliceBip47.getSerializedPaymentCode();

// P2PKH notification address
const aliceNotificationAddress = aliceBip47.getNotificationAddress();

// bip47 from payment code
const bobPublicBip47 = BIP47Factory(ecc).fromPaymentCode(bobPaymentCode);

// third payment address from alice to bob
const paymentAddress = aliceBip47.getPaymentAddress(bobPublicBip47.getPaymentCodeNode(), 2);

// bob private bip47
const bobPrivateBip47 = BIP47Factory(ecc).fromBip39Seed(bobSeedPhrase);

// third alice to bob wallet (bip32)
const wallet = bobPrivateBip47.getPaymentWallet(aliceBip47.getPaymentCodeNode(), 2);

// third wallet private key
const privateKey = wallet.privateKey?.toString('hex');

// examples of how to generate blinded payment code
// and retrieving payment code from notification transaction
// can be found in tests

```

see tests for more examples.


## Supported Functionality
- generate payment code from seed phrase or seed hex
- generate payment addresses
- generate notification address from payment code
- generate receiving addresses/privateKeys for a payment code
- generate blinded payment code for notification transaction
- retrieve payment code from raw notification transaction


## Reference
[BIP-47](https://github.com/bitcoin/bips/blob/master/bip-0047.mediawiki)

[BIP-47 Test Vectors](https://gist.github.com/SamouraiDev/6aad669604c5930864bd)

## Donations
We appreciate your donations if you found this repository useful :)

[paynym.is/+frostydarkness08a](https://paynym.is/+frostydarkness08a)

---
_Source: https://npm.io/package/@spsina/bip47 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
