Skip to content

Commit

Permalink
installer: use appended path instead of account number for xpubs
Browse files Browse the repository at this point in the history
  • Loading branch information
edouardparis committed Aug 11, 2023
1 parent 6c969ae commit 30ce2de
Show file tree
Hide file tree
Showing 11 changed files with 448 additions and 441 deletions.
10 changes: 5 additions & 5 deletions gui/Cargo.lock

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

2 changes: 1 addition & 1 deletion gui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ name = "liana-gui"
path = "src/main.rs"

[dependencies]
async-hwi = "0.0.9"
async-hwi = "0.0.10"
liana = { git = "https://github.com/wizardsardine/liana", branch = "master", default-features = false }
liana_ui = { path = "ui" }
backtrace = "0.3"
Expand Down
4 changes: 4 additions & 0 deletions gui/src/app/state/coins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,24 +136,28 @@ mod tests {
amount: bitcoin::Amount::from_sat(1),
block_height: Some(3),
spend_info: None,
is_immature: false,
},
Coin {
outpoint: bitcoin::OutPoint { txid, vout: 3 },
amount: bitcoin::Amount::from_sat(1),
block_height: None,
spend_info: None,
is_immature: false,
},
Coin {
outpoint: bitcoin::OutPoint { txid, vout: 0 },
amount: bitcoin::Amount::from_sat(1),
block_height: Some(2),
spend_info: None,
is_immature: false,
},
Coin {
outpoint: bitcoin::OutPoint { txid, vout: 1 },
amount: bitcoin::Amount::from_sat(1),
block_height: Some(3),
spend_info: None,
is_immature: false,
},
]);

Expand Down
3 changes: 2 additions & 1 deletion gui/src/app/state/recovery.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::collections::HashSet;
use std::str::FromStr;
use std::sync::Arc;

Expand Down Expand Up @@ -197,7 +198,7 @@ impl From<RecoveryPanel> for Box<dyn State> {
pub struct RecoveryPath {
threshold: usize,
sequence: u16,
origins: Vec<(Fingerprint, DerivationPath)>,
origins: Vec<(Fingerprint, HashSet<DerivationPath>)>,
total_amount: Amount,
number_of_coins: usize,
}
Expand Down
18 changes: 9 additions & 9 deletions gui/src/app/view/psbt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,19 +309,19 @@ pub fn signatures<'a>(
sigs.signed_pubkeys
.keys()
.fold(Row::new().spacing(5), |row, value| {
row.push(if let Some(alias) = keys_aliases.get(&value.0) {
row.push(if let Some(alias) = keys_aliases.get(value) {
Container::new(
tooltip::Tooltip::new(
Container::new(text(alias))
.padding(10)
.style(theme::Container::Pill(theme::Pill::Simple)),
value.0.to_string(),
value.to_string(),
tooltip::Position::Bottom,
)
.style(theme::Container::Card(theme::Card::Simple)),
)
} else {
Container::new(text(value.0.to_string()))
Container::new(text(value.to_string()))
.padding(10)
.style(theme::Container::Pill(theme::Pill::Simple))
})
Expand Down Expand Up @@ -401,14 +401,14 @@ pub fn path_view<'a>(
sigs: &'a PathSpendInfo,
key_aliases: &'a HashMap<Fingerprint, String>,
) -> Element<'a, Message> {
let mut keys: Vec<(Fingerprint, DerivationPath)> =
let mut keys: Vec<(Fingerprint, HashSet<DerivationPath>)> =
path.thresh_origins().1.into_iter().collect();
let missing_signatures = if sigs.sigs_count >= sigs.threshold {
0
} else {
sigs.threshold - sigs.sigs_count
};
keys.sort();
keys.sort_by_key(|a| a.0);
scrollable(
Row::new()
.align_items(Alignment::Center)
Expand Down Expand Up @@ -439,7 +439,7 @@ pub fn path_view<'a>(
None
} else {
Some(keys.iter().fold(Row::new().spacing(5), |row, value| {
row.push_maybe(if !sigs.signed_pubkeys.contains_key(value) {
row.push_maybe(if !sigs.signed_pubkeys.contains_key(&value.0) {
Some(if let Some(alias) = key_aliases.get(&value.0) {
Container::new(
tooltip::Tooltip::new(
Expand Down Expand Up @@ -470,19 +470,19 @@ pub fn path_view<'a>(
sigs.signed_pubkeys
.keys()
.fold(Row::new().spacing(5), |row, value| {
row.push(if let Some(alias) = key_aliases.get(&value.0) {
row.push(if let Some(alias) = key_aliases.get(value) {
Container::new(
tooltip::Tooltip::new(
Container::new(text(alias))
.padding(10)
.style(theme::Container::Pill(theme::Pill::Simple)),
value.0.to_string(),
value.to_string(),
tooltip::Position::Bottom,
)
.style(theme::Container::Card(theme::Card::Simple)),
)
} else {
Container::new(text(value.0.to_string()))
Container::new(text(value.to_string()))
.padding(10)
.style(theme::Container::Pill(theme::Pill::Simple))
})
Expand Down
4 changes: 2 additions & 2 deletions gui/src/app/view/recovery.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::collections::HashMap;
use std::collections::{HashMap, HashSet};

use iced::{
widget::{checkbox, tooltip, Space},
Expand Down Expand Up @@ -137,7 +137,7 @@ pub fn recovery<'a>(
pub fn recovery_path_view<'a>(
index: usize,
threshold: usize,
origins: &'a [(Fingerprint, DerivationPath)],
origins: &'a [(Fingerprint, HashSet<DerivationPath>)],
total_amount: Amount,
number_of_coins: usize,
key_aliases: &'a HashMap<Fingerprint, String>,
Expand Down
4 changes: 2 additions & 2 deletions gui/src/daemon/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ impl SpendTx {

pub fn signers(&self) -> HashSet<Fingerprint> {
let mut signers = HashSet::new();
for (fg, _) in self.sigs.primary_path().signed_pubkeys.keys() {
for fg in self.sigs.primary_path().signed_pubkeys.keys() {
signers.insert(*fg);
}

for path in self.sigs.recovery_paths().values() {
for (fg, _) in path.signed_pubkeys.keys() {
for fg in path.signed_pubkeys.keys() {
signers.insert(*fg);
}
}
Expand Down
13 changes: 5 additions & 8 deletions gui/src/hw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,10 @@ fn ledger_version_supported(version: Option<&Version>) -> bool {
}
}

pub async fn list_unregistered_hardware_wallets(
aliases: Option<&HashMap<Fingerprint, String>>,
) -> Vec<HardwareWallet> {
pub async fn list_unregistered_hardware_wallets() -> Vec<HardwareWallet> {
let mut hws: Vec<HardwareWallet> = Vec::new();
match specter::SpecterSimulator::try_connect().await {
Ok(device) => match HardwareWallet::new(Arc::new(device), aliases).await {
Ok(device) => match HardwareWallet::new(Arc::new(device), None).await {
Ok(hw) => hws.push(hw),
Err(e) => {
debug!("{}", e);
Expand All @@ -249,7 +247,7 @@ pub async fn list_unregistered_hardware_wallets(
match specter::Specter::enumerate().await {
Ok(devices) => {
for device in devices {
match HardwareWallet::new(Arc::new(device), aliases).await {
match HardwareWallet::new(Arc::new(device), None).await {
Ok(hw) => hws.push(hw),
Err(e) => {
debug!("{}", e);
Expand All @@ -270,7 +268,7 @@ pub async fn list_unregistered_hardware_wallets(
device: Arc::new(device),
version,
registered: None,
alias: aliases.and_then(|aliases| aliases.get(&fingerprint).cloned()),
alias: None,
});
} else {
hws.push(HardwareWallet::Unsupported {
Expand Down Expand Up @@ -310,8 +308,7 @@ pub async fn list_unregistered_hardware_wallets(
device: Arc::new(device),
version,
registered: None,
alias: aliases
.and_then(|aliases| aliases.get(&fingerprint).cloned()),
alias: None,
});
} else {
hws.push(HardwareWallet::Unsupported {
Expand Down
1 change: 1 addition & 0 deletions gui/src/installer/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ pub enum ImportKeyModal {
EditName,
NameEdited(String),
ConfirmXpub,
SelectKey(usize),
}

#[derive(Debug, Clone)]
Expand Down
Loading

0 comments on commit 30ce2de

Please sign in to comment.