Skip to content

Commit 5feb4dc

Browse files
committed
Rewrite Invoice's interface in terms of msats
InvoiceBuilder's interface was changed recently to work in terms of msats. Update Invoice's interface to return the amount in msats, too, and make amount_pico_btc private.
1 parent 73f601f commit 5feb4dc

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lightning-invoice/src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1219,8 +1219,13 @@ impl Invoice {
12191219
self.signed_invoice.currency()
12201220
}
12211221

1222+
/// Returns the amount if specified in the invoice as millisatoshis.
1223+
pub fn amount_milli_satoshis(&self) -> Option<u64> {
1224+
self.signed_invoice.amount_pico_btc().map(|v| v / 10)
1225+
}
1226+
12221227
/// Returns the amount if specified in the invoice as pico <currency>.
1223-
pub fn amount_pico_btc(&self) -> Option<u64> {
1228+
fn amount_pico_btc(&self) -> Option<u64> {
12241229
self.signed_invoice.amount_pico_btc()
12251230
}
12261231
}
@@ -1867,6 +1872,7 @@ mod test {
18671872
assert!(invoice.check_signature().is_ok());
18681873
assert_eq!(invoice.tagged_fields().count(), 10);
18691874

1875+
assert_eq!(invoice.amount_milli_satoshis(), Some(123));
18701876
assert_eq!(invoice.amount_pico_btc(), Some(1230));
18711877
assert_eq!(invoice.currency(), Currency::BitcoinTestnet);
18721878
assert_eq!(

0 commit comments

Comments
 (0)