Skip to content

Commit 01227de

Browse files
Remove user_payment_id
In upcoming commits, we'll be making the payment secret and payment hash/preimage derivable from info about the payment + a node secret. This means we don't need to store any info about incoming payments and can eventually get rid of the channelmanager::pending_inbound_payments map.
1 parent 4a3139d commit 01227de

File tree

7 files changed

+33
-56
lines changed

7 files changed

+33
-56
lines changed

fuzz/src/chanmon_consistency.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ fn get_payment_secret_hash(dest: &ChanMan, payment_id: &mut u8) -> Option<(Payme
284284
let mut payment_hash;
285285
for _ in 0..256 {
286286
payment_hash = PaymentHash(Sha256::hash(&[*payment_id; 1]).into_inner());
287-
if let Ok(payment_secret) = dest.create_inbound_payment_for_hash(payment_hash, None, 3600, 0) {
287+
if let Ok(payment_secret) = dest.create_inbound_payment_for_hash(payment_hash, None, 3600) {
288288
return Some((payment_secret, payment_hash));
289289
}
290290
*payment_id = payment_id.wrapping_add(1);

fuzz/src/full_stack.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ pub fn do_test(data: &[u8], logger: &Arc<dyn Logger>) {
529529
let payment_hash = PaymentHash(Sha256::from_engine(sha).into_inner());
530530
// Note that this may fail - our hashes may collide and we'll end up trying to
531531
// double-register the same payment_hash.
532-
let _ = channelmanager.create_inbound_payment_for_hash(payment_hash, None, 1, 0);
532+
let _ = channelmanager.create_inbound_payment_for_hash(payment_hash, None, 1);
533533
},
534534
9 => {
535535
for payment in payments_received.drain(..) {

lightning-invoice/src/utils.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ where
6363
let (payment_hash, payment_secret) = channelmanager.create_inbound_payment(
6464
amt_msat,
6565
DEFAULT_EXPIRY_TIME.try_into().unwrap(),
66-
0,
6766
);
6867
let our_node_pubkey = channelmanager.get_our_node_id();
6968
let mut invoice = InvoiceBuilder::new(network)

lightning/src/ln/channelmanager.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2886,7 +2886,6 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
28862886
purpose: events::PaymentPurpose::InvoicePayment {
28872887
payment_preimage: inbound_payment.get().payment_preimage,
28882888
payment_secret: payment_data.payment_secret,
2889-
user_payment_id: inbound_payment.get().user_payment_id,
28902889
},
28912890
amt: total_value,
28922891
});
@@ -4517,7 +4516,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
45174516
}
45184517
}
45194518

4520-
fn set_payment_hash_secret_map(&self, payment_hash: PaymentHash, payment_preimage: Option<PaymentPreimage>, min_value_msat: Option<u64>, invoice_expiry_delta_secs: u32, user_payment_id: u64) -> Result<PaymentSecret, APIError> {
4519+
fn set_payment_hash_secret_map(&self, payment_hash: PaymentHash, payment_preimage: Option<PaymentPreimage>, min_value_msat: Option<u64>, invoice_expiry_delta_secs: u32) -> Result<PaymentSecret, APIError> {
45214520
assert!(invoice_expiry_delta_secs <= 60*60*24*365); // Sadly bitcoin timestamps are u32s, so panic before 2106
45224521

45234522
let payment_secret = PaymentSecret(self.keys_manager.get_secure_random_bytes());
@@ -4527,7 +4526,8 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
45274526
match payment_secrets.entry(payment_hash) {
45284527
hash_map::Entry::Vacant(e) => {
45294528
e.insert(PendingInboundPayment {
4530-
payment_secret, min_value_msat, user_payment_id, payment_preimage,
4529+
payment_secret, min_value_msat, payment_preimage,
4530+
user_payment_id: 0, // For compatibility with version 0.0.103 and earlier
45314531
// We assume that highest_seen_timestamp is pretty close to the current time -
45324532
// its updated when we receive a new block with the maximum time we've seen in
45334533
// a header. It should never be more than two hours in the future.
@@ -4559,12 +4559,12 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
45594559
/// [`PaymentReceived`]: events::Event::PaymentReceived
45604560
/// [`PaymentReceived::payment_preimage`]: events::Event::PaymentReceived::payment_preimage
45614561
/// [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
4562-
pub fn create_inbound_payment(&self, min_value_msat: Option<u64>, invoice_expiry_delta_secs: u32, user_payment_id: u64) -> (PaymentHash, PaymentSecret) {
4562+
pub fn create_inbound_payment(&self, min_value_msat: Option<u64>, invoice_expiry_delta_secs: u32) -> (PaymentHash, PaymentSecret) {
45634563
let payment_preimage = PaymentPreimage(self.keys_manager.get_secure_random_bytes());
45644564
let payment_hash = PaymentHash(Sha256::hash(&payment_preimage.0).into_inner());
45654565

45664566
(payment_hash,
4567-
self.set_payment_hash_secret_map(payment_hash, Some(payment_preimage), min_value_msat, invoice_expiry_delta_secs, user_payment_id)
4567+
self.set_payment_hash_secret_map(payment_hash, Some(payment_preimage), min_value_msat, invoice_expiry_delta_secs)
45684568
.expect("RNG Generated Duplicate PaymentHash"))
45694569
}
45704570

@@ -4578,12 +4578,6 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
45784578
/// The [`PaymentHash`] (and corresponding [`PaymentPreimage`]) must be globally unique. This
45794579
/// method may return an Err if another payment with the same payment_hash is still pending.
45804580
///
4581-
/// `user_payment_id` will be provided back in [`PaymentPurpose::InvoicePayment::user_payment_id`] events to
4582-
/// allow tracking of which events correspond with which calls to this and
4583-
/// [`create_inbound_payment`]. `user_payment_id` has no meaning inside of LDK, it is simply
4584-
/// copied to events and otherwise ignored. It may be used to correlate PaymentReceived events
4585-
/// with invoice metadata stored elsewhere.
4586-
///
45874581
/// `min_value_msat` should be set if the invoice being generated contains a value. Any payment
45884582
/// received for the returned [`PaymentHash`] will be required to be at least `min_value_msat`
45894583
/// before a [`PaymentReceived`] event will be generated, ensuring that we do not provide the
@@ -4612,9 +4606,8 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
46124606
///
46134607
/// [`create_inbound_payment`]: Self::create_inbound_payment
46144608
/// [`PaymentReceived`]: events::Event::PaymentReceived
4615-
/// [`PaymentPurpose::InvoicePayment::user_payment_id`]: events::PaymentPurpose::InvoicePayment::user_payment_id
4616-
pub fn create_inbound_payment_for_hash(&self, payment_hash: PaymentHash, min_value_msat: Option<u64>, invoice_expiry_delta_secs: u32, user_payment_id: u64) -> Result<PaymentSecret, APIError> {
4617-
self.set_payment_hash_secret_map(payment_hash, None, min_value_msat, invoice_expiry_delta_secs, user_payment_id)
4609+
pub fn create_inbound_payment_for_hash(&self, payment_hash: PaymentHash, min_value_msat: Option<u64>, invoice_expiry_delta_secs: u32) -> Result<PaymentSecret, APIError> {
4610+
self.set_payment_hash_secret_map(payment_hash, None, min_value_msat, invoice_expiry_delta_secs)
46184611
}
46194612

46204613
#[cfg(any(test, feature = "fuzztarget", feature = "_test_utils"))]

lightning/src/ln/functional_test_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,7 @@ macro_rules! get_payment_preimage_hash {
999999
let payment_preimage = PaymentPreimage([*payment_count; 32]);
10001000
*payment_count += 1;
10011001
let payment_hash = PaymentHash(Sha256::hash(&payment_preimage.0[..]).into_inner());
1002-
let payment_secret = $dest_node.node.create_inbound_payment_for_hash(payment_hash, $min_value_msat, 7200, 0).unwrap();
1002+
let payment_secret = $dest_node.node.create_inbound_payment_for_hash(payment_hash, $min_value_msat, 7200).unwrap();
10031003
(payment_preimage, payment_hash, payment_secret)
10041004
}
10051005
}

lightning/src/ln/functional_tests.rs

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@ fn test_duplicate_htlc_different_direction_onchain() {
11521152
let (payment_preimage, payment_hash, _) = route_payment(&nodes[0], &vec!(&nodes[1])[..], 900_000);
11531153

11541154
let (route, _, _, _) = get_route_and_payment_hash!(nodes[1], nodes[0], 800_000);
1155-
let node_a_payment_secret = nodes[0].node.create_inbound_payment_for_hash(payment_hash, None, 7200, 0).unwrap();
1155+
let node_a_payment_secret = nodes[0].node.create_inbound_payment_for_hash(payment_hash, None, 7200).unwrap();
11561156
send_along_route_with_secret(&nodes[1], route, &[&[&nodes[0]]], 800_000, payment_hash, node_a_payment_secret);
11571157

11581158
// Provide preimage to node 0 by claiming payment
@@ -4957,7 +4957,7 @@ fn test_duplicate_payment_hash_one_failure_one_success() {
49574957

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

4960-
let payment_secret = nodes[3].node.create_inbound_payment_for_hash(duplicate_payment_hash, None, 7200, 0).unwrap();
4960+
let payment_secret = nodes[3].node.create_inbound_payment_for_hash(duplicate_payment_hash, None, 7200).unwrap();
49614961
// We reduce the final CLTV here by a somewhat arbitrary constant to keep it under the one-byte
49624962
// script push size limit so that the below script length checks match
49634963
// ACCEPTED_HTLC_SCRIPT_WEIGHT.
@@ -5160,30 +5160,30 @@ fn do_test_fail_backwards_unrevoked_remote_announce(deliver_last_raa: bool, anno
51605160
let (_, payment_hash_2, _) = route_payment(&nodes[0], &[&nodes[2], &nodes[3], &nodes[4]], ds_dust_limit*1000); // not added < dust limit + HTLC tx fee
51615161
let (route, _, _, _) = get_route_and_payment_hash!(nodes[1], nodes[5], ds_dust_limit*1000);
51625162
// 2nd HTLC:
5163-
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.create_inbound_payment_for_hash(payment_hash_1, None, 7200, 0).unwrap()); // not added < dust limit + HTLC tx fee
5163+
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.create_inbound_payment_for_hash(payment_hash_1, None, 7200).unwrap()); // not added < dust limit + HTLC tx fee
51645164
// 3rd HTLC:
5165-
send_along_route_with_secret(&nodes[1], route, &[&[&nodes[2], &nodes[3], &nodes[5]]], ds_dust_limit*1000, payment_hash_2, nodes[5].node.create_inbound_payment_for_hash(payment_hash_2, None, 7200, 0).unwrap()); // not added < dust limit + HTLC tx fee
5165+
send_along_route_with_secret(&nodes[1], route, &[&[&nodes[2], &nodes[3], &nodes[5]]], ds_dust_limit*1000, payment_hash_2, nodes[5].node.create_inbound_payment_for_hash(payment_hash_2, None, 7200).unwrap()); // not added < dust limit + HTLC tx fee
51665166
// 4th HTLC:
51675167
let (_, payment_hash_3, _) = route_payment(&nodes[0], &[&nodes[2], &nodes[3], &nodes[4]], 1000000);
51685168
// 5th HTLC:
51695169
let (_, payment_hash_4, _) = route_payment(&nodes[0], &[&nodes[2], &nodes[3], &nodes[4]], 1000000);
51705170
let (route, _, _, _) = get_route_and_payment_hash!(nodes[1], nodes[5], 1000000);
51715171
// 6th HTLC:
5172-
send_along_route_with_secret(&nodes[1], route.clone(), &[&[&nodes[2], &nodes[3], &nodes[5]]], 1000000, payment_hash_3, nodes[5].node.create_inbound_payment_for_hash(payment_hash_3, None, 7200, 0).unwrap());
5172+
send_along_route_with_secret(&nodes[1], route.clone(), &[&[&nodes[2], &nodes[3], &nodes[5]]], 1000000, payment_hash_3, nodes[5].node.create_inbound_payment_for_hash(payment_hash_3, None, 7200).unwrap());
51735173
// 7th HTLC:
5174-
send_along_route_with_secret(&nodes[1], route, &[&[&nodes[2], &nodes[3], &nodes[5]]], 1000000, payment_hash_4, nodes[5].node.create_inbound_payment_for_hash(payment_hash_4, None, 7200, 0).unwrap());
5174+
send_along_route_with_secret(&nodes[1], route, &[&[&nodes[2], &nodes[3], &nodes[5]]], 1000000, payment_hash_4, nodes[5].node.create_inbound_payment_for_hash(payment_hash_4, None, 7200).unwrap());
51755175

51765176
// 8th HTLC:
51775177
let (_, payment_hash_5, _) = route_payment(&nodes[0], &[&nodes[2], &nodes[3], &nodes[4]], 1000000);
51785178
// 9th HTLC:
51795179
let (route, _, _, _) = get_route_and_payment_hash!(nodes[1], nodes[5], ds_dust_limit*1000);
5180-
send_along_route_with_secret(&nodes[1], route, &[&[&nodes[2], &nodes[3], &nodes[5]]], ds_dust_limit*1000, payment_hash_5, nodes[5].node.create_inbound_payment_for_hash(payment_hash_5, None, 7200, 0).unwrap()); // not added < dust limit + HTLC tx fee
5180+
send_along_route_with_secret(&nodes[1], route, &[&[&nodes[2], &nodes[3], &nodes[5]]], ds_dust_limit*1000, payment_hash_5, nodes[5].node.create_inbound_payment_for_hash(payment_hash_5, None, 7200).unwrap()); // not added < dust limit + HTLC tx fee
51815181

51825182
// 10th HTLC:
51835183
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
51845184
// 11th HTLC:
51855185
let (route, _, _, _) = get_route_and_payment_hash!(nodes[1], nodes[5], 1000000);
5186-
send_along_route_with_secret(&nodes[1], route, &[&[&nodes[2], &nodes[3], &nodes[5]]], 1000000, payment_hash_6, nodes[5].node.create_inbound_payment_for_hash(payment_hash_6, None, 7200, 0).unwrap());
5186+
send_along_route_with_secret(&nodes[1], route, &[&[&nodes[2], &nodes[3], &nodes[5]]], 1000000, payment_hash_6, nodes[5].node.create_inbound_payment_for_hash(payment_hash_6, None, 7200).unwrap());
51875187

51885188
// Double-check that six of the new HTLC were added
51895189
// We now have six HTLCs pending over the dust limit and six HTLCs under the dust limit (ie,
@@ -7164,7 +7164,7 @@ fn test_check_htlc_underpaying() {
71647164
let payee = Payee::from_node_id(nodes[1].node.get_our_node_id()).with_features(InvoiceFeatures::known());
71657165
let route = get_route(&nodes[0].node.get_our_node_id(), &payee, nodes[0].network_graph, None, 10_000, TEST_FINAL_CLTV, nodes[0].logger, &scorer).unwrap();
71667166
let (_, our_payment_hash, _) = get_payment_preimage_hash!(nodes[0]);
7167-
let our_payment_secret = nodes[1].node.create_inbound_payment_for_hash(our_payment_hash, Some(100_000), 7200, 0).unwrap();
7167+
let our_payment_secret = nodes[1].node.create_inbound_payment_for_hash(our_payment_hash, Some(100_000), 7200).unwrap();
71687168
nodes[0].node.send_payment(&route, our_payment_hash, &Some(our_payment_secret)).unwrap();
71697169
check_added_monitors!(nodes[0], 1);
71707170

@@ -7982,7 +7982,7 @@ fn test_preimage_storage() {
79827982
create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known()).0.contents.short_channel_id;
79837983

79847984
{
7985-
let (payment_hash, payment_secret) = nodes[1].node.create_inbound_payment(Some(100_000), 7200, 42);
7985+
let (payment_hash, payment_secret) = nodes[1].node.create_inbound_payment(Some(100_000), 7200);
79867986
let (route, _, _, _) = get_route_and_payment_hash!(nodes[0], nodes[1], 100_000);
79877987
nodes[0].node.send_payment(&route, payment_hash, &Some(payment_secret)).unwrap();
79887988
check_added_monitors!(nodes[0], 1);
@@ -7999,8 +7999,7 @@ fn test_preimage_storage() {
79997999
match events[0] {
80008000
Event::PaymentReceived { ref purpose, .. } => {
80018001
match &purpose {
8002-
PaymentPurpose::InvoicePayment { payment_preimage, user_payment_id, .. } => {
8003-
assert_eq!(*user_payment_id, 42);
8002+
PaymentPurpose::InvoicePayment { payment_preimage, .. } => {
80048003
claim_payment(&nodes[0], &[&nodes[1]], payment_preimage.unwrap());
80058004
},
80068005
_ => panic!("expected PaymentPurpose::InvoicePayment")
@@ -8020,11 +8019,11 @@ fn test_secret_timeout() {
80208019

80218020
create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known()).0.contents.short_channel_id;
80228021

8023-
let (payment_hash, payment_secret_1) = nodes[1].node.create_inbound_payment(Some(100_000), 2, 0);
8022+
let (payment_hash, payment_secret_1) = nodes[1].node.create_inbound_payment(Some(100_000), 2);
80248023

80258024
// We should fail to register the same payment hash twice, at least until we've connected a
80268025
// block with time 7200 + CHAN_CONFIRM_DEPTH + 1.
8027-
if let Err(APIError::APIMisuseError { err }) = nodes[1].node.create_inbound_payment_for_hash(payment_hash, Some(100_000), 2, 0) {
8026+
if let Err(APIError::APIMisuseError { err }) = nodes[1].node.create_inbound_payment_for_hash(payment_hash, Some(100_000), 2) {
80288027
assert_eq!(err, "Duplicate payment hash");
80298028
} else { panic!(); }
80308029
let mut block = {
@@ -8039,16 +8038,16 @@ fn test_secret_timeout() {
80398038
}
80408039
};
80418040
connect_block(&nodes[1], &block);
8042-
if let Err(APIError::APIMisuseError { err }) = nodes[1].node.create_inbound_payment_for_hash(payment_hash, Some(100_000), 2, 0) {
8041+
if let Err(APIError::APIMisuseError { err }) = nodes[1].node.create_inbound_payment_for_hash(payment_hash, Some(100_000), 2) {
80438042
assert_eq!(err, "Duplicate payment hash");
80448043
} else { panic!(); }
80458044

80468045
// If we then connect the second block, we should be able to register the same payment hash
8047-
// again with a different user_payment_id (this time getting a new payment secret).
8046+
// again (this time getting a new payment secret).
80488047
block.header.prev_blockhash = block.header.block_hash();
80498048
block.header.time += 1;
80508049
connect_block(&nodes[1], &block);
8051-
let our_payment_secret = nodes[1].node.create_inbound_payment_for_hash(payment_hash, Some(100_000), 2, 42).unwrap();
8050+
let our_payment_secret = nodes[1].node.create_inbound_payment_for_hash(payment_hash, Some(100_000), 2).unwrap();
80528051
assert_ne!(payment_secret_1, our_payment_secret);
80538052

80548053
{
@@ -8066,9 +8065,8 @@ fn test_secret_timeout() {
80668065
let events = nodes[1].node.get_and_clear_pending_events();
80678066
assert_eq!(events.len(), 1);
80688067
match events[0] {
8069-
Event::PaymentReceived { purpose: PaymentPurpose::InvoicePayment { payment_preimage, payment_secret, user_payment_id }, .. } => {
8068+
Event::PaymentReceived { purpose: PaymentPurpose::InvoicePayment { payment_preimage, payment_secret }, .. } => {
80708069
assert!(payment_preimage.is_none());
8071-
assert_eq!(user_payment_id, 42);
80728070
assert_eq!(payment_secret, our_payment_secret);
80738071
// We don't actually have the payment preimage with which to claim this payment!
80748072
},
@@ -8088,7 +8086,7 @@ fn test_bad_secret_hash() {
80888086

80898087
let random_payment_hash = PaymentHash([42; 32]);
80908088
let random_payment_secret = PaymentSecret([43; 32]);
8091-
let (our_payment_hash, our_payment_secret) = nodes[1].node.create_inbound_payment(Some(100_000), 2, 0);
8089+
let (our_payment_hash, our_payment_secret) = nodes[1].node.create_inbound_payment(Some(100_000), 2);
80928090
let (route, _, _, _) = get_route_and_payment_hash!(nodes[0], nodes[1], 100_000);
80938091

80948092
// All the below cases should end up being handled exactly identically, so we macro the

lightning/src/util/events.rs

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,6 @@ pub enum PaymentPurpose {
5959
/// [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment
6060
/// [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
6161
payment_secret: PaymentSecret,
62-
/// This is the `user_payment_id` which was provided to
63-
/// [`ChannelManager::create_inbound_payment_for_hash`] or
64-
/// [`ChannelManager::create_inbound_payment`]. It has no meaning inside of LDK and is
65-
/// simply copied here. It may be used to correlate PaymentReceived events with invoice
66-
/// metadata stored elsewhere.
67-
///
68-
/// [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment
69-
/// [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
70-
user_payment_id: u64,
7162
},
7263
/// Because this is a spontaneous payment, the payer generated their own preimage rather than us
7364
/// (the payee) providing a preimage.
@@ -326,18 +317,17 @@ impl Writeable for Event {
326317
&Event::PaymentReceived { ref payment_hash, ref amt, ref purpose } => {
327318
1u8.write(writer)?;
328319
let mut payment_secret = None;
329-
let mut user_payment_id = None;
330320
let payment_preimage;
331321
match &purpose {
332-
PaymentPurpose::InvoicePayment { payment_preimage: preimage, payment_secret: secret, user_payment_id: id } => {
322+
PaymentPurpose::InvoicePayment { payment_preimage: preimage, payment_secret: secret } => {
333323
payment_secret = Some(secret);
334324
payment_preimage = *preimage;
335-
user_payment_id = Some(id);
336325
},
337326
PaymentPurpose::SpontaneousPayment(preimage) => {
338327
payment_preimage = Some(*preimage);
339328
}
340329
}
330+
let user_payment_id: Option<u64> = None; // for compatibility with 0.0.103 and earlier
341331
write_tlv_fields!(writer, {
342332
(0, payment_hash, required),
343333
(2, payment_secret, option),
@@ -431,21 +421,18 @@ impl MaybeReadable for Event {
431421
let mut payment_preimage = None;
432422
let mut payment_secret = None;
433423
let mut amt = 0;
434-
let mut user_payment_id = None;
424+
let mut _user_payment_id = None; // For compatibility with 0.0.103 and earlier
435425
read_tlv_fields!(reader, {
436426
(0, payment_hash, required),
437427
(2, payment_secret, option),
438428
(4, amt, required),
439-
(6, user_payment_id, option),
429+
(6, _user_payment_id, option),
440430
(8, payment_preimage, option),
441431
});
442432
let purpose = match payment_secret {
443433
Some(secret) => PaymentPurpose::InvoicePayment {
444434
payment_preimage,
445-
payment_secret: secret,
446-
user_payment_id: if let Some(id) = user_payment_id {
447-
id
448-
} else { return Err(msgs::DecodeError::InvalidValue) }
435+
payment_secret: secret
449436
},
450437
None if payment_preimage.is_some() => PaymentPurpose::SpontaneousPayment(payment_preimage.unwrap()),
451438
None => return Err(msgs::DecodeError::InvalidValue),

0 commit comments

Comments
 (0)