From 2198e8549b767dffe80547e806f293e1c4d4fc66 Mon Sep 17 00:00:00 2001 From: Steve Myers Date: Sat, 7 Dec 2024 20:24:35 -0600 Subject: [PATCH] refactor(chain)!: use Amount for DescriptorExt::dust_value() --- crates/chain/src/descriptor_ext.rs | 8 ++++---- example-crates/example_cli/src/lib.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/chain/src/descriptor_ext.rs b/crates/chain/src/descriptor_ext.rs index eac01a684..9cf147582 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 6a97252fc..68951df52 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(