Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add proper signet support for invoices #943

Merged
merged 1 commit into from
Jun 8, 2021
Merged
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: 2 additions & 0 deletions lightning-invoice/src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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))
}

Expand Down
5 changes: 4 additions & 1 deletion lightning-invoice/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 @@ -153,6 +153,7 @@ impl Display for Currency {
Currency::BitcoinTestnet => "tb",
Currency::Regtest => "bcrt",
Currency::Simnet => "sb",
Currency::Signet => "tbs",
};
write!(f, "{}", currency_code)
}
Expand Down Expand Up @@ -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]
Expand Down