Skip to content

Commit

Permalink
feat: allow checking if a given e-cash note is spent
Browse files Browse the repository at this point in the history
  • Loading branch information
elsirion committed Nov 6, 2024
1 parent b41bc17 commit 57cf5e0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions modules/fedimint-mint-common/src/endpoint_constants.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub const AWAIT_OUTPUT_OUTCOME_ENDPOINT: &str = "await_output_outcome";
pub const BACKUP_ENDPOINT: &str = "backup";
pub const RECOVER_ENDPOINT: &str = "recover";
pub const NOTE_SPENT_ENDPOINT: &str = "note_spent";
11 changes: 10 additions & 1 deletion modules/fedimint-mint-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ use threshold_crypto::group::Curve;
use threshold_crypto::{G2Projective, Scalar};
use tracing::{debug, info};

use crate::common::endpoint_constants::NOTE_SPENT_ENDPOINT;
use crate::common::Nonce;
use crate::db::{
DbKeyPrefix, ECashUserBackupSnapshot, EcashBackupKey, EcashBackupKeyPrefix, MintAuditItemKey,
MintAuditItemKeyPrefix, MintOutputOutcomeKey, MintOutputOutcomePrefix, NonceKey,
Expand Down Expand Up @@ -136,7 +138,7 @@ impl ServerModuleInit for MintInit {
MODULE_CONSENSUS_VERSION.major,
MODULE_CONSENSUS_VERSION.minor,
),
&[(0, 0)],
&[(0, 1)],
)
}

Expand Down Expand Up @@ -526,6 +528,13 @@ impl ServerModule for Mint {
.handle_recover_request(&mut context.dbtx().into_nc(), id).await)
}
},
api_endpoint! {
NOTE_SPENT_ENDPOINT,
ApiVersion::new(0, 1),
async |_module: &Mint, context, nonce: Nonce| -> bool {
Ok(context.dbtx().get_value(&NonceKey(nonce)).await.is_some())
}
},
]
}
}
Expand Down

0 comments on commit 57cf5e0

Please sign in to comment.