beignet 0.20.1 → 0.21.0

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 (36) hide show
  1. package/dist/cli/beignet-node.js +12 -3
  2. package/dist/cli/beignet-node.js.map +1 -1
  3. package/dist/cli/daemon.js +1 -0
  4. package/dist/cli/daemon.js.map +1 -1
  5. package/dist/cli/errors.js +2 -0
  6. package/dist/cli/errors.js.map +1 -1
  7. package/dist/electrum/index.js +208 -39
  8. package/dist/electrum/index.js.map +1 -1
  9. package/dist/lightning/direct-funding/sender/engine.js +3 -1
  10. package/dist/lightning/direct-funding/sender/engine.js.map +1 -1
  11. package/dist/lightning/direct-funding/sender/types.js +3 -1
  12. package/dist/lightning/direct-funding/sender/types.js.map +1 -1
  13. package/dist/lightning/direct-funding/transport/direct-peer.js +44 -3
  14. package/dist/lightning/direct-funding/transport/direct-peer.js.map +1 -1
  15. package/dist/lightning/direct-funding/transport/onion.js +2 -0
  16. package/dist/lightning/direct-funding/transport/onion.js.map +1 -1
  17. package/dist/lightning/direct-funding/transport/registry.js +33 -6
  18. package/dist/lightning/direct-funding/transport/registry.js.map +1 -1
  19. package/dist/lightning/direct-funding/transport/types.js +1 -0
  20. package/dist/lightning/direct-funding/transport/types.js.map +1 -1
  21. package/dist/lightning/node/lightning-node.js +83 -12
  22. package/dist/lightning/node/lightning-node.js.map +1 -1
  23. package/dist/lightning/node/types.js.map +1 -1
  24. package/dist/lightning/storage/serialization.js +2 -0
  25. package/dist/lightning/storage/serialization.js.map +1 -1
  26. package/dist/types/cli/beignet-node.d.ts +1 -0
  27. package/dist/types/cli/errors.d.ts +1 -0
  28. package/dist/types/electrum/index.d.ts +3 -0
  29. package/dist/types/lightning/direct-funding/transport/types.d.ts +4 -1
  30. package/dist/types/lightning/node/lightning-node.d.ts +2 -0
  31. package/dist/types/lightning/node/types.d.ts +1 -0
  32. package/dist/types/lightning/storage/serialization.d.ts +1 -0
  33. package/dist/types/wallet/index.d.ts +7 -1
  34. package/dist/wallet/index.js +36 -8
  35. package/dist/wallet/index.js.map +1 -1
  36. package/package.json +1 -1
@@ -4613,6 +4613,14 @@ class BeignetNode extends events_1.EventEmitter {
4613
4613
  info.expiry = opts.expiry;
4614
4614
  return info;
4615
4615
  }
4616
+ holdResolutionRefusal(paymentHash, action, notFound) {
4617
+ const parked = this.node
4618
+ .listHeldHtlcs()
4619
+ .find((h) => h.paymentHash.equals(paymentHash));
4620
+ if (!parked)
4621
+ return new errors_1.BeignetError(errors_1.BeignetErrorCode.NOT_FOUND, notFound);
4622
+ return new errors_1.BeignetError(errors_1.BeignetErrorCode.HOLD_RESOLUTION_PENDING, `${parked.htlcCount} parked HTLC(s) remain for this payment hash: a channel refused the ${action} for them, or a settle or cancel is already under way`);
4623
+ }
4616
4624
  settleHoldInvoice(preimage) {
4617
4625
  if (!/^[0-9a-fA-F]{64}$/.test(preimage)) {
4618
4626
  throw new errors_1.BeignetError(errors_1.BeignetErrorCode.INVALID_PARAMS, 'preimage must be 32 bytes hex (64 hex chars)');
@@ -4624,7 +4632,7 @@ class BeignetNode extends events_1.EventEmitter {
4624
4632
  .digest();
4625
4633
  const settled = this.node.settleHeldHtlc(paymentHash, preimageBuf);
4626
4634
  if (!settled) {
4627
- throw new errors_1.BeignetError(errors_1.BeignetErrorCode.NOT_FOUND, 'No parked HTLCs for this preimage (invoice unknown, not yet paid, or already resolved)');
4635
+ throw this.holdResolutionRefusal(paymentHash, 'settle', 'No parked HTLCs for this preimage (invoice unknown, not yet paid, or already resolved)');
4628
4636
  }
4629
4637
  return { paymentHash: paymentHash.toString('hex') };
4630
4638
  }
@@ -4632,9 +4640,10 @@ class BeignetNode extends events_1.EventEmitter {
4632
4640
  if (!/^[0-9a-fA-F]{64}$/.test(paymentHash)) {
4633
4641
  throw new errors_1.BeignetError(errors_1.BeignetErrorCode.INVALID_PARAMS, 'paymentHash must be 32 bytes hex (64 hex chars)');
4634
4642
  }
4635
- const result = this.node.cancelHoldInvoice(Buffer.from(paymentHash, 'hex'));
4643
+ const hash = Buffer.from(paymentHash, 'hex');
4644
+ const result = this.node.cancelHoldInvoice(hash);
4636
4645
  if (!result) {
4637
- throw new errors_1.BeignetError(errors_1.BeignetErrorCode.NOT_FOUND, 'No open hold invoice for this payment hash');
4646
+ throw this.holdResolutionRefusal(hash, 'cancel', 'No open hold invoice for this payment hash');
4638
4647
  }
4639
4648
  return { paymentHash, htlcsFailed: result.htlcsFailed };
4640
4649
  }