-
Notifications
You must be signed in to change notification settings - Fork 366
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
Support paying static invoices #3140
Merged
TheBlueMatt
merged 24 commits into
lightningdevkit:main
from
valentinewallace:2024-06-pay-static-invoice
Sep 15, 2024
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
732ee14
Tweak debug_assert message for parsed onion messages.
valentinewallace a3216ac
Add MessageContext for async payments.
valentinewallace e162278
Pass context into held_htlc_available message handling.
valentinewallace 3d5d64a
Store AsyncPaymentsMessages for later sending
valentinewallace cff6e34
Support checking that a static invoice matches an outbound invreq.
valentinewallace ad63a70
Support creating PaymentParameters from static invoices.
valentinewallace c3ed4a2
Store async payment data in PendingOutboundPayment.
valentinewallace 7fb16ea
Pass full message context into ChanMan blinded path util.
valentinewallace c976e4c
Release pending async payments to PeerManager.
valentinewallace b6f4479
Support initiating an async payment to a static invoice.
valentinewallace 28269a7
DRY handling when initiating payment to BOLT 12 invoice.
valentinewallace e4d7681
Error on static invoice with unknown required features.
valentinewallace 8569830
Set max path len on receipt of static invoice.
valentinewallace 69356e7
Split off send_payment_for_bolt12_invoice_internal util.
valentinewallace 0297a1e
Support sending async payments as an always-online sender.
valentinewallace 985e6ac
Timeout expired outbound async payments.
valentinewallace 6d415b1
Support abandoning pending outbound async payments.
valentinewallace 7dd1787
Correct docs on payment id in RecentPaymentDetails.
valentinewallace c4f3e25
Don't trigger manager persistence on unexpected release_htlc message.
valentinewallace 5a7f523
Rename Payment{Hash,Id} hmac creation/verification methods for offers.
valentinewallace 615eefb
Verify inbound ReleaseHeldHtlc messages via hmac.
valentinewallace 26d1582
Add new Bolt12PaymentError for failed blinded path creation.
valentinewallace 4bcf53e
Document PendingOutboundPayment::{Static}InvoiceReceived semantics.
valentinewallace 6e27aec
Remove payment_release_secret from async payments messages.
valentinewallace File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -936,7 +936,8 @@ impl OutboundPayments { | |
|
||
#[cfg(async_payments)] | ||
pub(super) fn static_invoice_received<ES: Deref>( | ||
&self, invoice: &StaticInvoice, payment_id: PaymentId, entropy_source: ES, | ||
&self, invoice: &StaticInvoice, payment_id: PaymentId, features: Bolt12InvoiceFeatures, | ||
entropy_source: ES, | ||
pending_events: &Mutex<VecDeque<(events::Event, Option<EventCompletionAction>)>> | ||
) -> Result<[u8; 32], Bolt12PaymentError> where ES::Target: EntropySource { | ||
macro_rules! abandon_with_entry { | ||
|
@@ -967,6 +968,10 @@ impl OutboundPayments { | |
if !invoice.from_same_offer(invreq) { | ||
return Err(Bolt12PaymentError::UnexpectedInvoice) | ||
} | ||
if invoice.invoice_features().requires_unknown_bits_from(&features) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this in a separate commit? Its exclusively updating code that was added in |
||
abandon_with_entry!(entry, PaymentFailureReason::UnknownRequiredFeatures); | ||
return Err(Bolt12PaymentError::UnknownRequiredFeatures) | ||
} | ||
let amount_msat = match InvoiceBuilder::<DerivedSigningPubkey>::amount_msats(invreq) { | ||
Ok(amt) => amt, | ||
Err(_) => { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for reviewers: would like to get your thoughts on whether a malicious third party would be able to create an invoice that passes this check, since they could then cause us to spuriously abandon the payment. I don't think so because the invoice's signature needs to match the offer
issuer_id
, but could be missing something.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concern also would be if they sent a static invoice they paid someone else. But I think you're right that the signature check when parsing the
StaticInvoice
should be sufficient to prevent this.