@@ -26,7 +26,7 @@ import fr.acinq.eclair.transactions.CommitmentSpec
26
26
import fr .acinq .eclair .transactions .Transactions ._
27
27
import fr .acinq .eclair .wire .protocol .{AcceptChannel , ChannelAnnouncement , ChannelReestablish , ChannelUpdate , ClosingSigned , FailureMessage , FundingCreated , FundingLocked , FundingSigned , Init , OnionRoutingPacket , OpenChannel , Shutdown , UpdateAddHtlc , UpdateFailHtlc , UpdateFailMalformedHtlc , UpdateFulfillHtlc }
28
28
import fr .acinq .eclair .{CltvExpiry , CltvExpiryDelta , Features , MilliSatoshi , ShortChannelId , UInt64 }
29
- import scodec .bits .{ BitVector , ByteVector }
29
+ import scodec .bits .ByteVector
30
30
31
31
import java .util .UUID
32
32
@@ -87,8 +87,14 @@ case class INPUT_INIT_FUNDER(temporaryChannelId: ByteVector32,
87
87
remote : ActorRef ,
88
88
remoteInit : Init ,
89
89
channelFlags : Byte ,
90
- channelVersion : ChannelVersion )
91
- case class INPUT_INIT_FUNDEE (temporaryChannelId : ByteVector32 , localParams : LocalParams , remote : ActorRef , remoteInit : Init , channelVersion : ChannelVersion )
90
+ channelConfig : ChannelConfigOptions ,
91
+ supportedChannelTypes : Seq [ChannelType ])
92
+ case class INPUT_INIT_FUNDEE (temporaryChannelId : ByteVector32 ,
93
+ localParams : LocalParams ,
94
+ remote : ActorRef ,
95
+ remoteInit : Init ,
96
+ channelConfig : ChannelConfigOptions ,
97
+ channelType : ChannelType )
92
98
case object INPUT_CLOSE_COMPLETE_TIMEOUT // when requesting a mutual close, we wait for as much as this timeout, then unilateral close
93
99
case object INPUT_DISCONNECTED
94
100
case class INPUT_RECONNECTED (remote : ActorRef , localInit : Init , remoteInit : Init )
@@ -375,7 +381,8 @@ final case class DATA_WAIT_FOR_FUNDING_INTERNAL(temporaryChannelId: ByteVector32
375
381
initialFeeratePerKw : FeeratePerKw ,
376
382
initialRelayFees_opt : Option [(MilliSatoshi , Int )],
377
383
remoteFirstPerCommitmentPoint : PublicKey ,
378
- channelVersion : ChannelVersion ,
384
+ channelConfig : ChannelConfigOptions ,
385
+ channelType : ChannelType ,
379
386
lastSent : OpenChannel ) extends Data {
380
387
val channelId : ByteVector32 = temporaryChannelId
381
388
}
@@ -388,7 +395,8 @@ final case class DATA_WAIT_FOR_FUNDING_CREATED(temporaryChannelId: ByteVector32,
388
395
initialRelayFees_opt : Option [(MilliSatoshi , Int )],
389
396
remoteFirstPerCommitmentPoint : PublicKey ,
390
397
channelFlags : Byte ,
391
- channelVersion : ChannelVersion ,
398
+ channelConfig : ChannelConfigOptions ,
399
+ channelType : ChannelType ,
392
400
lastSent : AcceptChannel ) extends Data {
393
401
val channelId : ByteVector32 = temporaryChannelId
394
402
}
@@ -402,7 +410,8 @@ final case class DATA_WAIT_FOR_FUNDING_SIGNED(channelId: ByteVector32,
402
410
localCommitTx : CommitTx ,
403
411
remoteCommit : RemoteCommit ,
404
412
channelFlags : Byte ,
405
- channelVersion : ChannelVersion ,
413
+ channelConfig : ChannelConfigOptions ,
414
+ channelType : ChannelType ,
406
415
lastSent : FundingCreated ) extends Data
407
416
final case class DATA_WAIT_FOR_FUNDING_CONFIRMED (commitments : Commitments ,
408
417
fundingTx : Option [Transaction ],
@@ -445,8 +454,8 @@ final case class DATA_WAIT_FOR_REMOTE_PUBLISH_FUTURE_COMMITMENT(commitments: Com
445
454
446
455
/**
447
456
* @param features current connection features, or last features used if the channel is disconnected. Note that these
448
- * features are updated at each reconnection and may be different from the ones that were used when the
449
- * channel was created. See [[ChannelVersion ]] for permanent features associated to a channel .
457
+ * features are updated at each reconnection and may be different from the channel permanent features
458
+ * used to select the [[ChannelType ]] .
450
459
*/
451
460
final case class LocalParams (nodeId : PublicKey ,
452
461
fundingKeyPath : DeterministicWallet .KeyPath ,
@@ -482,55 +491,4 @@ object ChannelFlags {
482
491
val AnnounceChannel = 0x01 .toByte
483
492
val Empty = 0x00 .toByte
484
493
}
485
-
486
- case class ChannelVersion (bits : BitVector ) {
487
- import ChannelVersion ._
488
-
489
- require(bits.size == ChannelVersion .LENGTH_BITS , " channel version takes 4 bytes" )
490
-
491
- val commitmentFormat : CommitmentFormat = if (hasAnchorOutputs) {
492
- AnchorOutputsCommitmentFormat
493
- } else {
494
- DefaultCommitmentFormat
495
- }
496
-
497
- def | (other : ChannelVersion ) = ChannelVersion (bits | other.bits)
498
- def & (other : ChannelVersion ) = ChannelVersion (bits & other.bits)
499
- def ^ (other : ChannelVersion ) = ChannelVersion (bits ^ other.bits)
500
-
501
- def isSet (bit : Int ): Boolean = bits.reverse.get(bit)
502
-
503
- def hasPubkeyKeyPath : Boolean = isSet(USE_PUBKEY_KEYPATH_BIT )
504
- def hasStaticRemotekey : Boolean = isSet(USE_STATIC_REMOTEKEY_BIT )
505
- def hasAnchorOutputs : Boolean = isSet(USE_ANCHOR_OUTPUTS_BIT )
506
- /** True if our main output in the remote commitment is directly sent (without any delay) to one of our wallet addresses. */
507
- def paysDirectlyToWallet : Boolean = hasStaticRemotekey && ! hasAnchorOutputs
508
- }
509
-
510
- object ChannelVersion {
511
- import scodec .bits ._
512
-
513
- val LENGTH_BITS : Int = 4 * 8
514
-
515
- private val USE_PUBKEY_KEYPATH_BIT = 0 // bit numbers start at 0
516
- private val USE_STATIC_REMOTEKEY_BIT = 1
517
- private val USE_ANCHOR_OUTPUTS_BIT = 2
518
-
519
- def fromBit (bit : Int ): ChannelVersion = ChannelVersion (BitVector .low(LENGTH_BITS ).set(bit).reverse)
520
-
521
- def pickChannelVersion (localFeatures : Features , remoteFeatures : Features ): ChannelVersion = {
522
- if (Features .canUseFeature(localFeatures, remoteFeatures, Features .AnchorOutputs )) {
523
- ANCHOR_OUTPUTS
524
- } else if (Features .canUseFeature(localFeatures, remoteFeatures, Features .StaticRemoteKey )) {
525
- STATIC_REMOTEKEY
526
- } else {
527
- STANDARD
528
- }
529
- }
530
-
531
- val ZEROES = ChannelVersion (bin " 00000000000000000000000000000000 " )
532
- val STANDARD = ZEROES | fromBit(USE_PUBKEY_KEYPATH_BIT )
533
- val STATIC_REMOTEKEY = STANDARD | fromBit(USE_STATIC_REMOTEKEY_BIT ) // PUBKEY_KEYPATH + STATIC_REMOTEKEY
534
- val ANCHOR_OUTPUTS = STATIC_REMOTEKEY | fromBit(USE_ANCHOR_OUTPUTS_BIT ) // PUBKEY_KEYPATH + STATIC_REMOTEKEY + ANCHOR_OUTPUTS
535
- }
536
494
// @formatter:on
0 commit comments