rust-lightning icon indicating copy to clipboard operation
rust-lightning copied to clipboard

Support paying static invoices

Open valentinewallace opened this issue 1 year ago • 3 comments

Support sending async payments as an always-online sender per https://github.com/lightning/bolts/pull/1149, minus including the invreq in the payment onion.

Async receive is not yet supported, nor is sending async payments as an often-offline sender. Upcoming PRs will add async receive which will allow us to test the flow end-to-end.

Blocked on ~#3125~, ~#3145~, ~#3085~.

valentinewallace avatar Jun 20 '24 20:06 valentinewallace

Codecov Report

Attention: Patch coverage is 85.78199% with 30 lines in your changes missing coverage. Please review.

Project coverage is 90.02%. Comparing base (1059f5f) to head (6e27aec). Report is 32 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/ln/channelmanager.rs 50.00% 16 Missing and 1 partial :warning:
lightning/src/ln/outbound_payment.rs 94.93% 8 Missing :warning:
lightning/src/onion_message/messenger.rs 0.00% 2 Missing :warning:
lightning/src/ln/peer_handler.rs 0.00% 1 Missing :warning:
lightning/src/offers/signer.rs 93.33% 0 Missing and 1 partial :warning:
lightning/src/onion_message/functional_tests.rs 0.00% 1 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3140      +/-   ##
==========================================
+ Coverage   89.63%   90.02%   +0.38%     
==========================================
  Files         126      126              
  Lines      102383   104805    +2422     
  Branches   102383   104805    +2422     
==========================================
+ Hits        91776    94350    +2574     
+ Misses       7877     7750     -127     
+ Partials     2730     2705      -25     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Jun 24 '24 16:06 codecov-commenter

Rebased so I could get #3156 in the follow-up.

valentinewallace avatar Jul 08 '24 17:07 valentinewallace

Needs rebase.

TheBlueMatt avatar Jul 10 '24 13:07 TheBlueMatt

Rebased due to conflicts and added a commit for some outdated docs I happened to see.

valentinewallace avatar Aug 20 '24 19:08 valentinewallace

Realized that post-#3192 I need to redo some of the error handling to be more along the lines of that PR's approach. Working on some updates.

valentinewallace avatar Aug 21 '24 19:08 valentinewallace

Rebased, updated the error handling and added some code to avoid unnecessarily persisting ChannelManager.

valentinewallace avatar Aug 29 '24 20:08 valentinewallace

Noticed one of the commits was out of order, pushed with no diff.

valentinewallace avatar Sep 05 '24 14:09 valentinewallace

There's a handful of additional commits here that could really use a second and third sentence to explain why we're doing what, even if it feels kinda obvious based on the next commit or two.

TheBlueMatt avatar Sep 05 '24 16:09 TheBlueMatt

Reworded a commit message, pushed with no diff.

valentinewallace avatar Sep 11 '24 21:09 valentinewallace

Squashed in the new changes with the following diff:

diff --git a/lightning/src/offers/signer.rs b/lightning/src/offers/signer.rs
index d6372bca8..d8caa2175 100644
--- a/lightning/src/offers/signer.rs
+++ b/lightning/src/offers/signer.rs
@@ -44,7 +44,7 @@ const OFFER_PAYMENT_ID_HMAC_INPUT: &[u8; 16] = &[5; 16];
 const ASYNC_PAYMENT_ID_HMAC_INPUT: &[u8; 16] = &[6; 16];

 // HMAC input for a `PaymentHash`. The HMAC is used in `OffersContext::InboundPayment`.
-const PAYMENT_HASH_HMAC_INPUT: &[u8; 16] = &[6; 16];
+const PAYMENT_HASH_HMAC_INPUT: &[u8; 16] = &[7; 16];

 /// Message metadata which possibly is derived from [`MetadataMaterial`] such that it can be
 /// verified.
diff --git a/lightning/src/offers/static_invoice.rs b/lightning/src/offers/static_invoice.rs
index 74955abe0..d083cae88 100644
--- a/lightning/src/offers/static_invoice.rs
+++ b/lightning/src/offers/static_invoice.rs
@@ -315,8 +315,10 @@ impl StaticInvoice {
        }

        pub(crate) fn from_same_offer(&self, invreq: &InvoiceRequest) -> bool {
-               let invoice_offer_tlv_stream = TlvStream::new(&self.bytes).range(OFFER_TYPES);
-               let invreq_offer_tlv_stream = TlvStream::new(invreq.bytes()).range(OFFER_TYPES);
+               let invoice_offer_tlv_stream = TlvStream::new(&self.bytes).range(OFFER_TYPES)
+                       .map(|tlv_record| tlv_record.record_bytes);
+               let invreq_offer_tlv_stream = TlvStream::new(invreq.bytes()).range(OFFER_TYPES)
+                       .map(|tlv_record| tlv_record.record_bytes);
                invoice_offer_tlv_stream.eq(invreq_offer_tlv_stream)
        }
 }

valentinewallace avatar Sep 13 '24 14:09 valentinewallace

Oops, and a rustfmt fix:

diff --git a/lightning/src/offers/static_invoice.rs b/lightning/src/offers/static_invoice.rs
index d083cae88..4910c57c5 100644
--- a/lightning/src/offers/static_invoice.rs
+++ b/lightning/src/offers/static_invoice.rs
@@ -315,9 +315,11 @@ impl StaticInvoice {
        }

        pub(crate) fn from_same_offer(&self, invreq: &InvoiceRequest) -> bool {
-               let invoice_offer_tlv_stream = TlvStream::new(&self.bytes).range(OFFER_TYPES)
+               let invoice_offer_tlv_stream = TlvStream::new(&self.bytes)
+                       .range(OFFER_TYPES)
                        .map(|tlv_record| tlv_record.record_bytes);
-               let invreq_offer_tlv_stream = TlvStream::new(invreq.bytes()).range(OFFER_TYPES)
+               let invreq_offer_tlv_stream = TlvStream::new(invreq.bytes())
+                       .range(OFFER_TYPES)
                        .map(|tlv_record| tlv_record.record_bytes);
                invoice_offer_tlv_stream.eq(invreq_offer_tlv_stream)
        }

valentinewallace avatar Sep 13 '24 14:09 valentinewallace