import { LNWallet, Sats, WalletError, WalletErrorCode, WalletInfo, WalletInvoice } from "Wallet"; import { CashuMint, CashuWallet as TheCashuWallet, Proof } from "@cashu/cashu-ts"; export class CashuWallet implements LNWallet { #mint: string; #wallet?: TheCashuWallet; constructor(mint: string) { this.#mint = mint; } canAutoLogin(): boolean { return true; } isReady(): boolean { return this.#wallet !== undefined; } async getInfo(): Promise { if (!this.#wallet) { throw new WalletError(WalletErrorCode.GeneralError, "Wallet not initialized"); } return { nodePubKey: "asdd", alias: "Cashu mint: " + this.#mint, } as WalletInfo; } async login(): Promise { const m = new CashuMint(this.#mint); const keys = await m.getKeys(); this.#wallet = new TheCashuWallet(keys, m); return true; } close(): Promise { return Promise.resolve(true); } getBalance(): Promise { throw new Error("Method not implemented."); } createInvoice(): Promise { throw new Error("Method not implemented."); } payInvoice(): Promise { throw new Error("Method not implemented."); } getInvoices(): Promise { return Promise.resolve([]); } } export interface NutStashBackup { proofs: Array; mints: [ { mintURL: string; } ]; }