beignet 0.6.6 → 0.6.8

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.
@@ -448,7 +448,8 @@ class BeignetNode extends events_1.EventEmitter {
448
448
  const pi = this.toPaymentInfo(info);
449
449
  this.log('warn', 'Payment failed', {
450
450
  paymentHash: pi.paymentHash,
451
- failureCode: pi.failureCode
451
+ failureCode: pi.failureCode,
452
+ ...this.describeFailureSource(info)
452
453
  });
453
454
  this.emit('payment:failed', pi);
454
455
  });
@@ -2396,6 +2397,26 @@ class BeignetNode extends events_1.EventEmitter {
2396
2397
  this.node.failPayment(Buffer.from(paymentHash, 'hex'));
2397
2398
  return { ok: true };
2398
2399
  }
2400
+ describeFailureSource(p) {
2401
+ const index = p.failureSourceIndex;
2402
+ if (index === undefined || !p.route)
2403
+ return {};
2404
+ const fields = { failureSourceIndex: index };
2405
+ const erringHop = p.route.hops[index];
2406
+ if (erringHop) {
2407
+ fields.failureSourceNode = erringHop.pubkey.toString('hex');
2408
+ }
2409
+ const outgoingHop = p.route.hops[index + 1];
2410
+ if (outgoingHop) {
2411
+ try {
2412
+ fields.failureOutgoingScid = formatScid(outgoingHop.shortChannelId);
2413
+ }
2414
+ catch {
2415
+ fields.failureOutgoingScid = outgoingHop.shortChannelId.toString('hex');
2416
+ }
2417
+ }
2418
+ return fields;
2419
+ }
2399
2420
  toPaymentInfo(p) {
2400
2421
  const info = {
2401
2422
  paymentHash: p.paymentHash.toString('hex'),
@@ -2951,7 +2972,16 @@ class BeignetNode extends events_1.EventEmitter {
2951
2972
  return this.node.estimatePayment(bolt11, amountSats);
2952
2973
  }
2953
2974
  probeRoute(destination, amountSats) {
2954
- return this.node.probeRoute(destination, amountSats);
2975
+ const result = this.node.probeRoute(destination, amountSats);
2976
+ if (!result.path)
2977
+ return result;
2978
+ return {
2979
+ ...result,
2980
+ path: result.path.map((hop) => ({
2981
+ pubkey: hop.pubkey,
2982
+ shortChannelId: formatScid(Buffer.from(hop.shortChannelId, 'hex'))
2983
+ }))
2984
+ };
2955
2985
  }
2956
2986
  getGraphInfo() {
2957
2987
  const graph = this.node.getGraph();