Skip to content

Commit 5e86002

Browse files
add the bolt12 invoice to the PaymentSend event
To enable proof of payment, we need to share the bolt12 invoice with the library user. This is already possible if we `manually_handle_bolt12_invoices`, but this approach requires a significant amount of work from the user. This commit adds the bolt12 invoice to the PaymentSend event when the payment is completed. This allows the user to always have the option to perform proof of payment. Link: lightningdevkit#3344 Signed-off-by: Vincenzo Palazzo <[email protected]>
1 parent f0d17d4 commit 5e86002

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lightning/src/events/mod.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,8 @@ pub enum Event {
939939
///
940940
/// [`Route::get_total_fees`]: crate::routing::router::Route::get_total_fees
941941
fee_paid_msat: Option<u64>,
942+
/// The bolt12 invoice that was paid. `None` if the payment was a non-bolt12 payment.
943+
bolt12_invoice: Option<Bolt12Invoice>,
942944
},
943945
/// Indicates an outbound payment failed. Individual [`Event::PaymentPathFailed`] events
944946
/// provide failure information for each path attempt in the payment, including retries.
@@ -1190,12 +1192,12 @@ pub enum Event {
11901192
/// events generated or serialized by versions prior to 0.0.122.
11911193
next_user_channel_id: Option<u128>,
11921194
/// The node id of the previous node.
1193-
///
1195+
///
11941196
/// This is only `None` for HTLCs received prior to 0.1 or for events serialized by
11951197
/// versions prior to 0.1
11961198
prev_node_id: Option<PublicKey>,
11971199
/// The node id of the next node.
1198-
///
1200+
///
11991201
/// This is only `None` for HTLCs received prior to 0.1 or for events serialized by
12001202
/// versions prior to 0.1
12011203
next_node_id: Option<PublicKey>,
@@ -1546,13 +1548,14 @@ impl Writeable for Event {
15461548
(13, payment_id, option),
15471549
});
15481550
},
1549-
&Event::PaymentSent { ref payment_id, ref payment_preimage, ref payment_hash, ref fee_paid_msat } => {
1551+
&Event::PaymentSent { ref payment_id, ref payment_preimage, ref payment_hash, ref fee_paid_msat, ref bolt12_invoice } => {
15501552
2u8.write(writer)?;
15511553
write_tlv_fields!(writer, {
15521554
(0, payment_preimage, required),
15531555
(1, payment_hash, required),
15541556
(3, payment_id, option),
15551557
(5, fee_paid_msat, option),
1558+
(7, bolt12_invoice, option),
15561559
});
15571560
},
15581561
&Event::PaymentPathFailed {
@@ -1886,11 +1889,13 @@ impl MaybeReadable for Event {
18861889
let mut payment_hash = None;
18871890
let mut payment_id = None;
18881891
let mut fee_paid_msat = None;
1892+
let mut bolt12_invoice = None;
18891893
read_tlv_fields!(reader, {
18901894
(0, payment_preimage, required),
18911895
(1, payment_hash, option),
18921896
(3, payment_id, option),
18931897
(5, fee_paid_msat, option),
1898+
(7, bolt12_invoice, option),
18941899
});
18951900
if payment_hash.is_none() {
18961901
payment_hash = Some(PaymentHash(Sha256::hash(&payment_preimage.0[..]).to_byte_array()));
@@ -1900,6 +1905,7 @@ impl MaybeReadable for Event {
19001905
payment_preimage,
19011906
payment_hash: payment_hash.unwrap(),
19021907
fee_paid_msat,
1908+
bolt12_invoice,
19031909
}))
19041910
};
19051911
f()

0 commit comments

Comments
 (0)