@fiber-pay/runtime 0.1.0-rc.5 → 0.1.0-rc.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +70 -15
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1401,6 +1401,19 @@ async function* runPaymentJob(job, rpc, policy, signal) {
|
|
|
1401
1401
|
yield current;
|
|
1402
1402
|
continue;
|
|
1403
1403
|
}
|
|
1404
|
+
if (current.params.sendPaymentParams.dry_run) {
|
|
1405
|
+
current = transitionJobState(current, paymentStateMachine, "payment_success", {
|
|
1406
|
+
patch: {
|
|
1407
|
+
result: {
|
|
1408
|
+
paymentHash: sendResult.payment_hash,
|
|
1409
|
+
status: "DryRunSuccess",
|
|
1410
|
+
fee: sendResult.fee
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
});
|
|
1414
|
+
yield current;
|
|
1415
|
+
return;
|
|
1416
|
+
}
|
|
1404
1417
|
current = transitionJobState(current, paymentStateMachine, "payment_inflight");
|
|
1405
1418
|
if (paymentHash) {
|
|
1406
1419
|
current = {
|
|
@@ -2154,11 +2167,13 @@ var HealthMonitor = class extends BaseMonitor {
|
|
|
2154
2167
|
};
|
|
2155
2168
|
|
|
2156
2169
|
// src/monitors/tracker-utils.ts
|
|
2170
|
+
function isNotFoundError(error) {
|
|
2171
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2172
|
+
return /not found|does not exist|no such/i.test(message);
|
|
2173
|
+
}
|
|
2157
2174
|
function isExpectedTrackerError(error) {
|
|
2158
2175
|
const message = error instanceof Error ? error.message : String(error);
|
|
2159
|
-
return /
|
|
2160
|
-
message
|
|
2161
|
-
);
|
|
2176
|
+
return /temporarily unavailable|connection refused|timed out|timeout/i.test(message);
|
|
2162
2177
|
}
|
|
2163
2178
|
|
|
2164
2179
|
// src/monitors/invoice-tracker.ts
|
|
@@ -2230,6 +2245,21 @@ var InvoiceTracker = class extends BaseMonitor {
|
|
|
2230
2245
|
}
|
|
2231
2246
|
}
|
|
2232
2247
|
} catch (error) {
|
|
2248
|
+
if (isNotFoundError(error)) {
|
|
2249
|
+
this.store.updateTrackedInvoice(invoice.paymentHash, "Cancelled");
|
|
2250
|
+
await this.alerts.emit({
|
|
2251
|
+
type: "invoice_cancelled",
|
|
2252
|
+
priority: "medium",
|
|
2253
|
+
source: this.name,
|
|
2254
|
+
data: {
|
|
2255
|
+
paymentHash: invoice.paymentHash,
|
|
2256
|
+
previousStatus: invoice.status,
|
|
2257
|
+
currentStatus: "Cancelled",
|
|
2258
|
+
reason: "not_found"
|
|
2259
|
+
}
|
|
2260
|
+
});
|
|
2261
|
+
continue;
|
|
2262
|
+
}
|
|
2233
2263
|
if (isExpectedTrackerError(error)) {
|
|
2234
2264
|
continue;
|
|
2235
2265
|
}
|
|
@@ -2299,6 +2329,21 @@ var PaymentTracker = class extends BaseMonitor {
|
|
|
2299
2329
|
}
|
|
2300
2330
|
}
|
|
2301
2331
|
} catch (error) {
|
|
2332
|
+
if (isNotFoundError(error)) {
|
|
2333
|
+
this.store.updateTrackedPayment(payment.paymentHash, "Failed");
|
|
2334
|
+
await this.alerts.emit({
|
|
2335
|
+
type: "outgoing_payment_failed",
|
|
2336
|
+
priority: "high",
|
|
2337
|
+
source: this.name,
|
|
2338
|
+
data: {
|
|
2339
|
+
paymentHash: payment.paymentHash,
|
|
2340
|
+
previousStatus: payment.status,
|
|
2341
|
+
currentStatus: "Failed",
|
|
2342
|
+
reason: "not_found"
|
|
2343
|
+
}
|
|
2344
|
+
});
|
|
2345
|
+
continue;
|
|
2346
|
+
}
|
|
2302
2347
|
if (isExpectedTrackerError(error)) {
|
|
2303
2348
|
continue;
|
|
2304
2349
|
}
|
|
@@ -2537,7 +2582,8 @@ function collectJsonRpcMethods(requestBody) {
|
|
|
2537
2582
|
const methods = /* @__PURE__ */ new Map();
|
|
2538
2583
|
for (const item of normalizeJsonRpcRequest(requestBody)) {
|
|
2539
2584
|
if (item.id !== void 0 && typeof item.method === "string") {
|
|
2540
|
-
|
|
2585
|
+
const dryRun = isDryRunRequest(item);
|
|
2586
|
+
methods.set(item.id, { method: item.method, dryRun });
|
|
2541
2587
|
}
|
|
2542
2588
|
}
|
|
2543
2589
|
return methods;
|
|
@@ -2548,17 +2594,17 @@ function captureTrackedHashes(methodById, responseBody, handlers) {
|
|
|
2548
2594
|
if (message.error || message.id === void 0) {
|
|
2549
2595
|
continue;
|
|
2550
2596
|
}
|
|
2551
|
-
const
|
|
2552
|
-
if (!
|
|
2597
|
+
const meta = methodById.get(message.id);
|
|
2598
|
+
if (!meta) {
|
|
2553
2599
|
continue;
|
|
2554
2600
|
}
|
|
2555
|
-
if (method === "new_invoice") {
|
|
2601
|
+
if (meta.method === "new_invoice") {
|
|
2556
2602
|
const paymentHash = extractInvoicePaymentHash(message.result);
|
|
2557
2603
|
if (paymentHash) {
|
|
2558
2604
|
handlers.onInvoiceTracked(paymentHash);
|
|
2559
2605
|
}
|
|
2560
2606
|
}
|
|
2561
|
-
if (method === "send_payment") {
|
|
2607
|
+
if (meta.method === "send_payment" && !meta.dryRun) {
|
|
2562
2608
|
const paymentHash = extractPaymentHash(message.result);
|
|
2563
2609
|
if (paymentHash) {
|
|
2564
2610
|
handlers.onPaymentTracked(paymentHash);
|
|
@@ -2610,6 +2656,13 @@ function extractPaymentHash(result) {
|
|
|
2610
2656
|
}
|
|
2611
2657
|
return typeof result.payment_hash === "string" ? result.payment_hash : void 0;
|
|
2612
2658
|
}
|
|
2659
|
+
function isDryRunRequest(message) {
|
|
2660
|
+
if (!Array.isArray(message.params) || message.params.length === 0) {
|
|
2661
|
+
return false;
|
|
2662
|
+
}
|
|
2663
|
+
const firstParam = message.params[0];
|
|
2664
|
+
return isObject(firstParam) && firstParam.dry_run === true;
|
|
2665
|
+
}
|
|
2613
2666
|
|
|
2614
2667
|
// src/proxy/monitor-routes.ts
|
|
2615
2668
|
function handleMonitorEndpoint(req, res, deps) {
|
|
@@ -3374,6 +3427,8 @@ var FiberMonitorService = class extends EventEmitter2 {
|
|
|
3374
3427
|
this.alerts.onEmit((alert) => {
|
|
3375
3428
|
this.emit("alert", alert);
|
|
3376
3429
|
});
|
|
3430
|
+
const jobManager = this.jobManager;
|
|
3431
|
+
const jobStore = this.jobStore;
|
|
3377
3432
|
this.proxy = new RpcMonitorProxy(
|
|
3378
3433
|
{
|
|
3379
3434
|
listen: this.config.proxy.listen,
|
|
@@ -3390,13 +3445,13 @@ var FiberMonitorService = class extends EventEmitter2 {
|
|
|
3390
3445
|
listTrackedPayments: () => this.store.listTrackedPayments(),
|
|
3391
3446
|
listAlerts: (filters) => this.store.listAlerts(filters),
|
|
3392
3447
|
getStatus: () => this.getStatus(),
|
|
3393
|
-
createPaymentJob:
|
|
3394
|
-
createInvoiceJob:
|
|
3395
|
-
createChannelJob:
|
|
3396
|
-
getJob:
|
|
3397
|
-
listJobs:
|
|
3398
|
-
cancelJob:
|
|
3399
|
-
listJobEvents:
|
|
3448
|
+
createPaymentJob: jobManager ? (params, options) => jobManager.ensurePayment(params, options) : void 0,
|
|
3449
|
+
createInvoiceJob: jobManager ? (params, options) => jobManager.manageInvoice(params, options) : void 0,
|
|
3450
|
+
createChannelJob: jobManager ? (params, options) => jobManager.manageChannel(params, options) : void 0,
|
|
3451
|
+
getJob: jobManager ? (id) => jobManager.getJob(id) : void 0,
|
|
3452
|
+
listJobs: jobManager ? (filter) => jobManager.listJobs(filter) : void 0,
|
|
3453
|
+
cancelJob: jobManager ? (id) => jobManager.cancelJob(id) : void 0,
|
|
3454
|
+
listJobEvents: jobStore ? (jobId) => jobStore.listJobEvents(jobId) : void 0
|
|
3400
3455
|
}
|
|
3401
3456
|
);
|
|
3402
3457
|
}
|