beignet 0.30.0 → 0.30.2
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/cli/beignet-node.js +80 -32
- package/dist/cli/beignet-node.js.map +1 -1
- package/dist/cli/cli.js +20 -5
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/config.js +1 -0
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/daemon-options.js +1 -0
- package/dist/cli/daemon-options.js.map +1 -1
- package/dist/cli/daemon.js +56 -8
- package/dist/cli/daemon.js.map +1 -1
- package/dist/cli/direct-funding.js +0 -2
- package/dist/cli/direct-funding.js.map +1 -1
- package/dist/cli/onchain-sweep.js +4 -2
- package/dist/cli/onchain-sweep.js.map +1 -1
- package/dist/cli/openapi.js +10 -3
- package/dist/cli/openapi.js.map +1 -1
- package/dist/cli/restore.js +47 -1
- package/dist/cli/restore.js.map +1 -1
- package/dist/lightning/channel/channel-manager.js +87 -10
- package/dist/lightning/channel/channel-manager.js.map +1 -1
- package/dist/lightning/channel/channel-state.js.map +1 -1
- package/dist/lightning/channel/channel.js +23 -3
- package/dist/lightning/channel/channel.js.map +1 -1
- package/dist/lightning/channel/dual-funding.js +5 -10
- package/dist/lightning/channel/dual-funding.js.map +1 -1
- package/dist/lightning/channel/splice.js +2 -2
- package/dist/lightning/channel/splice.js.map +1 -1
- package/dist/lightning/channel/validation.js +2 -1
- package/dist/lightning/channel/validation.js.map +1 -1
- package/dist/lightning/direct-funding/sender/engine.js +8 -4
- package/dist/lightning/direct-funding/sender/engine.js.map +1 -1
- package/dist/lightning/gossip/gossip-sync.js +14 -2
- package/dist/lightning/gossip/gossip-sync.js.map +1 -1
- package/dist/lightning/gossip/rapid-sync.js +13 -3
- package/dist/lightning/gossip/rapid-sync.js.map +1 -1
- package/dist/lightning/interactive-tx/builder.js +19 -2
- package/dist/lightning/interactive-tx/builder.js.map +1 -1
- package/dist/lightning/interactive-tx/validation.js +2 -1
- package/dist/lightning/interactive-tx/validation.js.map +1 -1
- package/dist/lightning/node/lightning-node.js +264 -49
- package/dist/lightning/node/lightning-node.js.map +1 -1
- package/dist/lightning/node/types.js.map +1 -1
- package/dist/lightning/recovery/guardian-store.js +17 -1
- package/dist/lightning/recovery/guardian-store.js.map +1 -1
- package/dist/lightning/recovery/guardian.js +37 -1
- package/dist/lightning/recovery/guardian.js.map +1 -1
- package/dist/lightning/recovery/restore-driver.js +82 -26
- package/dist/lightning/recovery/restore-driver.js.map +1 -1
- package/dist/lightning/storage/durable-ledger.js +62 -12
- package/dist/lightning/storage/durable-ledger.js.map +1 -1
- package/dist/lightning/storage/serialization.js +4 -0
- package/dist/lightning/storage/serialization.js.map +1 -1
- package/dist/lightning/storage/sqlite-storage.js +189 -6
- package/dist/lightning/storage/sqlite-storage.js.map +1 -1
- package/dist/lightning/storage/types.js.map +1 -1
- package/dist/lightning/swaps/chain-resolver.js +49 -11
- package/dist/lightning/swaps/chain-resolver.js.map +1 -1
- package/dist/lightning/swaps/ledger.js +152 -10
- package/dist/lightning/swaps/ledger.js.map +1 -1
- package/dist/lightning/swaps/reverse-engine.js +110 -22
- package/dist/lightning/swaps/reverse-engine.js.map +1 -1
- package/dist/lightning/swaps/submarine-engine.js +42 -5
- package/dist/lightning/swaps/submarine-engine.js.map +1 -1
- package/dist/lightning/transport/peer.js +59 -8
- package/dist/lightning/transport/peer.js.map +1 -1
- package/dist/transaction/index.js +451 -107
- package/dist/transaction/index.js.map +1 -1
- package/dist/types/cli/beignet-node.d.ts +0 -1
- package/dist/types/cli/daemon.d.ts +5 -0
- package/dist/types/cli/restore.d.ts +8 -0
- package/dist/types/cli/types.d.ts +1 -0
- package/dist/types/lightning/channel/channel-manager.d.ts +7 -0
- package/dist/types/lightning/channel/channel-state.d.ts +1 -0
- package/dist/types/lightning/channel/channel.d.ts +3 -1
- package/dist/types/lightning/channel/dual-funding.d.ts +1 -1
- package/dist/types/lightning/channel/splice.d.ts +1 -1
- package/dist/types/lightning/channel/validation.d.ts +1 -0
- package/dist/types/lightning/gossip/gossip-sync.d.ts +1 -0
- package/dist/types/lightning/gossip/rapid-sync.d.ts +2 -1
- package/dist/types/lightning/interactive-tx/builder.d.ts +3 -1
- package/dist/types/lightning/interactive-tx/validation.d.ts +1 -0
- package/dist/types/lightning/node/lightning-node.d.ts +19 -1
- package/dist/types/lightning/node/types.d.ts +2 -0
- package/dist/types/lightning/recovery/guardian-store.d.ts +2 -0
- package/dist/types/lightning/recovery/guardian.d.ts +1 -0
- package/dist/types/lightning/recovery/restore-driver.d.ts +3 -0
- package/dist/types/lightning/storage/durable-ledger.d.ts +13 -1
- package/dist/types/lightning/storage/serialization.d.ts +1 -0
- package/dist/types/lightning/storage/sqlite-storage.d.ts +26 -1
- package/dist/types/lightning/storage/types.d.ts +5 -0
- package/dist/types/lightning/swaps/chain-resolver.d.ts +3 -0
- package/dist/types/lightning/swaps/ledger.d.ts +13 -0
- package/dist/types/lightning/swaps/reverse-engine.d.ts +10 -1
- package/dist/types/lightning/swaps/submarine-engine.d.ts +6 -0
- package/dist/types/lightning/transport/peer.d.ts +5 -0
- package/dist/types/transaction/index.d.ts +12 -5
- package/dist/types/transaction.js.map +1 -1
- package/dist/types/types/transaction.d.ts +1 -0
- package/dist/types/wallet/constants.d.ts +1 -7
- package/dist/types/wallet/index.d.ts +9 -3
- package/dist/utils/transaction.js +9 -3
- package/dist/utils/transaction.js.map +1 -1
- package/dist/utils/wallet.js +3 -3
- package/dist/utils/wallet.js.map +1 -1
- package/dist/wallet/constants.js +3 -10
- package/dist/wallet/constants.js.map +1 -1
- package/dist/wallet/index.js +122 -48
- package/dist/wallet/index.js.map +1 -1
- package/docs/RECOVERY-GUARDIAN-WIRE.md +5 -1
- package/package.json +1 -1
package/dist/cli/beignet-node.js
CHANGED
|
@@ -45,6 +45,7 @@ const wallet_3 = require("../types/wallet");
|
|
|
45
45
|
const wallet_storage_1 = require("./wallet-storage");
|
|
46
46
|
const onchain_sweep_1 = require("./onchain-sweep");
|
|
47
47
|
const fs_utils_1 = require("./fs-utils");
|
|
48
|
+
const restore_1 = require("./restore");
|
|
48
49
|
const backup_mac_1 = require("./backup-mac");
|
|
49
50
|
const node_storage_view_1 = require("./node-storage-view");
|
|
50
51
|
const electrum_1 = require("../types/electrum");
|
|
@@ -928,6 +929,12 @@ class BeignetNode extends events_1.EventEmitter {
|
|
|
928
929
|
}, encryptionKey ? { encryptionKey } : undefined);
|
|
929
930
|
this.storage.open();
|
|
930
931
|
this._bootOpts = opts;
|
|
932
|
+
const dbRestore = (0, restore_1.holdDbRestoredChannels)(dbPath, this.storage);
|
|
933
|
+
if (dbRestore) {
|
|
934
|
+
this.log('warn', 'Database was restored from a backup that cannot be proven ' +
|
|
935
|
+
'current, so its channels are held: no automatic force close and ' +
|
|
936
|
+
'no new HTLCs. Closing one from this node needs acceptStaleStateRisk', { ...dbRestore });
|
|
937
|
+
}
|
|
931
938
|
await this.prepareRecovery(opts);
|
|
932
939
|
if (this._recoveryAutoApply && this.recoveryMode !== 'peer-storage') {
|
|
933
940
|
throw new errors_1.BeignetError('INVALID_PARAMS', 'recoveryAutoApply applies to peer-storage mode only');
|
|
@@ -6726,34 +6733,82 @@ class BeignetNode extends events_1.EventEmitter {
|
|
|
6726
6733
|
}
|
|
6727
6734
|
}
|
|
6728
6735
|
listPayments(filter) {
|
|
6729
|
-
|
|
6730
|
-
|
|
6731
|
-
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
|
|
6735
|
-
|
|
6736
|
-
|
|
6736
|
+
const since = filter?.since;
|
|
6737
|
+
const status = filter?.status || undefined;
|
|
6738
|
+
const direction = filter?.direction || undefined;
|
|
6739
|
+
const metadata = filter?.metadataKey !== undefined
|
|
6740
|
+
? { key: filter.metadataKey, value: filter.metadataValue }
|
|
6741
|
+
: undefined;
|
|
6742
|
+
const matches = (p) => {
|
|
6743
|
+
if (since !== undefined && p.createdAt < since)
|
|
6744
|
+
return false;
|
|
6745
|
+
if (status && p.status !== status)
|
|
6746
|
+
return false;
|
|
6747
|
+
if (direction && p.direction !== direction)
|
|
6748
|
+
return false;
|
|
6749
|
+
if (!metadata)
|
|
6750
|
+
return true;
|
|
6751
|
+
if (!p.metadata ||
|
|
6752
|
+
!Object.prototype.hasOwnProperty.call(p.metadata, metadata.key)) {
|
|
6753
|
+
return false;
|
|
6737
6754
|
}
|
|
6738
|
-
|
|
6739
|
-
|
|
6755
|
+
return (metadata.value === undefined ||
|
|
6756
|
+
p.metadata[metadata.key] === metadata.value);
|
|
6757
|
+
};
|
|
6758
|
+
const live = new Map();
|
|
6759
|
+
for (const p of this.node.listPayments()) {
|
|
6760
|
+
live.set(p.paymentHash.toString('hex'), p);
|
|
6761
|
+
}
|
|
6762
|
+
const newer = (a, b) => a.createdAt > b.createdAt ||
|
|
6763
|
+
(a.createdAt === b.createdAt && a.paymentHash > b.paymentHash);
|
|
6764
|
+
const liveNewestFirst = [...live]
|
|
6765
|
+
.filter(([, p]) => matches(p))
|
|
6766
|
+
.map(([paymentHash, p]) => ({
|
|
6767
|
+
paymentHash,
|
|
6768
|
+
createdAt: p.createdAt,
|
|
6769
|
+
load: () => p
|
|
6770
|
+
}))
|
|
6771
|
+
.sort((a, b) => (newer(a, b) ? -1 : newer(b, a) ? 1 : 0));
|
|
6772
|
+
const rows = this.storage.paymentsNewestFirst(since, {
|
|
6773
|
+
status,
|
|
6774
|
+
direction,
|
|
6775
|
+
metadata
|
|
6776
|
+
});
|
|
6777
|
+
const nextRow = () => {
|
|
6778
|
+
for (let r = rows.next(); !r.done; r = rows.next()) {
|
|
6779
|
+
if (!live.has(r.value.paymentHash))
|
|
6780
|
+
return r.value;
|
|
6740
6781
|
}
|
|
6741
|
-
|
|
6742
|
-
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
|
|
6746
|
-
|
|
6747
|
-
|
|
6782
|
+
return undefined;
|
|
6783
|
+
};
|
|
6784
|
+
const offset = filter?.offset !== undefined && filter.offset > 0 ? filter.offset : 0;
|
|
6785
|
+
const limit = filter?.limit !== undefined && filter.limit > 0 ? filter.limit : Infinity;
|
|
6786
|
+
const page = [];
|
|
6787
|
+
let skipped = 0;
|
|
6788
|
+
let i = 0;
|
|
6789
|
+
let row = nextRow();
|
|
6790
|
+
while (page.length < limit) {
|
|
6791
|
+
let next;
|
|
6792
|
+
if (i < liveNewestFirst.length &&
|
|
6793
|
+
(!row || newer(liveNewestFirst[i], row))) {
|
|
6794
|
+
next = liveNewestFirst[i++];
|
|
6795
|
+
}
|
|
6796
|
+
else if (row) {
|
|
6797
|
+
next = row;
|
|
6798
|
+
row = nextRow();
|
|
6748
6799
|
}
|
|
6749
|
-
|
|
6750
|
-
|
|
6800
|
+
else {
|
|
6801
|
+
break;
|
|
6751
6802
|
}
|
|
6752
|
-
if (
|
|
6753
|
-
|
|
6803
|
+
if (skipped < offset) {
|
|
6804
|
+
skipped++;
|
|
6805
|
+
continue;
|
|
6754
6806
|
}
|
|
6807
|
+
const record = next.load();
|
|
6808
|
+
if (record)
|
|
6809
|
+
page.push(this.toPaymentInfo(record));
|
|
6755
6810
|
}
|
|
6756
|
-
return
|
|
6811
|
+
return page;
|
|
6757
6812
|
}
|
|
6758
6813
|
getPayment(paymentHash) {
|
|
6759
6814
|
const live = this.livePayment(paymentHash);
|
|
@@ -6769,16 +6824,6 @@ class BeignetNode extends events_1.EventEmitter {
|
|
|
6769
6824
|
const p = this.node.getPayment(Buffer.from(paymentHash, 'hex'));
|
|
6770
6825
|
return p ? this.toPaymentInfo(p) : null;
|
|
6771
6826
|
}
|
|
6772
|
-
paymentRecords() {
|
|
6773
|
-
const byHash = new Map();
|
|
6774
|
-
for (const { paymentHash, payment } of this.storage.loadAllPayments()) {
|
|
6775
|
-
byHash.set(paymentHash, payment);
|
|
6776
|
-
}
|
|
6777
|
-
for (const p of this.node.listPayments()) {
|
|
6778
|
-
byHash.set(p.paymentHash.toString('hex'), p);
|
|
6779
|
-
}
|
|
6780
|
-
return [...byHash.values()];
|
|
6781
|
-
}
|
|
6782
6827
|
durablePaymentFor(err, hashHex) {
|
|
6783
6828
|
if (!(err instanceof errors_1.BeignetError) ||
|
|
6784
6829
|
err.code !== errors_1.BeignetErrorCode.DUPLICATE_PAYMENT) {
|
|
@@ -7709,6 +7754,9 @@ class BeignetNode extends events_1.EventEmitter {
|
|
|
7709
7754
|
throw new errors_1.BeignetError(errors_1.BeignetErrorCode.INVALID_PARAMS, 'budgetSatsPerDay must be a non-negative integer');
|
|
7710
7755
|
}
|
|
7711
7756
|
this._checkDraining();
|
|
7757
|
+
if (this.destroyed) {
|
|
7758
|
+
throw new errors_1.BeignetError(errors_1.BeignetErrorCode.NODE_DESTROYED, 'Node is shutting down; no new rebalances accepted');
|
|
7759
|
+
}
|
|
7712
7760
|
const holdSats = this.node.rebalanceBudgetSatsPerDay(budgetSatsPerDay);
|
|
7713
7761
|
if (!Number.isInteger(holdSats) || holdSats < 0) {
|
|
7714
7762
|
throw new errors_1.BeignetError(errors_1.BeignetErrorCode.INVALID_PARAMS, 'autoRebalance.budgetSatsPerDay must be a non-negative integer');
|