mirror of
https://github.com/aljazceru/cdk.git
synced 2026-02-05 05:06:14 +01:00
add pending to nut07 check spendable
This commit is contained in:
11
src/mint.rs
11
src/mint.rs
@@ -19,6 +19,7 @@ pub struct Mint {
|
||||
pub active_keyset: nut02::mint::KeySet,
|
||||
pub inactive_keysets: HashMap<String, nut02::mint::KeySet>,
|
||||
pub spent_secrets: HashSet<String>,
|
||||
pub pending_secrets: HashSet<String>,
|
||||
}
|
||||
|
||||
impl Mint {
|
||||
@@ -33,6 +34,7 @@ impl Mint {
|
||||
active_keyset: nut02::mint::KeySet::generate(secret, derivation_path, max_order),
|
||||
inactive_keysets,
|
||||
spent_secrets,
|
||||
pending_secrets: HashSet::new(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,12 +185,15 @@ impl Mint {
|
||||
&self,
|
||||
check_spendable: &CheckSpendableRequest,
|
||||
) -> Result<CheckSpendableResponse, Error> {
|
||||
let mut spendable = vec![];
|
||||
let mut spendable = Vec::with_capacity(check_spendable.proofs.len());
|
||||
let mut pending = Vec::with_capacity(check_spendable.proofs.len());
|
||||
|
||||
for proof in &check_spendable.proofs {
|
||||
spendable.push(!self.spent_secrets.contains(&proof.secret))
|
||||
spendable.push(!self.spent_secrets.contains(&proof.secret));
|
||||
pending.push(!self.pending_secrets.contains(&proof.secret));
|
||||
}
|
||||
|
||||
Ok(CheckSpendableResponse { spendable })
|
||||
Ok(CheckSpendableResponse { spendable, pending })
|
||||
}
|
||||
|
||||
pub fn verify_melt_request(&mut self, melt_request: &MeltRequest) -> Result<(), Error> {
|
||||
|
||||
@@ -17,4 +17,5 @@ pub struct CheckSpendableResponse {
|
||||
/// booleans indicating whether the provided Proof is still spendable.
|
||||
/// In same order as provided proofs
|
||||
pub spendable: Vec<bool>,
|
||||
pub pending: Vec<bool>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user