From bac5f4930f78c0aa95f5652bb16dd2cbdca66eca Mon Sep 17 00:00:00 2001 From: Devrandom Date: Mon, 7 Jun 2021 16:29:39 +0200 Subject: [PATCH] Add proper signet support for invoices --- lightning-invoice/src/de.rs | 2 ++ lightning-invoice/src/lib.rs | 5 ++++- lightning-invoice/src/ser.rs | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lightning-invoice/src/de.rs b/lightning-invoice/src/de.rs index 3610bc4b6..47557665b 100644 --- a/lightning-invoice/src/de.rs +++ b/lightning-invoice/src/de.rs @@ -185,6 +185,7 @@ impl FromStr for super::Currency { "tb" => Ok(Currency::BitcoinTestnet), "bcrt" => Ok(Currency::Regtest), "sb" => Ok(Currency::Simnet), + "tbs" => Ok(Currency::Signet), _ => Err(ParseError::UnknownCurrency) } } @@ -774,6 +775,7 @@ mod test { assert_eq!("tb".parse::(), Ok(Currency::BitcoinTestnet)); assert_eq!("bcrt".parse::(), Ok(Currency::Regtest)); assert_eq!("sb".parse::(), Ok(Currency::Simnet)); + assert_eq!("tbs".parse::(), Ok(Currency::Signet)); assert_eq!("something_else".parse::(), Err(ParseError::UnknownCurrency)) } diff --git a/lightning-invoice/src/lib.rs b/lightning-invoice/src/lib.rs index 29c093dec..064b36265 100644 --- a/lightning-invoice/src/lib.rs +++ b/lightning-invoice/src/lib.rs @@ -328,8 +328,11 @@ pub enum Currency { /// Bitcoin regtest Regtest, - /// Bitcoin simnet/signet + /// Bitcoin simnet Simnet, + + /// Bitcoin signet + Signet, } /// Tagged field which may have an unknown tag diff --git a/lightning-invoice/src/ser.rs b/lightning-invoice/src/ser.rs index 881192678..885ea2684 100644 --- a/lightning-invoice/src/ser.rs +++ b/lightning-invoice/src/ser.rs @@ -153,6 +153,7 @@ impl Display for Currency { Currency::BitcoinTestnet => "tb", Currency::Regtest => "bcrt", Currency::Simnet => "sb", + Currency::Signet => "tbs", }; write!(f, "{}", currency_code) } @@ -473,6 +474,7 @@ mod test { assert_eq!("tb", Currency::BitcoinTestnet.to_string()); assert_eq!("bcrt", Currency::Regtest.to_string()); assert_eq!("sb", Currency::Simnet.to_string()); + assert_eq!("tbs", Currency::Signet.to_string()); } #[test] -- 2.39.5