beignet 0.28.0 → 0.29.0
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 +40 -0
- package/dist/cli/beignet-node.js.map +1 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/lightning/gossip/graph-restore.js +162 -0
- package/dist/lightning/gossip/graph-restore.js.map +1 -0
- package/dist/lightning/gossip/index.js +1 -0
- package/dist/lightning/gossip/index.js.map +1 -1
- package/dist/lightning/keys/wallet-keys.js +26 -3
- package/dist/lightning/keys/wallet-keys.js.map +1 -1
- package/dist/lightning/node/lightning-node.js +317 -48
- package/dist/lightning/node/lightning-node.js.map +1 -1
- package/dist/lightning/node/types.js.map +1 -1
- package/dist/lightning/storage/sqlite-storage.js +38 -0
- package/dist/lightning/storage/sqlite-storage.js.map +1 -1
- package/dist/lightning/storage/types.js.map +1 -1
- package/dist/types/cli/beignet-node.d.ts +6 -1
- package/dist/types/cli/index.d.ts +1 -1
- package/dist/types/cli/types.d.ts +3 -0
- package/dist/types/lightning/gossip/graph-restore.d.ts +37 -0
- package/dist/types/lightning/gossip/index.d.ts +1 -0
- package/dist/types/lightning/keys/wallet-keys.d.ts +1 -0
- package/dist/types/lightning/node/lightning-node.d.ts +26 -1
- package/dist/types/lightning/node/types.d.ts +22 -0
- package/dist/types/lightning/storage/sqlite-storage.d.ts +3 -1
- package/dist/types/lightning/storage/types.d.ts +7 -0
- package/package.json +1 -1
package/dist/cli/beignet-node.js
CHANGED
|
@@ -1094,6 +1094,7 @@ class BeignetNode extends events_1.EventEmitter {
|
|
|
1094
1094
|
});
|
|
1095
1095
|
}
|
|
1096
1096
|
this._nodeStorageView = (0, node_storage_view_1.nodeStorageView)(this.storage);
|
|
1097
|
+
const constructStarted = Date.now();
|
|
1097
1098
|
this.node = lightning_node_1.LightningNode.fromMnemonic(this.mnemonic, {
|
|
1098
1099
|
coinType,
|
|
1099
1100
|
seed: this.walletSeed(),
|
|
@@ -1265,6 +1266,7 @@ class BeignetNode extends events_1.EventEmitter {
|
|
|
1265
1266
|
: {}
|
|
1266
1267
|
},
|
|
1267
1268
|
eagerGossipVerify: opts.eagerGossipVerify ?? false,
|
|
1269
|
+
cooperativeGraphRestore: opts.deferGraphRestore === true,
|
|
1268
1270
|
localFeatures: lightning_node_1.LightningNode.defaultFeatures(),
|
|
1269
1271
|
chainHashes: [chainHash],
|
|
1270
1272
|
alias: opts.alias,
|
|
@@ -1309,6 +1311,12 @@ class BeignetNode extends events_1.EventEmitter {
|
|
|
1309
1311
|
watchtowers: opts.watchtowers,
|
|
1310
1312
|
recovery: this.recoveryNodeConfig
|
|
1311
1313
|
});
|
|
1314
|
+
this._nodeConstructMs = Date.now() - constructStarted;
|
|
1315
|
+
this.node.on('graph:restored', () => {
|
|
1316
|
+
const stats = this.getGraphRestoreStats();
|
|
1317
|
+
if (stats)
|
|
1318
|
+
this.emit('graph:restored', stats);
|
|
1319
|
+
});
|
|
1312
1320
|
this.fforReceiveService = new ffor_receive_1.FforReceiveService(this, opts.fforSettle, opts.fforReceiveFunding, opts.fforSettleConcurrent !== false);
|
|
1313
1321
|
const receiveKey = 'automatic_receive_jobs_v1';
|
|
1314
1322
|
const receiveJobs = this.storage.loadWalletData(receiveKey);
|
|
@@ -4230,6 +4238,10 @@ class BeignetNode extends events_1.EventEmitter {
|
|
|
4230
4238
|
const downloadStart = Date.now();
|
|
4231
4239
|
const data = await (0, rapid_sync_1.fetchRapidGossipSnapshot)(url);
|
|
4232
4240
|
const downloadMs = Date.now() - downloadStart;
|
|
4241
|
+
if (this.destroyed)
|
|
4242
|
+
throw new rapid_sync_1.RapidGossipCancelledError();
|
|
4243
|
+
if (this.isGraphRestoring())
|
|
4244
|
+
await this.whenGraphRestored();
|
|
4233
4245
|
if (this.destroyed)
|
|
4234
4246
|
throw new rapid_sync_1.RapidGossipCancelledError();
|
|
4235
4247
|
let slices = 0;
|
|
@@ -4299,6 +4311,8 @@ class BeignetNode extends events_1.EventEmitter {
|
|
|
4299
4311
|
return this.openChannel(pubkey, amountSats, opts?.pushSats, opts?.satsPerVbyte, opts?.max, opts?.trusted ?? false);
|
|
4300
4312
|
}
|
|
4301
4313
|
async ensureMinimumChannels(count, satsPerChannel, _opts) {
|
|
4314
|
+
if (this.isGraphRestoring())
|
|
4315
|
+
await this.whenGraphRestored();
|
|
4302
4316
|
const existing = this.getReadyChannels();
|
|
4303
4317
|
if (existing.length >= count)
|
|
4304
4318
|
return existing;
|
|
@@ -6377,6 +6391,8 @@ class BeignetNode extends events_1.EventEmitter {
|
|
|
6377
6391
|
}
|
|
6378
6392
|
async payInvoiceAll(bolt11, debitMsat, maxFeeMsat, timeoutMs = 60000) {
|
|
6379
6393
|
this._checkDraining();
|
|
6394
|
+
if (this.isGraphRestoring())
|
|
6395
|
+
await this.whenGraphRestored();
|
|
6380
6396
|
const decoded = decodeInvoiceInput(bolt11);
|
|
6381
6397
|
const debit = requireMsatValue(debitMsat, 'debitMsat');
|
|
6382
6398
|
const feeCap = requireMsatValue(maxFeeMsat, 'maxFeeMsat');
|
|
@@ -6395,6 +6411,8 @@ class BeignetNode extends events_1.EventEmitter {
|
|
|
6395
6411
|
}
|
|
6396
6412
|
async payInvoice(bolt11, timeoutMs = 60000, maxFeeSats, amountSats, metadata, cltvLimit, maxFeeMsatCap) {
|
|
6397
6413
|
this._checkDraining();
|
|
6414
|
+
if (this.isGraphRestoring())
|
|
6415
|
+
await this.whenGraphRestored();
|
|
6398
6416
|
const decoded = decodeInvoiceInput(bolt11);
|
|
6399
6417
|
const paymentHashHex = decoded.paymentHash.toString('hex');
|
|
6400
6418
|
const amountMsat = amountSats !== undefined
|
|
@@ -6619,6 +6637,8 @@ class BeignetNode extends events_1.EventEmitter {
|
|
|
6619
6637
|
}
|
|
6620
6638
|
async sendKeysend(pubkey, amountSats, timeoutMs = 60000, maxFeeSats, metadata, onPaymentHash) {
|
|
6621
6639
|
this._checkDraining();
|
|
6640
|
+
if (this.isGraphRestoring())
|
|
6641
|
+
await this.whenGraphRestored();
|
|
6622
6642
|
const amountMsat = BigInt(requireNonNegativeSafeInteger(amountSats, 'amountSats')) * 1000n;
|
|
6623
6643
|
const maxFeeMsat = resolveMaxFeeMsat(maxFeeSats, undefined, amountMsat);
|
|
6624
6644
|
const preimage = crypto.randomBytes(32);
|
|
@@ -7206,6 +7226,8 @@ class BeignetNode extends events_1.EventEmitter {
|
|
|
7206
7226
|
.map(({ offer, encoded }) => this.toOfferInfo(offer, encoded));
|
|
7207
7227
|
}
|
|
7208
7228
|
async payOffer(offerStr, amountSats, timeoutMs = 60000, maxFeeSats, maxFeeMsatCap, onPaymentHash) {
|
|
7229
|
+
if (this.isGraphRestoring())
|
|
7230
|
+
await this.whenGraphRestored();
|
|
7209
7231
|
this._checkDraining();
|
|
7210
7232
|
const offer = decodeOfferInput(offerStr);
|
|
7211
7233
|
const callerMaxFeeMsat = explicitMaxFeeMsat(maxFeeSats, maxFeeMsatCap);
|
|
@@ -7629,6 +7651,8 @@ class BeignetNode extends events_1.EventEmitter {
|
|
|
7629
7651
|
return { ...this.getLiquiditySnapshot(), rebalancePlan: plan };
|
|
7630
7652
|
}
|
|
7631
7653
|
async rebalanceChannel(fromChannelId, toChannelId, amountSats, maxFeeSats) {
|
|
7654
|
+
if (this.isGraphRestoring())
|
|
7655
|
+
await this.whenGraphRestored();
|
|
7632
7656
|
if (!/^[0-9a-fA-F]{64}$/.test(fromChannelId))
|
|
7633
7657
|
throw new errors_1.BeignetError(errors_1.BeignetErrorCode.INVALID_PARAMS, 'fromChannelId must be 64 hex chars');
|
|
7634
7658
|
if (!/^[0-9a-fA-F]{64}$/.test(toChannelId))
|
|
@@ -7765,6 +7789,20 @@ class BeignetNode extends events_1.EventEmitter {
|
|
|
7765
7789
|
}))
|
|
7766
7790
|
};
|
|
7767
7791
|
}
|
|
7792
|
+
isGraphRestoring() {
|
|
7793
|
+
return this.node?.isGraphRestoring?.() ?? false;
|
|
7794
|
+
}
|
|
7795
|
+
whenGraphRestored() {
|
|
7796
|
+
return this.node?.whenGraphRestored?.() ?? Promise.resolve(true);
|
|
7797
|
+
}
|
|
7798
|
+
getGraphRestoreStats() {
|
|
7799
|
+
const stats = this.node?.getGraphRestoreStats() ?? null;
|
|
7800
|
+
if (!stats)
|
|
7801
|
+
return null;
|
|
7802
|
+
return this._nodeConstructMs === undefined
|
|
7803
|
+
? stats
|
|
7804
|
+
: { ...stats, constructMs: this._nodeConstructMs };
|
|
7805
|
+
}
|
|
7768
7806
|
getGraphInfo() {
|
|
7769
7807
|
const graph = this.node.getGraph();
|
|
7770
7808
|
const info = {
|
|
@@ -7774,6 +7812,8 @@ class BeignetNode extends events_1.EventEmitter {
|
|
|
7774
7812
|
if (this._lastGraphSyncAt !== undefined) {
|
|
7775
7813
|
info.lastSyncAt = this._lastGraphSyncAt;
|
|
7776
7814
|
}
|
|
7815
|
+
if (this.isGraphRestoring())
|
|
7816
|
+
info.restoring = true;
|
|
7777
7817
|
return info;
|
|
7778
7818
|
}
|
|
7779
7819
|
getGraphNode(pubkey) {
|