descriptors: make signed_pubkeys a mapping from fingerprint

It's supposed to represent the number of signature per "master" key, i
guess. At the moment it would always be 1 because the origin changes
when we queried more keys from the signing device (because we increased
the account).
This commit is contained in:
Antoine Poinsot 2023-07-26 18:56:48 +02:00
parent 5b6c2b5c43
commit 7a33040b83
No known key found for this signature in database
GPG Key ID: E13FC145CD3F4304
2 changed files with 10 additions and 24 deletions

View File

@ -292,10 +292,10 @@ impl PathInfo {
// the (fingerprint, der_path) tuple is a UID for an xpub.
if origins.contains(&parent_origin) {
sigs_count += 1;
if let Some(count) = signed_pubkeys.get_mut(&parent_origin) {
if let Some(count) = signed_pubkeys.get_mut(&parent_origin.0) {
*count += 1;
} else {
signed_pubkeys.insert(parent_origin, 1);
signed_pubkeys.insert(parent_origin.0, 1);
}
}
}
@ -516,7 +516,7 @@ pub struct PathSpendInfo {
pub sigs_count: usize,
/// The keys for which a signature was provided and the number (always >=1) of
/// signatures provided for this key.
pub signed_pubkeys: HashMap<(bip32::Fingerprint, bip32::DerivationPath), usize>,
pub signed_pubkeys: HashMap<bip32::Fingerprint, usize>,
}
/// Information about a partial spend of Liana coins

View File

@ -762,10 +762,7 @@ mod tests {
// A simple descriptor with 1 keys as primary path and 1 recovery key.
let desc = LianaDescriptor::from_str("wsh(or_d(pk([f5acc2fd]tpubD6NzVbkrYhZ4YgUx2ZLNt2rLYAMTdYysCRzKoLu2BeSHKvzqPaBDvf17GeBPnExUVPkuBpx4kniP964e2MxyzzazcXLptxLXModSVCVEV1T/<0;1>/*),and_v(v:pkh([8a64f2a9]tpubD6NzVbkrYhZ4WmzFjvQrp7sDa4ECUxTi9oby8K4FZkd3XCBtEdKwUiQyYJaxiJo5y42gyDWEczrFpozEjeLxMPxjf2WtkfcbpUdfvNnozWF/<0;1>/*),older(10))))#d72le4dr").unwrap();
let desc_info = desc.policy();
let prim_key_origin = (
bip32::Fingerprint::from_str("f5acc2fd").unwrap(),
Vec::new().into(),
);
let prim_key_fg = bip32::Fingerprint::from_str("f5acc2fd").unwrap();
let recov_key_origin: (_, bip32::DerivationPath) = (
bip32::Fingerprint::from_str("8a64f2a9").unwrap(),
Vec::new().into(),
@ -806,12 +803,10 @@ mod tests {
assert_eq!(signed_single_psbt.inputs[0].partial_sigs.len(), 1);
assert_eq!(info.primary_path.threshold, 1);
assert_eq!(info.primary_path.sigs_count, 1);
dbg!(&info.primary_path.signed_pubkeys);
assert!(
info.primary_path.signed_pubkeys.len() == 1
&& info
.primary_path
.signed_pubkeys
.contains_key(&prim_key_origin)
&& info.primary_path.signed_pubkeys.contains_key(&prim_key_fg)
);
assert!(info.recovery_paths.is_empty());
@ -852,7 +847,7 @@ mod tests {
assert_eq!(recov_info.sigs_count, 1);
assert!(
recov_info.signed_pubkeys.len() == 1
&& recov_info.signed_pubkeys.contains_key(&recov_key_origin)
&& recov_info.signed_pubkeys.contains_key(&recov_key_origin.0)
);
// A PSBT with multiple inputs, all signed for the primary path.
@ -866,10 +861,7 @@ mod tests {
assert_eq!(info.primary_path.sigs_count, 1);
assert!(
info.primary_path.signed_pubkeys.len() == 1
&& info
.primary_path
.signed_pubkeys
.contains_key(&prim_key_origin)
&& info.primary_path.signed_pubkeys.contains_key(&prim_key_fg)
);
assert!(info.recovery_paths.is_empty());
@ -887,10 +879,7 @@ mod tests {
assert_eq!(info.primary_path.sigs_count, 1);
assert!(
info.primary_path.signed_pubkeys.len() == 1
&& info
.primary_path
.signed_pubkeys
.contains_key(&prim_key_origin)
&& info.primary_path.signed_pubkeys.contains_key(&prim_key_fg)
);
let recov_info = info.recovery_paths.get(&timelock).unwrap();
assert_eq!(recov_info.threshold, 1);
@ -927,10 +916,7 @@ mod tests {
assert_eq!(info.primary_path.sigs_count, 1);
assert!(
info.primary_path.signed_pubkeys.len() == 1
&& info
.primary_path
.signed_pubkeys
.contains_key(&prim_key_origin)
&& info.primary_path.signed_pubkeys.contains_key(&prim_key_fg)
);
assert!(info.recovery_paths.is_empty());