Skip to content

Commit 46e07b8

Browse files
notmandatoryruben
authored andcommitted
refactor(chain)!: use Amount for DescriptorExt::dust_value()
1 parent 7e14ff3 commit 46e07b8

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

crates/chain/src/descriptor_ext.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::miniscript::{Descriptor, DescriptorPublicKey};
22
use bitcoin::hashes::{hash_newtype, sha256, Hash};
3+
use bitcoin::Amount;
34

45
hash_newtype! {
56
/// Represents the unique ID of a descriptor.
@@ -13,22 +14,21 @@ hash_newtype! {
1314

1415
/// A trait to extend the functionality of a miniscript descriptor.
1516
pub trait DescriptorExt {
16-
/// Returns the minimum value (in satoshis) at which an output is broadcastable.
17+
/// Returns the minimum [`Amount`] at which an output is broadcast-able.
1718
/// Panics if the descriptor wildcard is hardened.
18-
fn dust_value(&self) -> u64;
19+
fn dust_value(&self) -> Amount;
1920

2021
/// Returns the descriptor ID, calculated as the sha256 hash of the spk derived from the
2122
/// descriptor at index 0.
2223
fn descriptor_id(&self) -> DescriptorId;
2324
}
2425

2526
impl DescriptorExt for Descriptor<DescriptorPublicKey> {
26-
fn dust_value(&self) -> u64 {
27+
fn dust_value(&self) -> Amount {
2728
self.at_derivation_index(0)
2829
.expect("descriptor can't have hardened derivation")
2930
.script_pubkey()
3031
.minimal_non_dust()
31-
.to_sat()
3232
}
3333

3434
fn descriptor_id(&self) -> DescriptorId {

example-crates/example_cli/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ where
324324
.expect("must exist")
325325
.1;
326326

327-
let min_drain_value = change_desc.dust_value();
327+
let min_drain_value = change_desc.dust_value().to_sat();
328328

329329
let target = Target {
330330
outputs: TargetOutputs::fund_outputs(

0 commit comments

Comments
 (0)