Merge #250: fix various bugs with hws and spend signing process
73eb1d38e3612110ad467fd608863519838aa988 fix state: add new hws in list without dropping the old ones (edouard) d9336c11ea7d3ad4dcb68fbe322d9247cf9ad52e spend detail: add a refresh button for hws (edouard) 5a7eaff17ba895418b368deaa74f8ed1b4ac26e7 fix hws: ledger dongle must load wallet (edouard) Pull request description: Fixes #246 Fixes #238 ACKs for top commit: edouardparis: ACK 73eb1d38e3612110ad467fd608863519838aa988 Tree-SHA512: 969824ba2ac28a5726b8b0e87cc9a0e216ae54e2ec1fde6c5cb73d9a9326071d3b1ede9dcde1e06eb1946a38627b4ed3be2efa23955b88b11db66f36f94de14a
This commit is contained in:
commit
805c8e192b
@ -118,8 +118,13 @@ impl State for RecoveryPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// We add the new hws without dropping the reference of the previous ones.
|
||||||
Message::ConnectedHardwareWallets(hws) => {
|
Message::ConnectedHardwareWallets(hws) => {
|
||||||
self.hws = hws;
|
for h in hws {
|
||||||
|
if !self.hws.iter().any(|hw| hw.fingerprint == h.fingerprint) {
|
||||||
|
self.hws.push(h);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Message::Psbt(res) => match res {
|
Message::Psbt(res) => match res {
|
||||||
Ok(psbt) => self.generated = Some(psbt),
|
Ok(psbt) => self.generated = Some(psbt),
|
||||||
|
|||||||
@ -330,8 +330,13 @@ impl Action for SignAction {
|
|||||||
Ok(()) => self.updated = true,
|
Ok(()) => self.updated = true,
|
||||||
Err(e) => self.error = Some(e),
|
Err(e) => self.error = Some(e),
|
||||||
},
|
},
|
||||||
|
// We add the new hws without dropping the reference of the previous ones.
|
||||||
Message::ConnectedHardwareWallets(hws) => {
|
Message::ConnectedHardwareWallets(hws) => {
|
||||||
self.hws = hws;
|
for h in hws {
|
||||||
|
if !self.hws.iter().any(|hw| hw.fingerprint == h.fingerprint) {
|
||||||
|
self.hws.push(h);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Message::View(view::Message::Reload) => {
|
Message::View(view::Message::Reload) => {
|
||||||
return self.load(daemon);
|
return self.load(daemon);
|
||||||
|
|||||||
@ -480,7 +480,16 @@ pub fn sign_action<'a>(
|
|||||||
Column::new()
|
Column::new()
|
||||||
.push(if !hws.is_empty() {
|
.push(if !hws.is_empty() {
|
||||||
Column::new()
|
Column::new()
|
||||||
.push(text("Select hardware wallet to sign with:").bold())
|
.push(
|
||||||
|
Row::new()
|
||||||
|
.push(
|
||||||
|
text("Select hardware wallet to sign with:")
|
||||||
|
.bold()
|
||||||
|
.width(Length::Fill),
|
||||||
|
)
|
||||||
|
.push(button::border(None, "Refresh").on_press(Message::Reload))
|
||||||
|
.align_items(Alignment::Center),
|
||||||
|
)
|
||||||
.spacing(10)
|
.spacing(10)
|
||||||
.push(
|
.push(
|
||||||
hws.iter()
|
hws.iter()
|
||||||
@ -503,7 +512,7 @@ pub fn sign_action<'a>(
|
|||||||
.spacing(20)
|
.spacing(20)
|
||||||
.width(Length::Fill)
|
.width(Length::Fill)
|
||||||
.push("Please connect a hardware wallet")
|
.push("Please connect a hardware wallet")
|
||||||
.push(button::primary(None, "Refresh").on_press(Message::Reload))
|
.push(button::border(None, "Refresh").on_press(Message::Reload))
|
||||||
.align_items(Alignment::Center),
|
.align_items(Alignment::Center),
|
||||||
)
|
)
|
||||||
.width(Length::Fill)
|
.width(Length::Fill)
|
||||||
|
|||||||
@ -110,8 +110,26 @@ pub async fn list_hardware_wallets(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
match ledger::Ledger::try_connect_hid() {
|
match ledger::Ledger::try_connect_hid() {
|
||||||
Ok(device) => match HardwareWallet::new(Arc::new(device)).await {
|
Ok(mut device) => match device.get_master_fingerprint().await {
|
||||||
Ok(hw) => hws.push(hw),
|
Ok(fingerprint) => {
|
||||||
|
if let Some((name, descriptor)) = wallet {
|
||||||
|
device
|
||||||
|
.load_wallet(
|
||||||
|
name,
|
||||||
|
descriptor,
|
||||||
|
cfg.iter()
|
||||||
|
.find(|cfg| cfg.fingerprint == fingerprint.to_string())
|
||||||
|
.map(|cfg| cfg.token()),
|
||||||
|
)
|
||||||
|
.expect("Configuration must be correct");
|
||||||
|
}
|
||||||
|
|
||||||
|
hws.push(HardwareWallet {
|
||||||
|
kind: device.device_kind(),
|
||||||
|
fingerprint,
|
||||||
|
device: Arc::new(device),
|
||||||
|
});
|
||||||
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
debug!("{}", e);
|
debug!("{}", e);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user