Skip to content

Commit e40919b

Browse files
fixup! add the bolt12 invoice to the PaymentSend event
Signed-off-by: Vincenzo Palazzo <[email protected]>
1 parent 0cd70fa commit e40919b

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

lightning/src/events/mod.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,10 @@ pub enum Event {
955955
/// payment hash. A third party can verify that the payment was made by
956956
/// showing the invoice and confirming that the payment hash matches
957957
/// the hash of the payment preimage.
958+
///
959+
/// However, the [`PaidInvoice`] can also be of type [`StaticInvoice`], which
960+
/// is a special [`Bolt12Invoice`] where proof of payment is not possible.
961+
/// For more details, see the `async_payments` specification.
958962
bolt12_invoice: Option<PaidInvoice>,
959963
},
960964
/// Indicates an outbound payment failed. Individual [`Event::PaymentPathFailed`] events
@@ -2450,13 +2454,12 @@ impl<T: EventHandler> EventHandler for Arc<T> {
24502454
}
24512455
}
24522456

2453-
/// Wrapper time to move the bolt12 invoice and the static
2454-
/// invoice across the same event as a unique type.
2457+
/// The BOLT 12 invoice that was paid, surfaced in [`Event::PaymentSent::bolt12_invoice`].
24552458
#[derive(Clone, Debug, PartialEq, Eq)]
24562459
pub enum PaidInvoice {
2457-
/// Bolt12 invoice
2460+
///
24582461
Bolt12Invoice(crate::offers::invoice::Bolt12Invoice),
2459-
/// Static invoice
2462+
///
24602463
StaticInvoice(crate::offers::static_invoice::StaticInvoice),
24612464
}
24622465

lightning/src/ln/outbound_payment.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ impl_writeable_tlv_based!(RetryableInvoiceRequest, {
157157
});
158158

159159
impl PendingOutboundPayment {
160-
fn bolt12_invoice(&self) -> Option<&PaidInvoice> {
160+
fn bolt12_invoice(&self) -> Option<PaidInvoice> {
161161
match self {
162-
PendingOutboundPayment::Retryable { bolt12_invoice, .. } => bolt12_invoice.as_ref(),
162+
PendingOutboundPayment::Retryable { bolt12_invoice, .. } => bolt12_invoice.clone(),
163163
_ => None,
164164
}
165165
}
@@ -968,7 +968,7 @@ impl OutboundPayments {
968968
}
969969
let invoice = PaidInvoice::Bolt12Invoice(invoice.clone());
970970
self.send_payment_for_bolt12_invoice_internal(
971-
payment_id, payment_hash, None, None, Some(&invoice), route_params, retry_strategy, router, first_hops,
971+
payment_id, payment_hash, None, None, Some(invoice), route_params, retry_strategy, router, first_hops,
972972
inflight_htlcs, entropy_source, node_signer, node_id_lookup, secp_ctx, best_block_height,
973973
logger, pending_events, send_payment_along_path
974974
)
@@ -979,7 +979,7 @@ impl OutboundPayments {
979979
>(
980980
&self, payment_id: PaymentId, payment_hash: PaymentHash,
981981
keysend_preimage: Option<PaymentPreimage>, invoice_request: Option<&InvoiceRequest>,
982-
bolt12_invoice: Option<&PaidInvoice>,
982+
bolt12_invoice: Option<PaidInvoice>,
983983
mut route_params: RouteParameters, retry_strategy: Retry, router: &R,
984984
first_hops: Vec<ChannelDetails>, inflight_htlcs: IH, entropy_source: &ES, node_signer: &NS,
985985
node_id_lookup: &NL, secp_ctx: &Secp256k1<secp256k1::All>, best_block_height: u32, logger: &L,
@@ -1042,7 +1042,7 @@ impl OutboundPayments {
10421042
hash_map::Entry::Occupied(entry) => match entry.get() {
10431043
PendingOutboundPayment::InvoiceReceived { .. } => {
10441044
let (retryable_payment, onion_session_privs) = Self::create_pending_payment(
1045-
payment_hash, recipient_onion.clone(), keysend_preimage, None, bolt12_invoice.cloned(), &route,
1045+
payment_hash, recipient_onion.clone(), keysend_preimage, None, bolt12_invoice, &route,
10461046
Some(retry_strategy), payment_params, entropy_source, best_block_height,
10471047
);
10481048
*entry.into_mut() = retryable_payment;
@@ -1053,7 +1053,7 @@ impl OutboundPayments {
10531053
invoice_request
10541054
} else { unreachable!() };
10551055
let (retryable_payment, onion_session_privs) = Self::create_pending_payment(
1056-
payment_hash, recipient_onion.clone(), keysend_preimage, Some(invreq), bolt12_invoice.cloned(), &route,
1056+
payment_hash, recipient_onion.clone(), keysend_preimage, Some(invreq), bolt12_invoice, &route,
10571057
Some(retry_strategy), payment_params, entropy_source, best_block_height
10581058
);
10591059
outbounds.insert(payment_id, retryable_payment);
@@ -2029,7 +2029,7 @@ impl OutboundPayments {
20292029
payment_hash,
20302030
amount_msat,
20312031
fee_paid_msat,
2032-
bolt12_invoice: payment.get().bolt12_invoice().cloned(),
2032+
bolt12_invoice: payment.get().bolt12_invoice(),
20332033
}, Some(ev_completion_action.clone())));
20342034
payment.get_mut().mark_fulfilled();
20352035
}
@@ -2388,7 +2388,7 @@ impl OutboundPayments {
23882388
payment_metadata: None, // only used for retries, and we'll never retry on startup
23892389
keysend_preimage: None, // only used for retries, and we'll never retry on startup
23902390
invoice_request: None, // only used for retries, and we'll never retry on startup
2391-
bolt12_invoice: None, // only used for retries, and we'll never retry on startup! TODO(vincenzopalazzo): double check this
2391+
bolt12_invoice: None, // only used for retries, and we'll never retry on startup!
23922392
custom_tlvs: Vec::new(), // only used for retries, and we'll never retry on startup
23932393
pending_amt_msat: path_amt,
23942394
pending_fee_msat: Some(path_fee),

0 commit comments

Comments
 (0)