@openreceive/node 0.4.2 → 0.4.3
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.
|
@@ -2282,6 +2282,16 @@ function createNwcEndpointLogger(options) {
|
|
|
2282
2282
|
if (options.onEvent === void 0 && options.logger === void 0) return void 0;
|
|
2283
2283
|
return (entry) => emitEvent(options, entry);
|
|
2284
2284
|
}
|
|
2285
|
+
function summarizeReconcilePass(input) {
|
|
2286
|
+
const decided = [
|
|
2287
|
+
[input.settledCount, "settled"],
|
|
2288
|
+
[input.pendingCount, "pending"],
|
|
2289
|
+
[input.notFoundCount, "not found"]
|
|
2290
|
+
].filter(([count]) => count > 0).map(([count, label]) => `${count} ${label}`);
|
|
2291
|
+
const summary = decided.length === 0 ? "0 decided" : decided.join(", ");
|
|
2292
|
+
const attempts = `${input.attemptCount} ${input.attemptCount === 1 ? "attempt" : "attempts"}`;
|
|
2293
|
+
return input.resultCount === input.attemptCount ? summary : `${summary} of ${attempts}`;
|
|
2294
|
+
}
|
|
2285
2295
|
function sanitizeEvent(entry) {
|
|
2286
2296
|
const clean = {};
|
|
2287
2297
|
for (const [key, value] of Object.entries(entry)) {
|
|
@@ -2418,6 +2428,7 @@ export {
|
|
|
2418
2428
|
createLscSwapProvidersFromEnvironment,
|
|
2419
2429
|
emitLog,
|
|
2420
2430
|
createNwcEndpointLogger,
|
|
2431
|
+
summarizeReconcilePass,
|
|
2421
2432
|
sanitizeEvent,
|
|
2422
2433
|
redactSecrets,
|
|
2423
2434
|
summarizeSwapProviderApiRequest,
|
package/dist/cli.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -14,9 +14,10 @@ import {
|
|
|
14
14
|
isSwapPayInAsset,
|
|
15
15
|
listSwapAssetInfo,
|
|
16
16
|
sanitizeEvent,
|
|
17
|
+
summarizeReconcilePass,
|
|
17
18
|
summarizeSwapProviderApiRequest,
|
|
18
19
|
summarizeSwapProviderApiResponse
|
|
19
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-LWN4JJ24.js";
|
|
20
21
|
|
|
21
22
|
// src/index.ts
|
|
22
23
|
import { OpenReceiveError as OpenReceiveError2 } from "@openreceive/core";
|
|
@@ -54,6 +55,7 @@ import path from "path";
|
|
|
54
55
|
import { compact as compact2 } from "@openreceive/core";
|
|
55
56
|
|
|
56
57
|
// src/console-logger.ts
|
|
58
|
+
import { inspect } from "util";
|
|
57
59
|
import { compact } from "@openreceive/core";
|
|
58
60
|
|
|
59
61
|
// src/log-level.ts
|
|
@@ -104,9 +106,9 @@ function createConsoleLogger(options = {}) {
|
|
|
104
106
|
level,
|
|
105
107
|
prefix,
|
|
106
108
|
event,
|
|
107
|
-
message
|
|
108
|
-
|
|
109
|
-
|
|
109
|
+
message,
|
|
110
|
+
fields: compact(fields)
|
|
111
|
+
})
|
|
110
112
|
);
|
|
111
113
|
};
|
|
112
114
|
}
|
|
@@ -125,14 +127,26 @@ function createAppConsoleLogger(options) {
|
|
|
125
127
|
level,
|
|
126
128
|
prefix: options.prefix,
|
|
127
129
|
event,
|
|
128
|
-
message
|
|
129
|
-
|
|
130
|
-
|
|
130
|
+
message,
|
|
131
|
+
fields: compact(fields)
|
|
132
|
+
})
|
|
131
133
|
);
|
|
132
134
|
};
|
|
133
135
|
}
|
|
134
136
|
function formatConsoleLogLine(input) {
|
|
135
|
-
|
|
137
|
+
const head = `[${input.at}] ${input.level.toUpperCase()} [${input.prefix}] ${input.event}: ${input.message}`;
|
|
138
|
+
const fields = Object.entries(input.fields).map(
|
|
139
|
+
([key, value]) => `${key}=${formatFieldValue(value)}`
|
|
140
|
+
);
|
|
141
|
+
return fields.length === 0 ? head : `${head} ${fields.join(" ")}`;
|
|
142
|
+
}
|
|
143
|
+
function formatFieldValue(value) {
|
|
144
|
+
if (typeof value === "string")
|
|
145
|
+
return /^[\w.\-:/@+]*$/.test(value) ? value : JSON.stringify(value);
|
|
146
|
+
if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
|
|
147
|
+
return String(value);
|
|
148
|
+
}
|
|
149
|
+
return inspect(value, { breakLength: Number.POSITIVE_INFINITY, compact: true, depth: 4 });
|
|
136
150
|
}
|
|
137
151
|
|
|
138
152
|
// src/service/file-logger.ts
|
|
@@ -1379,24 +1393,35 @@ async function createOpenReceive(supplied = {}) {
|
|
|
1379
1393
|
maxPages: input.maxPages,
|
|
1380
1394
|
onWalk: (walk) => walks.push(walk)
|
|
1381
1395
|
});
|
|
1396
|
+
const settledCount = results.filter((result) => result.status === "settled").length;
|
|
1397
|
+
const pendingCount = results.filter((result) => result.status === "pending").length;
|
|
1398
|
+
const notFoundCount = results.filter((result) => result.status === "not_found").length;
|
|
1382
1399
|
emitLog(
|
|
1383
1400
|
nodeOptions,
|
|
1384
1401
|
"info",
|
|
1385
1402
|
"payment.reconcile.completed",
|
|
1386
|
-
|
|
1403
|
+
summarizeReconcilePass({
|
|
1404
|
+
attemptCount: input.attempts.length,
|
|
1405
|
+
resultCount: results.length,
|
|
1406
|
+
settledCount,
|
|
1407
|
+
pendingCount,
|
|
1408
|
+
notFoundCount
|
|
1409
|
+
}),
|
|
1387
1410
|
{
|
|
1411
|
+
attempt_count: input.attempts.length,
|
|
1412
|
+
settled_count: settledCount,
|
|
1413
|
+
pending_count: pendingCount,
|
|
1414
|
+
// Zero-valued extras stay off the line; the message already says
|
|
1415
|
+
// what was decided.
|
|
1416
|
+
...notFoundCount === 0 ? {} : { not_found_count: notFoundCount },
|
|
1388
1417
|
// Attempts scanned vs hashes decided: results collapse duplicate
|
|
1389
1418
|
// hashes and omit any the wallet walk could not reach, so a gap
|
|
1390
1419
|
// between these two is how a truncated scan shows up in the log.
|
|
1391
|
-
|
|
1392
|
-
result_count: results.length,
|
|
1393
|
-
settled_count: results.filter((result) => result.status === "settled").length,
|
|
1394
|
-
pending_count: results.filter((result) => result.status === "pending").length,
|
|
1395
|
-
not_found_count: results.filter((result) => result.status === "not_found").length,
|
|
1420
|
+
...results.length === input.attempts.length ? {} : { result_count: results.length },
|
|
1396
1421
|
// All pending attempts share these walks: one creation-time window,
|
|
1397
1422
|
// never one wallet call per invoice.
|
|
1398
|
-
|
|
1399
|
-
...walks[0] === void 0 ? {} : {
|
|
1423
|
+
walks: walks.length,
|
|
1424
|
+
...walks[0] === void 0 ? {} : { window: `${walks[0].from}..${walks[0].until}` }
|
|
1400
1425
|
}
|
|
1401
1426
|
);
|
|
1402
1427
|
return results;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openreceive/node",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "The OpenReceive Node service: receive-only NWC wallet client, checkout and swap service, pricing, and the openreceive CLI.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bitcoin",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"types": "./dist/index.d.ts",
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@getalby/sdk": "^8.0.3",
|
|
20
|
-
"@openreceive/core": "0.4.
|
|
20
|
+
"@openreceive/core": "0.4.3"
|
|
21
21
|
},
|
|
22
22
|
"bin": {
|
|
23
23
|
"openreceive": "./bin/openreceive.mjs"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# OpenReceive agent directions (Node.js)
|
|
2
2
|
|
|
3
|
-
These directions describe OpenReceive 0.4.
|
|
3
|
+
These directions describe OpenReceive 0.4.3.
|
|
4
4
|
|
|
5
5
|
Add OpenReceive to a Node application — the app you are already working in. You
|
|
6
6
|
do not need a copy of the OpenReceive source: the packages are on npm, and the
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# OpenReceive agent directions (Rails)
|
|
2
2
|
|
|
3
|
-
These directions describe OpenReceive 0.4.
|
|
3
|
+
These directions describe OpenReceive 0.4.3.
|
|
4
4
|
|
|
5
5
|
Add OpenReceive to a Rails application — the app you are already working in. You
|
|
6
6
|
do not need a copy of the OpenReceive source: the gem is on RubyGems, the
|