beignet 0.6.7 → 0.6.9

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,9 @@ 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
+ ...(info.failureReason ? { reason: info.failureReason } : {}),
453
+ ...this.describeFailureSource(info)
452
454
  });
453
455
  this.emit('payment:failed', pi);
454
456
  });
@@ -2396,6 +2398,26 @@ class BeignetNode extends events_1.EventEmitter {
2396
2398
  this.node.failPayment(Buffer.from(paymentHash, 'hex'));
2397
2399
  return { ok: true };
2398
2400
  }
2401
+ describeFailureSource(p) {
2402
+ const index = p.failureSourceIndex;
2403
+ if (index === undefined || !p.route)
2404
+ return {};
2405
+ const fields = { failureSourceIndex: index };
2406
+ const erringHop = p.route.hops[index];
2407
+ if (erringHop) {
2408
+ fields.failureSourceNode = erringHop.pubkey.toString('hex');
2409
+ }
2410
+ const outgoingHop = p.route.hops[index + 1];
2411
+ if (outgoingHop) {
2412
+ try {
2413
+ fields.failureOutgoingScid = formatScid(outgoingHop.shortChannelId);
2414
+ }
2415
+ catch {
2416
+ fields.failureOutgoingScid = outgoingHop.shortChannelId.toString('hex');
2417
+ }
2418
+ }
2419
+ return fields;
2420
+ }
2399
2421
  toPaymentInfo(p) {
2400
2422
  const info = {
2401
2423
  paymentHash: p.paymentHash.toString('hex'),
@@ -2412,6 +2434,9 @@ class BeignetNode extends events_1.EventEmitter {
2412
2434
  info.failureCode = p.failureCode;
2413
2435
  info.failureDescription = (0, errors_1.describeFailureCode)(p.failureCode);
2414
2436
  }
2437
+ else if (p.failureReason) {
2438
+ info.failureDescription = p.failureReason;
2439
+ }
2415
2440
  if (p.route?.totalFeeMsat !== undefined) {
2416
2441
  info.feeSats = Number(p.route.totalFeeMsat / 1000n);
2417
2442
  }
@@ -2951,7 +2976,16 @@ class BeignetNode extends events_1.EventEmitter {
2951
2976
  return this.node.estimatePayment(bolt11, amountSats);
2952
2977
  }
2953
2978
  probeRoute(destination, amountSats) {
2954
- return this.node.probeRoute(destination, amountSats);
2979
+ const result = this.node.probeRoute(destination, amountSats);
2980
+ if (!result.path)
2981
+ return result;
2982
+ return {
2983
+ ...result,
2984
+ path: result.path.map((hop) => ({
2985
+ pubkey: hop.pubkey,
2986
+ shortChannelId: formatScid(Buffer.from(hop.shortChannelId, 'hex'))
2987
+ }))
2988
+ };
2955
2989
  }
2956
2990
  getGraphInfo() {
2957
2991
  const graph = this.node.getGraph();