From: Matt Corallo Date: Sun, 26 Nov 2023 19:07:10 +0000 (+0000) Subject: Drop panic if `rust-bitcoin` adds a new `Network` X-Git-Tag: v0.0.119~46^2~1 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=b28068cc42882631799696b144d343686d2c3ebc;p=rust-lightning Drop panic if `rust-bitcoin` adds a new `Network` `rust-bitcoin` 0.30 added `#[non_exhaustive]` to the `Network` enum, allowing them to "add support" for a new network type without a major version change in the future. When upgrading, we added a simple `unreachable` for the general match arm, which would break in a minor version change of `rust-bitcoin`. While it seems [possible rust-bitcoin will change this](https://github.com/rust-bitcoin/rust-bitcoin/issues/2225), we still shouldn't ba panicking, which we drop here in favor of a `debug_assert`ion, and a default value. --- diff --git a/lightning-invoice/src/lib.rs b/lightning-invoice/src/lib.rs index d30fb638d..d87c6c893 100644 --- a/lightning-invoice/src/lib.rs +++ b/lightning-invoice/src/lib.rs @@ -407,7 +407,10 @@ impl From for Currency { Network::Testnet => Currency::BitcoinTestnet, Network::Regtest => Currency::Regtest, Network::Signet => Currency::Signet, - _ => unreachable!(), + _ => { + debug_assert!(false, "Need to handle new rust-bitcoin network type"); + Currency::Regtest + }, } } }