Use debug logger package

Fix profile loading loop for expired profile same result
This commit is contained in:
2023-05-25 00:03:54 +01:00
parent 7b151e1b17
commit 2ccee7bd7c
13 changed files with 89 additions and 70 deletions

View File

@ -11,6 +11,7 @@ import {
WalletInvoice,
WalletInvoiceState,
} from "Wallet";
import debug from "debug";
enum Payment_PaymentStatus {
UNKNOWN = "UNKNOWN",
@ -22,6 +23,7 @@ enum Payment_PaymentStatus {
export class LNCWallet implements LNWallet {
#lnc: LNC;
readonly #log = debug("LNC");
private constructor(pairingPhrase?: string, password?: string) {
this.#lnc = new LNC({
@ -90,7 +92,7 @@ export class LNCWallet implements LNWallet {
async getBalance(): Promise<number> {
const rsp = await this.#lnc.lnd.lightning.channelBalance();
console.debug(rsp);
this.#log(rsp);
return parseInt(rsp.localBalance?.sat ?? "0");
}
@ -112,7 +114,7 @@ export class LNCWallet implements LNWallet {
feeLimitSat: "100",
},
msg => {
console.debug(msg);
this.#log(msg);
if (msg.status === Payment_PaymentStatus.SUCCEEDED) {
resolve({
preimage: msg.paymentPreimage,
@ -122,7 +124,7 @@ export class LNCWallet implements LNWallet {
}
},
err => {
console.debug(err);
this.#log(err);
reject(err);
}
);
@ -135,7 +137,7 @@ export class LNCWallet implements LNWallet {
reversed: true,
});
console.debug(invoices);
this.#log(invoices);
return invoices.payments.map(a => {
const parsedInvoice = prToWalletInvoice(a.paymentRequest);
if (!parsedInvoice) {

View File

@ -26,7 +26,6 @@ export default class LNDHubWallet implements LNWallet {
if (url.startsWith("lndhub://")) {
const regex = /^lndhub:\/\/([\S-]+):([\S-]+)@(.*)$/i;
const parsedUrl = url.match(regex);
console.debug(parsedUrl);
if (!parsedUrl || parsedUrl.length !== 4) {
throw new Error("Invalid LNDHUB config");
}

View File

@ -2,6 +2,7 @@ import { Connection, EventKind, RawEvent } from "@snort/nostr";
import { EventBuilder } from "System";
import { EventExt } from "System/EventExt";
import { LNWallet, WalletError, WalletErrorCode, WalletInfo, WalletInvoice, WalletInvoiceState } from "Wallet";
import debug from "debug";
interface WalletConnectConfig {
relayUrl: string;
@ -184,7 +185,7 @@ export class NostrConnectWallet implements LNWallet {
this.#commandQueue.set(evCommand.id, {
resolve: async (o: string) => {
const reply = JSON.parse(await EventExt.decryptData(o, this.#config.secret, this.#config.walletPubkey));
console.debug("NWC", reply);
debug("NWC")("%o", reply);
resolve(reply);
},
reject,