├── .github └── workflows │ └── main_ci.yml ├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── LICENSE ├── README.md ├── index.cjs ├── index.d.ts ├── index.js ├── package-lock.json ├── package.json └── test ├── fixtures.json └── index.js /.github/workflows/main_ci.yml: -------------------------------------------------------------------------------- 1 | name: Run Tests 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | 9 | jobs: 10 | unit: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v3 14 | - uses: actions/setup-node@v4 15 | with: 16 | node-version: 18 17 | registry-url: https://registry.npmjs.org/ 18 | - run: npm ci 19 | - run: npm run test 20 | format: 21 | runs-on: ubuntu-latest 22 | steps: 23 | - uses: actions/checkout@v3 24 | - uses: actions/setup-node@v4 25 | with: 26 | node-version: 18 27 | registry-url: https://registry.npmjs.org/ 28 | - run: npm ci 29 | - run: npm run standard 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .nyc_output 3 | coverage 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | if: (type = push AND branch = master) OR type = pull_request 2 | sudo: false 3 | language: node_js 4 | node_js: 5 | - "4" 6 | - "5" 7 | - "6" 8 | - "7" 9 | - "8" 10 | - "9" 11 | matrix: 12 | include: 13 | - node_js: "8" 14 | env: TEST_SUITE=standard 15 | - node_js: "8" 16 | env: TEST_SUITE=coverage 17 | env: 18 | - TEST_SUITE=unit 19 | script: npm run-script $TEST_SUITE 20 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 2.0.0 2 | __changed__ 3 | * `decode` does not throw an exception for an invalid address, the address MUST be checked by the user 4 | * `decode` returns `{ address, options }` instead of assigning the options to the parent decode object 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 bitcoinjs 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # bip21 2 | 3 | [![build status](https://secure.travis-ci.org/bitcoinjs/bip21.png)](http://travis-ci.org/bitcoinjs/bip21) 4 | [![Version](http://img.shields.io/npm/v/bip21.svg)](https://www.npmjs.org/package/bip21) 5 | 6 | A [BIP21](https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki) compatible URL encoding library. 7 | 8 | 9 | ## Example 10 | 11 | ``` javascript 12 | var bip21 = require('bip21') 13 | 14 | var decoded = bip21.decode('bitcoin:1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH?amount=20.3&label=Foobar') 15 | 16 | console.log(decoded) 17 | // { address: '1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH', 18 | // options: { 19 | // amount: 20.3, 20 | // label: 'Foobar' } 21 | // } 22 | // 23 | // WARNING: Remember to error check the `.address`! 24 | 25 | console.log(bip21.encode('1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH')) 26 | // => bitcoin:1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH 27 | 28 | console.log(bip21.encode('1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH', { 29 | amount: 20.3, 30 | label: 'Foobar' 31 | })) 32 | // => bitcoin:1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH?amount=20.3&label=Foobar 33 | ``` 34 | 35 | 36 | ## License [MIT](LICENSE) 37 | -------------------------------------------------------------------------------- /index.cjs: -------------------------------------------------------------------------------- 1 | // https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki 2 | // bitcoin:
[?amount=][?label=