Skip to content

Commit 90e3612

Browse files
committed
Make the PaymentSecret in PaymentReceived events non-Optional
1 parent 989849b commit 90e3612

File tree

5 files changed

+19
-18
lines changed

5 files changed

+19
-18
lines changed

lightning/src/ln/chanmon_update_fail_tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ fn do_test_simple_monitor_temporary_update_fail(disconnect: bool, persister_fail
208208
match events_3[0] {
209209
Event::PaymentReceived { ref payment_hash, ref payment_secret, amt, user_payment_id: _ } => {
210210
assert_eq!(payment_hash_1, *payment_hash);
211-
assert_eq!(Some(payment_secret_1), *payment_secret);
211+
assert_eq!(payment_secret_1, *payment_secret);
212212
assert_eq!(amt, 1000000);
213213
},
214214
_ => panic!("Unexpected event"),
@@ -576,7 +576,7 @@ fn do_test_monitor_temporary_update_fail(disconnect_count: usize) {
576576
match events_5[0] {
577577
Event::PaymentReceived { ref payment_hash, ref payment_secret, amt, user_payment_id: _ } => {
578578
assert_eq!(payment_hash_2, *payment_hash);
579-
assert_eq!(Some(payment_secret_2), *payment_secret);
579+
assert_eq!(payment_secret_2, *payment_secret);
580580
assert_eq!(amt, 1000000);
581581
},
582582
_ => panic!("Unexpected event"),
@@ -690,7 +690,7 @@ fn test_monitor_update_fail_cs() {
690690
match events[0] {
691691
Event::PaymentReceived { payment_hash, payment_secret, amt, user_payment_id: _ } => {
692692
assert_eq!(payment_hash, our_payment_hash);
693-
assert_eq!(Some(our_payment_secret), payment_secret);
693+
assert_eq!(our_payment_secret, payment_secret);
694694
assert_eq!(amt, 1000000);
695695
},
696696
_ => panic!("Unexpected event"),

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2014,7 +2014,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
20142014
} else if total_value == payment_data.total_msat {
20152015
new_events.push(events::Event::PaymentReceived {
20162016
payment_hash,
2017-
payment_secret: Some(payment_data.payment_secret),
2017+
payment_secret: payment_data.payment_secret,
20182018
amt: total_value,
20192019
user_payment_id: inbound_payment.get().user_payment_id,
20202020
});

lightning/src/ln/functional_test_utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ macro_rules! expect_payment_received {
943943
match events[0] {
944944
Event::PaymentReceived { ref payment_hash, ref payment_secret, amt, user_payment_id: _ } => {
945945
assert_eq!($expected_payment_hash, *payment_hash);
946-
assert_eq!(Some($expected_payment_secret), *payment_secret);
946+
assert_eq!($expected_payment_secret, *payment_secret);
947947
assert_eq!($expected_recv_value, amt);
948948
},
949949
_ => panic!("Unexpected event"),
@@ -1011,7 +1011,7 @@ pub fn pass_along_path<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_path
10111011
match events_2[0] {
10121012
Event::PaymentReceived { ref payment_hash, ref payment_secret, amt, user_payment_id: _ } => {
10131013
assert_eq!(our_payment_hash, *payment_hash);
1014-
assert_eq!(Some(our_payment_secret), *payment_secret);
1014+
assert_eq!(our_payment_secret, *payment_secret);
10151015
assert_eq!(amt, recv_value);
10161016
},
10171017
_ => panic!("Unexpected event"),

lightning/src/ln/functional_tests.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2072,15 +2072,15 @@ fn test_channel_reserve_holding_cell_htlcs() {
20722072
match events[0] {
20732073
Event::PaymentReceived { ref payment_hash, ref payment_secret, amt, user_payment_id: _ } => {
20742074
assert_eq!(our_payment_hash_21, *payment_hash);
2075-
assert_eq!(Some(our_payment_secret_21), *payment_secret);
2075+
assert_eq!(our_payment_secret_21, *payment_secret);
20762076
assert_eq!(recv_value_21, amt);
20772077
},
20782078
_ => panic!("Unexpected event"),
20792079
}
20802080
match events[1] {
20812081
Event::PaymentReceived { ref payment_hash, ref payment_secret, amt, user_payment_id: _ } => {
20822082
assert_eq!(our_payment_hash_22, *payment_hash);
2083-
assert_eq!(Some(our_payment_secret_22), *payment_secret);
2083+
assert_eq!(our_payment_secret_22, *payment_secret);
20842084
assert_eq!(recv_value_22, amt);
20852085
},
20862086
_ => panic!("Unexpected event"),
@@ -3648,7 +3648,7 @@ fn do_test_drop_messages_peer_disconnect(messages_delivered: u8) {
36483648
match events_2[0] {
36493649
Event::PaymentReceived { ref payment_hash, ref payment_secret, amt, user_payment_id: _ } => {
36503650
assert_eq!(payment_hash_1, *payment_hash);
3651-
assert_eq!(Some(payment_secret_1), *payment_secret);
3651+
assert_eq!(payment_secret_1, *payment_secret);
36523652
assert_eq!(amt, 1000000);
36533653
},
36543654
_ => panic!("Unexpected event"),
@@ -3985,7 +3985,7 @@ fn test_drop_messages_peer_disconnect_dual_htlc() {
39853985
match events_5[0] {
39863986
Event::PaymentReceived { ref payment_hash, ref payment_secret, amt: _, user_payment_id: _ } => {
39873987
assert_eq!(payment_hash_2, *payment_hash);
3988-
assert_eq!(Some(payment_secret_2), *payment_secret);
3988+
assert_eq!(payment_secret_2, *payment_secret);
39893989
},
39903990
_ => panic!("Unexpected event"),
39913991
}

lightning/src/util/events.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,15 @@ pub enum Event {
6363
payment_hash: PaymentHash,
6464
/// The "payment secret". This authenticates the sender to the recipient, preventing a
6565
/// number of deanonymization attacks during the routing process.
66-
/// As nodes upgrade, the invoices you provide should likely migrate to setting the
67-
/// payment_secret feature to required, at which point you should fail_backwards any HTLCs
68-
/// which have a None here.
69-
/// Until then, however, values of None should be ignored, and only incorrect Some values
70-
/// should result in an HTLC fail_backwards.
71-
/// Note that, in any case, this value must be passed as-is to any fail or claim calls as
72-
/// the HTLC index includes this value.
73-
payment_secret: Option<PaymentSecret>,
66+
/// It is provided here for your reference, however its accuracy is enforced directly by
67+
/// [`ChannelManager`] using the values you previously provided to
68+
/// [`ChannelManager::get_payment_secret_preimage`] or
69+
/// [`ChannelManager::get_payment_secret`].
70+
///
71+
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
72+
/// [`ChannelManager::get_payment_secret_preimage`]: crate::ln::channelmanager::ChannelManager::get_payment_secret_preimage
73+
/// [`ChannelManager::get_payment_secret`]: crate::ln::channelmanager::ChannelManager::get_payment_secret
74+
payment_secret: PaymentSecret,
7475
/// The value, in thousandths of a satoshi, that this payment is for. Note that you must
7576
/// compare this to the expected value before accepting the payment (as otherwise you are
7677
/// providing proof-of-payment for less than the value you expected!).

0 commit comments

Comments
 (0)