beignet 0.34.0 → 0.35.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.
@@ -2559,9 +2559,8 @@ class BeignetNode extends typed_emitter_1.TypedEmitter {
2559
2559
  this.node.on('peer:connect', (pubkey) => {
2560
2560
  let direction;
2561
2561
  try {
2562
- direction = this.node
2563
- .getPeerManager()
2564
- ?.getConnectionInfo(pubkey)?.direction;
2562
+ direction = this.node.getPeerManager()?.getConnectionInfo(pubkey)
2563
+ ?.direction;
2565
2564
  }
2566
2565
  catch {
2567
2566
  // The log line must not cost the gossip sync below.
@@ -2604,20 +2603,22 @@ class BeignetNode extends typed_emitter_1.TypedEmitter {
2604
2603
  this.emit('peer:connect', { pubkey });
2605
2604
  });
2606
2605
  this.node.on('peer:disconnect', (pubkey, info) => {
2607
- this.log('info', 'Peer disconnected', {
2608
- pubkey,
2609
- ...(info
2610
- ? {
2611
- closedBy: info.initiator === 'remote' ? 'peer' : 'us',
2612
- ...(info.reason ? { reason: info.reason } : {}),
2613
- direction: info.direction,
2614
- ...(info.uptimeMs !== undefined
2615
- ? { uptimeMs: info.uptimeMs }
2616
- : {})
2617
- }
2618
- : {})
2619
- });
2620
- this.emit('peer:disconnect', { pubkey });
2606
+ // Subscribers (SSE, webhooks, an embedding app's diagnostics)
2607
+ // get the same cause the log line names.
2608
+ const cause = info
2609
+ ? {
2610
+ closedBy: info.initiator === 'remote'
2611
+ ? 'peer'
2612
+ : 'us',
2613
+ ...(info.reason ? { reason: info.reason } : {}),
2614
+ direction: info.direction,
2615
+ ...(info.uptimeMs !== undefined
2616
+ ? { uptimeMs: info.uptimeMs }
2617
+ : {})
2618
+ }
2619
+ : {};
2620
+ this.log('info', 'Peer disconnected', { pubkey, ...cause });
2621
+ this.emit('peer:disconnect', { pubkey, ...cause });
2621
2622
  });
2622
2623
  // The transport error that caused a disconnect (pong timeout, decrypt
2623
2624
  // failure, socket reset, ...) is the only place the reason is known —
@@ -6872,6 +6873,11 @@ class BeignetNode extends typed_emitter_1.TypedEmitter {
6872
6873
  if (!channel)
6873
6874
  return null;
6874
6875
  const state = channel.getFullState();
6876
+ // Nothing clears preReestablishState when a marked channel closes, so
6877
+ // it names the earlier state only while the channel is still wrapped.
6878
+ const wrappedState = state.state === types_7.ChannelState.AWAITING_REESTABLISH
6879
+ ? state.preReestablishState
6880
+ : null;
6875
6881
  // Mid-negotiation v2 channels are keyed by temporary id in the peer map
6876
6882
  // (see buildChannelInfo); fall back so diagnostics name the peer too.
6877
6883
  const peerPubkey = this.node.getChannelManager().getPeerForChannel(channelIdBuf) ||
@@ -6904,9 +6910,9 @@ class BeignetNode extends typed_emitter_1.TypedEmitter {
6904
6910
  if (state.fundingUnaccounted === true)
6905
6911
  issues.push('FUNDING_UNACCOUNTED: Neither mempool nor chain can account for the funding transaction, so the channel takes no new HTLCs. Routing hints will be skipped. Existing HTLCs still settle, and the quarantine lifts by itself if the funding reappears.');
6906
6912
  if (state.state !== 'NORMAL' &&
6907
- state.preReestablishState !== 'NORMAL' &&
6913
+ wrappedState !== 'NORMAL' &&
6908
6914
  !acceptsNewThrough) {
6909
- issues.push(`NOT_NORMAL: Channel state is ${state.state} (pre-reestablish: ${state.preReestablishState || 'none'}). Routing hints require a usable channel.`);
6915
+ issues.push(`NOT_NORMAL: Channel state is ${state.state} (pre-reestablish: ${wrappedState || 'none'}). Routing hints require a usable channel.`);
6910
6916
  }
6911
6917
  if (!state.announceChannel)
6912
6918
  issues.push('PRIVATE_CHANNEL: Channel is private (not announced). Routing hints are required for payments.');
@@ -6920,7 +6926,7 @@ class BeignetNode extends typed_emitter_1.TypedEmitter {
6920
6926
  channelId,
6921
6927
  peerPubkey,
6922
6928
  state: state.state,
6923
- preReestablishState: state.preReestablishState || null,
6929
+ preReestablishState: wrappedState || null,
6924
6930
  isPeerConnected,
6925
6931
  announceChannel: state.announceChannel,
6926
6932
  announcementSigsSent: state.announcementSigsSent || false,