rust-lightning
rust-lightning copied to clipboard
Support paying static invoices
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~.
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.
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.
Rebased so I could get #3156 in the follow-up.
Needs rebase.
Rebased due to conflicts and added a commit for some outdated docs I happened to see.
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.
Rebased, updated the error handling and added some code to avoid unnecessarily persisting ChannelManager.
Noticed one of the commits was out of order, pushed with no diff.
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.
Reworded a commit message, pushed with no diff.
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)
}
}
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)
}