bitcoinjs / bolt11

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

Bring back support for regtest #39

Closed mrfelton closed 3 years ago

mrfelton commented 3 years ago

Seems that in latest code regtest is no longer a recognised network

junderw commented 3 years ago

You can pass any network directly, so we removed support for all the networks.

Anyone can pass in any network whenever they want.

This is all you need.

{
  bech32: 'bcrt',
  pubKeyHash: 0x6f,
  scriptHash: 0xc4,
  validWitnessVersions: [0],
}
Evanfeenstra commented 3 years ago

manually checking prefixes before decoding is something that the library should handle. Please support regtest again

apotdevin commented 3 years ago

Yes! Please bring this back 🙏

apotdevin commented 3 years ago

Made a PR for this https://github.com/bitcoinjs/bolt11/pull/49 @junderw

junderw commented 3 years ago

manually checking prefixes before decoding

Your application knows what network it should be using. If your application is regtest, it only needs to pass regtest to decode and then the library will make sure it is a invoice for regtest.

The problem with answering the question "What network is this?" is that we can't possibly know all the possible future networks using lightning invoices. So there has to be a line drawn, and there should be a way for other networks to use the library (passing the network param).

The line was drawn to not include regtest. Because anyone using regtest (which is for automated testing) should know they are looking for regtest invoices ahead of time and can just as easily pass in the network parameter.


That said, dealing with this problem at a more structural level by changing the way this library deals with networks is something I don't have the bandwidth for right now... so we'll re-draw the line in the sand and kick the can down the road for now.

Evanfeenstra commented 3 years ago

yes that makes sense. If it were me I would draw the line just past bitcoin regtest :)

junderw commented 3 years ago

Published as 1.3.2