Skip to content

Commit

Permalink
Merge #1475: remove commands import in spend module
Browse files Browse the repository at this point in the history
4668980 remove commands import in spend module (edouardparis)

Pull request description:

  This is preparatory work to create a specific liana lib.
  We keep modules separated.

ACKs for top commit:
  edouardparis:
    Self-ACK 4668980

Tree-SHA512: 0c33ab252a2e8b5404893367467ea48dbed8d84b5de0cb15dcc91bf5491b8af0d6bddd4aafe55699e16dcd7cd97b96d462d004b1921a38ae5e438c908d515c03
  • Loading branch information
edouardparis committed Nov 19, 2024
2 parents 1454c11 + 4668980 commit 36b24d4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
30 changes: 28 additions & 2 deletions liana/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,20 @@ impl DaemonControl {
// any ancestor info.
Some((
c,
self.bitcoin.mempool_entry(&op.txid).map(AncestorInfo::from),
self.bitcoin
.mempool_entry(&op.txid)
.map(|info| AncestorInfo {
vsize: info
.ancestor_vsize
.try_into()
.expect("vsize must fit in u32"),
fee: info
.fees
.ancestor
.to_sat()
.try_into()
.expect("fee in sat should fit in u32"),
}),
))
} else {
None
Expand Down Expand Up @@ -538,7 +551,20 @@ impl DaemonControl {
// We include any non-change coins here as they have been selected by the caller.
// If the unconfirmed coin's transaction is no longer in the mempool, keep the
// coin as a candidate but without any ancestor info (same as confirmed candidate).
self.bitcoin.mempool_entry(&op.txid).map(AncestorInfo::from)
self.bitcoin
.mempool_entry(&op.txid)
.map(|info| AncestorInfo {
vsize: info
.ancestor_vsize
.try_into()
.expect("vsize must fit in u32"),
fee: info
.fees
.ancestor
.to_sat()
.try_into()
.expect("fee in sat should fit in u32"),
})
} else {
None
};
Expand Down
19 changes: 1 addition & 18 deletions liana/src/spend.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{bitcoin::MempoolEntry, descriptors};
use crate::descriptors;

use std::{
collections::{BTreeMap, HashMap},
Expand Down Expand Up @@ -171,23 +171,6 @@ pub struct AncestorInfo {
pub fee: u32,
}

impl From<MempoolEntry> for AncestorInfo {
fn from(entry: MempoolEntry) -> Self {
Self {
vsize: entry
.ancestor_vsize
.try_into()
.expect("vsize must fit in a u32"),
fee: entry
.fees
.ancestor
.to_sat()
.try_into()
.expect("fee in sats should fit in a u32"),
}
}
}

/// A candidate for coin selection when creating a transaction.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct CandidateCoin {
Expand Down

0 comments on commit 36b24d4

Please sign in to comment.