Skip to content

Simple and standalone javascript implementation of modified BIP173 for Bitcoin Cash addresses

Notifications You must be signed in to change notification settings

Ayms/cashaddress

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

Cashaddress

Simple and standalone javascript implementation of modified BIP173 for Bitcoin Cash addresses

Code

The Bitcoin Cash specs are here

Unlike other implementations this module does not require any external one and can be used standalone, this is implemented for nodejs but can be easily adapted for browsers, Buffer then need to be changed, you might consider Ayms/node-typedarray

Cashaddresses are computed by group of 5 bits with 5 bytes which does not make it easy for a js implementation since js handles numbers and operators with 4 bytes, therefore standard operators can't be used and some manipulations can look strange in the code but are not (and certainly less than other implementations bypassing this little difficulty by funnily using Big Integers)

Installation

Just copy the cashaddress.js file

Use

//hash:'76a04053bda0a88bda5177b86a15c3b29f559873' //1BpEi6DfDAUFd7GtittLSdBeYJvcoaVggu

var addr=encode_b(new Buffer(hash,'hex'),'p2pkh','bitcoincash');

console.log(addr)

//bitcoincash:qpm2qsznhks23z7629mms6s4cwef74vcwvy22gdx6a

console.log(decode_b(addr));

//{hash:'76a04053bda0a88bda5177b86a15c3b29f559873',type:'p2pkh'}

See the test vectors at the end of the code

License

MIT License

Related projects :

About

Simple and standalone javascript implementation of modified BIP173 for Bitcoin Cash addresses

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published