use crate::offers::invoice_request::UnsignedInvoiceRequest;
use crate::prelude::*;
-use core::convert::TryInto;
use core::ops::Deref;
use core::sync::atomic::{AtomicUsize, Ordering};
#[cfg(taproot)]
pub fn witness_script(&self) -> Option<ScriptBuf> {
self.channel_transaction_parameters.as_ref()
.and_then(|channel_params|
- if channel_params.channel_type_features.supports_anchors_zero_fee_htlc_tx() {
+ if channel_params.supports_anchors() {
let payment_point = channel_params.holder_pubkeys.payment_point;
Some(chan_utils::get_to_countersignatory_with_anchors_redeemscript(&payment_point))
} else {
/// Note: If you have the grind_signatures feature enabled, this will be at least 1 byte
/// shorter.
pub fn max_witness_length(&self) -> u64 {
- if self.channel_transaction_parameters.as_ref()
- .map(|channel_params| channel_params.channel_type_features.supports_anchors_zero_fee_htlc_tx())
- .unwrap_or(false)
+ if self.channel_transaction_parameters.as_ref().map_or(false, |p| p.supports_anchors())
{
let witness_script_weight = 1 /* pubkey push */ + 33 /* pubkey */ +
1 /* OP_CHECKSIGVERIFY */ + 1 /* OP_1 */ + 1 /* OP_CHECKSEQUENCEVERIFY */;
let mut input = Vec::with_capacity(descriptors.len());
let mut input_value = 0;
let mut witness_weight = 0;
- let mut output_set = HashSet::with_capacity(descriptors.len());
+ let mut output_set = hash_set_with_capacity(descriptors.len());
for outp in descriptors {
match outp {
SpendableOutputDescriptor::StaticPaymentOutput(descriptor) => {
if !output_set.insert(descriptor.outpoint) { return Err(()); }
let sequence =
if descriptor.channel_transaction_parameters.as_ref()
- .map(|channel_params| channel_params.channel_type_features.supports_anchors_zero_fee_htlc_tx())
- .unwrap_or(false)
+ .map_or(false, |p| p.supports_anchors())
{
Sequence::from_consensus(1)
} else {
});
witness_weight += descriptor.max_witness_length();
#[cfg(feature = "grind_signatures")]
- { witness_weight -= 1; } // Guarantees a low R signature
+ { // Guarantees a low R signature
+ witness_weight -= 1;
+ }
input_value += descriptor.output.value;
},
SpendableOutputDescriptor::DelayedPaymentOutput(descriptor) => {
});
witness_weight += DelayedPaymentOutputDescriptor::MAX_WITNESS_LENGTH;
#[cfg(feature = "grind_signatures")]
- { witness_weight -= 1; } // Guarantees a low R signature
+ { // Guarantees a low R signature
+ witness_weight -= 1;
+ }
input_value += descriptor.output.value;
},
SpendableOutputDescriptor::StaticOutput { ref outpoint, ref output, .. } => {
});
witness_weight += 1 + 73 + 34;
#[cfg(feature = "grind_signatures")]
- { witness_weight -= 1; } // Guarantees a low R signature
+ { // Guarantees a low R signature
+ witness_weight -= 1;
+ }
input_value += output.value;
}
}
fn sign_gossip_message(&self, msg: UnsignedGossipMessage) -> Result<Signature, ()>;
}
+// Primarily needed in doctests because of https://github.com/rust-lang/rust/issues/67295
+/// A dynamic [`SignerProvider`] temporarily needed for doc tests.
+#[cfg(taproot)]
+#[doc(hidden)]
+#[deprecated(note = "Remove once taproot cfg is removed")]
+pub type DynSignerProvider = dyn SignerProvider<EcdsaSigner = InMemorySigner, TaprootSigner = InMemorySigner>;
+
+/// A dynamic [`SignerProvider`] temporarily needed for doc tests.
+#[cfg(not(taproot))]
+#[doc(hidden)]
+#[deprecated(note = "Remove once taproot cfg is removed")]
+pub type DynSignerProvider = dyn SignerProvider<EcdsaSigner = InMemorySigner>;
+
/// A trait that can return signer instances for individual channels.
pub trait SignerProvider {
/// A type which implements [`WriteableEcdsaChannelSigner`] which will be returned by [`Self::derive_channel_signer`].