beignet 0.15.0 → 0.15.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.
@@ -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.jsonSafeEvent = exports.jitReceiveRefusal = exports.leaseRatesRefusal = exports.clampDirectFundingMinimum = exports.MAX_ASYNC_SPEND_CLAIMS = exports.ASYNC_SPEND_CLAIM_TTL_MS = exports.jsonToRouteHops = exports.routeHopsToJson = exports.spliceRefusalError = exports.decodeOfferInput = exports.paymentSpendSats = exports.spendLimitSats = exports.decodeInvoiceInput = 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.clampDirectFundingMinimum = exports.MAX_ASYNC_SPEND_CLAIMS = exports.ASYNC_SPEND_CLAIM_TTL_MS = exports.jsonToRouteHops = exports.routeHopsToJson = exports.spliceRefusalError = exports.decodeOfferInput = exports.paymentSpendSats = exports.spendLimitSats = exports.decodeInvoiceInput = exports.parseScid = exports.formatScid = exports.gossipPrimeLatch = exports.defaultDataDirForMnemonic = exports.parseRecoveryMode = void 0;
27
27
  const path = __importStar(require("path"));
28
28
  const fs = __importStar(require("fs"));
29
29
  const net = __importStar(require("net"));
@@ -430,6 +430,15 @@ function jsonSafeEvent(value) {
430
430
  return value;
431
431
  }
432
432
  exports.jsonSafeEvent = jsonSafeEvent;
433
+ function holdInvoiceEvent(e) {
434
+ return {
435
+ paymentHash: e.paymentHash.toString('hex'),
436
+ state: e.state,
437
+ heldAmountMsat: e.heldAmountMsat.toString(),
438
+ htlcCount: e.htlcCount
439
+ };
440
+ }
441
+ exports.holdInvoiceEvent = holdInvoiceEvent;
433
442
  function jitInvoiceError(err) {
434
443
  if (err instanceof errors_1.BeignetError)
435
444
  return err;
@@ -1151,6 +1160,29 @@ class BeignetNode extends events_1.EventEmitter {
1151
1160
  });
1152
1161
  this.emit('invoice:settled', info);
1153
1162
  });
1163
+ this.node.on('hold:accepted', (e) => {
1164
+ const info = holdInvoiceEvent(e);
1165
+ this.emit('hold:accepted', info);
1166
+ this.log('info', 'Hold invoice accepted', {
1167
+ paymentHash: info.paymentHash,
1168
+ heldAmountMsat: info.heldAmountMsat,
1169
+ htlcCount: info.htlcCount
1170
+ });
1171
+ });
1172
+ this.node.on('hold:settled', (e) => {
1173
+ this.emit('hold:settled', holdInvoiceEvent(e));
1174
+ });
1175
+ this.node.on('hold:cancelled', (e) => {
1176
+ this.emit('hold:cancelled', {
1177
+ ...holdInvoiceEvent({
1178
+ paymentHash: e.paymentHash,
1179
+ state: 'CANCELLED',
1180
+ heldAmountMsat: e.heldAmountMsat,
1181
+ htlcCount: e.htlcsFailed
1182
+ }),
1183
+ reason: e.reason
1184
+ });
1185
+ });
1154
1186
  this.node.on('htlc:forward', (inChannelId, outChannelId, amountMsat, paymentHash) => {
1155
1187
  this.log('info', 'HTLC forward', {
1156
1188
  paymentHash: paymentHash.toString('hex'),
@@ -4422,7 +4454,12 @@ class BeignetNode extends events_1.EventEmitter {
4422
4454
  description: opts.description || '',
4423
4455
  expiry: opts.expiry,
4424
4456
  hold: true,
4425
- paymentHash: Buffer.from(opts.paymentHash, 'hex')
4457
+ paymentHash: Buffer.from(opts.paymentHash, 'hex'),
4458
+ ...(opts.minFinalCltvExpiry !== undefined
4459
+ ? {
4460
+ minFinalCltvExpiry: requireFinalCltvExpiry(opts.minFinalCltvExpiry)
4461
+ }
4462
+ : {})
4426
4463
  });
4427
4464
  const info = {
4428
4465
  bolt11: result.bolt11,