@@ -20,7 +20,6 @@ import akka.actor.{ActorRef, PossiblyHarmful, typed}
2020import fr .acinq .bitcoin .scalacompat .Crypto .PublicKey
2121import fr .acinq .bitcoin .scalacompat .{ByteVector32 , DeterministicWallet , OutPoint , Satoshi , SatoshiLong , Transaction , TxId , TxOut }
2222import fr .acinq .eclair .blockchain .fee .{ConfirmationTarget , FeeratePerKw }
23- import fr .acinq .eclair .channel .LocalFundingStatus .DualFundedUnconfirmedFundingTx
2423import fr .acinq .eclair .channel .fund .InteractiveTxBuilder ._
2524import fr .acinq .eclair .channel .fund .{InteractiveTxBuilder , InteractiveTxSigningSession }
2625import fr .acinq .eclair .io .Peer
@@ -430,6 +429,7 @@ case class RevokedCommitPublished(commitTx: Transaction, localOutput_opt: Option
430429case class ShortIdAliases (localAlias : Alias , remoteAlias_opt : Option [Alias ])
431430
432431sealed trait LocalFundingStatus {
432+ /** While the transaction is unconfirmed, we keep the funding transaction (if available) to allow rebroadcasting. */
433433 def signedTx_opt : Option [Transaction ]
434434 /** We store local signatures for the purpose of retransmitting if the funding/splicing flow is interrupted. */
435435 def localSigs_opt : Option [TxSignatures ]
@@ -458,8 +458,8 @@ object LocalFundingStatus {
458458 case class ZeroconfPublishedFundingTx (tx : Transaction , localSigs_opt : Option [TxSignatures ], liquidityPurchase_opt : Option [LiquidityAds .PurchaseBasicInfo ]) extends UnconfirmedFundingTx with Locked {
459459 override val signedTx_opt : Option [Transaction ] = Some (tx)
460460 }
461- case class ConfirmedFundingTx (tx : Transaction , shortChannelId : RealShortChannelId , localSigs_opt : Option [TxSignatures ], liquidityPurchase_opt : Option [LiquidityAds .PurchaseBasicInfo ]) extends LocalFundingStatus with Locked {
462- override val signedTx_opt : Option [Transaction ] = Some (tx)
461+ case class ConfirmedFundingTx (txOut : TxOut , shortChannelId : RealShortChannelId , localSigs_opt : Option [TxSignatures ], liquidityPurchase_opt : Option [LiquidityAds .PurchaseBasicInfo ]) extends LocalFundingStatus with Locked {
462+ override val signedTx_opt : Option [Transaction ] = None
463463 }
464464}
465465
@@ -567,23 +567,34 @@ final case class DATA_WAIT_FOR_ACCEPT_CHANNEL(initFunder: INPUT_INIT_CHANNEL_INI
567567 val channelId : ByteVector32 = initFunder.temporaryChannelId
568568}
569569final case class DATA_WAIT_FOR_FUNDING_INTERNAL (channelParams : ChannelParams ,
570+ channelType : SupportedChannelType ,
571+ localCommitParams : CommitParams ,
572+ remoteCommitParams : CommitParams ,
570573 fundingAmount : Satoshi ,
571574 pushAmount : MilliSatoshi ,
572575 commitTxFeerate : FeeratePerKw ,
573576 remoteFundingPubKey : PublicKey ,
574577 remoteFirstPerCommitmentPoint : PublicKey ,
575578 replyTo : akka.actor.typed.ActorRef [Peer .OpenChannelResponse ]) extends TransientChannelData {
576579 val channelId : ByteVector32 = channelParams.channelId
580+ val commitmentFormat : CommitmentFormat = channelType.commitmentFormat
577581}
578582final case class DATA_WAIT_FOR_FUNDING_CREATED (channelParams : ChannelParams ,
583+ channelType : SupportedChannelType ,
584+ localCommitParams : CommitParams ,
585+ remoteCommitParams : CommitParams ,
579586 fundingAmount : Satoshi ,
580587 pushAmount : MilliSatoshi ,
581588 commitTxFeerate : FeeratePerKw ,
582589 remoteFundingPubKey : PublicKey ,
583590 remoteFirstPerCommitmentPoint : PublicKey ) extends TransientChannelData {
584591 val channelId : ByteVector32 = channelParams.channelId
592+ val commitmentFormat : CommitmentFormat = channelType.commitmentFormat
585593}
586594final case class DATA_WAIT_FOR_FUNDING_SIGNED (channelParams : ChannelParams ,
595+ channelType : SupportedChannelType ,
596+ localCommitParams : CommitParams ,
597+ remoteCommitParams : CommitParams ,
587598 remoteFundingPubKey : PublicKey ,
588599 fundingTx : Transaction ,
589600 fundingTxFee : Satoshi ,
@@ -593,6 +604,7 @@ final case class DATA_WAIT_FOR_FUNDING_SIGNED(channelParams: ChannelParams,
593604 lastSent : FundingCreated ,
594605 replyTo : akka.actor.typed.ActorRef [Peer .OpenChannelResponse ]) extends TransientChannelData {
595606 val channelId : ByteVector32 = channelParams.channelId
607+ val commitmentFormat : CommitmentFormat = channelType.commitmentFormat
596608}
597609final case class DATA_WAIT_FOR_FUNDING_CONFIRMED (commitments : Commitments ,
598610 waitingSince : BlockHeight , // how long have we been waiting for the funding tx to confirm
@@ -610,6 +622,8 @@ final case class DATA_WAIT_FOR_ACCEPT_DUAL_FUNDED_CHANNEL(init: INPUT_INIT_CHANN
610622}
611623final case class DATA_WAIT_FOR_DUAL_FUNDING_CREATED (channelId : ByteVector32 ,
612624 channelParams : ChannelParams ,
625+ localCommitParams : CommitParams ,
626+ remoteCommitParams : CommitParams ,
613627 secondRemotePerCommitmentPoint : PublicKey ,
614628 localPushAmount : MilliSatoshi ,
615629 remotePushAmount : MilliSatoshi ,
@@ -620,29 +634,28 @@ final case class DATA_WAIT_FOR_DUAL_FUNDING_SIGNED(channelParams: ChannelParams,
620634 secondRemotePerCommitmentPoint : PublicKey ,
621635 localPushAmount : MilliSatoshi ,
622636 remotePushAmount : MilliSatoshi ,
623- signingSession : InteractiveTxSigningSession .WaitingForSigs ,
624- remoteChannelData_opt : Option [ByteVector ]) extends ChannelDataWithoutCommitments
637+ signingSession : InteractiveTxSigningSession .WaitingForSigs ) extends ChannelDataWithoutCommitments
625638final case class DATA_WAIT_FOR_DUAL_FUNDING_CONFIRMED (commitments : Commitments ,
626639 localPushAmount : MilliSatoshi ,
627640 remotePushAmount : MilliSatoshi ,
628641 waitingSince : BlockHeight , // how long have we been waiting for a funding tx to confirm
629642 lastChecked : BlockHeight , // last time we checked if the channel was double-spent
630643 status : DualFundingStatus ,
631644 deferred : Option [ChannelReady ]) extends ChannelDataWithCommitments {
632- def allFundingTxs : Seq [DualFundedUnconfirmedFundingTx ] = commitments.active.map(_.localFundingStatus).collect { case fundingTx : DualFundedUnconfirmedFundingTx => fundingTx }
633- def latestFundingTx : DualFundedUnconfirmedFundingTx = commitments.latest.localFundingStatus.asInstanceOf [DualFundedUnconfirmedFundingTx ]
634- def previousFundingTxs : Seq [DualFundedUnconfirmedFundingTx ] = allFundingTxs diff Seq (latestFundingTx)
645+ def allFundingTxs : Seq [LocalFundingStatus . DualFundedUnconfirmedFundingTx ] = commitments.active.map(_.localFundingStatus).collect { case fundingTx : LocalFundingStatus . DualFundedUnconfirmedFundingTx => fundingTx }
646+ def latestFundingTx : LocalFundingStatus . DualFundedUnconfirmedFundingTx = commitments.latest.localFundingStatus.asInstanceOf [LocalFundingStatus . DualFundedUnconfirmedFundingTx ]
647+ def previousFundingTxs : Seq [LocalFundingStatus . DualFundedUnconfirmedFundingTx ] = allFundingTxs diff Seq (latestFundingTx)
635648}
636649final case class DATA_WAIT_FOR_DUAL_FUNDING_READY (commitments : Commitments , aliases : ShortIdAliases ) extends ChannelDataWithCommitments
637650
638651final case class DATA_NORMAL (commitments : Commitments ,
639652 aliases : ShortIdAliases ,
640653 lastAnnouncement_opt : Option [ChannelAnnouncement ],
641654 channelUpdate : ChannelUpdate ,
655+ spliceStatus : SpliceStatus ,
642656 localShutdown : Option [Shutdown ],
643657 remoteShutdown : Option [Shutdown ],
644- closeStatus_opt : Option [CloseStatus ],
645- spliceStatus : SpliceStatus ) extends ChannelDataWithCommitments {
658+ closeStatus_opt : Option [CloseStatus ]) extends ChannelDataWithCommitments {
646659 val lastAnnouncedCommitment_opt : Option [AnnouncedCommitment ] = lastAnnouncement_opt.flatMap(ann => commitments.resolveCommitment(ann.shortChannelId).map(c => AnnouncedCommitment (c, ann)))
647660 val lastAnnouncedFundingTxId_opt : Option [TxId ] = lastAnnouncedCommitment_opt.map(_.fundingTxId)
648661 val isNegotiatingQuiescence : Boolean = spliceStatus.isNegotiatingQuiescence
@@ -675,24 +688,21 @@ final case class DATA_CLOSING(commitments: Commitments,
675688 remoteCommitPublished : Option [RemoteCommitPublished ] = None ,
676689 nextRemoteCommitPublished : Option [RemoteCommitPublished ] = None ,
677690 futureRemoteCommitPublished : Option [RemoteCommitPublished ] = None ,
678- revokedCommitPublished : List [RevokedCommitPublished ] = Nil ) extends ChannelDataWithCommitments {
691+ revokedCommitPublished : List [RevokedCommitPublished ] = Nil ,
692+ maxClosingFeerate_opt : Option [FeeratePerKw ] = None ) extends ChannelDataWithCommitments {
679693 val spendingTxs : List [Transaction ] = mutualClosePublished.map(_.tx) ::: localCommitPublished.map(_.commitTx).toList ::: remoteCommitPublished.map(_.commitTx).toList ::: nextRemoteCommitPublished.map(_.commitTx).toList ::: futureRemoteCommitPublished.map(_.commitTx).toList ::: revokedCommitPublished.map(_.commitTx)
680694 require(spendingTxs.nonEmpty, " there must be at least one tx published in this state" )
681695}
682696
683697final case class DATA_WAIT_FOR_REMOTE_PUBLISH_FUTURE_COMMITMENT (commitments : Commitments , remoteChannelReestablish : ChannelReestablish ) extends ChannelDataWithCommitments
684698
699+ /** Local params that apply for the channel's lifetime. */
685700case class LocalChannelParams (nodeId : PublicKey ,
686701 fundingKeyPath : DeterministicWallet .KeyPath ,
687- dustLimit : Satoshi ,
688- maxHtlcValueInFlightMsat : UInt64 ,
689702 // Channel reserve applied to the remote peer, if we're not using [[Features.DualFunding]] (in
690703 // which case the reserve is set to 1%). If the channel is spliced, this initial value will be
691704 // ignored in favor of a 1% reserve of the resulting capacity.
692705 initialRequestedChannelReserve_opt : Option [Satoshi ],
693- htlcMinimum : MilliSatoshi ,
694- toRemoteDelay : CltvExpiryDelta ,
695- maxAcceptedHtlcs : Int ,
696706 isChannelOpener : Boolean ,
697707 paysCommitTxFees : Boolean ,
698708 upfrontShutdownScript_opt : Option [ByteVector ],
@@ -704,18 +714,12 @@ case class LocalChannelParams(nodeId: PublicKey,
704714 // The node responsible for the commit tx fees is also the node paying the mutual close fees.
705715 // The other node's balance may be empty, which wouldn't allow them to pay the closing fees.
706716 val paysClosingFees : Boolean = paysCommitTxFees
707-
708- val proposedCommitParams : ProposedCommitParams = ProposedCommitParams (dustLimit, htlcMinimum, maxHtlcValueInFlightMsat, maxAcceptedHtlcs, toRemoteDelay)
709717}
710718
719+ /** Remote params that apply for the channel's lifetime. */
711720case class RemoteChannelParams (nodeId : PublicKey ,
712- dustLimit : Satoshi ,
713- maxHtlcValueInFlightMsat : UInt64 ,
714721 // See comment in LocalChannelParams for details.
715722 initialRequestedChannelReserve_opt : Option [Satoshi ],
716- htlcMinimum : MilliSatoshi ,
717- toRemoteDelay : CltvExpiryDelta ,
718- maxAcceptedHtlcs : Int ,
719723 revocationBasepoint : PublicKey ,
720724 paymentBasepoint : PublicKey ,
721725 delayedPaymentBasepoint : PublicKey ,
0 commit comments