bug: allow redeeming cashui when cashu wallet is stuck
TODO: separate wallets from UI
This commit is contained in:
parent
1c2677b547
commit
1df32badfb
1 changed files with 4 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
import {
|
import {
|
||||||
CashuMint,
|
CashuMint,
|
||||||
CashuWallet,
|
CashuWallet,
|
||||||
|
getDecodedToken,
|
||||||
MintQuoteState,
|
MintQuoteState,
|
||||||
type Proof,
|
type Proof,
|
||||||
} from "@cashu/cashu-ts";
|
} from "@cashu/cashu-ts";
|
||||||
|
@ -225,7 +226,9 @@ function updateBalance() {
|
||||||
export async function redeemToken(token: string): Promise<void> {
|
export async function redeemToken(token: string): Promise<void> {
|
||||||
if (!token.trim()) throw new Error("Token is empty");
|
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());
|
const received = await wallet.receive(token.trim());
|
||||||
proofs.push(...received);
|
proofs.push(...received);
|
||||||
const amountReceived = received.reduce((sum, p) => sum + p.amount, 0);
|
const amountReceived = received.reduce((sum, p) => sum + p.amount, 0);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue