parse tokens

This commit is contained in:
callebtc
2023-04-04 22:29:21 +02:00
committed by Kieran
parent ca1bb86036
commit 4f8f472e84
5 changed files with 2042 additions and 1942 deletions

View File

@ -1,6 +1,16 @@
import { CashuMint, CashuWallet as TheCashuWallet, getEncodedProofs, Proof } from "@gandlaf21/cashu-ts";
import {
InvoiceRequest,
LNWallet,
prToWalletInvoice,
Sats,
WalletError,
WalletErrorCode,
WalletInfo,
WalletInvoice,
WalletInvoiceState,
} from "Wallet";
import { InvoiceRequest, LNWallet, WalletInfo, WalletInvoice } from "Wallet";
import { CashuMint, CashuWallet as TheCashuWallet, getEncodedToken, Proof } from "@cashu/cashu-ts";
export class CashuWallet implements LNWallet {
#mint: string;
@ -16,7 +26,15 @@ export class CashuWallet implements LNWallet {
return this.#wallet !== undefined;
}
getInfo: () => Promise<WalletInfo>;
async getInfo(): Promise<WalletInfo> {
if (!this.#wallet) {
throw new WalletError(WalletErrorCode.GeneralError, "Wallet not initialized");
}
return {
nodePubKey: "asd",
alias: "asd",
} as WalletInfo;
}
async login(_?: string | undefined): Promise<boolean> {
const m = new CashuMint(this.#mint, this.#walletPath);
@ -25,11 +43,23 @@ export class CashuWallet implements LNWallet {
return true;
}
close: () => Promise<boolean>;
getBalance: () => Promise<number>;
createInvoice: (req: InvoiceRequest) => Promise<WalletInvoice>;
payInvoice: (pr: string) => Promise<WalletInvoice>;
getInvoices: () => Promise<WalletInvoice[]>;
close(): Promise<boolean> {
return Promise.resolve(true);
}
getBalance(): Promise<Sats> {
// return dummy balance of 1337 sats
return Promise.resolve(1337);
}
createInvoice(req: InvoiceRequest): Promise<WalletInvoice> {
throw new Error("Method not implemented.");
}
payInvoice(pr: string): Promise<WalletInvoice> {
throw new Error("Method not implemented.");
}
getInvoices(): Promise<WalletInvoice[]> {
throw new Error("Method not implemented.");
}
}
interface NutBank {