Skip to content

Conversation

@tnull
Copy link
Contributor

@tnull tnull commented Oct 8, 2025

We simply add support for bitcoin::Network::Testnet4, which was added with release v0.32.4, which we hence deem the new minimal requirement for lightning and lightning-invoice.

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Oct 8, 2025

👋 Thanks for assigning @benthecarman as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

match currency {
Currency::Bitcoin => Network::Bitcoin,
Currency::BitcoinTestnet => Network::Testnet,
Currency::BitcoinTestnet4 => Network::Testnet4,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also consider not adding a new Currency variant, but if we just kept Currency::BitcoinTestnet we wouldn't be able to make this mapping back to Testnet4.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already kinda cant, though? If someone reads an invoice with the tb prefix they'll get a Currency/Network of testnet, which won't map to tn4.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already kinda cant, though? If someone reads an invoice with the tb prefix they'll get a Currency/Network of testnet, which won't map to tn4.

Okay, so what resolution do you suggest then? Opening a spec PR for a new BOLT11 prefix for Testnet4? As I mentioned below I was close to do this, but refrained so far as I thought the idea was that Testnet3 eventually is just superseded by Testnet4 and goes away. But maybe it's the easiest solution here, though we'll need to double-check that other impls are onboard with it ofc.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, I dunno, its definitely awk either way. We should at least explore it at the spec level, I imagine, but we can also map Testnet4 to Currency::BitcoinTestnet for now so that you can build an invoice from Network::Testnet4?

@tnull tnull requested a review from jkczyz October 8, 2025 08:48
@codecov
Copy link

codecov bot commented Oct 8, 2025

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 89.33%. Comparing base (6d4897c) to head (743f43f).
⚠️ Report is 25 commits behind head on main.

Files with missing lines Patch % Lines
lightning-invoice/src/lib.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main    #4148    +/-   ##
========================================
  Coverage   89.32%   89.33%            
========================================
  Files         180      180            
  Lines      138329   138480   +151     
  Branches   138329   138480   +151     
========================================
+ Hits       123566   123710   +144     
+ Misses      12157    12148     -9     
- Partials     2606     2622    +16     
Flag Coverage Δ
fuzzing 35.96% <0.00%> (+0.07%) ⬆️
tests 88.70% <0.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

let currency_code = match *self {
Currency::Bitcoin => "bc",
Currency::BitcoinTestnet => "tb",
Currency::BitcoinTestnet4 => "tb",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this what other implementations are doing? would be a shame to lose the one-to-one mapping

Copy link
Contributor Author

@tnull tnull Oct 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT yes. BOLT11 speaks about 'testnet' overall, without a specific version. I considered a PR to introduce a change specific to Testnet4 (e.g. tb4), but given that Testnet3 is supposed to eventually go away it could make sense to reuse the same prefix?

Not sure how this was handled during previous testnet upgrades though.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lightning postdates tn3

@ldk-reviews-bot
Copy link

🔔 1st Reminder

Hey @jkczyz! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 2nd Reminder

Hey @jkczyz! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 3rd Reminder

Hey @jkczyz! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 4th Reminder

Hey @jkczyz! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 5th Reminder

Hey @jkczyz! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@jkczyz jkczyz removed their request for review October 20, 2025 15:21
@tnull tnull force-pushed the 2025-10-testnet4-support branch from a0b4c2e to c49c982 Compare November 18, 2025 14:08
@tnull
Copy link
Contributor Author

tnull commented Nov 18, 2025

Since the other Lightning implementations seem to just map Testnet4 to Testnet, I now updated this PR to follow suit and not introduce a new Currency variant. Note this could lead to verification issues down the line, since we now might return a wrong Network from Bolt11Invoice::network and use a wrong network in fallback_addresses.

@TheBlueMatt @benthecarman Any opinions how to do better if the community doesn't seem to be enthused about introducing a separate prefix for testnet4?

TheBlueMatt
TheBlueMatt previously approved these changes Nov 18, 2025
Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, yea, this is fine. Annoying, but fine. Maybe the docs for Currency::Testnet should be updated to reference that its both?

@TheBlueMatt
Copy link
Collaborator

It seemed like people on the call were just viewing testnet4 LN as DoA, so not much reason to worry about supporting it well IMO.

We simply add support for `bitcoin::Network::Testnet4`, which was added
with release v0.32.4, which we hence deem the new minimal requirement
for `lightning` and `lightning-invoice`.

As other Lightning implementations seem to simply map `Testnet4` coins
to be `Testnet` (also reusing the `tb` prefix), we here follow their
lead and choose not to introduce a separate `Currecy` variant, even
though that could lead to checks failing if someone validated the
returned `fallback_addresses` for the given `Network`.
@tnull
Copy link
Contributor Author

tnull commented Nov 18, 2025

Hmm, yea, this is fine. Annoying, but fine. Maybe the docs for Currency::Testnet should be updated to reference that its both?

Amended with some more docs:

> git diff-tree -U2 c49c982bb 743f43fcf
diff --git a/lightning-invoice/src/lib.rs b/lightning-invoice/src/lib.rs
index 2bc6e53d9..0dbb3bdb0 100644
--- a/lightning-invoice/src/lib.rs
+++ b/lightning-invoice/src/lib.rs
@@ -439,4 +439,6 @@ pub enum Currency {

        /// Bitcoin testnet
+       ///
+       /// Note this will also be used for invoices on [`Network::Testnet4`].
        BitcoinTestnet,

@@ -1623,4 +1625,7 @@ impl Bolt11Invoice {
        /// Returns the network for which the invoice was issued
        ///
+       /// **Caution**: On Testnet4, this method will return [`Network::Testnet`]` rather than
+       /// [`Network::Testnet4`].
+       ///
        /// This is not exported to bindings users, see [`Self::currency`] instead.
        pub fn network(&self) -> Network {

Copy link
Contributor

@benthecarman benthecarman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mutinynet stock rises more

@TheBlueMatt @benthecarman Any opinions how to do better if the community doesn't seem to be enthused about introducing a separate prefix for testnet4?

i think the caution docs are probably sufficient for now, it is only testnet 3 vs 4 so not like people can lose money or anything on this

@TheBlueMatt
Copy link
Collaborator

CI failure looks like a flake.

@TheBlueMatt TheBlueMatt merged commit 6749bc6 into lightningdevkit:main Nov 18, 2025
24 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants