From 5feb4dc9c4aea77be83427c66f7ec93551753d26 Mon Sep 17 00:00:00 2001 From: Jeffrey Czyz Date: Mon, 4 Oct 2021 09:20:49 -0500 Subject: [PATCH] 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. --- lightning-invoice/src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lightning-invoice/src/lib.rs b/lightning-invoice/src/lib.rs index 0f125362c..f81af8623 100644 --- a/lightning-invoice/src/lib.rs +++ b/lightning-invoice/src/lib.rs @@ -1219,8 +1219,13 @@ impl Invoice { self.signed_invoice.currency() } + /// Returns the amount if specified in the invoice as millisatoshis. + pub fn amount_milli_satoshis(&self) -> Option { + self.signed_invoice.amount_pico_btc().map(|v| v / 10) + } + /// Returns the amount if specified in the invoice as pico . - pub fn amount_pico_btc(&self) -> Option { + fn amount_pico_btc(&self) -> Option { self.signed_invoice.amount_pico_btc() } } @@ -1867,6 +1872,7 @@ mod test { assert!(invoice.check_signature().is_ok()); assert_eq!(invoice.tagged_fields().count(), 10); + assert_eq!(invoice.amount_milli_satoshis(), Some(123)); assert_eq!(invoice.amount_pico_btc(), Some(1230)); assert_eq!(invoice.currency(), Currency::BitcoinTestnet); assert_eq!( -- 2.39.5