]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Make the PaymentSecret in `PaymentReceived` events non-Optional
authorMatt Corallo <git@bluematt.me>
Fri, 23 Apr 2021 16:53:53 +0000 (16:53 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 28 Apr 2021 19:30:25 +0000 (15:30 -0400)
lightning/src/ln/chanmon_update_fail_tests.rs
lightning/src/ln/channelmanager.rs
lightning/src/ln/functional_test_utils.rs
lightning/src/ln/functional_tests.rs
lightning/src/util/events.rs

index 619d02c8c0c452553deb156558eac250512fbd38..bcc115ae9f07cf73faca45dba849706ec8e79c32 100644 (file)
@@ -208,7 +208,7 @@ fn do_test_simple_monitor_temporary_update_fail(disconnect: bool, persister_fail
        match events_3[0] {
                Event::PaymentReceived { ref payment_hash, ref payment_secret, amt, user_payment_id: _ } => {
                        assert_eq!(payment_hash_1, *payment_hash);
-                       assert_eq!(Some(payment_secret_1), *payment_secret);
+                       assert_eq!(payment_secret_1, *payment_secret);
                        assert_eq!(amt, 1000000);
                },
                _ => panic!("Unexpected event"),
@@ -576,7 +576,7 @@ fn do_test_monitor_temporary_update_fail(disconnect_count: usize) {
        match events_5[0] {
                Event::PaymentReceived { ref payment_hash, ref payment_secret, amt, user_payment_id: _ } => {
                        assert_eq!(payment_hash_2, *payment_hash);
-                       assert_eq!(Some(payment_secret_2), *payment_secret);
+                       assert_eq!(payment_secret_2, *payment_secret);
                        assert_eq!(amt, 1000000);
                },
                _ => panic!("Unexpected event"),
@@ -690,7 +690,7 @@ fn test_monitor_update_fail_cs() {
        match events[0] {
                Event::PaymentReceived { payment_hash, payment_secret, amt, user_payment_id: _ } => {
                        assert_eq!(payment_hash, our_payment_hash);
-                       assert_eq!(Some(our_payment_secret), payment_secret);
+                       assert_eq!(our_payment_secret, payment_secret);
                        assert_eq!(amt, 1000000);
                },
                _ => panic!("Unexpected event"),
index 1c43d8b0f7537952e4e002ad000f3c69e16d5353..b1890853ec10630f4953f61cae03f99c4310a56d 100644 (file)
@@ -2024,7 +2024,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
                                                                                        } else if total_value == payment_data.total_msat {
                                                                                                new_events.push(events::Event::PaymentReceived {
                                                                                                        payment_hash,
-                                                                                                       payment_secret: Some(payment_data.payment_secret),
+                                                                                                       payment_secret: payment_data.payment_secret,
                                                                                                        amt: total_value,
                                                                                                        user_payment_id: inbound_payment.get().user_payment_id,
                                                                                                });
index bc1d7ef068488f8a12cea70fd1b25bcdb7031313..1b0567ab3a7c4f7142660d060f79a82c78a6addb 100644 (file)
@@ -943,7 +943,7 @@ macro_rules! expect_payment_received {
                match events[0] {
                        Event::PaymentReceived { ref payment_hash, ref payment_secret, amt, user_payment_id: _ } => {
                                assert_eq!($expected_payment_hash, *payment_hash);
-                               assert_eq!(Some($expected_payment_secret), *payment_secret);
+                               assert_eq!($expected_payment_secret, *payment_secret);
                                assert_eq!($expected_recv_value, amt);
                        },
                        _ => panic!("Unexpected event"),
@@ -1011,7 +1011,7 @@ pub fn pass_along_path<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_path
                                match events_2[0] {
                                        Event::PaymentReceived { ref payment_hash, ref payment_secret, amt, user_payment_id: _ } => {
                                                assert_eq!(our_payment_hash, *payment_hash);
-                                               assert_eq!(Some(our_payment_secret), *payment_secret);
+                                               assert_eq!(our_payment_secret, *payment_secret);
                                                assert_eq!(amt, recv_value);
                                        },
                                        _ => panic!("Unexpected event"),
index aea006fe71fbed21def1d079b85386ee01dc1381..56c795d8edccee3dfe05cf16f0cd188d1e41b38f 100644 (file)
@@ -2072,7 +2072,7 @@ fn test_channel_reserve_holding_cell_htlcs() {
        match events[0] {
                Event::PaymentReceived { ref payment_hash, ref payment_secret, amt, user_payment_id: _ } => {
                        assert_eq!(our_payment_hash_21, *payment_hash);
-                       assert_eq!(Some(our_payment_secret_21), *payment_secret);
+                       assert_eq!(our_payment_secret_21, *payment_secret);
                        assert_eq!(recv_value_21, amt);
                },
                _ => panic!("Unexpected event"),
@@ -2080,7 +2080,7 @@ fn test_channel_reserve_holding_cell_htlcs() {
        match events[1] {
                Event::PaymentReceived { ref payment_hash, ref payment_secret, amt, user_payment_id: _ } => {
                        assert_eq!(our_payment_hash_22, *payment_hash);
-                       assert_eq!(Some(our_payment_secret_22), *payment_secret);
+                       assert_eq!(our_payment_secret_22, *payment_secret);
                        assert_eq!(recv_value_22, amt);
                },
                _ => panic!("Unexpected event"),
@@ -3648,7 +3648,7 @@ fn do_test_drop_messages_peer_disconnect(messages_delivered: u8) {
        match events_2[0] {
                Event::PaymentReceived { ref payment_hash, ref payment_secret, amt, user_payment_id: _ } => {
                        assert_eq!(payment_hash_1, *payment_hash);
-                       assert_eq!(Some(payment_secret_1), *payment_secret);
+                       assert_eq!(payment_secret_1, *payment_secret);
                        assert_eq!(amt, 1000000);
                },
                _ => panic!("Unexpected event"),
@@ -3985,7 +3985,7 @@ fn test_drop_messages_peer_disconnect_dual_htlc() {
        match events_5[0] {
                Event::PaymentReceived { ref payment_hash, ref payment_secret, amt: _, user_payment_id: _ } => {
                        assert_eq!(payment_hash_2, *payment_hash);
-                       assert_eq!(Some(payment_secret_2), *payment_secret);
+                       assert_eq!(payment_secret_2, *payment_secret);
                },
                _ => panic!("Unexpected event"),
        }
index 4486d0510cbd2e1bafeeab069c437f9075bb5bda..ad7e61177a578b302b214a8fb6912f32d185db46 100644 (file)
@@ -63,14 +63,15 @@ pub enum Event {
                payment_hash: PaymentHash,
                /// The "payment secret". This authenticates the sender to the recipient, preventing a
                /// number of deanonymization attacks during the routing process.
-               /// As nodes upgrade, the invoices you provide should likely migrate to setting the
-               /// payment_secret feature to required, at which point you should fail_backwards any HTLCs
-               /// which have a None here.
-               /// Until then, however, values of None should be ignored, and only incorrect Some values
-               /// should result in an HTLC fail_backwards.
-               /// Note that, in any case, this value must be passed as-is to any fail or claim calls as
-               /// the HTLC index includes this value.
-               payment_secret: Option<PaymentSecret>,
+               /// It is provided here for your reference, however its accuracy is enforced directly by
+               /// [`ChannelManager`] using the values you previously provided to
+               /// [`ChannelManager::create_inbound_payment`] or
+               /// [`ChannelManager::create_inbound_payment_for_hash`].
+               ///
+               /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
+               /// [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment
+               /// [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash
+               payment_secret: PaymentSecret,
                /// The value, in thousandths of a satoshi, that this payment is for. Note that you must
                /// compare this to the expected value before accepting the payment (as otherwise you are
                /// providing proof-of-payment for less than the value you expected!).