feat: LNC wallet

This commit is contained in:
2023-02-24 10:25:14 +00:00
parent 1b363ec15f
commit cff605b188
8 changed files with 125 additions and 46 deletions

View File

@ -1,5 +1,4 @@
import { EventPublisher } from "Feed/EventPublisher";
import EventKind from "Nostr/EventKind";
import {
InvoiceRequest,
LNWallet,
@ -48,6 +47,10 @@ export default class LNDHubWallet implements LNWallet {
}
}
close(): Promise<boolean | WalletError> {
throw new Error("Not implemented");
}
async createAccount() {
return Promise.resolve(UnknownWalletError);
}
@ -136,7 +139,7 @@ export default class LNDHubWallet implements LNWallet {
private async getJson<T>(method: "GET" | "POST", path: string, body?: any): Promise<T | WalletError> {
let auth = `Bearer ${this.auth?.access_token}`;
if (this.type === "snort") {
const ev = await this.publisher?.generic(`${new URL(this.url).pathname}${path}`, EventKind.Ephemeral);
const ev = await this.publisher?.generic(`${new URL(this.url).pathname}${path}`, 30_000);
auth = JSON.stringify(ev?.ToObject());
}
const rsp = await fetch(`${this.url}${path}`, {