beignet 0.23.0 → 0.23.1

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.
Files changed (30) hide show
  1. package/dist/cli/beignet-node.js +219 -145
  2. package/dist/cli/beignet-node.js.map +1 -1
  3. package/dist/cli/daemon.js.map +1 -1
  4. package/dist/cli/openapi.js +19 -3
  5. package/dist/cli/openapi.js.map +1 -1
  6. package/dist/lightning/chain/chain-monitor.js +12 -8
  7. package/dist/lightning/chain/chain-monitor.js.map +1 -1
  8. package/dist/lightning/chain/chain-watcher.js +4 -3
  9. package/dist/lightning/chain/chain-watcher.js.map +1 -1
  10. package/dist/lightning/channel/channel-state.js.map +1 -1
  11. package/dist/lightning/channel/channel.js +8 -0
  12. package/dist/lightning/channel/channel.js.map +1 -1
  13. package/dist/lightning/gossip/pathfinding.js +23 -8
  14. package/dist/lightning/gossip/pathfinding.js.map +1 -1
  15. package/dist/lightning/node/lightning-node.js +270 -40
  16. package/dist/lightning/node/lightning-node.js.map +1 -1
  17. package/dist/lightning/node/types.js.map +1 -1
  18. package/dist/lightning/storage/serialization.js +2 -0
  19. package/dist/lightning/storage/serialization.js.map +1 -1
  20. package/dist/types/cli/beignet-node.d.ts +11 -0
  21. package/dist/types/cli/types.d.ts +4 -0
  22. package/dist/types/lightning/chain/chain-monitor.d.ts +1 -0
  23. package/dist/types/lightning/channel/channel-state.d.ts +1 -0
  24. package/dist/types/lightning/gossip/pathfinding.d.ts +7 -4
  25. package/dist/types/lightning/node/lightning-node.d.ts +9 -2
  26. package/dist/types/lightning/node/types.d.ts +7 -1
  27. package/dist/types/lightning/storage/serialization.d.ts +1 -0
  28. package/dist/wallet/index.js +5 -1
  29. package/dist/wallet/index.js.map +1 -1
  30. package/package.json +1 -1
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.BeignetNode = exports.jitInvoiceError = exports.holdInvoiceEvent = exports.jsonSafeEvent = exports.jitReceiveRefusal = exports.leaseRatesRefusal = exports.defaultMaxFeeMsat = exports.DEFAULT_MAX_FEE_FLOOR_SATS = exports.DEFAULT_MAX_FEE_PPM = exports.clampDirectFundingMinimum = exports.DAILY_SPEND_STATE_KEY = exports.MAX_ASYNC_SPEND_CLAIMS = exports.ASYNC_SPEND_CLAIM_TTL_MS = exports.jsonToRouteHops = exports.routeHopsToJson = exports.spliceRefusalError = exports.decodeOfferInput = exports.paymentAdmissionSats = exports.paymentSpendSats = exports.spendLimitSats = exports.decodeInvoiceInput = exports.ENGINE_PAYMENT_ERROR_CODES = exports.parseScid = exports.formatScid = exports.gossipPrimeLatch = exports.defaultDataDirForMnemonic = exports.parseRecoveryMode = void 0;
26
+ exports.BeignetNode = exports.jitInvoiceError = exports.holdInvoiceEvent = exports.jsonSafeEvent = exports.jitReceiveRefusal = exports.leaseRatesRefusal = exports.defaultMaxFeeMsat = exports.DEFAULT_MAX_FEE_FLOOR_SATS = exports.DEFAULT_MAX_FEE_PPM = exports.clampDirectFundingMinimum = exports.DAILY_SPEND_STATE_KEY = exports.MAX_ASYNC_SPEND_CLAIMS = exports.ASYNC_SPEND_CLAIM_TTL_MS = exports.jsonToRouteHops = exports.routeHopsToJson = exports.spliceRefusalError = exports.decodeOfferInput = exports.paymentAdmissionSats = exports.paymentSpendSats = exports.hopFeeMsat = exports.spendLimitSats = exports.decodeInvoiceInput = exports.ENGINE_PAYMENT_ERROR_CODES = exports.parseScid = exports.formatScid = exports.gossipPrimeLatch = exports.defaultDataDirForMnemonic = exports.parseRecoveryMode = void 0;
27
27
  const offline_receive_1 = require("./offline-receive");
28
28
  const ffor_receive_1 = require("./ffor-receive");
29
29
  const path = __importStar(require("path"));
@@ -45,9 +45,10 @@ const fs_utils_1 = require("./fs-utils");
45
45
  const node_storage_view_1 = require("./node-storage-view");
46
46
  const electrum_1 = require("../types/electrum");
47
47
  const lightning_node_1 = require("../lightning/node/lightning-node");
48
- const types_1 = require("../lightning/direct-funding/receiver/types");
48
+ const types_1 = require("../lightning/chain/types");
49
+ const types_2 = require("../lightning/direct-funding/receiver/types");
49
50
  const splice_1 = require("../lightning/message/splice");
50
- const types_2 = require("../lightning/ffor/types");
51
+ const types_3 = require("../lightning/ffor/types");
51
52
  const messages_1 = require("../lightning/ffor/messages");
52
53
  const splice_weight_1 = require("../lightning/channel/splice-weight");
53
54
  const l402_1 = require("../lightning/l402");
@@ -58,9 +59,9 @@ const scb_1 = require("../lightning/backup/scb");
58
59
  const bip39 = __importStar(require("bip39"));
59
60
  const rapid_sync_1 = require("../lightning/gossip/rapid-sync");
60
61
  const messages_2 = require("../lightning/gossip/messages");
61
- const types_3 = require("../lightning/gossip/types");
62
+ const types_4 = require("../lightning/gossip/types");
62
63
  const electrum_backend_1 = require("../lightning/chain/electrum-backend");
63
- const types_4 = require("../lightning/invoice/types");
64
+ const types_5 = require("../lightning/invoice/types");
64
65
  const wallet_keys_1 = require("../lightning/keys/wallet-keys");
65
66
  const recovery_1 = require("../lightning/recovery");
66
67
  const peer_manager_1 = require("../lightning/transport/peer-manager");
@@ -69,8 +70,8 @@ const ecdh_1 = require("../lightning/crypto/ecdh");
69
70
  const direct_funding_1 = require("../lightning/direct-funding");
70
71
  const direct_funding_2 = require("./direct-funding");
71
72
  const auth_1 = require("./auth");
72
- const types_5 = require("../lightning/node/types");
73
- const types_6 = require("../lightning/channel/types");
73
+ const types_6 = require("../lightning/node/types");
74
+ const types_7 = require("../lightning/channel/types");
74
75
  const channel_state_1 = require("../lightning/channel/channel-state");
75
76
  const decode_1 = require("../lightning/invoice/decode");
76
77
  const decode_2 = require("../lightning/offer/decode");
@@ -148,14 +149,14 @@ function gossipPrimeLatch(rgs, timeoutMs) {
148
149
  }
149
150
  exports.gossipPrimeLatch = gossipPrimeLatch;
150
151
  function formatScid(scid) {
151
- const { block, txIndex, outputIndex } = (0, types_3.decodeShortChannelId)(scid);
152
+ const { block, txIndex, outputIndex } = (0, types_4.decodeShortChannelId)(scid);
152
153
  return `${block}x${txIndex}x${outputIndex}`;
153
154
  }
154
155
  exports.formatScid = formatScid;
155
156
  function parseScid(scid) {
156
157
  const human = scid.match(/^(\d+)x(\d+)x(\d+)$/);
157
158
  if (human) {
158
- return (0, types_3.encodeShortChannelId)({
159
+ return (0, types_4.encodeShortChannelId)({
159
160
  block: parseInt(human[1], 10),
160
161
  txIndex: parseInt(human[2], 10),
161
162
  outputIndex: parseInt(human[3], 10)
@@ -191,6 +192,14 @@ function spendLimitSats(amountMsat) {
191
192
  return Number((amountMsat + 999n) / 1000n);
192
193
  }
193
194
  exports.spendLimitSats = spendLimitSats;
195
+ function hopFeeMsat(hops, i) {
196
+ const received = hops[i]?.amountToForwardMsat;
197
+ const forwarded = hops[i + 1]?.amountToForwardMsat;
198
+ if (typeof received !== 'bigint' || typeof forwarded !== 'bigint')
199
+ return 0;
200
+ return received > forwarded ? Number(received - forwarded) : 0;
201
+ }
202
+ exports.hopFeeMsat = hopFeeMsat;
194
203
  function paymentSpendSats(amountMsat, amountSats) {
195
204
  return amountMsat !== undefined
196
205
  ? spendLimitSats(amountMsat)
@@ -212,6 +221,9 @@ function sentSats(info) {
212
221
  }
213
222
  return spendLimitSats(info.amountMsat);
214
223
  }
224
+ function settlesInvoice(p) {
225
+ return p?.status === 'COMPLETED' && p.direction === 'INCOMING';
226
+ }
215
227
  function decodeOfferInput(offerStr) {
216
228
  try {
217
229
  return (0, decode_2.decodeOffer)(offerStr);
@@ -222,19 +234,19 @@ function decodeOfferInput(offerStr) {
222
234
  }
223
235
  exports.decodeOfferInput = decodeOfferInput;
224
236
  const FUNDING_UNAVAILABLE_CODES = {
225
- [types_5.ChannelFundingUnavailableCode.FUNDING_PROVIDER_REQUIRED]: errors_1.BeignetErrorCode.FUNDING_PROVIDER_REQUIRED,
226
- [types_5.ChannelFundingUnavailableCode.INSUFFICIENT_BALANCE]: errors_1.BeignetErrorCode.INSUFFICIENT_BALANCE,
227
- [types_5.ChannelFundingUnavailableCode.FEE_ESTIMATE_NOT_READY]: errors_1.BeignetErrorCode.FEE_ESTIMATE_NOT_READY,
228
- [types_5.ChannelFundingUnavailableCode.CHANNEL_NOT_FOUND]: errors_1.BeignetErrorCode.CHANNEL_NOT_FOUND
237
+ [types_6.ChannelFundingUnavailableCode.FUNDING_PROVIDER_REQUIRED]: errors_1.BeignetErrorCode.FUNDING_PROVIDER_REQUIRED,
238
+ [types_6.ChannelFundingUnavailableCode.INSUFFICIENT_BALANCE]: errors_1.BeignetErrorCode.INSUFFICIENT_BALANCE,
239
+ [types_6.ChannelFundingUnavailableCode.FEE_ESTIMATE_NOT_READY]: errors_1.BeignetErrorCode.FEE_ESTIMATE_NOT_READY,
240
+ [types_6.ChannelFundingUnavailableCode.CHANNEL_NOT_FOUND]: errors_1.BeignetErrorCode.CHANNEL_NOT_FOUND
229
241
  };
230
242
  const SPLICE_REFUSAL_CODES = {
231
- [types_5.SpliceRefusalCode.CHANNEL_NOT_FOUND]: errors_1.BeignetErrorCode.CHANNEL_NOT_FOUND,
232
- [types_5.SpliceRefusalCode.SPLICING_NOT_NEGOTIATED]: errors_1.BeignetErrorCode.SPLICING_NOT_NEGOTIATED,
233
- [types_5.SpliceRefusalCode.INVALID_PARAMS]: errors_1.BeignetErrorCode.INVALID_PARAMS,
234
- [types_5.SpliceRefusalCode.INSUFFICIENT_BALANCE]: errors_1.BeignetErrorCode.INSUFFICIENT_BALANCE,
235
- [types_5.SpliceRefusalCode.FUNDING_PROVIDER_REQUIRED]: errors_1.BeignetErrorCode.FUNDING_PROVIDER_REQUIRED,
236
- [types_5.SpliceRefusalCode.SPLICE_BUSY]: errors_1.BeignetErrorCode.SPLICE_BUSY,
237
- [types_5.SpliceRefusalCode.SPLICE_REFUSED]: errors_1.BeignetErrorCode.SPLICE_REFUSED
243
+ [types_6.SpliceRefusalCode.CHANNEL_NOT_FOUND]: errors_1.BeignetErrorCode.CHANNEL_NOT_FOUND,
244
+ [types_6.SpliceRefusalCode.SPLICING_NOT_NEGOTIATED]: errors_1.BeignetErrorCode.SPLICING_NOT_NEGOTIATED,
245
+ [types_6.SpliceRefusalCode.INVALID_PARAMS]: errors_1.BeignetErrorCode.INVALID_PARAMS,
246
+ [types_6.SpliceRefusalCode.INSUFFICIENT_BALANCE]: errors_1.BeignetErrorCode.INSUFFICIENT_BALANCE,
247
+ [types_6.SpliceRefusalCode.FUNDING_PROVIDER_REQUIRED]: errors_1.BeignetErrorCode.FUNDING_PROVIDER_REQUIRED,
248
+ [types_6.SpliceRefusalCode.SPLICE_BUSY]: errors_1.BeignetErrorCode.SPLICE_BUSY,
249
+ [types_6.SpliceRefusalCode.SPLICE_REFUSED]: errors_1.BeignetErrorCode.SPLICE_REFUSED
238
250
  };
239
251
  function spliceRefusalError(result) {
240
252
  if (result.ok)
@@ -249,10 +261,10 @@ function fundingOrRefuse(run) {
249
261
  return run();
250
262
  }
251
263
  catch (err) {
252
- if (err instanceof types_5.InvalidRequestError) {
264
+ if (err instanceof types_6.InvalidRequestError) {
253
265
  throw new errors_1.BeignetError(errors_1.BeignetErrorCode.INVALID_PARAMS, err.message);
254
266
  }
255
- if (err instanceof types_5.ChannelFundingUnavailableError) {
267
+ if (err instanceof types_6.ChannelFundingUnavailableError) {
256
268
  throw new errors_1.BeignetError(FUNDING_UNAVAILABLE_CODES[err.code], err.message);
257
269
  }
258
270
  throw err;
@@ -535,15 +547,15 @@ function isHeldRestore(ch) {
535
547
  ch.restoreRevokedRisk === true);
536
548
  }
537
549
  const CLOSING_CHANNEL_STATES = new Set([
538
- types_6.ChannelState.SHUTTING_DOWN,
539
- types_6.ChannelState.NEGOTIATING_CLOSING,
540
- types_6.ChannelState.CLOSED,
541
- types_6.ChannelState.FORCE_CLOSED,
542
- types_6.ChannelState.ERRORED
550
+ types_7.ChannelState.SHUTTING_DOWN,
551
+ types_7.ChannelState.NEGOTIATING_CLOSING,
552
+ types_7.ChannelState.CLOSED,
553
+ types_7.ChannelState.FORCE_CLOSED,
554
+ types_7.ChannelState.ERRORED
543
555
  ]);
544
556
  function canBecomeUsable(channel) {
545
557
  const st = channel.getFullState();
546
- const effective = st.state === types_6.ChannelState.AWAITING_REESTABLISH && st.preReestablishState
558
+ const effective = st.state === types_7.ChannelState.AWAITING_REESTABLISH && st.preReestablishState
547
559
  ? st.preReestablishState
548
560
  : st.state;
549
561
  return !CLOSING_CHANNEL_STATES.has(effective) && !(0, channel_state_1.isRecencyUnproven)(st);
@@ -875,11 +887,11 @@ class BeignetNode extends events_1.EventEmitter {
875
887
  const beignetNetwork = this.toBeignetNetwork(networkName);
876
888
  const lnNetwork = this.toLnNetwork(networkName);
877
889
  const coinType = this.toCoinType(networkName);
878
- let chainHash = types_6.BITCOIN_CHAIN_HASH;
890
+ let chainHash = types_7.BITCOIN_CHAIN_HASH;
879
891
  if (networkName === 'regtest')
880
- chainHash = types_6.REGTEST_CHAIN_HASH;
892
+ chainHash = types_7.REGTEST_CHAIN_HASH;
881
893
  if (networkName === 'signet')
882
- chainHash = types_6.SIGNET_CHAIN_HASH;
894
+ chainHash = types_7.SIGNET_CHAIN_HASH;
883
895
  const electrumServer = {
884
896
  host: electrumHost,
885
897
  ssl: electrumTls ? electrumPort : 0,
@@ -1216,22 +1228,7 @@ class BeignetNode extends events_1.EventEmitter {
1216
1228
  if (!sweepDestinationScript) {
1217
1229
  this.scheduleSweepAddressRefresh();
1218
1230
  }
1219
- this.node.on('node:error', (err) => {
1220
- if (opts.onError) {
1221
- opts.onError({
1222
- code: err.code,
1223
- message: err.message,
1224
- timestamp: err.timestamp,
1225
- channelId: err.channelId ? err.channelId.toString('hex') : undefined
1226
- });
1227
- }
1228
- this.emit('node:error', {
1229
- code: err.code,
1230
- message: err.message,
1231
- timestamp: err.timestamp,
1232
- channelId: err.channelId ? err.channelId.toString('hex') : undefined
1233
- });
1234
- });
1231
+ this.wireNodeErrorRelay(opts.onError);
1235
1232
  this.node.on('payment:received', (info) => {
1236
1233
  const pi = this.toPaymentInfo(info);
1237
1234
  this.log('info', 'Payment received', {
@@ -1595,7 +1592,7 @@ class BeignetNode extends events_1.EventEmitter {
1595
1592
  const hex = channelId.toString('hex');
1596
1593
  this.emit('ffor:state', {
1597
1594
  channelId: hex,
1598
- state: types_2.FforState[state] ?? String(state),
1595
+ state: types_3.FforState[state] ?? String(state),
1599
1596
  epoch: this.fforEpochView(hex, record)
1600
1597
  });
1601
1598
  });
@@ -3138,22 +3135,66 @@ class BeignetNode extends events_1.EventEmitter {
3138
3135
  }
3139
3136
  getPendingCloseBalanceSats() {
3140
3137
  const recovering = new Set([
3141
- types_6.ChannelState.FORCE_CLOSED,
3142
- types_6.ChannelState.SHUTTING_DOWN,
3143
- types_6.ChannelState.NEGOTIATING_CLOSING
3138
+ types_7.ChannelState.FORCE_CLOSED,
3139
+ types_7.ChannelState.SHUTTING_DOWN,
3140
+ types_7.ChannelState.NEGOTIATING_CLOSING
3144
3141
  ]);
3145
3142
  let totalMsat = 0n;
3146
3143
  for (const ch of this.node.listChannels()) {
3147
- if (recovering.has(ch.state)) {
3148
- totalMsat += ch.localBalanceMsat;
3144
+ if (!recovering.has(ch.state))
3145
+ continue;
3146
+ if (ch.state === types_7.ChannelState.FORCE_CLOSED &&
3147
+ this.isForceCloseBalanceInWallet(ch.channelId)) {
3148
+ continue;
3149
3149
  }
3150
+ totalMsat += ch.localBalanceMsat;
3150
3151
  }
3151
3152
  return Number(totalMsat / 1000n);
3152
3153
  }
3154
+ isForceCloseBalanceInWallet(channelId) {
3155
+ const monitor = this.node.getChannelManager().getMonitor(channelId);
3156
+ const broadcast = monitor?.getFullState().commitmentBroadcast;
3157
+ if (!monitor || !broadcast)
3158
+ return false;
3159
+ let balanceOutputType;
3160
+ switch (broadcast.commitmentType) {
3161
+ case types_1.CommitmentType.OUR_COMMITMENT:
3162
+ balanceOutputType = types_1.OutputType.TO_LOCAL;
3163
+ break;
3164
+ case types_1.CommitmentType.THEIR_CURRENT_COMMITMENT:
3165
+ case types_1.CommitmentType.THEIR_REVOKED_COMMITMENT:
3166
+ case types_1.CommitmentType.THEIR_FUTURE_COMMITMENT:
3167
+ balanceOutputType = types_1.OutputType.TO_REMOTE;
3168
+ break;
3169
+ default:
3170
+ return false;
3171
+ }
3172
+ const balanceOutput = monitor
3173
+ .getTrackedOutputs()
3174
+ .find((o) => o.txid === broadcast.txid &&
3175
+ o.outputType === balanceOutputType &&
3176
+ !o.isSecondLevelHtlc);
3177
+ if (!balanceOutput)
3178
+ return false;
3179
+ let sweepTxid = balanceOutput.resolutionTxid;
3180
+ if (!sweepTxid && balanceOutput.sweepTxHex) {
3181
+ const bitcoin = require('bitcoinjs-lib');
3182
+ try {
3183
+ sweepTxid = bitcoin.Transaction.fromHex(balanceOutput.sweepTxHex).getId();
3184
+ }
3185
+ catch {
3186
+ return false;
3187
+ }
3188
+ }
3189
+ if (!sweepTxid)
3190
+ return false;
3191
+ const entry = this.wallet.transactions[sweepTxid];
3192
+ return entry !== undefined && entry.exists !== false;
3193
+ }
3153
3194
  getErroredBalanceSats() {
3154
3195
  let totalMsat = 0n;
3155
3196
  for (const ch of this.node.listChannels()) {
3156
- if (ch.state === types_6.ChannelState.ERRORED) {
3197
+ if (ch.state === types_7.ChannelState.ERRORED) {
3157
3198
  totalMsat += ch.localBalanceMsat;
3158
3199
  }
3159
3200
  }
@@ -3181,9 +3222,9 @@ class BeignetNode extends events_1.EventEmitter {
3181
3222
  return fresh;
3182
3223
  const bitcoin = require('bitcoinjs-lib');
3183
3224
  try {
3184
- const address = await this.wallet.getAddress({ index: '0' });
3185
- if (address) {
3186
- return bitcoin.address.toOutputScript(address, this.getBitcoinNetwork());
3225
+ const change = await this.wallet.getChangeAddress();
3226
+ if (change.isOk() && change.value?.address) {
3227
+ return bitcoin.address.toOutputScript(change.value.address, this.getBitcoinNetwork());
3187
3228
  }
3188
3229
  }
3189
3230
  catch {
@@ -3195,7 +3236,7 @@ class BeignetNode extends events_1.EventEmitter {
3195
3236
  try {
3196
3237
  const res = await this.wallet.getNextAvailableAddress();
3197
3238
  if (res.isOk()) {
3198
- return bitcoin.address.toOutputScript(res.value.addressIndex.address, this.getBitcoinNetwork());
3239
+ return bitcoin.address.toOutputScript(res.value.changeAddressIndex.address, this.getBitcoinNetwork());
3199
3240
  }
3200
3241
  }
3201
3242
  catch {
@@ -3796,7 +3837,7 @@ class BeignetNode extends events_1.EventEmitter {
3796
3837
  catch (err) {
3797
3838
  if (err instanceof errors_1.BeignetError)
3798
3839
  throw err;
3799
- if (err instanceof types_5.InvalidRequestError) {
3840
+ if (err instanceof types_6.InvalidRequestError) {
3800
3841
  throw new errors_1.BeignetError(errors_1.BeignetErrorCode.INVALID_PARAMS, err.message);
3801
3842
  }
3802
3843
  throw new errors_1.BeignetError('CONNECT_FAILED', `Failed to connect to ${pubkey.slice(0, 16)}…@${target}: ${err.message}`);
@@ -3896,7 +3937,7 @@ class BeignetNode extends events_1.EventEmitter {
3896
3937
  localBalanceSats: Number(balances.localMsat / 1000n),
3897
3938
  remoteBalanceSats: Number(balances.remoteMsat / 1000n),
3898
3939
  capacitySats: Number(state.fundingSatoshis),
3899
- isAnchor: (0, types_6.isAnchorChannel)(state.channelType)
3940
+ isAnchor: (0, types_7.isAnchorChannel)(state.channelType)
3900
3941
  };
3901
3942
  }
3902
3943
  async openChannelAndWait(pubkey, amountSats, opts) {
@@ -3989,9 +4030,9 @@ class BeignetNode extends events_1.EventEmitter {
3989
4030
  let state;
3990
4031
  if (f.role === 'S') {
3991
4032
  state =
3992
- f.slotStates[i] === types_2.FforSlotState.SETTLED
4033
+ f.slotStates[i] === types_3.FforSlotState.SETTLED
3993
4034
  ? 'settled'
3994
- : f.slotStates[i] === types_2.FforSlotState.SETTLING
4035
+ : f.slotStates[i] === types_3.FforSlotState.SETTLING
3995
4036
  ? 'settling'
3996
4037
  : 'unused';
3997
4038
  }
@@ -4019,7 +4060,7 @@ class BeignetNode extends events_1.EventEmitter {
4019
4060
  return {
4020
4061
  channelId: channelIdHex,
4021
4062
  role: f.role,
4022
- state: types_2.FforState[f.state],
4063
+ state: types_3.FforState[f.state],
4023
4064
  epochId: f.epochId.toString('hex'),
4024
4065
  peerNodeId: f.remoteNodeId.toString('hex'),
4025
4066
  variant: f.params.variant,
@@ -4145,7 +4186,7 @@ class BeignetNode extends events_1.EventEmitter {
4145
4186
  const idBuf = this.fforChannelId(body.channelId);
4146
4187
  const res = this.node.abortFforEpoch(idBuf.toString('hex'), typeof body.reason === 'number'
4147
4188
  ? body.reason
4148
- : types_2.FforAbortReason.OPERATOR, body.text ?? 'operator abort');
4189
+ : types_3.FforAbortReason.OPERATOR, body.text ?? 'operator abort');
4149
4190
  if (!res.ok)
4150
4191
  throw new errors_1.BeignetError('FFOR_REFUSED', res.error ?? 'abort refused');
4151
4192
  return this.fforEpoch(idBuf.toString('hex'));
@@ -4259,7 +4300,7 @@ class BeignetNode extends events_1.EventEmitter {
4259
4300
  destinationScript: this.fforDestinationScript()
4260
4301
  })
4261
4302
  .catch((err) => {
4262
- if (err instanceof types_5.InvalidRequestError) {
4303
+ if (err instanceof types_6.InvalidRequestError) {
4263
4304
  this.requireForceCloseAcknowledgement(idBuf, body.acceptStaleStateRisk === true);
4264
4305
  throw new errors_1.BeignetError('INVALID_PARAMS', err.message);
4265
4306
  }
@@ -4285,8 +4326,8 @@ class BeignetNode extends events_1.EventEmitter {
4285
4326
  throw new errors_1.BeignetError(errors_1.BeignetErrorCode.NOT_FOUND, 'no FFOR epoch of ours on this channel');
4286
4327
  }
4287
4328
  const channelState = this.node.getChannel(idBuf)?.state;
4288
- const closedOnChain = channelState === types_6.ChannelState.FORCE_CLOSED ||
4289
- channelState === types_6.ChannelState.CLOSED;
4329
+ const closedOnChain = channelState === types_7.ChannelState.FORCE_CLOSED ||
4330
+ channelState === types_7.ChannelState.CLOSED;
4290
4331
  if (f.settledBitmap === null && !closedOnChain) {
4291
4332
  throw new errors_1.BeignetError('FFOR_REFUSED', 'no ff_close_ack yet: close the epoch first');
4292
4333
  }
@@ -4512,6 +4553,23 @@ class BeignetNode extends events_1.EventEmitter {
4512
4553
  issues
4513
4554
  };
4514
4555
  }
4556
+ wireNodeErrorRelay(onError) {
4557
+ this.node.on('node:error', (err) => {
4558
+ const data = {
4559
+ code: err.code,
4560
+ message: err.message,
4561
+ timestamp: err.timestamp,
4562
+ channelId: err.channelId ? err.channelId.toString('hex') : undefined
4563
+ };
4564
+ if (err.txid !== undefined)
4565
+ data.txid = err.txid;
4566
+ if (err.retained !== undefined)
4567
+ data.retained = err.retained;
4568
+ if (onError)
4569
+ onError(data);
4570
+ this.emit('node:error', data);
4571
+ });
4572
+ }
4515
4573
  toChannelInfo(ch) {
4516
4574
  const peerPubkey = ch.peerPubkey ||
4517
4575
  this.node.getChannelManager().getPeerForChannel(ch.channelId) ||
@@ -4523,7 +4581,7 @@ class BeignetNode extends events_1.EventEmitter {
4523
4581
  localBalanceSats: Number(ch.localBalanceMsat / 1000n),
4524
4582
  remoteBalanceSats: Number(ch.remoteBalanceMsat / 1000n),
4525
4583
  capacitySats: Number(ch.fundingSatoshis),
4526
- isAnchor: (0, types_6.isAnchorChannel)(ch.channelType ?? null)
4584
+ isAnchor: (0, types_7.isAnchorChannel)(ch.channelType ?? null)
4527
4585
  };
4528
4586
  if (peerPubkey) {
4529
4587
  const splice = this.node.peerSupportsSplicing(peerPubkey);
@@ -4544,6 +4602,10 @@ class BeignetNode extends events_1.EventEmitter {
4544
4602
  info.htlcCount = ch.htlcCount;
4545
4603
  if (ch.pendingSpliceLocalBalanceMsat !== undefined)
4546
4604
  info.pendingSpliceLocalBalanceSats = Number(ch.pendingSpliceLocalBalanceMsat / 1000n);
4605
+ if (ch.pendingSpliceTxid !== undefined)
4606
+ info.pendingSpliceTxid = ch.pendingSpliceTxid;
4607
+ if (ch.previousFundingTxids && ch.previousFundingTxids.length > 0)
4608
+ info.previousFundingTxids = [...ch.previousFundingTxids];
4547
4609
  if (ch.htlcUsable !== undefined)
4548
4610
  info.htlcUsable = ch.htlcUsable;
4549
4611
  if (ch.restoreRecencyUnproven)
@@ -4865,7 +4927,7 @@ class BeignetNode extends events_1.EventEmitter {
4865
4927
  trusted: policy.allowZeroConf === true,
4866
4928
  allowSplice: policy.allowSplice === true,
4867
4929
  allowUnpairedSplice: policy.allowUnpairedSplice === true,
4868
- unpairedSpliceDepth: policy.unpairedSpliceDepth ?? types_1.DF_DEFAULT_UNPAIRED_SPLICE_DEPTH,
4930
+ unpairedSpliceDepth: policy.unpairedSpliceDepth ?? types_2.DF_DEFAULT_UNPAIRED_SPLICE_DEPTH,
4869
4931
  minAmountSat: clampDirectFundingMinimum(policy.minAmountSat ?? 0)
4870
4932
  };
4871
4933
  }
@@ -5476,13 +5538,13 @@ class BeignetNode extends events_1.EventEmitter {
5476
5538
  }
5477
5539
  _spendClaimOutcomeAtBoot(paymentHash, paymentHashHex) {
5478
5540
  const view = this.node.getOutgoingHtlcs(paymentHash);
5479
- if (view.preimage || view.status === types_5.PaymentStatus.COMPLETED) {
5541
+ if (view.preimage || view.status === types_6.PaymentStatus.COMPLETED) {
5480
5542
  return 'settled';
5481
5543
  }
5482
5544
  try {
5483
5545
  const durable = this.storage.loadPayment(paymentHashHex);
5484
- if (durable?.direction === types_5.PaymentDirection.OUTGOING &&
5485
- (durable.status === types_5.PaymentStatus.COMPLETED ||
5546
+ if (durable?.direction === types_6.PaymentDirection.OUTGOING &&
5547
+ (durable.status === types_6.PaymentStatus.COMPLETED ||
5486
5548
  durable.preimage !== undefined ||
5487
5549
  this.storage.loadPreimage(paymentHashHex) !== null)) {
5488
5550
  return 'settled';
@@ -5495,7 +5557,7 @@ class BeignetNode extends events_1.EventEmitter {
5495
5557
  });
5496
5558
  return 'live';
5497
5559
  }
5498
- if (view.status === types_5.PaymentStatus.PENDING ||
5560
+ if (view.status === types_6.PaymentStatus.PENDING ||
5499
5561
  this.node.hasHtlcInFlight(paymentHash)) {
5500
5562
  return 'live';
5501
5563
  }
@@ -5885,7 +5947,7 @@ class BeignetNode extends events_1.EventEmitter {
5885
5947
  catch {
5886
5948
  }
5887
5949
  if (hashHex !== 'unknown') {
5888
- const existing = this.getPayment(hashHex) ?? this.durablePaymentFor(err, hashHex);
5950
+ const existing = this.livePayment(hashHex) ?? this.durablePaymentFor(err, hashHex);
5889
5951
  if (existing)
5890
5952
  return existing;
5891
5953
  }
@@ -5917,7 +5979,7 @@ class BeignetNode extends events_1.EventEmitter {
5917
5979
  throw err;
5918
5980
  lastError = err;
5919
5981
  if (!(0, errors_1.isRetryableError)(err)) {
5920
- const pi = this.getPayment(paymentHashHex) ??
5982
+ const pi = this.livePayment(paymentHashHex) ??
5921
5983
  this.durablePaymentFor(err, paymentHashHex);
5922
5984
  if (pi)
5923
5985
  return { ...pi, attempts: attempt };
@@ -5950,7 +6012,7 @@ class BeignetNode extends events_1.EventEmitter {
5950
6012
  });
5951
6013
  await new Promise((resolve) => setTimeout(resolve, delayMs));
5952
6014
  if (this._draining) {
5953
- const pi = this.getPayment(paymentHashHex);
6015
+ const pi = this.livePayment(paymentHashHex);
5954
6016
  if (pi)
5955
6017
  return { ...pi, attempts: attempt };
5956
6018
  return {
@@ -5969,7 +6031,7 @@ class BeignetNode extends events_1.EventEmitter {
5969
6031
  const amountSats = Number(decoded.amountMsat / 1000n);
5970
6032
  const check = this.canSend(amountSats);
5971
6033
  if (!check.canSend) {
5972
- const pi = this.getPayment(paymentHashHex);
6034
+ const pi = this.livePayment(paymentHashHex);
5973
6035
  if (pi)
5974
6036
  return { ...pi, attempts: attempt };
5975
6037
  return {
@@ -5985,7 +6047,7 @@ class BeignetNode extends events_1.EventEmitter {
5985
6047
  }
5986
6048
  }
5987
6049
  }
5988
- const pi = this.getPayment(paymentHashHex);
6050
+ const pi = this.livePayment(paymentHashHex);
5989
6051
  if (pi)
5990
6052
  return { ...pi, attempts: maxRetries + 1 };
5991
6053
  return {
@@ -6118,7 +6180,7 @@ class BeignetNode extends events_1.EventEmitter {
6118
6180
  }
6119
6181
  }
6120
6182
  listPayments(filter) {
6121
- let payments = this.node.listPayments().map((p) => this.toPaymentInfo(p));
6183
+ let payments = this.paymentRecords().map((p) => this.toPaymentInfo(p));
6122
6184
  payments.sort((a, b) => b.createdAt - a.createdAt);
6123
6185
  if (filter) {
6124
6186
  if (filter.status) {
@@ -6148,10 +6210,25 @@ class BeignetNode extends events_1.EventEmitter {
6148
6210
  return payments;
6149
6211
  }
6150
6212
  getPayment(paymentHash) {
6213
+ const live = this.livePayment(paymentHash);
6214
+ if (live)
6215
+ return live;
6216
+ const durable = this.storage.loadPayment(paymentHash);
6217
+ return durable ? this.toPaymentInfo(durable) : null;
6218
+ }
6219
+ livePayment(paymentHash) {
6151
6220
  const p = this.node.getPayment(Buffer.from(paymentHash, 'hex'));
6152
- if (!p)
6153
- return null;
6154
- return this.toPaymentInfo(p);
6221
+ return p ? this.toPaymentInfo(p) : null;
6222
+ }
6223
+ paymentRecords() {
6224
+ const byHash = new Map();
6225
+ for (const { paymentHash, payment } of this.storage.loadAllPayments()) {
6226
+ byHash.set(paymentHash, payment);
6227
+ }
6228
+ for (const p of this.node.listPayments()) {
6229
+ byHash.set(p.paymentHash.toString('hex'), p);
6230
+ }
6231
+ return [...byHash.values()];
6155
6232
  }
6156
6233
  durablePaymentFor(err, hashHex) {
6157
6234
  if (!(err instanceof errors_1.BeignetError) ||
@@ -6374,14 +6451,15 @@ class BeignetNode extends events_1.EventEmitter {
6374
6451
  info.feeSats = Number(p.route.totalFeeMsat / 1000n);
6375
6452
  }
6376
6453
  if (p.route) {
6454
+ const hops = p.route.hops;
6377
6455
  info.route = {
6378
- hops: p.route.hops.map((h) => ({
6456
+ hops: hops.map((h, i) => ({
6379
6457
  pubkey: h.pubkey.toString('hex'),
6380
6458
  shortChannelId: h.shortChannelId.toString('hex'),
6381
- feeMsat: h.feeBaseMsat
6459
+ feeMsat: hopFeeMsat(hops, i)
6382
6460
  })),
6383
6461
  totalFeeMsat: Number(p.route.totalFeeMsat),
6384
- hopCount: p.route.hops.length
6462
+ hopCount: hops.length
6385
6463
  };
6386
6464
  }
6387
6465
  if (p.metadata)
@@ -6442,7 +6520,7 @@ class BeignetNode extends events_1.EventEmitter {
6442
6520
  localBalanceSats: Number(balances.localMsat / 1000n),
6443
6521
  remoteBalanceSats: Number(balances.remoteMsat / 1000n),
6444
6522
  capacitySats: amountSats,
6445
- isAnchor: (0, types_6.isAnchorChannel)(state.channelType)
6523
+ isAnchor: (0, types_7.isAnchorChannel)(state.channelType)
6446
6524
  };
6447
6525
  }
6448
6526
  openChannelV2(peerPubkey, params) {
@@ -6491,7 +6569,7 @@ class BeignetNode extends events_1.EventEmitter {
6491
6569
  localBalanceSats: Number(balances.localMsat / 1000n),
6492
6570
  remoteBalanceSats: Number(balances.remoteMsat / 1000n),
6493
6571
  capacitySats: params.amountSats,
6494
- isAnchor: (0, types_6.isAnchorChannel)(state.channelType)
6572
+ isAnchor: (0, types_7.isAnchorChannel)(state.channelType)
6495
6573
  };
6496
6574
  }
6497
6575
  spliceQuote(channelId, direction, feeratePerkw) {
@@ -6660,6 +6738,37 @@ class BeignetNode extends events_1.EventEmitter {
6660
6738
  const inv = this.node.getInvoice(paymentHash);
6661
6739
  if (!inv)
6662
6740
  return null;
6741
+ const live = this.node.getPayment(Buffer.from(inv.paymentHash, 'hex'));
6742
+ const paid = live
6743
+ ? settlesInvoice(live)
6744
+ : settlesInvoice(this.storage.loadPayment(inv.paymentHash));
6745
+ return this.toInvoiceInfo(inv, paid);
6746
+ }
6747
+ listInvoices() {
6748
+ let durablePaid;
6749
+ return this.node.listInvoices().map((inv) => {
6750
+ const live = this.node.getPayment(Buffer.from(inv.paymentHash, 'hex'));
6751
+ let paid;
6752
+ if (live) {
6753
+ paid = settlesInvoice(live);
6754
+ }
6755
+ else {
6756
+ if (!durablePaid)
6757
+ durablePaid = this.durablePaidHashes();
6758
+ paid = durablePaid.has(inv.paymentHash);
6759
+ }
6760
+ return this.toInvoiceInfo(inv, paid);
6761
+ });
6762
+ }
6763
+ durablePaidHashes() {
6764
+ const paid = new Set();
6765
+ for (const { paymentHash, payment } of this.storage.loadAllPayments()) {
6766
+ if (settlesInvoice(payment))
6767
+ paid.add(paymentHash);
6768
+ }
6769
+ return paid;
6770
+ }
6771
+ toInvoiceInfo(inv, paid) {
6663
6772
  const info = {
6664
6773
  bolt11: inv.bolt11,
6665
6774
  paymentHash: inv.paymentHash
@@ -6673,10 +6782,7 @@ class BeignetNode extends events_1.EventEmitter {
6673
6782
  info.expiry = inv.expiry;
6674
6783
  if (inv.createdAt !== undefined)
6675
6784
  info.createdAt = inv.createdAt;
6676
- const payment = this.node.getPayment(Buffer.from(inv.paymentHash, 'hex'));
6677
- if (payment &&
6678
- payment.status === 'COMPLETED' &&
6679
- payment.direction === 'INCOMING') {
6785
+ if (paid) {
6680
6786
  info.status = 'PAID';
6681
6787
  }
6682
6788
  else if (inv.createdAt !== undefined &&
@@ -6689,50 +6795,18 @@ class BeignetNode extends events_1.EventEmitter {
6689
6795
  }
6690
6796
  return info;
6691
6797
  }
6692
- listInvoices() {
6693
- return this.node.listInvoices().map((inv) => {
6694
- const info = {
6695
- bolt11: inv.bolt11,
6696
- paymentHash: inv.paymentHash
6697
- };
6698
- if (inv.amountMsat !== undefined) {
6699
- info.amountSats = Number(inv.amountMsat / 1000n);
6700
- }
6701
- if (inv.description)
6702
- info.description = inv.description;
6703
- if (inv.expiry !== undefined)
6704
- info.expiry = inv.expiry;
6705
- if (inv.createdAt !== undefined)
6706
- info.createdAt = inv.createdAt;
6707
- const payment = this.node.getPayment(Buffer.from(inv.paymentHash, 'hex'));
6708
- if (payment &&
6709
- payment.status === 'COMPLETED' &&
6710
- payment.direction === 'INCOMING') {
6711
- info.status = 'PAID';
6712
- }
6713
- else if (inv.createdAt !== undefined &&
6714
- inv.expiry !== undefined &&
6715
- Date.now() / 1000 > inv.createdAt + inv.expiry) {
6716
- info.status = 'EXPIRED';
6717
- }
6718
- else {
6719
- info.status = 'PENDING';
6720
- }
6721
- return info;
6722
- });
6723
- }
6724
6798
  getHealth() {
6725
6799
  const blockHeight = this.node.getCurrentBlockHeight();
6726
6800
  const electrumConnected = this.wallet?.electrum?.connectedToElectrum ?? false;
6727
6801
  const channels = this.node.listChannels();
6728
- const readyChannels = channels.filter((ch) => ch.state === types_6.ChannelState.NORMAL && !isHeldRestore(ch));
6802
+ const readyChannels = channels.filter((ch) => ch.state === types_7.ChannelState.NORMAL && !isHeldRestore(ch));
6729
6803
  const peerCount = this.node.listPeers().length;
6730
6804
  const graph = this.node.getGraph();
6731
- const operating = channels.filter((ch) => (ch.state === types_6.ChannelState.NORMAL ||
6732
- ch.state === types_6.ChannelState.SPLICING) &&
6805
+ const operating = channels.filter((ch) => (ch.state === types_7.ChannelState.NORMAL ||
6806
+ ch.state === types_7.ChannelState.SPLICING) &&
6733
6807
  !isHeldRestore(ch));
6734
- const broken = channels.filter((ch) => ch.state === types_6.ChannelState.AWAITING_REESTABLISH ||
6735
- ch.state === types_6.ChannelState.ERRORED);
6808
+ const broken = channels.filter((ch) => ch.state === types_7.ChannelState.AWAITING_REESTABLISH ||
6809
+ ch.state === types_7.ChannelState.ERRORED);
6736
6810
  let status = 'ready';
6737
6811
  if (!electrumConnected) {
6738
6812
  status = 'degraded';
@@ -6792,7 +6866,7 @@ class BeignetNode extends events_1.EventEmitter {
6792
6866
  ? 'Networking and auto-reconnect enabled'
6793
6867
  : 'Networking disabled — node cannot reconnect to peers'
6794
6868
  });
6795
- const hasAnchor = channels.some((ch) => ch.channelType != null && (0, types_6.isAnchorChannel)(ch.channelType));
6869
+ const hasAnchor = channels.some((ch) => ch.channelType != null && (0, types_7.isAnchorChannel)(ch.channelType));
6796
6870
  checks.push({
6797
6871
  name: 'ANCHOR_CHANNELS_PREFERRED',
6798
6872
  status: hasAnchor || channels.length === 0 ? 'PASS' : 'WARN',
@@ -6963,7 +7037,7 @@ class BeignetNode extends events_1.EventEmitter {
6963
7037
  for (const ch of this.node.listChannels()) {
6964
7038
  if (isHeldRestore(ch))
6965
7039
  continue;
6966
- if (ch.state !== types_6.ChannelState.NORMAL && !ch.htlcUsable)
7040
+ if (ch.state !== types_7.ChannelState.NORMAL && !ch.htlcUsable)
6967
7041
  continue;
6968
7042
  const chReserveMsat = ch.localReserveMsat ?? 0n;
6969
7043
  reserveMsat += chReserveMsat;
@@ -7174,7 +7248,7 @@ class BeignetNode extends events_1.EventEmitter {
7174
7248
  feeProportionalMillionths: update.feeProportionalMillionths,
7175
7249
  cltvExpiryDelta: update.cltvExpiryDelta,
7176
7250
  htlcMinimumMsat: update.htlcMinimumMsat.toString(),
7177
- disabled: (update.channelFlags & types_3.CHANNEL_FLAG_DISABLED) !== 0,
7251
+ disabled: (update.channelFlags & types_4.CHANNEL_FLAG_DISABLED) !== 0,
7178
7252
  lastUpdate: update.timestamp
7179
7253
  };
7180
7254
  if (update.htlcMaximumMsat !== undefined) {
@@ -7193,7 +7267,7 @@ class BeignetNode extends events_1.EventEmitter {
7193
7267
  requireNonNegativeSafeInteger(maxFeeSats, 'maxFeeSats');
7194
7268
  }
7195
7269
  const amountMsat = BigInt(amountSats) * 1000n;
7196
- const route = this.node.queryRoute(Buffer.from(destination, 'hex'), amountMsat, types_4.DEFAULT_MIN_FINAL_CLTV_EXPIRY);
7270
+ const route = this.node.queryRoute(Buffer.from(destination, 'hex'), amountMsat, types_5.DEFAULT_MIN_FINAL_CLTV_EXPIRY);
7197
7271
  if (!route) {
7198
7272
  throw new errors_1.BeignetError(errors_1.BeignetErrorCode.NO_ROUTE, 'No route found to destination');
7199
7273
  }
@@ -7208,7 +7282,7 @@ class BeignetNode extends events_1.EventEmitter {
7208
7282
  totalAmountMsat: route.totalAmountMsat.toString(),
7209
7283
  totalFeeMsat: route.totalFeeMsat.toString(),
7210
7284
  totalCltvDelta: route.totalCltvDelta,
7211
- finalCltvExpiry: types_4.DEFAULT_MIN_FINAL_CLTV_EXPIRY
7285
+ finalCltvExpiry: types_5.DEFAULT_MIN_FINAL_CLTV_EXPIRY
7212
7286
  };
7213
7287
  }
7214
7288
  sendToRoute(paymentHash, route, paymentSecret) {
@@ -7251,7 +7325,7 @@ class BeignetNode extends events_1.EventEmitter {
7251
7325
  : 'PAYMENT_FAILED';
7252
7326
  throw new errors_1.BeignetError(code, err instanceof Error ? err.message : String(err));
7253
7327
  }
7254
- if (claim && payment.status === types_5.PaymentStatus.FAILED) {
7328
+ if (claim && payment.status === types_6.PaymentStatus.FAILED) {
7255
7329
  this._releaseAsyncSpendClaim(claim);
7256
7330
  }
7257
7331
  return this.toPaymentInfo(payment);
@@ -7259,7 +7333,7 @@ class BeignetNode extends events_1.EventEmitter {
7259
7333
  getReadyChannels() {
7260
7334
  return this.node
7261
7335
  .listChannels()
7262
- .filter((ch) => ch.state === types_6.ChannelState.NORMAL && !isHeldRestore(ch))
7336
+ .filter((ch) => ch.state === types_7.ChannelState.NORMAL && !isHeldRestore(ch))
7263
7337
  .map((ch) => this.toChannelInfo(ch));
7264
7338
  }
7265
7339
  canSend(amountSats) {
@@ -7268,7 +7342,7 @@ class BeignetNode extends events_1.EventEmitter {
7268
7342
  let bestAvailableMsat = 0n;
7269
7343
  let totalAvailableMsat = 0n;
7270
7344
  for (const ch of this.node.listChannels()) {
7271
- if (ch.state !== types_6.ChannelState.NORMAL || isHeldRestore(ch))
7345
+ if (ch.state !== types_7.ChannelState.NORMAL || isHeldRestore(ch))
7272
7346
  continue;
7273
7347
  const reserveMsat = ch.localReserveMsat ?? 0n;
7274
7348
  const available = ch.localBalanceMsat > reserveMsat
@@ -7292,7 +7366,7 @@ class BeignetNode extends events_1.EventEmitter {
7292
7366
  let bestAvailableMsat = 0n;
7293
7367
  let totalAvailableMsat = 0n;
7294
7368
  for (const ch of this.node.listChannels()) {
7295
- if (ch.state !== types_6.ChannelState.NORMAL || isHeldRestore(ch))
7369
+ if (ch.state !== types_7.ChannelState.NORMAL || isHeldRestore(ch))
7296
7370
  continue;
7297
7371
  const reserveMsat = ch.remoteReserveMsat ?? 0n;
7298
7372
  const available = ch.remoteBalanceMsat > reserveMsat
@@ -7333,12 +7407,12 @@ class BeignetNode extends events_1.EventEmitter {
7333
7407
  }
7334
7408
  const hashHex = paymentHash.toString('hex');
7335
7409
  const view = await this.node.awaitPaymentResolution(paymentHash);
7336
- if (view.preimage || view.status === types_5.PaymentStatus.COMPLETED) {
7410
+ if (view.preimage || view.status === types_6.PaymentStatus.COMPLETED) {
7337
7411
  return { status: 'completed', paymentHash: hashHex };
7338
7412
  }
7339
7413
  const durable = this.storage.loadPayment(hashHex);
7340
- if (durable?.direction === types_5.PaymentDirection.OUTGOING &&
7341
- (durable.status === types_5.PaymentStatus.COMPLETED ||
7414
+ if (durable?.direction === types_6.PaymentDirection.OUTGOING &&
7415
+ (durable.status === types_6.PaymentStatus.COMPLETED ||
7342
7416
  durable.preimage !== undefined)) {
7343
7417
  return { status: 'completed', paymentHash: hashHex };
7344
7418
  }
@@ -7923,15 +7997,15 @@ class BeignetNode extends events_1.EventEmitter {
7923
7997
  toLnNetwork(network) {
7924
7998
  switch (network) {
7925
7999
  case 'mainnet':
7926
- return types_4.Network.MAINNET;
8000
+ return types_5.Network.MAINNET;
7927
8001
  case 'testnet':
7928
- return types_4.Network.TESTNET;
8002
+ return types_5.Network.TESTNET;
7929
8003
  case 'regtest':
7930
- return types_4.Network.REGTEST;
8004
+ return types_5.Network.REGTEST;
7931
8005
  case 'signet':
7932
- return types_4.Network.SIGNET;
8006
+ return types_5.Network.SIGNET;
7933
8007
  default:
7934
- return types_4.Network.MAINNET;
8008
+ return types_5.Network.MAINNET;
7935
8009
  }
7936
8010
  }
7937
8011
  toCoinType(network) {