X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fchain%2Fonchaintx.rs;h=1ca3effabd7e537afc0832cff5085abd3a6abf47;hb=28d33ff9e03b7e3a0cd7ba3bc59f1303b3903f88;hp=d6777cc5c8cfd494409f5832f29efb3699bc21ab;hpb=d523b6e42b5b0fde07a89770906e0193ea987538;p=rust-lightning diff --git a/lightning/src/chain/onchaintx.rs b/lightning/src/chain/onchaintx.rs index d6777cc5..1ca3effa 100644 --- a/lightning/src/chain/onchaintx.rs +++ b/lightning/src/chain/onchaintx.rs @@ -18,7 +18,7 @@ use bitcoin::blockdata::script::Script; use bitcoin::hash_types::Txid; -use bitcoin::secp256k1::{Secp256k1, Signature}; +use bitcoin::secp256k1::{Secp256k1, ecdsa::Signature}; use bitcoin::secp256k1; use ln::msgs::DecodeError; @@ -365,6 +365,14 @@ impl OnchainTxHandler { } } + pub(crate) fn get_prev_holder_commitment_to_self_value(&self) -> Option { + self.prev_holder_commitment.as_ref().map(|commitment| commitment.to_broadcaster_value_sat()) + } + + pub(crate) fn get_cur_holder_commitment_to_self_value(&self) -> u64 { + self.holder_commitment.to_broadcaster_value_sat() + } + /// Lightning security model (i.e being able to redeem/timeout HTLC or penalize coutnerparty onchain) lays on the assumption of claim transactions getting confirmed before timelock expiration /// (CSV or CLTV following cases). In case of high-fee spikes, claim tx may stuck in the mempool, so you need to bump its feerate quickly using Replace-By-Fee or Child-Pay-For-Parent. /// Panics if there are signing errors, because signing operations in reaction to on-chain events @@ -379,13 +387,14 @@ impl OnchainTxHandler { // didn't receive confirmation of it before, or not enough reorg-safe depth on top of it). let new_timer = Some(cached_request.get_height_timer(cur_height)); if cached_request.is_malleable() { - let predicted_weight = cached_request.package_weight(&self.destination_script); - if let Some((output_value, new_feerate)) = cached_request.compute_package_output(predicted_weight, fee_estimator, logger) { + let predicted_weight = cached_request.package_weight(&self.destination_script, self.channel_transaction_parameters.opt_anchors.is_some()); + if let Some((output_value, new_feerate)) = + cached_request.compute_package_output(predicted_weight, self.destination_script.dust_value().as_sat(), fee_estimator, logger) { assert!(new_feerate != 0); let transaction = cached_request.finalize_package(self, output_value, self.destination_script.clone(), logger).unwrap(); log_trace!(logger, "...with timer {} and feerate {}", new_timer.unwrap(), new_feerate); - assert!(predicted_weight >= transaction.get_weight()); + assert!(predicted_weight >= transaction.weight()); return Some((new_timer, new_feerate, transaction)) } } else { @@ -777,6 +786,10 @@ impl OnchainTxHandler { htlc_tx } + pub(crate) fn opt_anchors(&self) -> bool { + self.channel_transaction_parameters.opt_anchors.is_some() + } + #[cfg(any(test,feature = "unsafe_revoked_tx_signing"))] pub(crate) fn unsafe_get_fully_signed_htlc_tx(&mut self, outp: &::bitcoin::OutPoint, preimage: &Option) -> Option { let latest_had_sigs = self.holder_htlc_sigs.is_some();