gui: display if signer signed in modal

close #349
This commit is contained in:
edouard 2023-04-07 17:21:23 +02:00
parent e55432d2d6
commit 1a6221bbf0
3 changed files with 29 additions and 8 deletions

View File

@ -1,3 +1,4 @@
use std::collections::HashSet;
use std::sync::Arc;
use iced::Command;
@ -90,7 +91,7 @@ impl SpendTxState {
self.action = Some(Box::new(DeleteAction::default()));
}
view::SpendTxMessage::Sign => {
let action = SignAction::new(self.wallet.clone());
let action = SignAction::new(self.tx.signers(), self.wallet.clone());
let cmd = action.load(daemon);
self.action = Some(Box::new(action));
return cmd;
@ -270,18 +271,18 @@ pub struct SignAction {
processing: bool,
hws: Vec<HardwareWallet>,
error: Option<Error>,
signed: Vec<Fingerprint>,
signed: HashSet<Fingerprint>,
}
impl SignAction {
pub fn new(wallet: Arc<Wallet>) -> Self {
pub fn new(signed: HashSet<Fingerprint>, wallet: Arc<Wallet>) -> Self {
Self {
wallet,
chosen_hw: None,
processing: false,
hws: Vec::new(),
error: None,
signed: Vec::new(),
signed,
}
}
}
@ -332,7 +333,7 @@ impl Action for SignAction {
Err(e) => self.error = Some(e),
Ok((psbt, fingerprint)) => {
self.error = None;
self.signed.push(fingerprint);
self.signed.insert(fingerprint);
let daemon = daemon.clone();
tx.psbt = psbt.clone();
return Command::perform(

View File

@ -1,4 +1,4 @@
use std::collections::HashMap;
use std::collections::{HashMap, HashSet};
use iced::{
widget::{scrollable, tooltip, Space},
@ -713,7 +713,7 @@ pub fn sign_action<'a>(
signer_alias: Option<&'a String>,
processing: bool,
chosen_hw: Option<usize>,
signed: &[Fingerprint],
signed: &HashSet<Fingerprint>,
) -> Element<'a, Message> {
Column::new()
.push_maybe(warning.map(|w| warn(Some(w))))

View File

@ -1,10 +1,15 @@
use std::collections::HashSet;
pub use liana::{
commands::{
CreateSpendResult, GetAddressResult, GetInfoResult, ListCoinsEntry, ListCoinsResult,
ListSpendEntry, ListSpendResult, ListTransactionsResult, TransactionInfo,
},
descriptors::{PartialSpendInfo, PathSpendInfo},
miniscript::bitcoin::{util::psbt::Psbt, Amount, Transaction},
miniscript::bitcoin::{
util::{bip32::Fingerprint, psbt::Psbt},
Amount, Transaction,
},
};
pub type Coin = ListCoinsEntry;
@ -101,6 +106,21 @@ impl SpendTx {
.values()
.find(|&path| path.sigs_count >= path.threshold)
}
pub fn signers(&self) -> HashSet<Fingerprint> {
let mut signers = HashSet::new();
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() {
signers.insert(*fg);
}
}
signers
}
}
#[derive(Debug, Clone)]