Test htlc outputs shared tx claim case
[rust-lightning] / src / ln / channelmonitor.rs
index f3c5c89f6e67cbc1c0e175b75439729385212d33..3c3163b18badc0ec3e892a2b53f8293b42488fa8 100644 (file)
@@ -759,7 +759,7 @@ impl ChannelMonitor {
                                        ignore_error!(chan_utils::derive_public_key(&self.secp_ctx, &per_commitment_point, &htlc_base_key)))
                                },
                        };
-                       let delayed_key = ignore_error!(chan_utils::derive_public_key(&self.secp_ctx, &PublicKey::from_secret_key(&self.secp_ctx, &per_commitment_key), &self.delayed_payment_base_key));
+                       let delayed_key = ignore_error!(chan_utils::derive_public_key(&self.secp_ctx, &PublicKey::from_secret_key(&self.secp_ctx, &per_commitment_key), &self.their_delayed_payment_base_key.unwrap()));
                        let a_htlc_key = match self.their_htlc_base_key {
                                None => return (txn_to_broadcast, (commitment_txid, watch_outputs)),
                                Some(their_htlc_base_key) => ignore_error!(chan_utils::derive_public_key(&self.secp_ctx, &PublicKey::from_secret_key(&self.secp_ctx, &per_commitment_key), &their_htlc_base_key)),
@@ -1011,7 +1011,9 @@ impl ChannelMonitor {
 
        /// Attempst to claim a remote HTLC-Success/HTLC-Timeout s outputs using the revocation key
        fn check_spend_remote_htlc(&self, tx: &Transaction, commitment_number: u64) -> Option<Transaction> {
-               let htlc_txid = tx.txid(); //TODO: This is gonna be a performance bottleneck for watchtowers!
+               if tx.input.len() != 1 || tx.output.len() != 1 {
+                       return None;
+               }
 
                macro_rules! ignore_error {
                        ( $thing : expr ) => {
@@ -1039,6 +1041,7 @@ impl ChannelMonitor {
                };
                let redeemscript = chan_utils::get_revokeable_redeemscript(&revocation_pubkey, self.their_to_self_delay.unwrap(), &delayed_key);
                let revokeable_p2wsh = redeemscript.to_v0_p2wsh();
+               let htlc_txid = tx.txid(); //TODO: This is gonna be a performance bottleneck for watchtowers!
 
                let mut inputs = Vec::new();
                let mut amount = 0;