mirror of
https://github.com/aljazceru/cdk.git
synced 2026-02-12 08:36:44 +01:00
fix: delete proofs when unspent
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user