diff --git a/cashu.ts b/cashu.ts index 4717e81..d126581 100644 --- a/cashu.ts +++ b/cashu.ts @@ -9,16 +9,13 @@ export default class PortalBtcWalletCashu { private cashuTxns: CashuTxn[] = []; private proofs: Proof[] = []; private onBalanceUpdated: (() => void) | null = null; + private mint = new CashuMint(PortalBtcWallet.MINT_URL); + private cashuWallet: CashuWallet = new CashuWallet(this.mint); get txns() { return this.cashuTxns; } - get cashuWallet() { - const mint = new CashuMint(PortalBtcWallet.MINT_URL); - return new CashuWallet(mint); - } - get balance() { return this.proofs.reduce((sum, p) => sum + p.amount, 0); } @@ -66,6 +63,7 @@ export default class PortalBtcWalletCashu { } async meltProofsToPayInvoice(invoice: string) { + await this.cashuWallet.loadMint(); const meltQuote = await this.cashuWallet.createMeltQuote(invoice); const amountToMelt = meltQuote.amount + meltQuote.fee_reserve; const { keep, send } = await this.cashuWallet.send(