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

@ -34,10 +34,11 @@ export default class PortalBtcWalletCashu {
}
async redeemCashuQuotes() {
const attempt = this.npubCash.tryRedeemUnredeemedCashuQuotes(
await this.cashuStore.getLastRedeemedCashuQuoteTimestamp(),
);
for await (const quote of attempt) {
const { proofs, quotes } = await this.npubCash
.tryRedeemUnredeemedCashuQuotes(
await this.cashuStore.getLastRedeemedCashuQuoteTimestamp(),
);
for (const quote of quotes) {
this.cashuTxns.push({
txId: `cashu-quote-${quote.quoteId}`,
paymentType: "receive",
@ -46,12 +47,10 @@ export default class PortalBtcWalletCashu {
status: "complete",
});
}
const proofs = await attempt.next();
if (!proofs.done || typeof proofs.value === "undefined") return [];
this.proofs.push(...proofs.value);
this.proofs.push(...proofs);
await this.persistState();
this.onBalanceUpdated?.();
return proofs.value;
return proofs;
}
async persistState() {