feat: only increment keyset counter for derived secrets

This commit is contained in:
thesimplekid
2024-07-05 23:05:14 +01:00
parent 6c3f67392b
commit bfe6ecb197
2 changed files with 10 additions and 2 deletions

View File

@@ -14,6 +14,8 @@ pub struct PreSwap {
pub pre_mint_secrets: PreMintSecrets,
/// Swap request
pub swap_request: SwapRequest,
/// Amount to increment keyset counter by
pub derived_secret_count: u32,
}
/// Split Request [NUT-06]

View File

@@ -687,9 +687,8 @@ impl Wallet {
let active_keyset_id = self.active_mint_keyset().await?;
// FIXME: Should not increment keyset counter for condition proofs
self.localstore
.increment_keyset_counter(&active_keyset_id, post_swap_proofs.len() as u32)
.increment_keyset_counter(&active_keyset_id, pre_swap.derived_secret_count)
.await?;
let mut keep_proofs = Proofs::new();
@@ -791,6 +790,8 @@ impl Wallet {
let desired_amount = amount.unwrap_or(proofs_total);
let change_amount = proofs_total - desired_amount;
let derived_secret_count;
let (mut desired_messages, change_messages) = match spending_conditions {
Some(conditions) => {
let count = self
@@ -808,6 +809,8 @@ impl Wallet {
amount_split_target,
)?;
derived_secret_count = change_premint_secrets.len();
(
PreMintSecrets::with_conditions(
active_keyset_id,
@@ -844,6 +847,8 @@ impl Wallet {
amount_split_target,
)?;
derived_secret_count = change_premint_secrets.len() + premint_secrets.len();
(premint_secrets, change_premint_secrets)
}
};
@@ -858,6 +863,7 @@ impl Wallet {
Ok(PreSwap {
pre_mint_secrets: desired_messages,
swap_request,
derived_secret_count: derived_secret_count as u32,
})
}