This commit is contained in:
2023-03-09 09:57:14 +00:00
parent 1923273f6f
commit ca1bb86036
5 changed files with 134 additions and 2 deletions

View File

@ -0,0 +1,46 @@
import { CashuMint, CashuWallet as TheCashuWallet, getEncodedProofs, Proof } from "@gandlaf21/cashu-ts";
import { InvoiceRequest, LNWallet, WalletInfo, WalletInvoice } from "Wallet";
export class CashuWallet implements LNWallet {
#mint: string;
#walletPath: string;
#wallet?: TheCashuWallet;
constructor(mint: string, path: string) {
this.#mint = mint;
this.#walletPath = path;
}
isReady(): boolean {
return this.#wallet !== undefined;
}
getInfo: () => Promise<WalletInfo>;
async login(_?: string | undefined): Promise<boolean> {
const m = new CashuMint(this.#mint, this.#walletPath);
const keys = await m.getKeys();
this.#wallet = new TheCashuWallet(keys, m);
return true;
}
close: () => Promise<boolean>;
getBalance: () => Promise<number>;
createInvoice: (req: InvoiceRequest) => Promise<WalletInvoice>;
payInvoice: (pr: string) => Promise<WalletInvoice>;
getInvoices: () => Promise<WalletInvoice[]>;
}
interface NutBank {
proofs: Array<Proof>;
}
export interface NutStashBackup {
proofs: Array<Proof>;
mints: [
{
mintURL: string;
}
];
}