Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use create_spend to calculate amount left to select and coin selection #863

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading