X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Fchan_utils.rs;h=b7676ddff15290b876854b007c3f1a05572f1be4;hb=0e22b1245af2ddd5b226d989801d5427053dd9ed;hp=672e3aa862e460e94f26451ebff4ff39293eb4e9;hpb=f352d03ee98aed3d940e697fcb09371cfdc3ab15;p=rust-lightning diff --git a/lightning/src/ln/chan_utils.rs b/lightning/src/ln/chan_utils.rs index 672e3aa8..b7676ddf 100644 --- a/lightning/src/ln/chan_utils.rs +++ b/lightning/src/ln/chan_utils.rs @@ -37,7 +37,6 @@ use bitcoin::{secp256k1, Sequence, Witness}; use bitcoin::PublicKey as BitcoinPublicKey; use crate::io; -use crate::prelude::*; use core::cmp; use crate::ln::chan_utils; use crate::util::transaction_utils::sort_outputs; @@ -45,9 +44,12 @@ use crate::ln::channel::{INITIAL_COMMITMENT_NUMBER, ANCHOR_OUTPUT_VALUE_SATOSHI} use core::ops::Deref; use crate::chain; use crate::ln::features::ChannelTypeFeatures; -use crate::util::crypto::{sign, sign_with_aux_rand}; +use crate::crypto::utils::{sign, sign_with_aux_rand}; use super::channel_keys::{DelayedPaymentBasepoint, DelayedPaymentKey, HtlcKey, HtlcBasepoint, RevocationKey, RevocationBasepoint}; +#[allow(unused_imports)] +use crate::prelude::*; + /// Maximum number of one-way in-flight HTLC (protocol-level value). pub const MAX_HTLCS: u16 = 483; /// The weight of a BIP141 witnessScript for a BOLT3's "offered HTLC output" on a commitment transaction, non-anchor variant. @@ -850,6 +852,11 @@ impl ChannelTransactionParameters { self.counterparty_parameters.is_some() && self.funding_outpoint.is_some() } + /// Whether the channel supports zero-fee HTLC transaction anchors. + pub(crate) fn supports_anchors(&self) -> bool { + self.channel_type_features.supports_anchors_zero_fee_htlc_tx() + } + /// Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters, /// given that the holder is the broadcaster. /// @@ -1812,7 +1819,6 @@ pub fn get_commitment_transaction_number_obscure_factor( mod tests { use super::{CounterpartyCommitmentSecrets, ChannelPublicKeys}; use crate::chain; - use crate::prelude::*; use crate::ln::chan_utils::{get_htlc_redeemscript, get_to_countersignatory_with_anchors_redeemscript, CommitmentTransaction, TxCreationKeys, ChannelTransactionParameters, CounterpartyChannelTransactionParameters, HTLCOutputInCommitment}; use bitcoin::secp256k1::{PublicKey, SecretKey, Secp256k1}; use crate::util::test_utils; @@ -1825,6 +1831,9 @@ mod tests { use bitcoin::PublicKey as BitcoinPublicKey; use crate::ln::features::ChannelTypeFeatures; + #[allow(unused_imports)] + use crate::prelude::*; + struct TestCommitmentTxBuilder { commitment_number: u64, holder_funding_pubkey: PublicKey,