X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Futil%2Fenforcing_trait_impls.rs;h=acdd851ee7bc8297ff01cb990d48245d74abc77d;hb=f8334487036070de82628e085fb9a5ed58501fd2;hp=c13907bb9e4a4b5b8c299c588ef1d0c64fc44a47;hpb=45a6f3392d7868894a42d39cbec4d56d2b176e95;p=rust-lightning diff --git a/lightning/src/util/enforcing_trait_impls.rs b/lightning/src/util/enforcing_trait_impls.rs index c13907bb..acdd851e 100644 --- a/lightning/src/util/enforcing_trait_impls.rs +++ b/lightning/src/util/enforcing_trait_impls.rs @@ -10,7 +10,7 @@ use crate::ln::channel::{ANCHOR_OUTPUT_VALUE_SATOSHI, MIN_CHAN_DUST_LIMIT_SATOSHIS}; use crate::ln::chan_utils::{HTLCOutputInCommitment, ChannelPublicKeys, HolderCommitmentTransaction, CommitmentTransaction, ChannelTransactionParameters, TrustedCommitmentTransaction, ClosingTransaction}; use crate::ln::{chan_utils, msgs, PaymentPreimage}; -use crate::chain::keysinterface::{WriteableEcdsaChannelSigner, InMemorySigner, ChannelSigner, EcdsaChannelSigner}; +use crate::sign::{WriteableEcdsaChannelSigner, InMemorySigner, ChannelSigner, EcdsaChannelSigner}; use crate::prelude::*; use core::cmp; @@ -24,9 +24,10 @@ use bitcoin::secp256k1; use bitcoin::secp256k1::{SecretKey, PublicKey}; use bitcoin::secp256k1::{Secp256k1, ecdsa::Signature}; #[cfg(anchors)] -use crate::util::events::HTLCDescriptor; +use crate::events::bump_transaction::HTLCDescriptor; use crate::util::ser::{Writeable, Writer}; use crate::io::Error; +use crate::ln::features::ChannelTypeFeatures; /// Initial value for revoked commitment downward counter pub const INITIAL_REVOKED_COMMITMENT_NUMBER: u64 = 1 << 48; @@ -58,6 +59,12 @@ pub struct EnforcingSigner { pub disable_revocation_policy_check: bool, } +impl PartialEq for EnforcingSigner { + fn eq(&self, o: &Self) -> bool { + Arc::ptr_eq(&self.state, &o.state) + } +} + impl EnforcingSigner { /// Construct an EnforcingSigner pub fn new(inner: InMemorySigner) -> Self { @@ -82,7 +89,7 @@ impl EnforcingSigner { } } - pub fn opt_anchors(&self) -> bool { self.inner.opt_anchors() } + pub fn channel_type_features(&self) -> &ChannelTypeFeatures { self.inner.channel_type_features() } #[cfg(test)] pub fn get_enforcement_state(&self) -> MutexGuard { @@ -166,11 +173,11 @@ impl EcdsaChannelSigner for EnforcingSigner { for (this_htlc, sig) in trusted_tx.htlcs().iter().zip(&commitment_tx.counterparty_htlc_sigs) { assert!(this_htlc.transaction_output_index.is_some()); let keys = trusted_tx.keys(); - let htlc_tx = chan_utils::build_htlc_transaction(&commitment_txid, trusted_tx.feerate_per_kw(), holder_csv, &this_htlc, self.opt_anchors(), false, &keys.broadcaster_delayed_payment_key, &keys.revocation_key); + let htlc_tx = chan_utils::build_htlc_transaction(&commitment_txid, trusted_tx.feerate_per_kw(), holder_csv, &this_htlc, self.channel_type_features(), &keys.broadcaster_delayed_payment_key, &keys.revocation_key); - let htlc_redeemscript = chan_utils::get_htlc_redeemscript(&this_htlc, self.opt_anchors(), &keys); + let htlc_redeemscript = chan_utils::get_htlc_redeemscript(&this_htlc, self.channel_type_features(), &keys); - let sighash_type = if self.opt_anchors() { + let sighash_type = if self.channel_type_features().supports_anchors_zero_fee_htlc_tx() { EcdsaSighashType::SinglePlusAnyoneCanPay } else { EcdsaSighashType::All