Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion lightning-invoice/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,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"}
Expand Down
9 changes: 5 additions & 4 deletions lightning-invoice/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,9 @@ pub enum Currency {
/// Bitcoin testnet
BitcoinTestnet,

/// Bitcoin testnet4
BitcoinTestnet4,

/// Bitcoin regtest
Regtest,

Expand All @@ -452,12 +455,9 @@ impl From<Network> for Currency {
match network {
Network::Bitcoin => Currency::Bitcoin,
Network::Testnet => Currency::BitcoinTestnet,
Network::Testnet4 => Currency::BitcoinTestnet4,
Network::Regtest => Currency::Regtest,
Network::Signet => Currency::Signet,
_ => {
debug_assert!(false, "Need to handle new rust-bitcoin network type");
Currency::Regtest
},
}
}
}
Expand All @@ -467,6 +467,7 @@ impl From<Currency> for Network {
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?

Currency::Regtest => Network::Regtest,
Currency::Simnet => Network::Regtest,
Currency::Signet => Network::Signet,
Expand Down
2 changes: 2 additions & 0 deletions lightning-invoice/src/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ impl Display for Currency {
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

Currency::Regtest => "bcrt",
Currency::Simnet => "sb",
Currency::Signet => "tbs",
Expand Down Expand Up @@ -475,6 +476,7 @@ mod test {

assert_eq!("bc", Currency::Bitcoin.to_string());
assert_eq!("tb", Currency::BitcoinTestnet.to_string());
assert_eq!("tb", Currency::BitcoinTestnet4.to_string());
assert_eq!("bcrt", Currency::Regtest.to_string());
assert_eq!("sb", Currency::Simnet.to_string());
assert_eq!("tbs", Currency::Signet.to_string());
Expand Down
4 changes: 2 additions & 2 deletions lightning/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,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 }
Expand All @@ -56,7 +56,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"]

Expand Down