add pending to nut07 check spendable

This commit is contained in:
thesimplekid
2023-07-08 13:59:30 -04:00
parent eb31150031
commit 1b6487dec0
2 changed files with 9 additions and 3 deletions

View File

@@ -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> {

View File

@@ -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>,
}