mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-28 16:32:28 +00:00
Reset wallet client after NWC timeouts
This commit is contained in:
1 parent
af192952a7
commit
be6162f5cd
2 files changed
+43
-20
No files matched your search
+15
-1
@@ -54,7 +54,8 @@ import { getPlatformLightningAddress } from "./payments/platformAddress.js";
|
||||
import { devLogger, userLogger } from "./utils/logger.js";
|
||||
import {
|
||||
ensureWallet,
|
||||
sendPayment as sendWalletPayment
|
||||
sendPayment as sendWalletPayment,
|
||||
resetWalletClient
|
||||
} from "./payments/nwcClient.js";
|
||||
import {
|
||||
prepareStaticModal,
|
||||
@@ -2578,6 +2579,19 @@ function createZapDependencies({
|
||||
error
|
||||
});
|
||||
}
|
||||
if (
|
||||
typeof error?.message === "string" &&
|
||||
error.message.toLowerCase().includes("timed out")
|
||||
) {
|
||||
try {
|
||||
resetWalletClient();
|
||||
} catch (resetError) {
|
||||
devLogger?.warn?.(
|
||||
"[zap] Failed to reset wallet client after timeout",
|
||||
resetError
|
||||
);
|
||||
}
|
||||
}
|
||||
logZapError(
|
||||
"wallet.sendPayment",
|
||||
{
|
||||
|
||||
+28
-19
@@ -23,6 +23,7 @@ import { devLogger, userLogger } from "../utils/logger.js";
|
||||
import {
|
||||
ensureWallet as ensureWalletDefault,
|
||||
sendPayment as sendPaymentDefault,
|
||||
resetWalletClient as resetWalletClientDefault,
|
||||
} from "../payments/nwcClient.js";
|
||||
|
||||
const DEFAULT_SPLIT_SUMMARY = "Enter an amount to view the split.";
|
||||
@@ -474,6 +475,10 @@ export default class ZapController {
|
||||
typeof this.payments?.sendPayment === "function"
|
||||
? (bolt11, params) => this.payments.sendPayment(bolt11, params)
|
||||
: (bolt11, params) => sendPaymentDefault(bolt11, params);
|
||||
const resetWalletClientFn =
|
||||
typeof this.payments?.resetWalletClient === "function"
|
||||
? () => this.payments.resetWalletClient()
|
||||
: () => resetWalletClientDefault();
|
||||
|
||||
let activeShare = null;
|
||||
|
||||
@@ -543,18 +548,18 @@ export default class ZapController {
|
||||
}
|
||||
},
|
||||
sendPayment: async (bolt11, params) => {
|
||||
const shareType = activeShare || "unknown";
|
||||
const amount =
|
||||
shareType === "platform"
|
||||
? shares.platformShare
|
||||
: shares.creatorShare;
|
||||
const address =
|
||||
shareType === "platform"
|
||||
? platformEntry?.address || getCachedPlatformLightningAddress()
|
||||
: creatorEntry?.address || lightningAddress;
|
||||
try {
|
||||
const payment = await sendPaymentFn(bolt11, params);
|
||||
if (Array.isArray(shareTracker)) {
|
||||
const shareType = activeShare || "unknown";
|
||||
const amount =
|
||||
shareType === "platform"
|
||||
? shares.platformShare
|
||||
: shares.creatorShare;
|
||||
const address =
|
||||
shareType === "platform"
|
||||
? platformEntry?.address || getCachedPlatformLightningAddress()
|
||||
: creatorEntry?.address || lightningAddress;
|
||||
shareTracker.push({
|
||||
type: shareType,
|
||||
status: "success",
|
||||
@@ -566,15 +571,6 @@ export default class ZapController {
|
||||
return payment;
|
||||
} catch (error) {
|
||||
if (Array.isArray(shareTracker)) {
|
||||
const shareType = activeShare || "unknown";
|
||||
const amount =
|
||||
shareType === "platform"
|
||||
? shares.platformShare
|
||||
: shares.creatorShare;
|
||||
const address =
|
||||
shareType === "platform"
|
||||
? platformEntry?.address || getCachedPlatformLightningAddress()
|
||||
: creatorEntry?.address || lightningAddress;
|
||||
shareTracker.push({
|
||||
type: shareType,
|
||||
status: "error",
|
||||
@@ -583,10 +579,23 @@ export default class ZapController {
|
||||
error,
|
||||
});
|
||||
}
|
||||
if (
|
||||
typeof error?.message === "string" &&
|
||||
error.message.toLowerCase().includes("timed out")
|
||||
) {
|
||||
try {
|
||||
resetWalletClientFn();
|
||||
} catch (resetError) {
|
||||
devLogger.warn(
|
||||
"[zap] Failed to reset wallet client after timeout",
|
||||
resetError
|
||||
);
|
||||
}
|
||||
}
|
||||
logZapError(
|
||||
"wallet.sendPayment",
|
||||
{
|
||||
shareType: activeShare || "unknown",
|
||||
shareType,
|
||||
amount,
|
||||
address,
|
||||
tracker: shareTracker,
|
||||
|
||||
Reference in new issue
Block a user