]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Merge pull request #1062 from galderz/t_payment_hash_999
authorMatt Corallo <649246+TheBlueMatt@users.noreply.github.com>
Fri, 8 Oct 2021 20:49:19 +0000 (20:49 +0000)
committerGitHub <noreply@github.com>
Fri, 8 Oct 2021 20:49:19 +0000 (20:49 +0000)
1  2 
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/ln/reorg_tests.rs
lightning/src/ln/shutdown_tests.rs
lightning/src/util/events.rs

index 152de61fd8e56719f116393c44f55c9144773b36,43fd8f1de7babbacf1aa10af222d8cf31b2ce2db..1b5813a301851229fdd2967dc22e025042b2cab8
@@@ -3304,12 -3157,16 +3304,16 @@@ impl<Signer: Sign, M: Deref, T: Deref, 
                                let mut session_priv_bytes = [0; 32];
                                session_priv_bytes.copy_from_slice(&session_priv[..]);
                                let mut outbounds = self.pending_outbound_payments.lock().unwrap();
 -                              let found_payment = if let Some(mut sessions) = outbounds.remove(&mpp_id) {
 -                                      sessions.remove(&session_priv_bytes)
 +                              let found_payment = if let Some(mut sessions) = outbounds.remove(&payment_id) {
 +                                      sessions.remove(&session_priv_bytes, path.last().unwrap().fee_msat)
                                } else { false };
                                if found_payment {
+                                       let payment_hash = PaymentHash(Sha256::hash(&payment_preimage.0).into_inner());
                                        self.pending_events.lock().unwrap().push(
-                                               events::Event::PaymentSent { payment_preimage }
+                                               events::Event::PaymentSent {
+                                                       payment_preimage,
+                                                       payment_hash: payment_hash
+                                               }
                                        );
                                } else {
                                        log_trace!(self.logger, "Received duplicative fulfill for HTLC with payment_preimage {}", log_bytes!(payment_preimage.0));
index 30652e47864963ba91574a146bee0192f28ff250,08dc81e0206442c1b9263458ee6c3e3f54a3e55e..bb9556fc46a1003e334a990ad66efbcb7c1a4c4b
@@@ -2688,9 -2642,9 +2688,10 @@@ fn test_htlc_on_chain_success() 
                                        first_claimed = true;
                                } else {
                                        assert_eq!(payment_preimage, our_payment_preimage_2);
+                                       assert_eq!(payment_hash, payment_hash_2);
                                }
                        },
 +                      Event::ChannelClosed { reason: ClosureReason::CommitmentTxConfirmed, .. } => {},
                        _ => panic!("Unexpected event"),
                }
        }
Simple merge
Simple merge
index 22b2f40020371e98f022082a6798b961c724ad0f,ad82ca6cab9017051a64ff5bbb66bf8e56ae1537..2b6a55bcecc66bb54c87b6d7349efb1aa9c6ef81
  
  use chain::keysinterface::SpendableOutputDescriptor;
  use ln::msgs;
 +use ln::msgs::DecodeError;
  use ln::{PaymentPreimage, PaymentHash, PaymentSecret};
  use routing::network_graph::NetworkUpdate;
 -use util::ser::{Writeable, Writer, MaybeReadable, Readable, VecReadWrapper, VecWriteWrapper};
 +use util::ser::{BigSize, FixedLengthReader, Writeable, Writer, MaybeReadable, Readable, VecReadWrapper, VecWriteWrapper};
 +use routing::router::RouteHop;
  
  use bitcoin::blockdata::script::Script;
+ use bitcoin::hashes::Hash;
+ use bitcoin::hashes::sha256::Hash as Sha256;
  use bitcoin::secp256k1::key::PublicKey;
  
  use io;
@@@ -291,10 -231,10 +296,11 @@@ impl Writeable for Event 
                                2u8.write(writer)?;
                                write_tlv_fields!(writer, {
                                        (0, payment_preimage, required),
+                                       (1, payment_hash, required),
                                });
                        },
 -                      &Event::PaymentFailed { ref payment_hash, ref rejected_by_dest, ref network_update, ref all_paths_failed,
 +                      &Event::PaymentPathFailed { ref payment_hash, ref rejected_by_dest, ref network_update,
 +                                                  ref all_paths_failed, ref path,
                                #[cfg(test)]
                                ref error_code,
                                #[cfg(test)]