feat: cashu wallet setup

feat: wallet send/receive pages
This commit is contained in:
2024-01-04 16:10:40 +00:00
parent 1e08702072
commit 7bc00b4624
17 changed files with 348 additions and 143 deletions

View File

@ -44,6 +44,22 @@ export class WebLNWallet implements LNWallet {
return window.webln !== undefined && window.webln !== null;
}
canCreateInvoice() {
return true;
}
canPayInvoice() {
return true;
}
canGetInvoices() {
return false;
}
canGetBalance() {
return window.webln?.getBalance !== undefined;
}
canAutoLogin(): boolean {
return true;
}
@ -76,6 +92,7 @@ export class WebLNWallet implements LNWallet {
}
async getBalance(): Promise<Sats> {
await this.login();
if (window.webln?.getBalance) {
const rsp = await barrierQueue(WebLNQueue, async () => await unwrap(window.webln?.getBalance).call(window.webln));
return rsp.balance;
@ -116,6 +133,7 @@ export class WebLNWallet implements LNWallet {
if (rsp) {
invoice.state = WalletInvoiceState.Paid;
invoice.preimage = rsp.preimage;
invoice.fees = "route" in rsp ? (rsp.route as { total_fees: number }).total_fees : 0;
return invoice;
} else {
invoice.state = WalletInvoiceState.Failed;
@ -128,12 +146,4 @@ export class WebLNWallet implements LNWallet {
getInvoices(): Promise<WalletInvoice[]> {
return Promise.resolve([]);
}
canGetInvoices() {
return false;
}
canGetBalance() {
return window.webln?.getBalance !== undefined;
}
}