Merge #422: gui: display if signer signed in modal

1a6221bbf022b934c2ac89bcea536478c47cbcbb gui: display if signer signed in modal (edouard)

Pull request description:

  close #349

ACKs for top commit:
  edouardparis:
    Self-ACK 1a6221bbf022b934c2ac89bcea536478c47cbcbb

Tree-SHA512: ed7220374dd6c022daf39ac2f0137fce3c81a3b4bd99e9250a61438b42fbeaaff24e4cdbf604004a06b58c57ed1f3e9f28f7475f0c4d487856e14975e2472449
This commit is contained in:
edouard 2023-04-12 16:23:54 +02:00
commit 4064e92200
No known key found for this signature in database
GPG Key ID: E65F7A089C20DC8F
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)]