bip21
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/bip21 package

2.0.3 • Public • Published

bip21

build status Version

A BIP21 compatible URL encoding library.

Example

var bip21 = require('bip21')
 
var decoded = bip21.decode('bitcoin:1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH?amount=20.3&label=Foobar')
 
console.log(decoded)
// { address: '1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH',
//   options: {
//     amount: 20.3,
//     label: 'Foobar' }
// }
//
// WARNING: Remember to error check the `.address`!
 
console.log(bip21.encode('1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH'))
// => bitcoin:1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH
 
console.log(bip21.encode('1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH', {
    amount: 20.3,
    label: 'Foobar'
}))
// => bitcoin:1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH?amount=20.3&label=Foobar

License MIT

Readme

Keywords

Package Sidebar

Install

npm i bip21

Weekly Downloads

2,876

Version

2.0.3

License

MIT

Unpacked Size

4.5 kB

Total Files

5

Last publish

Collaborators

  • fanatid
  • jprichardson
  • junderw