beignet 0.7.2 → 0.7.3
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.
- package/dist/cli/beignet-node.js +6 -3
- package/dist/cli/beignet-node.js.map +1 -1
- package/dist/cli/cli.js +5 -2
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/daemon.js +2 -2
- package/dist/cli/daemon.js.map +1 -1
- package/dist/cli/openapi.js +2 -1
- package/dist/cli/openapi.js.map +1 -1
- package/dist/lightning/channel/channel-manager.js +40 -8
- package/dist/lightning/channel/channel-manager.js.map +1 -1
- package/dist/lightning/channel/channel.js +94 -22
- package/dist/lightning/channel/channel.js.map +1 -1
- package/dist/lightning/channel/dual-funding.js +1 -1
- package/dist/lightning/channel/dual-funding.js.map +1 -1
- package/dist/lightning/gossip/pathfinding.js +4 -2
- package/dist/lightning/gossip/pathfinding.js.map +1 -1
- package/dist/lightning/node/lightning-node.js +24 -12
- package/dist/lightning/node/lightning-node.js.map +1 -1
- package/dist/types/cli/beignet-node.d.ts +2 -1
- package/dist/types/lightning/channel/channel-manager.d.ts +6 -2
- package/dist/types/lightning/channel/channel.d.ts +1 -0
- package/dist/types/lightning/channel/dual-funding.d.ts +1 -0
- package/dist/types/lightning/node/lightning-node.d.ts +4 -2
- package/package.json +1 -1
|
@@ -226,6 +226,11 @@ class Channel {
|
|
|
226
226
|
channelTypeFlags.setCompulsory(flags_1.Feature.ANCHOR_ZERO_FEE_HTLC);
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
|
+
const zeroConf = this._state.zeroConfEnabled && this._state.trustedPeer;
|
|
230
|
+
if (zeroConf) {
|
|
231
|
+
channelTypeFlags.setCompulsory(flags_1.Feature.SCID_ALIAS);
|
|
232
|
+
channelTypeFlags.setCompulsory(flags_1.Feature.ZERO_CONF);
|
|
233
|
+
}
|
|
229
234
|
const channelType = channelTypeFlags.toBuffer();
|
|
230
235
|
this._state.channelType = channelType;
|
|
231
236
|
const channelReserve = computeChannelReserve(this._state.fundingSatoshis, this._state.localConfig.dustLimitSatoshis);
|
|
@@ -247,9 +252,12 @@ class Channel {
|
|
|
247
252
|
delayedPaymentBasepoint: this._state.localBasepoints.delayedPaymentBasepoint,
|
|
248
253
|
htlcBasepoint: this._state.localBasepoints.htlcBasepoint,
|
|
249
254
|
firstPerCommitmentPoint: firstPoint,
|
|
250
|
-
channelFlags: preferTaproot ? 0x00 : 0x01,
|
|
255
|
+
channelFlags: preferTaproot || zeroConf ? 0x00 : 0x01,
|
|
251
256
|
channelType
|
|
252
257
|
};
|
|
258
|
+
if (zeroConf) {
|
|
259
|
+
this._state.announceChannel = false;
|
|
260
|
+
}
|
|
253
261
|
if (preferTaproot) {
|
|
254
262
|
msg.nextLocalNonce = this._ensureLocalFundingNonce();
|
|
255
263
|
}
|
|
@@ -378,7 +386,20 @@ class Channel {
|
|
|
378
386
|
htlcBasepoint: msg.htlcBasepoint,
|
|
379
387
|
firstPerCommitmentPoint: msg.firstPerCommitmentPoint
|
|
380
388
|
};
|
|
381
|
-
this._state.
|
|
389
|
+
if (this._state.channelType &&
|
|
390
|
+
flags_1.FeatureFlags.fromBuffer(this._state.channelType).hasFeature(flags_1.Feature.ZERO_CONF)) {
|
|
391
|
+
if (msg.minimumDepth !== 0) {
|
|
392
|
+
return [
|
|
393
|
+
{
|
|
394
|
+
type: channel_actions_1.ChannelActionType.ERROR,
|
|
395
|
+
message: `zero_conf accept_channel must use minimum_depth 0, got ${msg.minimumDepth}`
|
|
396
|
+
}
|
|
397
|
+
];
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
else {
|
|
401
|
+
this._state.minimumDepth = msg.minimumDepth;
|
|
402
|
+
}
|
|
382
403
|
this._state.remoteCurrentPerCommitmentPoint = msg.firstPerCommitmentPoint;
|
|
383
404
|
if (msg.channelType && this._state.channelType) {
|
|
384
405
|
const localBits = flags_1.FeatureFlags.fromBuffer(this._state.channelType).listSetBits();
|
|
@@ -557,14 +578,17 @@ class Channel {
|
|
|
557
578
|
}
|
|
558
579
|
];
|
|
559
580
|
}
|
|
560
|
-
if (proposedFlags.hasFeature(flags_1.Feature.ZERO_CONF)
|
|
561
|
-
!
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
581
|
+
if (proposedFlags.hasFeature(flags_1.Feature.ZERO_CONF)) {
|
|
582
|
+
if (!this._state.trustedPeer) {
|
|
583
|
+
return [
|
|
584
|
+
{
|
|
585
|
+
type: channel_actions_1.ChannelActionType.ERROR,
|
|
586
|
+
message: 'Proposed zero_conf channel type requires a trusted peer'
|
|
587
|
+
}
|
|
588
|
+
];
|
|
589
|
+
}
|
|
590
|
+
this._state.zeroConfEnabled = true;
|
|
591
|
+
this._state.minimumDepth = 0;
|
|
568
592
|
}
|
|
569
593
|
this._state.channelType = msg.channelType;
|
|
570
594
|
}
|
|
@@ -677,7 +701,7 @@ class Channel {
|
|
|
677
701
|
partialSignatureWithNonce: taproot ? partialSignatureWithNonce : undefined
|
|
678
702
|
};
|
|
679
703
|
this._state.state = types_2.ChannelState.AWAITING_FUNDING_CONFIRMED;
|
|
680
|
-
|
|
704
|
+
const actions = [
|
|
681
705
|
{ type: channel_actions_1.ChannelActionType.PERSIST_STATE },
|
|
682
706
|
sendMsg(types_1.MessageType.FUNDING_SIGNED, (0, channel_funding_1.encodeFundingSignedMessage)(signedMsg)),
|
|
683
707
|
{
|
|
@@ -687,6 +711,10 @@ class Channel {
|
|
|
687
711
|
minimumDepth: this._state.minimumDepth
|
|
688
712
|
}
|
|
689
713
|
];
|
|
714
|
+
if (this._state.zeroConfEnabled && this._state.trustedPeer) {
|
|
715
|
+
actions.push(...this.fundingConfirmed());
|
|
716
|
+
}
|
|
717
|
+
return actions;
|
|
690
718
|
}
|
|
691
719
|
fundingConfirmed() {
|
|
692
720
|
if (this._state.state !== types_2.ChannelState.AWAITING_FUNDING_CONFIRMED &&
|
|
@@ -4341,10 +4369,15 @@ class Channel {
|
|
|
4341
4369
|
witnesses: this._spliceTx.ourWalletWitnesses,
|
|
4342
4370
|
sharedInputSignature: signed.signature
|
|
4343
4371
|
};
|
|
4344
|
-
|
|
4372
|
+
const actions = [
|
|
4345
4373
|
{ type: channel_actions_1.ChannelActionType.PERSIST_STATE },
|
|
4346
4374
|
sendMsg(types_1.MessageType.TX_SIGNATURES, (0, interactive_tx_1.encodeTxSignaturesMessage)(msg))
|
|
4347
4375
|
];
|
|
4376
|
+
if (this._isZeroConfChannelType() &&
|
|
4377
|
+
this._state.spliceInFlight?.receivedTxSignatures) {
|
|
4378
|
+
actions.push(...this.sendSpliceLocked());
|
|
4379
|
+
}
|
|
4380
|
+
return actions;
|
|
4348
4381
|
}
|
|
4349
4382
|
completeSplice() {
|
|
4350
4383
|
const inflight = this._state.spliceInFlight;
|
|
@@ -4792,14 +4825,18 @@ class Channel {
|
|
|
4792
4825
|
this._state.fundingLocktime = msg.locktime;
|
|
4793
4826
|
if (msg.channelType) {
|
|
4794
4827
|
const proposedFlags = flags_1.FeatureFlags.fromBuffer(msg.channelType);
|
|
4795
|
-
if (proposedFlags.hasFeature(flags_1.Feature.ZERO_CONF)
|
|
4796
|
-
!
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4828
|
+
if (proposedFlags.hasFeature(flags_1.Feature.ZERO_CONF)) {
|
|
4829
|
+
if (!this._state.trustedPeer) {
|
|
4830
|
+
return [
|
|
4831
|
+
{
|
|
4832
|
+
type: channel_actions_1.ChannelActionType.ERROR,
|
|
4833
|
+
message: 'Proposed zero_conf channel type requires a trusted peer'
|
|
4834
|
+
}
|
|
4835
|
+
];
|
|
4836
|
+
}
|
|
4837
|
+
this._state.zeroConfEnabled = true;
|
|
4838
|
+
this._state.minimumDepth = 0;
|
|
4839
|
+
localParams = { ...localParams, minimumDepth: 0 };
|
|
4803
4840
|
}
|
|
4804
4841
|
}
|
|
4805
4842
|
localParams = {
|
|
@@ -4923,6 +4960,16 @@ class Channel {
|
|
|
4923
4960
|
}
|
|
4924
4961
|
];
|
|
4925
4962
|
}
|
|
4963
|
+
if (this._state.channelType &&
|
|
4964
|
+
flags_1.FeatureFlags.fromBuffer(this._state.channelType).hasFeature(flags_1.Feature.ZERO_CONF) &&
|
|
4965
|
+
msg.minimumDepth !== 0) {
|
|
4966
|
+
return [
|
|
4967
|
+
{
|
|
4968
|
+
type: channel_actions_1.ChannelActionType.ERROR,
|
|
4969
|
+
message: `zero_conf accept_channel2 must use minimum_depth 0, got ${msg.minimumDepth}`
|
|
4970
|
+
}
|
|
4971
|
+
];
|
|
4972
|
+
}
|
|
4926
4973
|
this._state.remoteBasepoints = session.getRemoteBasepoints();
|
|
4927
4974
|
this._state.remoteCurrentPerCommitmentPoint = msg.firstPerCommitmentPoint;
|
|
4928
4975
|
this._state.channelId = (0, validation_1.deriveV2ChannelId)(this._state.localBasepoints.revocationBasepoint, this._state.remoteBasepoints.revocationBasepoint);
|
|
@@ -5819,7 +5866,7 @@ class Channel {
|
|
|
5819
5866
|
txid,
|
|
5820
5867
|
witnesses
|
|
5821
5868
|
};
|
|
5822
|
-
|
|
5869
|
+
const actions = [
|
|
5823
5870
|
{ type: channel_actions_1.ChannelActionType.PERSIST_STATE },
|
|
5824
5871
|
sendMsg(types_1.MessageType.TX_SIGNATURES, (0, interactive_tx_1.encodeTxSignaturesMessage)(msg)),
|
|
5825
5872
|
{
|
|
@@ -5829,6 +5876,12 @@ class Channel {
|
|
|
5829
5876
|
minimumDepth: this._state.minimumDepth
|
|
5830
5877
|
}
|
|
5831
5878
|
];
|
|
5879
|
+
if (this._state.state === types_2.ChannelState.AWAITING_FUNDING_CONFIRMED &&
|
|
5880
|
+
this._state.zeroConfEnabled &&
|
|
5881
|
+
this._state.trustedPeer) {
|
|
5882
|
+
actions.push(...this.fundingConfirmed());
|
|
5883
|
+
}
|
|
5884
|
+
return actions;
|
|
5832
5885
|
}
|
|
5833
5886
|
sendTxSignatures(txid, outputIndex, witnesses) {
|
|
5834
5887
|
const session = this._state.dualFundingSession;
|
|
@@ -5911,7 +5964,8 @@ class Channel {
|
|
|
5911
5964
|
fundingOutputIndex: this._spliceTx.newFundingOutputIndex,
|
|
5912
5965
|
minimumDepth: this._state.minimumDepth
|
|
5913
5966
|
});
|
|
5914
|
-
if (this.
|
|
5967
|
+
if (this._isZeroConfChannelType() ||
|
|
5968
|
+
this._state.spliceInFlight?.confirmed) {
|
|
5915
5969
|
actions.push(...this.sendSpliceLocked());
|
|
5916
5970
|
}
|
|
5917
5971
|
return actions;
|
|
@@ -5957,6 +6011,9 @@ class Channel {
|
|
|
5957
6011
|
});
|
|
5958
6012
|
}
|
|
5959
6013
|
}
|
|
6014
|
+
if (this._state.zeroConfEnabled && this._state.trustedPeer) {
|
|
6015
|
+
actions.push(...this.fundingConfirmed());
|
|
6016
|
+
}
|
|
5960
6017
|
}
|
|
5961
6018
|
return actions;
|
|
5962
6019
|
}
|
|
@@ -5995,7 +6052,19 @@ class Channel {
|
|
|
5995
6052
|
}
|
|
5996
6053
|
return built.tx.toBuffer();
|
|
5997
6054
|
}
|
|
6055
|
+
_isZeroConfChannelType() {
|
|
6056
|
+
return (this._state.channelType !== null &&
|
|
6057
|
+
flags_1.FeatureFlags.fromBuffer(this._state.channelType).hasFeature(flags_1.Feature.ZERO_CONF));
|
|
6058
|
+
}
|
|
5998
6059
|
initiateTxRbf(newFeeratePerkw, newLocktime) {
|
|
6060
|
+
if (this._isZeroConfChannelType()) {
|
|
6061
|
+
return [
|
|
6062
|
+
{
|
|
6063
|
+
type: channel_actions_1.ChannelActionType.ERROR,
|
|
6064
|
+
message: 'tx_init_rbf is forbidden on an option_zeroconf channel'
|
|
6065
|
+
}
|
|
6066
|
+
];
|
|
6067
|
+
}
|
|
5999
6068
|
const session = this._state.dualFundingSession;
|
|
6000
6069
|
if (!session) {
|
|
6001
6070
|
return [
|
|
@@ -6020,6 +6089,9 @@ class Channel {
|
|
|
6020
6089
|
return [sendMsg(types_1.MessageType.TX_INIT_RBF, (0, interactive_tx_1.encodeTxInitRbfMessage)(msg))];
|
|
6021
6090
|
}
|
|
6022
6091
|
handleTxInitRbf(msg) {
|
|
6092
|
+
if (this._isZeroConfChannelType()) {
|
|
6093
|
+
return this._failChannelWithWireError('tx_init_rbf is forbidden on an option_zeroconf channel');
|
|
6094
|
+
}
|
|
6023
6095
|
if (this._spliceSession && !this._spliceSession.isComplete()) {
|
|
6024
6096
|
return [
|
|
6025
6097
|
sendMsg(types_1.MessageType.TX_ABORT, (0, interactive_tx_1.encodeTxAbortMessage)({
|