fix issue with cashu

This commit is contained in:
Danny Morabito 2025-07-10 18:49:30 +02:00
parent 5089dc9365
commit b194ace128
Signed by: dannym
GPG key ID: 7CC8056A5A04557E
2 changed files with 20 additions and 14 deletions

View file

@ -89,13 +89,20 @@ export default class NpubCash {
);
}
async *tryRedeemUnredeemedCashuQuotes(
async tryRedeemUnredeemedCashuQuotes(
latestRedeemedCashuQuoteTimestamp: number,
) {
const proofs: Proof[] = [];
const quotes: NpubCashQuote[] = await this.getAllPaidQuotes(
latestRedeemedCashuQuoteTimestamp,
);
const ret = {
proofs: [] as Proof[],
quotes: [] as {
quoteId: string;
amountSat: number;
timestamp: number;
}[],
};
for (const quote of quotes) {
const mint = new CashuMint(quote.mintUrl);
const wallet = new CashuWallet(mint);
@ -107,18 +114,18 @@ export default class NpubCash {
quote.amount,
quote.quoteId,
);
proofs.push(...newProofs);
ret.proofs.push(...newProofs);
const amountReceived = newProofs.reduce(
(sum, p) => sum + p.amount,
0,
);
yield {
ret.quotes.push({
quoteId: quote.quoteId,
amountSat: amountReceived,
timestamp: quote.paidAt,
};
});
}
}
return proofs;
return ret;
}
}