bitcoinjs / bolt11

A library for encoding and decoding lightning network payment requests as defined in BOLT #11.
MIT License
92 stars 64 forks source link

lnd simnet payment request not supported #19

Closed bumi closed 5 years ago

bumi commented 5 years ago

For local development purposes I am using a lnd simnet cluster as described here in the lnd docs

bolt11 currently does not support decoding payment requests created from a lnd node running in simnet.

Code

var lightningPayReq = require('bolt11');

var decoded = lightningPayReq.decode('lnsb1u1pwslkj8pp52u27w39645j24a0zfxnwytshxserjchdqt8nz8uwv9fp8wasxrhsdql2pkxz7tfdenjqum0w4hxggrgv4kxj7qcqzpgnvqq8t63nxmgha5945s633fdd3p5x9k889g6p02qsghx4vrgqgr3xzz3hgld8r84ellwgz3teexvqzwlxj7lgkhl8xh2p7dstq0fgsspa5ldq6');

Error:

lightning/joule-extension@autopay  » node bolt11.js 
/home/bumi/src/lightning/joule-extension/node_modules/bolt11/payreq.js:764
    throw new Error('Unknown coin bech32 prefix')
    ^

Error: Unknown coin bech32 prefix
    at Object.decode (/home/bumi/src/lightning/joule-extension/node_modules/bolt11/payreq.js:764:11)
    at Object.<anonymous> (/home/bumi/src/lightning/joule-extension/bolt11.js:3:31)
    at Module._compile (internal/modules/cjs/loader.js:816:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10)
    at Module.load (internal/modules/cjs/loader.js:685:32)
    at Function.Module._load (internal/modules/cjs/loader.js:620:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:877:12)
    at internal/main/run_main_module.js:21:11
junderw commented 5 years ago

Simnet parameters seems to have changed... iirc simnet used to use testnet prefixes etc.

  1. We should add these parameters.
  2. We should add a way to provide your own parameters.

1 is easy. Pull requests welcome.

2 is a little harder.

Thanks for the report.

bumi commented 5 years ago

As the coininfo package is used, it seems the simnet data has to be added there: https://github.com/cryptocoinjs/coininfo/blob/master/lib/coins/btc.js need to see how different the simnet data is from regtest.

junderw commented 5 years ago

Published 2 as 1.2.6

If someone wants to add an optional network arg to encode as well, PRs are welcome.

But since decode is most likely to have weird versions fed to it, apps should specify the bech32 header they will expect of their users.