Skip to content

Commit 6d0eca5

Browse files
committed
Use create_spend to calculate amount left to select
close #822
1 parent b5a3e78 commit 6d0eca5

File tree

8 files changed

+144
-115
lines changed

8 files changed

+144
-115
lines changed

gui/Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gui/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ path = "src/main.rs"
1515

1616
[dependencies]
1717
async-hwi = "0.0.13"
18-
liana = { git = "https://github.com/wizardsardine/liana", branch = "master", default-features = false, features = ["nonblocking_shutdown"] }
18+
liana = { git = "https://github.com/edouardparis/liana", branch = "expose-spend-module", default-features = false, features = ["nonblocking_shutdown"] }
1919
liana_ui = { path = "ui" }
2020
backtrace = "0.3"
2121
base64 = "0.13"

gui/src/app/error.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::convert::From;
22
use std::io::ErrorKind;
33

4-
use liana::{config::ConfigError, descriptors::LianaDescError};
4+
use liana::{config::ConfigError, descriptors::LianaDescError, spend::SpendCreationError};
55

66
use crate::{
77
app::{settings::SettingsError, wallet::WalletError},
@@ -16,13 +16,15 @@ pub enum Error {
1616
Unexpected(String),
1717
HardwareWallet(async_hwi::Error),
1818
Desc(LianaDescError),
19+
Spend(SpendCreationError),
1920
}
2021

2122
impl std::fmt::Display for Error {
2223
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2324
match self {
2425
Self::Config(e) => write!(f, "{}", e),
2526
Self::Wallet(e) => write!(f, "{}", e),
27+
Self::Spend(e) => write!(f, "{}", e),
2628
Self::Daemon(e) => match e {
2729
DaemonError::Unexpected(e) => write!(f, "{}", e),
2830
DaemonError::NoAnswer => write!(f, "Daemon did not answer"),
@@ -84,3 +86,9 @@ impl From<async_hwi::Error> for Error {
8486
Error::HardwareWallet(error)
8587
}
8688
}
89+
90+
impl From<SpendCreationError> for Error {
91+
fn from(error: SpendCreationError) -> Self {
92+
Error::Spend(error)
93+
}
94+
}

gui/src/app/state/coins.rs

+8
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ mod tests {
216216
spend_info: None,
217217
is_immature: false,
218218
address: dummy_address.clone(),
219+
derivation_index: 0.into(),
220+
is_change: false,
219221
},
220222
Coin {
221223
outpoint: bitcoin::OutPoint { txid, vout: 3 },
@@ -224,6 +226,8 @@ mod tests {
224226
spend_info: None,
225227
is_immature: false,
226228
address: dummy_address.clone(),
229+
derivation_index: 1.into(),
230+
is_change: false,
227231
},
228232
Coin {
229233
outpoint: bitcoin::OutPoint { txid, vout: 0 },
@@ -232,6 +236,8 @@ mod tests {
232236
spend_info: None,
233237
is_immature: false,
234238
address: dummy_address.clone(),
239+
derivation_index: 2.into(),
240+
is_change: false,
235241
},
236242
Coin {
237243
outpoint: bitcoin::OutPoint { txid, vout: 1 },
@@ -240,6 +246,8 @@ mod tests {
240246
spend_info: None,
241247
is_immature: false,
242248
address: dummy_address,
249+
derivation_index: 3.into(),
250+
is_change: false,
243251
},
244252
]);
245253

gui/src/app/state/spend/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl CreateSpendPanel {
3232
current: 0,
3333
steps: vec![
3434
Box::new(
35-
step::DefineSpend::new(descriptor, coins, timelock)
35+
step::DefineSpend::new(network, descriptor, coins, timelock)
3636
.with_coins_sorted(blockheight),
3737
),
3838
Box::new(step::SaveSpend::new(wallet)),
@@ -54,7 +54,7 @@ impl CreateSpendPanel {
5454
current: 0,
5555
steps: vec![
5656
Box::new(
57-
step::DefineSpend::new(descriptor, coins, timelock)
57+
step::DefineSpend::new(network, descriptor, coins, timelock)
5858
.with_preselected_coins(preselected_coins)
5959
.with_coins_sorted(blockheight)
6060
.self_send(),

0 commit comments

Comments
 (0)