What changed, and why it matters
This commit adds support for Bitcoin's new Testnet4 network in the rust-lightning library. It mainly bumps a dependency version and maps Testnet4 invoices to use the existing Testnet currency type. The change is a routine compatibility update, not a security fix, though it removes a fallback that previously treated unknown networks as regtest.
No immediate security action required. Reviewers may want to confirm that downstream consumers handling fallback_addresses or network validation are aware of the Testnet/Testnet4 aliasing behavior documented in the commit.
Security signals we found
Removal of wildcard fallback that defaulted unrecognized rust-bitcoin Network variants to Regtest
Explicit handling of new network variant reduces risk of misclassification for future networks
No memory safety, cryptographic, or authorization changes present
Evidence from the diff
The patch bumps the rust-bitcoin dependency from 0.32.2 to 0.32.4 across fuzz, lightning, and lightning-invoice crates to gain access to Network::Testnet4. In lightning-invoice/src/lib.rs it adds Testnet4 to the Currency mapping, routing it to Currency::BitcoinTestnet (matching other Lightning implementations’ behavior). It also removes the wildcard _ arm that previously debug_asserted and defaulted unknown networks to Regtest, and adds a cautionary doc comment noting that Bolt11Invoice::network() will return Network::Testnet for Testnet4 invoices.
Changed components
lightning-invoice/src/lib.rslightning/Cargo.tomllightning-invoice/Cargo.tomlfuzz/Cargo.tomlInspect captured patch +10 / −8
diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml
index 908dd55..86ad12e 100644
--- a/fuzz/Cargo.toml
+++ b/fuzz/Cargo.toml
@@ -24,7 +24,7 @@ lightning-liquidity = { path = "../lightning-liquidity" }
lightning-rapid-gossip-sync = { path = "../lightning-rapid-gossip-sync" }
lightning-persister = { path = "../lightning-persister", features = ["tokio"]}
bech32 = "0.11.0"
-bitcoin = { version = "0.32.2", features = ["secp-lowmemory"] }
+bitcoin = { version = "0.32.4", features = ["secp-lowmemory"] }
tokio = { version = "~1.35", default-features = false, features = ["rt-multi-thread"] }
afl = { version = "0.12", optional = true }
diff --git a/lightning-invoice/Cargo.toml b/lightning-invoice/Cargo.toml
index 46b62ed..f92d8b9 100644
--- a/lightning-invoice/Cargo.toml
+++ b/lightning-invoice/Cargo.toml
@@ -22,7 +22,7 @@ std = []
bech32 = { version = "0.11.0", default-features = false }
lightning-types = { version = "0.3.0", path = "../lightning-types", default-features = false }
serde = { version = "1.0", optional = true, default-features = false, features = ["alloc"] }
-bitcoin = { version = "0.32.2", default-features = false, features = ["secp-recovery"] }
+bitcoin = { version = "0.32.4", default-features = false, features = ["secp-recovery"] }
[dev-dependencies]
serde_json = { version = "1"}
diff --git a/lightning-invoice/src/lib.rs b/lightning-invoice/src/lib.rs
index 47f9293..0dbb3bd 100644
--- a/lightning-invoice/src/lib.rs
+++ b/lightning-invoice/src/lib.rs
@@ -438,6 +438,8 @@ pub enum Currency {
Bitcoin,
/// Bitcoin testnet
+ ///
+ /// Note this will also be used for invoices on [`Network::Testnet4`].
BitcoinTestnet,
/// Bitcoin regtest
@@ -455,12 +457,9 @@ impl From<Network> for Currency {
match network {
Network::Bitcoin => Currency::Bitcoin,
Network::Testnet => Currency::BitcoinTestnet,
+ Network::Testnet4 => Currency::BitcoinTestnet,
Network::Regtest => Currency::Regtest,
Network::Signet => Currency::Signet,
- _ => {
- debug_assert!(false, "Need to handle new rust-bitcoin network type");
- Currency::Regtest
- },
}
}
}
@@ -1625,6 +1624,9 @@ 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 {
self.signed_invoice.currency().into()
diff --git a/lightning/Cargo.toml b/lightning/Cargo.toml
index 9df4a72..257c759 100644
--- a/lightning/Cargo.toml
+++ b/lightning/Cargo.toml
@@ -39,7 +39,7 @@ lightning-invoice = { version = "0.34.0", path = "../lightning-invoice", default
lightning-macros = { version = "0.2", path = "../lightning-macros" }
bech32 = { version = "0.11.0", default-features = false }
-bitcoin = { version = "0.32.2", default-features = false, features = ["secp-recovery"] }
+bitcoin = { version = "0.32.4", default-features = false, features = ["secp-recovery"] }
dnssec-prover = { version = "0.6", default-features = false }
hashbrown = { version = "0.13", default-features = false }
@@ -58,7 +58,7 @@ lightning-macros = { path = "../lightning-macros" }
parking_lot = { version = "0.12", default-features = false }
[dev-dependencies.bitcoin]
-version = "0.32.2"
+version = "0.32.4"
default-features = false
features = ["bitcoinconsensus", "secp-recovery"]
Why this scored 20/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.