]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Add proper signet support for invoices
authorDevrandom <c1.devrandom@niftybox.net>
Mon, 7 Jun 2021 14:29:39 +0000 (16:29 +0200)
committerDevrandom <c1.devrandom@niftybox.net>
Mon, 7 Jun 2021 14:29:39 +0000 (16:29 +0200)
lightning-invoice/src/de.rs
lightning-invoice/src/lib.rs
lightning-invoice/src/ser.rs

index 3610bc4b67fab01f11283aed957c1fe71ccb4731..47557665b4bf4b473a90657280c9b807ebadbfdc 100644 (file)
@@ -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::<Currency>(), Ok(Currency::BitcoinTestnet));
                assert_eq!("bcrt".parse::<Currency>(), Ok(Currency::Regtest));
                assert_eq!("sb".parse::<Currency>(), Ok(Currency::Simnet));
+               assert_eq!("tbs".parse::<Currency>(), Ok(Currency::Signet));
                assert_eq!("something_else".parse::<Currency>(), Err(ParseError::UnknownCurrency))
        }
 
index 29c093dec95925f19f86d745ecdf54bd98856851..064b3626537c2d93b753e6dd9095522010131a77 100644 (file)
@@ -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
index 8811926782348a263735b55824ea74fb65d662cb..885ea2684f2295665ebd0ac8800b90e08f7685ed 100644 (file)
@@ -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]