X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fln%2Fchannelmonitor.rs;h=8d6d23ad00a160b6342eade2dce0fffbf33ca06c;hb=0baf72bbdfa09775a92cfd181c02f0962e02cc63;hp=f3c5c89f6e67cbc1c0e175b75439729385212d33;hpb=6e1318b0e28522244493c280f556e6749694b81e;p=rust-lightning diff --git a/src/ln/channelmonitor.rs b/src/ln/channelmonitor.rs index f3c5c89f..8d6d23ad 100644 --- a/src/ln/channelmonitor.rs +++ b/src/ln/channelmonitor.rs @@ -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)), @@ -856,7 +856,7 @@ impl ChannelMonitor { }; let sighash_parts = bip143::SighashComponents::new(&single_htlc_tx); sign_input!(sighash_parts, single_htlc_tx.input[0], Some(idx), htlc.amount_msat / 1000); - txn_to_broadcast.push(single_htlc_tx); // TODO: This is not yet tested in ChannelManager! + txn_to_broadcast.push(single_htlc_tx); } } } @@ -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 { - 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;