Skip to content
This repository has been archived by the owner on Aug 30, 2022. It is now read-only.

A simple library to handle bitcoin cash payments with BIP44

License

Notifications You must be signed in to change notification settings

go-faast/bitcoin-cash-payments

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bitcoin-cash-payments

Library to assist in payment processing on Bitcoin cash. It first allows for generation of address according to the BIP44 standard.

The bip44 Path for Bitcoin Cash is: m/44'/145'/...

Bitcoincashjs is used for deterministic public and private keys. Please see the BIP32 standard for more information (BIP32).

Getting Started

npm install --save bitcoin-cash-payments

Create a new wallet (DON'T DO THIS ON PRODUCTION):

let bitcoincashPayments = require('bitcoin-cash-payments')()
let keys = bitcoincashPayments.generateNewKeys('really random entropy here')
console.log(keys.xpub)
console.log(keys.xprv)

Generate an bitcoincash deposit address from a public seed (xpub). This is useful if you are a hot wallet and don't store the private key. You will need to keep track of which path node you are on (increasing INT):

let depositAddress = bitcoincashPayments.bip44(keys.xpub, 1234) // for path m/44'/0'/0'/0/1234
console.log(depositAddress)

Get the private key for an address on a specific path:

let privateKey = bitcoincashPayments.getPrivateKey(keys.xprv, 1234) // for path m/44'/0'/0'/0/1234

Get the public key from a private key:

let address = bitcoincashPayments.privateToPublic(privateKey) // for path m/44'/0'/0'/0/1234
if(address === depositAddress){
  console.log('this library works')
} else {
  console.log('better not use this library')
}

Get the derived xpub key from a hardened private key:

let xpub = bitcoincashPayments.getXpubFromXprv(xprv) // for path m/44'/0'/0'/0/1234

Note: It is suggested to generate your Private key offline with FAR more entropy than the default function, then use getXpubFromXprv. You have been warned!

License

MIT

About

A simple library to handle bitcoin cash payments with BIP44

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published