Skip to content

Commit 4a6f42e

Browse files
committed
Add a user_payment_id to get_payment_secret+PaymentReceived
This allows users to store metadata about an invoice at invoice-generation time and then index into that storage with a general-purpose id when they call `get_payment_secret`. They will then be provided the same index when the payment has been received.
1 parent f9f31c6 commit 4a6f42e

File tree

7 files changed

+50
-26
lines changed

7 files changed

+50
-26
lines changed

fuzz/src/chanmon_consistency.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ fn get_payment_secret_hash(dest: &ChanMan, payment_id: &mut u8) -> Option<(Payme
265265
let mut payment_hash;
266266
for _ in 0..256 {
267267
payment_hash = PaymentHash(Sha256::hash(&[*payment_id; 1]).into_inner());
268-
if let Ok(payment_secret) = dest.get_payment_secret(payment_hash, None, 1008) {
268+
if let Ok(payment_secret) = dest.get_payment_secret(payment_hash, None, 1008, 0) {
269269
return Some((payment_secret, payment_hash));
270270
}
271271
*payment_id = payment_id.wrapping_add(1);
@@ -686,7 +686,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
686686
let had_events = !events.is_empty();
687687
for event in events.drain(..) {
688688
match event {
689-
events::Event::PaymentReceived { payment_hash, payment_secret, amt } => {
689+
events::Event::PaymentReceived { payment_hash, payment_secret, amt, user_payment_id: _ } => {
690690
if claim_set.insert(payment_hash.0) {
691691
if $fail {
692692
assert!(nodes[$node].fail_htlc_backwards(&payment_hash, &payment_secret));

fuzz/src/full_stack.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ pub fn do_test(data: &[u8], logger: &Arc<dyn Logger>) {
570570
Event::FundingGenerationReady { temporary_channel_id, channel_value_satoshis, output_script, .. } => {
571571
pending_funding_generation.push((temporary_channel_id, channel_value_satoshis, output_script));
572572
},
573-
Event::PaymentReceived { payment_hash, payment_secret, amt } => {
573+
Event::PaymentReceived { payment_hash, payment_secret, amt, user_payment_id: _ } => {
574574
//TODO: enhance by fetching random amounts from fuzz input?
575575
payments_received.push((payment_hash, payment_secret, amt));
576576
},

lightning/src/ln/chanmon_update_fail_tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ fn do_test_simple_monitor_temporary_update_fail(disconnect: bool, persister_fail
205205
let events_3 = nodes[1].node.get_and_clear_pending_events();
206206
assert_eq!(events_3.len(), 1);
207207
match events_3[0] {
208-
Event::PaymentReceived { ref payment_hash, ref payment_secret, amt } => {
208+
Event::PaymentReceived { ref payment_hash, ref payment_secret, amt, user_payment_id: _ } => {
209209
assert_eq!(payment_hash_1, *payment_hash);
210210
assert_eq!(Some(payment_secret_1), *payment_secret);
211211
assert_eq!(amt, 1000000);
@@ -573,7 +573,7 @@ fn do_test_monitor_temporary_update_fail(disconnect_count: usize) {
573573
let events_5 = nodes[1].node.get_and_clear_pending_events();
574574
assert_eq!(events_5.len(), 1);
575575
match events_5[0] {
576-
Event::PaymentReceived { ref payment_hash, ref payment_secret, amt } => {
576+
Event::PaymentReceived { ref payment_hash, ref payment_secret, amt, user_payment_id: _ } => {
577577
assert_eq!(payment_hash_2, *payment_hash);
578578
assert_eq!(Some(payment_secret_2), *payment_secret);
579579
assert_eq!(amt, 1000000);
@@ -687,7 +687,7 @@ fn test_monitor_update_fail_cs() {
687687
let events = nodes[1].node.get_and_clear_pending_events();
688688
assert_eq!(events.len(), 1);
689689
match events[0] {
690-
Event::PaymentReceived { payment_hash, payment_secret, amt } => {
690+
Event::PaymentReceived { payment_hash, payment_secret, amt, user_payment_id: _ } => {
691691
assert_eq!(payment_hash, our_payment_hash);
692692
assert_eq!(Some(our_payment_secret), payment_secret);
693693
assert_eq!(amt, 1000000);

lightning/src/ln/channelmanager.rs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,8 @@ struct PeerState {
360360
struct PendingInboundPayment {
361361
/// The payment secret which the sender must use for us to accept this payment
362362
payment_secret: PaymentSecret,
363+
/// Arbitrary identifier the user specifies (or not)
364+
user_payment_id: u64,
363365
/// Height at which this HTLC expires - block height above this value will result in this
364366
/// payment being removed. Note that we'll reject any payments within HTLC_FAIL_BACK_BUFFER of
365367
/// the height at which they are received.
@@ -1962,9 +1964,11 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
19621964
// that we are the ultimately recipient of the given payment hash.
19631965
// Further, we must not expose whether we have any other HTLCs
19641966
// associated with the same payment_hash pending or not.
1967+
let mut user_payment_id = 0;
19651968
if {
19661969
let payment_secrets = self.pending_inbound_payments.lock().unwrap();
19671970
if let Some(inbound_payment) = payment_secrets.get(&payment_hash) {
1971+
user_payment_id = inbound_payment.user_payment_id;
19681972
inbound_payment.payment_secret != payment_data.payment_secret ||
19691973
(inbound_payment.min_value_msat.is_some() && inbound_payment.min_value_msat.unwrap() > payment_data.total_msat)
19701974
} else { true }
@@ -1993,6 +1997,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
19931997
payment_hash,
19941998
payment_secret: Some(payment_data.payment_secret),
19951999
amt: total_value,
2000+
user_payment_id,
19962001
});
19972002
}
19982003
}
@@ -3343,6 +3348,12 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
33433348
/// secret fetched via this method or [`get_payment_secret`], and which is at least the `value`
33443349
/// provided here, if one is provided.
33453350
///
3351+
/// `user_payment_id` will be provided back in [`PaymentReceived::user_payment_id`] events to
3352+
/// allow tracking of which events correspond with which get_payment_secret_preimage calls.
3353+
/// user_payment_id has no meaning inside of LDK, it is simply copied to events and otherwise
3354+
/// ignored. It may be used to correlate PaymentReceived events with invoice metadata stored
3355+
/// elsewhere.
3356+
///
33463357
/// `min_value_msat` should be set if the invoice being generated contains a value. Any payment
33473358
/// received for the returned PaymentHash will be required to be at least `min_value_msat`
33483359
/// before a [`PaymentReceived`] event will be generated, ensuring that we do not provide the
@@ -3355,7 +3366,8 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
33553366
///
33563367
/// [`get_payment_secret`]: Self::get_payment_secret
33573368
/// [`PaymentReceived`]: events::Event::PaymentReceived
3358-
pub fn get_payment_secret_preimage(&self, min_value_msat: Option<u64>, invoice_expiry_delta_blocks: u32) -> (PaymentHash, PaymentSecret) {
3369+
/// [`PaymentReceived::user_payment_id`]: events::Event::PaymentReceived::user_payment_id
3370+
pub fn get_payment_secret_preimage(&self, min_value_msat: Option<u64>, invoice_expiry_delta_blocks: u32, user_payment_id: u64) -> (PaymentHash, PaymentSecret) {
33593371
assert!(invoice_expiry_delta_blocks <= 6*24*365); // We may overflow later if this value is too large
33603372

33613373
let payment_secret = PaymentSecret(self.keys_manager.get_secure_random_bytes());
@@ -3365,7 +3377,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
33653377
let _persistence_guard = PersistenceNotifierGuard::new(&self.total_consistency_lock, &self.persistence_notifier);
33663378
let mut payment_secrets = self.pending_inbound_payments.lock().unwrap();
33673379
if payment_secrets.insert(payment_hash, PendingInboundPayment {
3368-
payment_secret, min_value_msat,
3380+
payment_secret, min_value_msat, user_payment_id,
33693381
expiry_height: self.best_block.read().unwrap().height() + invoice_expiry_delta_blocks,
33703382
payment_preimage: Some(payment_preimage)
33713383
}).is_some() {
@@ -3384,6 +3396,12 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
33843396
/// The payment_hash (and corresponding payment preimage) must be globally unique. This method
33853397
/// may return an Err if another payment with the same payment_hash is still pending.
33863398
///
3399+
/// `user_payment_id` will be provided back in [`PaymentReceived::user_payment_id`] events to
3400+
/// allow tracking of which events correspond with which get_payment_secret_preimage calls.
3401+
/// user_payment_id has no meaning inside of LDK, it is simply copied to events and otherwise
3402+
/// ignored. It may be used to correlate PaymentReceived events with invoice metadata stored
3403+
/// elsewhere.
3404+
///
33873405
/// `min_value_msat` should be set if the invoice being generated contains a value. Any payment
33883406
/// received for the returned PaymentHash will be required to be at least `min_value_msat`
33893407
/// before a [`PaymentReceived`] event will be generated, ensuring that we do not provide the
@@ -3396,7 +3414,8 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
33963414
///
33973415
/// [`get_payment_secret_preimage`]: Self::get_payment_secret_preimage
33983416
/// [`PaymentReceived`]: events::Event::PaymentReceived
3399-
pub fn get_payment_secret(&self, payment_hash: PaymentHash, min_value_msat: Option<u64>, invoice_expiry_delta_blocks: u32) -> Result<PaymentSecret, APIError> {
3417+
/// [`PaymentReceived::user_payment_id`]: events::Event::PaymentReceived::user_payment_id
3418+
pub fn get_payment_secret(&self, payment_hash: PaymentHash, min_value_msat: Option<u64>, invoice_expiry_delta_blocks: u32, user_payment_id: u64) -> Result<PaymentSecret, APIError> {
34003419
assert!(invoice_expiry_delta_blocks <= 6*24*365); // We may overflow later if this value is too large
34013420

34023421
let payment_secret = PaymentSecret(self.keys_manager.get_secure_random_bytes());
@@ -3406,7 +3425,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
34063425
match payment_secrets.entry(payment_hash) {
34073426
hash_map::Entry::Vacant(e) => {
34083427
e.insert(PendingInboundPayment {
3409-
payment_secret, min_value_msat, payment_preimage: None,
3428+
payment_secret, min_value_msat, user_payment_id, payment_preimage: None,
34103429
expiry_height: self.best_block.read().unwrap().height() + invoice_expiry_delta_blocks,
34113430
});
34123431
},
@@ -4285,6 +4304,7 @@ impl Readable for HTLCForwardInfo {
42854304

42864305
impl_writeable!(PendingInboundPayment, 0, {
42874306
payment_secret,
4307+
user_payment_id,
42884308
expiry_height,
42894309
payment_preimage,
42904310
min_value_msat

lightning/src/ln/functional_test_utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ macro_rules! get_payment_preimage_hash {
899899
let payment_preimage = PaymentPreimage([*$dest_node.network_payment_count.borrow(); 32]);
900900
*$dest_node.network_payment_count.borrow_mut() += 1;
901901
let payment_hash = PaymentHash(Sha256::hash(&payment_preimage.0[..]).into_inner());
902-
let payment_secret = $dest_node.node.get_payment_secret(payment_hash, None, 1008).unwrap();
902+
let payment_secret = $dest_node.node.get_payment_secret(payment_hash, None, 1008, 0).unwrap();
903903
(payment_preimage, payment_hash, payment_secret)
904904
}
905905
}
@@ -941,7 +941,7 @@ macro_rules! expect_payment_received {
941941
let events = $node.node.get_and_clear_pending_events();
942942
assert_eq!(events.len(), 1);
943943
match events[0] {
944-
Event::PaymentReceived { ref payment_hash, ref payment_secret, amt } => {
944+
Event::PaymentReceived { ref payment_hash, ref payment_secret, amt, user_payment_id: _ } => {
945945
assert_eq!($expected_payment_hash, *payment_hash);
946946
assert_eq!(Some($expected_payment_secret), *payment_secret);
947947
assert_eq!($expected_recv_value, amt);
@@ -1009,7 +1009,7 @@ pub fn pass_along_path<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_path
10091009
if payment_received_expected {
10101010
assert_eq!(events_2.len(), 1);
10111011
match events_2[0] {
1012-
Event::PaymentReceived { ref payment_hash, ref payment_secret, amt } => {
1012+
Event::PaymentReceived { ref payment_hash, ref payment_secret, amt, user_payment_id: _ } => {
10131013
assert_eq!(our_payment_hash, *payment_hash);
10141014
assert_eq!(Some(our_payment_secret), *payment_secret);
10151015
assert_eq!(amt, recv_value);

lightning/src/ln/functional_tests.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,7 +1469,7 @@ fn test_duplicate_htlc_different_direction_onchain() {
14691469

14701470
let net_graph_msg_handler = &nodes[1].net_graph_msg_handler;
14711471
let route = get_route(&nodes[1].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[0].node.get_our_node_id(), Some(InvoiceFeatures::known()), None, &Vec::new(), 800_000, TEST_FINAL_CLTV, &logger).unwrap();
1472-
let node_a_payment_secret = nodes[0].node.get_payment_secret(payment_hash, None, 1008).unwrap();
1472+
let node_a_payment_secret = nodes[0].node.get_payment_secret(payment_hash, None, 1008, 0).unwrap();
14731473
send_along_route_with_secret(&nodes[1], route, &[&[&nodes[0]]], 800_000, payment_hash, node_a_payment_secret);
14741474

14751475
// Provide preimage to node 0 by claiming payment
@@ -2069,15 +2069,15 @@ fn test_channel_reserve_holding_cell_htlcs() {
20692069
let events = nodes[2].node.get_and_clear_pending_events();
20702070
assert_eq!(events.len(), 2);
20712071
match events[0] {
2072-
Event::PaymentReceived { ref payment_hash, ref payment_secret, amt } => {
2072+
Event::PaymentReceived { ref payment_hash, ref payment_secret, amt, user_payment_id: _ } => {
20732073
assert_eq!(our_payment_hash_21, *payment_hash);
20742074
assert_eq!(Some(our_payment_secret_21), *payment_secret);
20752075
assert_eq!(recv_value_21, amt);
20762076
},
20772077
_ => panic!("Unexpected event"),
20782078
}
20792079
match events[1] {
2080-
Event::PaymentReceived { ref payment_hash, ref payment_secret, amt } => {
2080+
Event::PaymentReceived { ref payment_hash, ref payment_secret, amt, user_payment_id: _ } => {
20812081
assert_eq!(our_payment_hash_22, *payment_hash);
20822082
assert_eq!(Some(our_payment_secret_22), *payment_secret);
20832083
assert_eq!(recv_value_22, amt);
@@ -3645,7 +3645,7 @@ fn do_test_drop_messages_peer_disconnect(messages_delivered: u8) {
36453645
let events_2 = nodes[1].node.get_and_clear_pending_events();
36463646
assert_eq!(events_2.len(), 1);
36473647
match events_2[0] {
3648-
Event::PaymentReceived { ref payment_hash, ref payment_secret, amt } => {
3648+
Event::PaymentReceived { ref payment_hash, ref payment_secret, amt, user_payment_id: _ } => {
36493649
assert_eq!(payment_hash_1, *payment_hash);
36503650
assert_eq!(Some(payment_secret_1), *payment_secret);
36513651
assert_eq!(amt, 1000000);
@@ -3982,7 +3982,7 @@ fn test_drop_messages_peer_disconnect_dual_htlc() {
39823982
let events_5 = nodes[1].node.get_and_clear_pending_events();
39833983
assert_eq!(events_5.len(), 1);
39843984
match events_5[0] {
3985-
Event::PaymentReceived { ref payment_hash, ref payment_secret, amt: _ } => {
3985+
Event::PaymentReceived { ref payment_hash, ref payment_secret, amt: _, user_payment_id: _ } => {
39863986
assert_eq!(payment_hash_2, *payment_hash);
39873987
assert_eq!(Some(payment_secret_2), *payment_secret);
39883988
},
@@ -5112,7 +5112,7 @@ fn test_duplicate_payment_hash_one_failure_one_success() {
51125112

51135113
let (our_payment_preimage, duplicate_payment_hash, _) = route_payment(&nodes[0], &vec!(&nodes[1], &nodes[2])[..], 900000);
51145114

5115-
let payment_secret = nodes[3].node.get_payment_secret(duplicate_payment_hash, None, 1008).unwrap();
5115+
let payment_secret = nodes[3].node.get_payment_secret(duplicate_payment_hash, None, 1008, 0).unwrap();
51165116
let route = get_route(&nodes[0].node.get_our_node_id(), &nodes[0].net_graph_msg_handler.network_graph.read().unwrap(),
51175117
&nodes[3].node.get_our_node_id(), Some(InvoiceFeatures::known()), None, &Vec::new(), 900000, TEST_FINAL_CLTV, nodes[0].logger).unwrap();
51185118
send_along_route_with_secret(&nodes[0], route, &[&[&nodes[1], &nodes[2], &nodes[3]]], 900000, duplicate_payment_hash, payment_secret);
@@ -5306,30 +5306,30 @@ fn do_test_fail_backwards_unrevoked_remote_announce(deliver_last_raa: bool, anno
53065306
let our_node_id = &nodes[1].node.get_our_node_id();
53075307
let route = get_route(our_node_id, &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[5].node.get_our_node_id(), Some(InvoiceFeatures::known()), None, &Vec::new(), ds_dust_limit*1000, TEST_FINAL_CLTV, &logger).unwrap();
53085308
// 2nd HTLC:
5309-
send_along_route_with_secret(&nodes[1], route.clone(), &[&[&nodes[2], &nodes[3], &nodes[5]]], ds_dust_limit*1000, payment_hash_1, nodes[5].node.get_payment_secret(payment_hash_1, None, 1008).unwrap()); // not added < dust limit + HTLC tx fee
5309+
send_along_route_with_secret(&nodes[1], route.clone(), &[&[&nodes[2], &nodes[3], &nodes[5]]], ds_dust_limit*1000, payment_hash_1, nodes[5].node.get_payment_secret(payment_hash_1, None, 1008, 0).unwrap()); // not added < dust limit + HTLC tx fee
53105310
// 3rd HTLC:
5311-
send_along_route_with_secret(&nodes[1], route, &[&[&nodes[2], &nodes[3], &nodes[5]]], ds_dust_limit*1000, payment_hash_2, nodes[5].node.get_payment_secret(payment_hash_2, None, 1008).unwrap()); // not added < dust limit + HTLC tx fee
5311+
send_along_route_with_secret(&nodes[1], route, &[&[&nodes[2], &nodes[3], &nodes[5]]], ds_dust_limit*1000, payment_hash_2, nodes[5].node.get_payment_secret(payment_hash_2, None, 1008, 0).unwrap()); // not added < dust limit + HTLC tx fee
53125312
// 4th HTLC:
53135313
let (_, payment_hash_3, _) = route_payment(&nodes[0], &[&nodes[2], &nodes[3], &nodes[4]], 1000000);
53145314
// 5th HTLC:
53155315
let (_, payment_hash_4, _) = route_payment(&nodes[0], &[&nodes[2], &nodes[3], &nodes[4]], 1000000);
53165316
let route = get_route(our_node_id, &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[5].node.get_our_node_id(), Some(InvoiceFeatures::known()), None, &Vec::new(), 1000000, TEST_FINAL_CLTV, &logger).unwrap();
53175317
// 6th HTLC:
5318-
send_along_route_with_secret(&nodes[1], route.clone(), &[&[&nodes[2], &nodes[3], &nodes[5]]], 1000000, payment_hash_3, nodes[5].node.get_payment_secret(payment_hash_3, None, 1008).unwrap());
5318+
send_along_route_with_secret(&nodes[1], route.clone(), &[&[&nodes[2], &nodes[3], &nodes[5]]], 1000000, payment_hash_3, nodes[5].node.get_payment_secret(payment_hash_3, None, 1008, 0).unwrap());
53195319
// 7th HTLC:
5320-
send_along_route_with_secret(&nodes[1], route, &[&[&nodes[2], &nodes[3], &nodes[5]]], 1000000, payment_hash_4, nodes[5].node.get_payment_secret(payment_hash_4, None, 1008).unwrap());
5320+
send_along_route_with_secret(&nodes[1], route, &[&[&nodes[2], &nodes[3], &nodes[5]]], 1000000, payment_hash_4, nodes[5].node.get_payment_secret(payment_hash_4, None, 1008, 0).unwrap());
53215321

53225322
// 8th HTLC:
53235323
let (_, payment_hash_5, _) = route_payment(&nodes[0], &[&nodes[2], &nodes[3], &nodes[4]], 1000000);
53245324
// 9th HTLC:
53255325
let route = get_route(our_node_id, &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[5].node.get_our_node_id(), Some(InvoiceFeatures::known()), None, &Vec::new(), ds_dust_limit*1000, TEST_FINAL_CLTV, &logger).unwrap();
5326-
send_along_route_with_secret(&nodes[1], route, &[&[&nodes[2], &nodes[3], &nodes[5]]], ds_dust_limit*1000, payment_hash_5, nodes[5].node.get_payment_secret(payment_hash_5, None, 1008).unwrap()); // not added < dust limit + HTLC tx fee
5326+
send_along_route_with_secret(&nodes[1], route, &[&[&nodes[2], &nodes[3], &nodes[5]]], ds_dust_limit*1000, payment_hash_5, nodes[5].node.get_payment_secret(payment_hash_5, None, 1008, 0).unwrap()); // not added < dust limit + HTLC tx fee
53275327

53285328
// 10th HTLC:
53295329
let (_, payment_hash_6, _) = route_payment(&nodes[0], &[&nodes[2], &nodes[3], &nodes[4]], ds_dust_limit*1000); // not added < dust limit + HTLC tx fee
53305330
// 11th HTLC:
53315331
let route = get_route(our_node_id, &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[5].node.get_our_node_id(), Some(InvoiceFeatures::known()), None, &Vec::new(), 1000000, TEST_FINAL_CLTV, &logger).unwrap();
5332-
send_along_route_with_secret(&nodes[1], route, &[&[&nodes[2], &nodes[3], &nodes[5]]], 1000000, payment_hash_6, nodes[5].node.get_payment_secret(payment_hash_6, None, 1008).unwrap());
5332+
send_along_route_with_secret(&nodes[1], route, &[&[&nodes[2], &nodes[3], &nodes[5]]], 1000000, payment_hash_6, nodes[5].node.get_payment_secret(payment_hash_6, None, 1008, 0).unwrap());
53335333

53345334
// Double-check that six of the new HTLC were added
53355335
// We now have six HTLCs pending over the dust limit and six HTLCs under the dust limit (ie,

lightning/src/util/events.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ pub enum Event {
7575
/// compare this to the expected value before accepting the payment (as otherwise you are
7676
/// providing proof-of-payment for less than the value you expected!).
7777
amt: u64,
78+
/// ;
79+
user_payment_id: u64,
7880
},
7981
/// Indicates an outbound payment we made succeeded (ie it made it all the way to its target
8082
/// and we got back the payment preimage for it).
@@ -129,11 +131,12 @@ impl Writeable for Event {
129131
// We never write out FundingGenerationReady events as, upon disconnection, peers
130132
// drop any channels which have not yet exchanged funding_signed.
131133
},
132-
&Event::PaymentReceived { ref payment_hash, ref payment_secret, ref amt } => {
134+
&Event::PaymentReceived { ref payment_hash, ref payment_secret, ref amt, ref user_payment_id } => {
133135
1u8.write(writer)?;
134136
payment_hash.write(writer)?;
135137
payment_secret.write(writer)?;
136138
amt.write(writer)?;
139+
user_payment_id.write(writer)?;
137140
},
138141
&Event::PaymentSent { ref payment_preimage } => {
139142
2u8.write(writer)?;
@@ -177,6 +180,7 @@ impl MaybeReadable for Event {
177180
payment_hash: Readable::read(reader)?,
178181
payment_secret: Readable::read(reader)?,
179182
amt: Readable::read(reader)?,
183+
user_payment_id: Readable::read(reader)?,
180184
})),
181185
2u8 => Ok(Some(Event::PaymentSent {
182186
payment_preimage: Readable::read(reader)?,

0 commit comments

Comments
 (0)