bug: allow redeeming cashui when cashu wallet is stuck

TODO: separate wallets from UI
This commit is contained in:
Danny Morabito 2025-07-07 17:32:45 +02:00
parent 1c2677b547
commit 1df32badfb
Signed by: dannym
GPG key ID: 7CC8056A5A04557E

View file

@ -1,6 +1,7 @@
import {
CashuMint,
CashuWallet,
getDecodedToken,
MintQuoteState,
type Proof,
} from "@cashu/cashu-ts";
@ -225,7 +226,9 @@ function updateBalance() {
export async function redeemToken(token: string): Promise<void> {
if (!token.trim()) throw new Error("Token is empty");
const wallet = await walletReady;
const parsedToken = getDecodedToken(token);
const mint = new CashuMint(parsedToken.mint);
const wallet = new CashuWallet(mint);
const received = await wallet.receive(token.trim());
proofs.push(...received);
const amountReceived = received.reduce((sum, p) => sum + p.amount, 0);