fix issue with cashu wallet always reinitializing
This commit is contained in:
parent
2d858727b0
commit
5089dc9365
1 changed files with 3 additions and 5 deletions
8
cashu.ts
8
cashu.ts
|
@ -9,16 +9,13 @@ export default class PortalBtcWalletCashu {
|
||||||
private cashuTxns: CashuTxn[] = [];
|
private cashuTxns: CashuTxn[] = [];
|
||||||
private proofs: Proof[] = [];
|
private proofs: Proof[] = [];
|
||||||
private onBalanceUpdated: (() => void) | null = null;
|
private onBalanceUpdated: (() => void) | null = null;
|
||||||
|
private mint = new CashuMint(PortalBtcWallet.MINT_URL);
|
||||||
|
private cashuWallet: CashuWallet = new CashuWallet(this.mint);
|
||||||
|
|
||||||
get txns() {
|
get txns() {
|
||||||
return this.cashuTxns;
|
return this.cashuTxns;
|
||||||
}
|
}
|
||||||
|
|
||||||
get cashuWallet() {
|
|
||||||
const mint = new CashuMint(PortalBtcWallet.MINT_URL);
|
|
||||||
return new CashuWallet(mint);
|
|
||||||
}
|
|
||||||
|
|
||||||
get balance() {
|
get balance() {
|
||||||
return this.proofs.reduce((sum, p) => sum + p.amount, 0);
|
return this.proofs.reduce((sum, p) => sum + p.amount, 0);
|
||||||
}
|
}
|
||||||
|
@ -66,6 +63,7 @@ export default class PortalBtcWalletCashu {
|
||||||
}
|
}
|
||||||
|
|
||||||
async meltProofsToPayInvoice(invoice: string) {
|
async meltProofsToPayInvoice(invoice: string) {
|
||||||
|
await this.cashuWallet.loadMint();
|
||||||
const meltQuote = await this.cashuWallet.createMeltQuote(invoice);
|
const meltQuote = await this.cashuWallet.createMeltQuote(invoice);
|
||||||
const amountToMelt = meltQuote.amount + meltQuote.fee_reserve;
|
const amountToMelt = meltQuote.amount + meltQuote.fee_reserve;
|
||||||
const { keep, send } = await this.cashuWallet.send(
|
const { keep, send } = await this.cashuWallet.send(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue