{"id":28493782,"url":"https://github.com/bitcoinjs/bolt11","last_synced_at":"2025-07-08T13:31:53.701Z","repository":{"id":27301742,"uuid":"113274880","full_name":"bitcoinjs/bolt11","owner":"bitcoinjs","description":"A library for encoding and decoding lightning network payment requests as defined in BOLT #11.","archived":false,"fork":false,"pushed_at":"2024-10-29T16:06:20.000Z","size":341,"stargazers_count":102,"open_issues_count":10,"forks_count":71,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-06-27T09:55:18.408Z","etag":null,"topics":["bech32","bitcoin","bolt11","invoice","lightning","network","payment","request"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bitcoinjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-06T05:52:29.000Z","updated_at":"2025-05-12T23:33:59.000Z","dependencies_parsed_at":"2024-11-19T22:48:11.651Z","dependency_job_id":null,"html_url":"https://github.com/bitcoinjs/bolt11","commit_stats":{"total_commits":132,"total_committers":11,"mean_commits":12.0,"dds":0.2727272727272727,"last_synced_commit":"d42c17209cb0fd7f4d503fdda26d9835da867054"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/bitcoinjs/bolt11","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitcoinjs%2Fbolt11","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitcoinjs%2Fbolt11/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitcoinjs%2Fbolt11/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitcoinjs%2Fbolt11/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitcoinjs","download_url":"https://codeload.github.com/bitcoinjs/bolt11/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitcoinjs%2Fbolt11/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264277699,"owners_count":23583652,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bech32","bitcoin","bolt11","invoice","lightning","network","payment","request"],"created_at":"2025-06-08T09:31:12.331Z","updated_at":"2025-07-08T13:31:53.694Z","avatar_url":"https://github.com/bitcoinjs.png","language":"JavaScript","readme":"# bolt11\nA library for encoding and decoding lightning network payment requests as defined in [BOLT #11](https://github.com/lightningnetwork/lightning-rfc/blob/master/11-payment-encoding.md).\n\n\n## Installation\n``` bash\nnpm install bolt11\n```\n\n## Setup\n### Node.js\n``` javascript\nvar lightningPayReq = require('bolt11')\n```\n\n\n## Examples\n### Decoding\n``` javascript\n// The tags array output can be parsed into an object using the tagsObject getter (see below)\nvar decoded = lightningPayReq.decode('lnbc20u1pvjluezhp58yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqfppqw508d6qejxtdg4y5r3zarvary0c5xw7kxqrrsssp5m6kmam774klwlh4dhmhaatd7al02m0h0m6kmam774klwlh4dhmhs9qypqqqcqpf3cwux5979a8j28d4ydwahx00saa68wq3az7v9jdgzkghtxnkf3z5t7q5suyq2dl9tqwsap8j0wptc82cpyvey9gf6zyylzrm60qtcqsq7egtsq')\n/* decoded == below\n{\n  \"complete\": true,\n  \"millisatoshis\": \"2000000\",\n  \"network\": {\n    \"bech32\": \"bc\",\n    \"pubKeyHash\": 0,\n    \"scriptHash\": 5,\n    \"validWitnessVersions\": [0, 1]\n  },\n  \"payeeNodeKey\": \"03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad\",\n  \"paymentRequest\": \"lnbc20u1pvjluezhp58yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqfppqw508d6qejxtdg4y5r3zarvary0c5xw7kxqrrsssp5m6kmam774klwlh4dhmhaatd7al02m0h0m6kmam774klwlh4dhmhs9qypqqqcqpf3cwux5979a8j28d4ydwahx00saa68wq3az7v9jdgzkghtxnkf3z5t7q5suyq2dl9tqwsap8j0wptc82cpyvey9gf6zyylzrm60qtcqsq7egtsq\",\n  \"prefix\": \"lnbc20u\",\n  \"recoveryFlag\": 0,\n  \"satoshis\": 2000,\n  \"signature\": \"8e1dc350be2f4f251db5235ddb99ef877ba3b811e8bcc2c9a81591759a764c4545f81487080537e5581d0e84f27b82bc1d580919921509d0884f887bd3c0bc02\",\n  \"tags\": [\n    {\n      \"tagName\": \"purpose_commit_hash\",\n      \"data\": \"3925b6f67e2c340036ed12093dd44e0368df1b6ea26c53dbe4811f58fd5db8c1\"\n    },\n    {\n      \"tagName\": \"payment_hash\",\n      \"data\": \"0001020304050607080900010203040506070809000102030405060708090102\"\n    },\n    {\n      \"tagName\": \"fallback_address\",\n      \"data\": {\n        \"code\": 0,\n        \"address\": \"bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4\",\n        \"addressHash\": \"751e76e8199196d454941c45d1b3a323f1433bd6\"\n      }\n    },\n    {\n      \"tagName\": \"expire_time\",\n      \"data\": 3600\n    },\n    {\n      \"tagName\": \"payment_secret\",\n      \"data\": \"deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef\"\n    },\n    {\n      \"tagName\": \"feature_bits\",\n      \"data\": {\n        \"word_length\": 4,\n        \"option_data_loss_protect\": {\n          \"required\": false,\n          \"supported\": false\n        },\n        \"initial_routing_sync\": {\n          \"required\": false,\n          \"supported\": false\n        },\n        \"option_upfront_shutdown_script\": {\n          \"required\": false,\n          \"supported\": false\n        },\n        \"gossip_queries\": {\n          \"required\": false,\n          \"supported\": false\n        },\n        \"var_onion_optin\": {\n          \"required\": false,\n          \"supported\": false\n        },\n        \"gossip_queries_ex\": {\n          \"required\": false,\n          \"supported\": false\n        },\n        \"option_static_remotekey\": {\n          \"required\": false,\n          \"supported\": false\n        },\n        \"payment_secret\": {\n          \"required\": false,\n          \"supported\": true\n        },\n        \"basic_mpp\": {\n          \"required\": false,\n          \"supported\": false\n        },\n        \"option_support_large_channel\": {\n          \"required\": false,\n          \"supported\": false\n        },\n        \"extra_bits\": {\n          \"start_bit\": 20,\n          \"bits\": [],\n          \"has_required\": false\n        }\n      }\n    },\n    {\n      \"tagName\": \"min_final_cltv_expiry\",\n      \"data\": 9\n    }\n  ],\n  \"timeExpireDate\": 1496318258,\n  \"timeExpireDateString\": \"2017-06-01T11:57:38.000Z\",\n  \"timestamp\": 1496314658,\n  \"timestampString\": \"2017-06-01T10:57:38.000Z\",\n  \"wordsTemp\": \"temp1pvjluezhp58yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqfppqw508d6qejxtdg4y5r3zarvary0c5xw7kxqrrsssp5m6kmam774klwlh4dhmhaatd7al02m0h0m6kmam774klwlh4dhmhs9qypqqqcqpf3cwux5979a8j28d4ydwahx00saa68wq3az7v9jdgzkghtxnkf3z5t7q5suyq2dl9tqwsap8j0wptc82cpyvey9gf6zyylzrm60qtcqsq5xx76e\"\n}\n*/\n```\n\n### Get tags as an object\n```javascript\n// decoded is from above\ndecoded.tagsObject\n/*\n{\n  \"purpose_commit_hash\": \"3925b6f67e2c340036ed12093dd44e0368df1b6ea26c53dbe4811f58fd5db8c1\",\n  \"payment_hash\": \"0001020304050607080900010203040506070809000102030405060708090102\",\n  \"fallback_address\": {\n    \"code\": 0,\n    \"address\": \"bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4\",\n    \"addressHash\": \"751e76e8199196d454941c45d1b3a323f1433bd6\"\n  },\n  \"expire_time\": 3600,\n  \"payment_secret\": \"deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef\",\n  \"feature_bits\": {\n    \"word_length\": 4,\n    \"option_data_loss_protect\": {\n      \"required\": false,\n      \"supported\": false\n    },\n    \"initial_routing_sync\": {\n      \"required\": false,\n      \"supported\": false\n    },\n    \"option_upfront_shutdown_script\": {\n      \"required\": false,\n      \"supported\": false\n    },\n    \"gossip_queries\": {\n      \"required\": false,\n      \"supported\": false\n    },\n    \"var_onion_optin\": {\n      \"required\": false,\n      \"supported\": false\n    },\n    \"gossip_queries_ex\": {\n      \"required\": false,\n      \"supported\": false\n    },\n    \"option_static_remotekey\": {\n      \"required\": false,\n      \"supported\": false\n    },\n    \"payment_secret\": {\n      \"required\": false,\n      \"supported\": true\n    },\n    \"basic_mpp\": {\n      \"required\": false,\n      \"supported\": false\n    },\n    \"option_support_large_channel\": {\n      \"required\": false,\n      \"supported\": false\n    },\n    \"extra_bits\": {\n      \"start_bit\": 20,\n      \"bits\": [],\n      \"has_required\": false\n    }\n  },\n  \"min_final_cltv_expiry\": 9\n}\n*/\n```\n\n### Warning\nThe `\"satoshis\"` field will only be set if the invoice is for a whole number of satoshis. If it is in a fractional number of satoshis, the `\"millisatoshis\"` field must be used. 1000 millisatoshis is 1 satoshi.\n\n### Encoding\n* MINIMUM NEED: `privateKey` and one `payment_hash` tag as well as one `description`\n  * (`timestamp` defaults to current time, `description` defaults to empty string,\n    and `network` defaults to bitcoin mainnet)\n* Alternatively: You can pass the result of decode into encode and it will use the\nsignature and recoveryFlag attributes to reconstruct the payment request. In this\ncase you will require also `network` and `timestamp` as well as all tags in the\nexact order of the original signed request.\n  * It is also required to pass the `payeeNodeKey` attribute when encoding an\n  already signed request, as decoders will recover the pubkey, any incorrect data\n  would cause an incorrect pubkey to be generated and will cause an error on the\n  decoding end when trying to send.\n* Note: tag order matters. The message is signed, so to maintain tag order it is\n  an array type.\n\n``` javascript\nvar encoded = lightningPayReq.encode({\n  \"network\": {\n    \"bech32\": \"bc\",\n    \"pubKeyHash\": 0,\n    \"scriptHash\": 5,\n    \"validWitnessVersions\": [0, 1]\n  },\n  \"satoshis\": 2000,\n  \"timestamp\": 1496314658,\n  \"tags\": [\n    {\n      \"tagName\": \"purpose_commit_hash\",\n      \"data\": \"3925b6f67e2c340036ed12093dd44e0368df1b6ea26c53dbe4811f58fd5db8c1\"\n    },\n    {\n      \"tagName\": \"payment_hash\",\n      \"data\": \"0001020304050607080900010203040506070809000102030405060708090102\"\n    },\n    {\n      \"tagName\": \"fallback_address\",\n      \"data\": {\n        \"address\": \"bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4\"\n      }\n    },\n    {\n      \"tagName\": \"expire_time\",\n      \"data\": 3600\n    },\n    {\n      \"tagName\": \"payment_secret\",\n      \"data\": \"deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef\"\n    },\n    {\n        \"tagName\": \"feature_bits\",\n        \"data\": {\n          \"payment_secret\": {\n            \"required\": false,\n            \"supported\": true\n          }\n        }\n    }\n  ]\n})\n// sign takes the encoded object and the private key as arguments\nvar privateKeyHex = 'e126f68f7eafcc8b74f54d269fe206be715000f94dac067d1c04a8ca3b2db734'\nvar signed = lightningPayReq.sign(encoded, privateKeyHex)\n/* signed.paymentRequest == below\nlnbc20u1pvjluezhp58yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqfppqw508d6qejxtdg4y5r3zarvary0c5xw7kxqrrsssp5m6kmam774klwlh4dhmhaatd7al02m0h0m6kmam774klwlh4dhmhs9qypqqqcqpf3cwux5979a8j28d4ydwahx00saa68wq3az7v9jdgzkghtxnkf3z5t7q5suyq2dl9tqwsap8j0wptc82cpyvey9gf6zyylzrm60qtcqsq7egtsq\n*/\n```\n\n## Browser Use\nYou can use this in the browser. First install browserify and uglify-es (uglifyjs for ES6+) globally.\n\n``` bash\nnpm install -g browserify uglify-es\n```\n\nThen run the command.\n\n``` bash\nbrowserify -r bolt11 --standalone lightningPayReq | uglifyjs -c -m -o bolt11.min.js\n```\n\nNow load bolt11.min.js into an HTML page like so:\n\n``` HTML\n\u003cscript src=\"./js/bolt11.min.js\"\u003e\u003c/script\u003e\n```\n\nAnd now you can do all the examples above in a browser using the global\n`lightningPayReq` object.\n\n## Contributing\nWe are always accepting of pull requests, but we do adhere to specific standards in regards to coding style, test driven development and commit messages.\n\nPlease make your best effort to adhere to these when contributing to save on trivial corrections.\n\n\n### Running the test suite\n\n``` bash\nnpm test\nnpm run-script coverage\n```\n\n\n## LICENSE [MIT](LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitcoinjs%2Fbolt11","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitcoinjs%2Fbolt11","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitcoinjs%2Fbolt11/lists"}