Skip to content

Commit

Permalink
Merge #863: Use create_spend to calculate amount left to select and c…
Browse files Browse the repository at this point in the history
…oin selection

a732468 spend: check max feerate (edouardparis)
4ccecd1 Use create_spend to calculate amount left to select (edouardparis)

Pull request description:

  Fixes #822. based on #865

ACKs for top commit:
  jp1ac4:
    ACK a732468.

Tree-SHA512: aa2728218d9ccf7b6511f881d88b262522705b4162b5b4235560626ee8b5b8c6d57e743ebfaf85dc633d6e3d2380badfe354a6dc4d19b89d3f380c63e123704e
  • Loading branch information
darosior committed Dec 12, 2023
2 parents 3e0f82a + a732468 commit 0346b7a
Show file tree
Hide file tree
Showing 8 changed files with 152 additions and 116 deletions.
2 changes: 1 addition & 1 deletion gui/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion gui/src/app/error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::convert::From;
use std::io::ErrorKind;

use liana::{config::ConfigError, descriptors::LianaDescError};
use liana::{config::ConfigError, descriptors::LianaDescError, spend::SpendCreationError};

use crate::{
app::{settings::SettingsError, wallet::WalletError},
Expand All @@ -16,13 +16,15 @@ pub enum Error {
Unexpected(String),
HardwareWallet(async_hwi::Error),
Desc(LianaDescError),
Spend(SpendCreationError),
}

impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
Self::Config(e) => write!(f, "{}", e),
Self::Wallet(e) => write!(f, "{}", e),
Self::Spend(e) => write!(f, "{}", e),
Self::Daemon(e) => match e {
DaemonError::Unexpected(e) => write!(f, "{}", e),
DaemonError::NoAnswer => write!(f, "Daemon did not answer"),
Expand Down Expand Up @@ -84,3 +86,9 @@ impl From<async_hwi::Error> for Error {
Error::HardwareWallet(error)
}
}

impl From<SpendCreationError> for Error {
fn from(error: SpendCreationError) -> Self {
Error::Spend(error)
}
}
8 changes: 8 additions & 0 deletions gui/src/app/state/coins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ mod tests {
spend_info: None,
is_immature: false,
address: dummy_address.clone(),
derivation_index: 0.into(),
is_change: false,
},
Coin {
outpoint: bitcoin::OutPoint { txid, vout: 3 },
Expand All @@ -224,6 +226,8 @@ mod tests {
spend_info: None,
is_immature: false,
address: dummy_address.clone(),
derivation_index: 1.into(),
is_change: false,
},
Coin {
outpoint: bitcoin::OutPoint { txid, vout: 0 },
Expand All @@ -232,6 +236,8 @@ mod tests {
spend_info: None,
is_immature: false,
address: dummy_address.clone(),
derivation_index: 2.into(),
is_change: false,
},
Coin {
outpoint: bitcoin::OutPoint { txid, vout: 1 },
Expand All @@ -240,6 +246,8 @@ mod tests {
spend_info: None,
is_immature: false,
address: dummy_address,
derivation_index: 3.into(),
is_change: false,
},
]);

Expand Down
4 changes: 2 additions & 2 deletions gui/src/app/state/spend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl CreateSpendPanel {
current: 0,
steps: vec![
Box::new(
step::DefineSpend::new(descriptor, coins, timelock)
step::DefineSpend::new(network, descriptor, coins, timelock)
.with_coins_sorted(blockheight),
),
Box::new(step::SaveSpend::new(wallet)),
Expand All @@ -54,7 +54,7 @@ impl CreateSpendPanel {
current: 0,
steps: vec![
Box::new(
step::DefineSpend::new(descriptor, coins, timelock)
step::DefineSpend::new(network, descriptor, coins, timelock)
.with_preselected_coins(preselected_coins)
.with_coins_sorted(blockheight)
.self_send(),
Expand Down
Loading

0 comments on commit 0346b7a

Please sign in to comment.