fix: delete proofs when unspent

This commit is contained in:
thesimplekid
2025-02-05 11:00:17 +00:00
parent 7b69aa966a
commit 0e3f35b0de
2 changed files with 7 additions and 19 deletions

View File

@@ -385,7 +385,7 @@ impl Mint {
let input_ys = melt_request.inputs.ys()?;
self.localstore
.update_proofs_states(&input_ys, State::Unspent)
.remove_proofs(&input_ys, Some(melt_request.quote))
.await?;
self.localstore

View File

@@ -72,18 +72,14 @@ impl Mint {
.len()
.ne(&proof_count)
{
self.localstore
.update_proofs_states(&input_ys, State::Unspent)
.await?;
self.localstore.remove_proofs(&input_ys, None).await?;
return Err(Error::DuplicateProofs);
}
for proof in &swap_request.inputs {
if let Err(err) = self.verify_proof(proof).await {
tracing::info!("Error verifying proof in swap");
self.localstore
.update_proofs_states(&input_ys, State::Unspent)
.await?;
self.localstore.remove_proofs(&input_ys, None).await?;
return Err(err);
}
}
@@ -100,9 +96,7 @@ impl Mint {
}
None => {
tracing::info!("Swap request with unknown keyset in inputs");
self.localstore
.update_proofs_states(&input_ys, State::Unspent)
.await?;
self.localstore.remove_proofs(&input_ys, None).await?;
}
}
}
@@ -117,9 +111,7 @@ impl Mint {
}
None => {
tracing::info!("Swap request with unknown keyset in outputs");
self.localstore
.update_proofs_states(&input_ys, State::Unspent)
.await?;
self.localstore.remove_proofs(&input_ys, None).await?;
}
}
}
@@ -129,9 +121,7 @@ impl Mint {
// now
if keyset_units.len().gt(&1) {
tracing::error!("Only one unit is allowed in request: {:?}", keyset_units);
self.localstore
.update_proofs_states(&input_ys, State::Unspent)
.await?;
self.localstore.remove_proofs(&input_ys, None).await?;
return Err(Error::UnsupportedUnit);
}
@@ -146,9 +136,7 @@ impl Mint {
for blinded_message in &swap_request.outputs {
if let Err(err) = blinded_message.verify_p2pk(&pubkeys, sigs_required) {
tracing::info!("Could not verify p2pk in swap request");
self.localstore
.update_proofs_states(&input_ys, State::Unspent)
.await?;
self.localstore.remove_proofs(&input_ys, None).await?;
return Err(err.into());
}
}