From: Steve Myers Date: Sun, 8 Dec 2024 02:24:35 +0000 (-0600) Subject: refactor(chain)!: use Amount for DescriptorExt::dust_value() X-Git-Tag: v1.0.0-beta.6~1^2~1 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/database/scripts/static/struct.CommandStringError.html?a=commitdiff_plain;h=20789ec9e833ad8d24608201960789614dfae52b;p=bdk refactor(chain)!: use Amount for DescriptorExt::dust_value() --- diff --git a/crates/chain/src/descriptor_ext.rs b/crates/chain/src/descriptor_ext.rs index eac01a68..9cf14758 100644 --- a/crates/chain/src/descriptor_ext.rs +++ b/crates/chain/src/descriptor_ext.rs @@ -1,5 +1,6 @@ use crate::miniscript::{Descriptor, DescriptorPublicKey}; use bitcoin::hashes::{hash_newtype, sha256, Hash}; +use bitcoin::Amount; hash_newtype! { /// Represents the unique ID of a descriptor. @@ -13,9 +14,9 @@ hash_newtype! { /// A trait to extend the functionality of a miniscript descriptor. pub trait DescriptorExt { - /// Returns the minimum value (in satoshis) at which an output is broadcastable. + /// Returns the minimum [`Amount`] at which an output is broadcast-able. /// Panics if the descriptor wildcard is hardened. - fn dust_value(&self) -> u64; + fn dust_value(&self) -> Amount; /// Returns the descriptor ID, calculated as the sha256 hash of the spk derived from the /// descriptor at index 0. @@ -23,12 +24,11 @@ pub trait DescriptorExt { } impl DescriptorExt for Descriptor { - fn dust_value(&self) -> u64 { + fn dust_value(&self) -> Amount { self.at_derivation_index(0) .expect("descriptor can't have hardened derivation") .script_pubkey() .minimal_non_dust() - .to_sat() } fn descriptor_id(&self) -> DescriptorId { diff --git a/example-crates/example_cli/src/lib.rs b/example-crates/example_cli/src/lib.rs index 8c17348b..3a700db3 100644 --- a/example-crates/example_cli/src/lib.rs +++ b/example-crates/example_cli/src/lib.rs @@ -324,7 +324,7 @@ where .expect("must exist") .1; - let min_drain_value = change_desc.dust_value(); + let min_drain_value = change_desc.dust_value().to_sat(); let target = Target { outputs: TargetOutputs::fund_outputs(