@@ -651,7 +651,7 @@ class Channel(val nodeParams: NodeParams, val channelKeys: ChannelKeys, val wall
651651 case (s : SpliceStatus .SpliceInProgress , sig : CommitSig ) =>
652652 log.debug(" received their commit_sig, deferring message" )
653653 stay() using d.copy(spliceStatus = s.copy(remoteCommitSig = Some (sig)))
654- case (SpliceStatus .SpliceAborted , sig : CommitSig ) =>
654+ case (SpliceStatus .SpliceAborted , _ : CommitSig ) =>
655655 log.warning(" received commit_sig after sending tx_abort, they probably sent it before receiving our tx_abort, ignoring..." )
656656 stay()
657657 case (SpliceStatus .SpliceWaitingForSigs (signingSession), sig : CommitSig ) =>
@@ -1456,7 +1456,7 @@ class Channel(val nodeParams: NodeParams, val channelKeys: ChannelKeys, val wall
14561456 case Event (w : WatchPublishedTriggered , d : DATA_NORMAL ) =>
14571457 val fundingStatus = LocalFundingStatus .ZeroconfPublishedFundingTx (w.tx, d.commitments.localFundingSigs(w.tx.txid), d.commitments.liquidityPurchase(w.tx.txid))
14581458 d.commitments.updateLocalFundingStatus(w.tx.txid, fundingStatus, d.lastAnnouncedFundingTxId_opt) match {
1459- case Right ((commitments1, commitment )) =>
1459+ case Right ((commitments1, _ )) =>
14601460 watchFundingConfirmed(w.tx.txid, Some (nodeParams.channelConf.minDepth), delay_opt = None )
14611461 maybeEmitEventsPostSplice(d.aliases, d.commitments, commitments1, d.lastAnnouncement_opt)
14621462 maybeUpdateMaxHtlcAmount(d.channelUpdate.htlcMaximumMsat, commitments1)
@@ -2370,7 +2370,7 @@ class Channel(val nodeParams: NodeParams, val channelKeys: ChannelKeys, val wall
23702370 case Event (INPUT_RECONNECTED (r, localInit, remoteInit), d : DATA_WAIT_FOR_DUAL_FUNDING_SIGNED ) =>
23712371 activeConnection = r
23722372 val myFirstPerCommitmentPoint = channelKeys.commitmentPoint(0 )
2373- val nextFundingTlv : Set [ChannelReestablishTlv ] = Set (ChannelReestablishTlv .NextFundingTlv (d.signingSession.fundingTxId))
2373+ val nextFundingTlv = Set [ChannelReestablishTlv ](ChannelReestablishTlv .NextFundingTlv (d.signingSession.fundingTxId, d.signingSession.retransmitRemoteCommitSig ))
23742374 val nonceTlvs = d.signingSession.fundingParams.commitmentFormat match {
23752375 case _ : SegwitV0CommitmentFormat => Set .empty
23762376 case _ : SimpleTaprootChannelCommitmentFormat =>
@@ -2388,7 +2388,7 @@ class Channel(val nodeParams: NodeParams, val channelKeys: ChannelKeys, val wall
23882388 }
23892389 val channelReestablish = ChannelReestablish (
23902390 channelId = d.channelId,
2391- nextLocalCommitmentNumber = d.signingSession.nextLocalCommitmentNumber ,
2391+ nextLocalCommitmentNumber = 1 ,
23922392 nextRemoteRevocationNumber = 0 ,
23932393 yourLastPerCommitmentSecret = PrivateKey (ByteVector32 .Zeroes ),
23942394 myCurrentPerCommitmentPoint = myFirstPerCommitmentPoint,
@@ -2402,31 +2402,19 @@ class Channel(val nodeParams: NodeParams, val channelKeys: ChannelKeys, val wall
24022402 val remotePerCommitmentSecrets = d.commitments.remotePerCommitmentSecrets
24032403 val yourLastPerCommitmentSecret = remotePerCommitmentSecrets.lastIndex.flatMap(remotePerCommitmentSecrets.getHash).getOrElse(ByteVector32 .Zeroes )
24042404 val myCurrentPerCommitmentPoint = channelKeys.commitmentPoint(d.commitments.localCommitIndex)
2405- // If we disconnected while signing a funding transaction, we may need our peer to retransmit their commit_sig.
2406- val nextLocalCommitmentNumber = d match {
2407- case d : DATA_WAIT_FOR_DUAL_FUNDING_CONFIRMED => d.status match {
2408- case DualFundingStatus .RbfWaitingForSigs (status) => status.nextLocalCommitmentNumber
2409- case _ => d.commitments.localCommitIndex + 1
2410- }
2411- case d : DATA_NORMAL => d.spliceStatus match {
2412- case SpliceStatus .SpliceWaitingForSigs (status) => status.nextLocalCommitmentNumber
2413- case _ => d.commitments.localCommitIndex + 1
2414- }
2415- case _ => d.commitments.localCommitIndex + 1
2416- }
2417- // If we disconnected while signing a funding transaction, we may need our peer to (re)transmit their tx_signatures.
2405+ // If we disconnected while signing a funding transaction, we may need our peer to (re)transmit their tx_signatures and commit_sig.
24182406 val rbfTlv : Set [ChannelReestablishTlv ] = d match {
24192407 case d : DATA_WAIT_FOR_DUAL_FUNDING_CONFIRMED => d.status match {
2420- case DualFundingStatus .RbfWaitingForSigs (status) => Set (ChannelReestablishTlv .NextFundingTlv (status.fundingTx.txId))
2408+ case DualFundingStatus .RbfWaitingForSigs (status) => Set (ChannelReestablishTlv .NextFundingTlv (status.fundingTx.txId, status.retransmitRemoteCommitSig ))
24212409 case _ => d.latestFundingTx.sharedTx match {
2422- case _ : InteractiveTxBuilder .PartiallySignedSharedTransaction => Set (ChannelReestablishTlv .NextFundingTlv (d.latestFundingTx.sharedTx.txId))
2410+ case _ : InteractiveTxBuilder .PartiallySignedSharedTransaction => Set (ChannelReestablishTlv .NextFundingTlv (d.latestFundingTx.sharedTx.txId, retransmitCommitSig = false ))
24232411 case _ : InteractiveTxBuilder .FullySignedSharedTransaction => Set .empty
24242412 }
24252413 }
24262414 case d : DATA_NORMAL => d.spliceStatus match {
2427- case SpliceStatus .SpliceWaitingForSigs (status) => Set (ChannelReestablishTlv .NextFundingTlv (status.fundingTx.txId))
2415+ case SpliceStatus .SpliceWaitingForSigs (status) => Set (ChannelReestablishTlv .NextFundingTlv (status.fundingTx.txId, status.retransmitRemoteCommitSig ))
24282416 case _ => d.commitments.latest.localFundingStatus match {
2429- case LocalFundingStatus .DualFundedUnconfirmedFundingTx (fundingTx : PartiallySignedSharedTransaction , _, _, _) => Set (ChannelReestablishTlv .NextFundingTlv (fundingTx.txId))
2417+ case LocalFundingStatus .DualFundedUnconfirmedFundingTx (fundingTx : PartiallySignedSharedTransaction , _, _, _) => Set (ChannelReestablishTlv .NextFundingTlv (fundingTx.txId, retransmitCommitSig = false ))
24302418 case _ => Set .empty
24312419 }
24322420 }
@@ -2476,7 +2464,7 @@ class Channel(val nodeParams: NodeParams, val channelKeys: ChannelKeys, val wall
24762464
24772465 val channelReestablish = ChannelReestablish (
24782466 channelId = d.channelId,
2479- nextLocalCommitmentNumber = nextLocalCommitmentNumber ,
2467+ nextLocalCommitmentNumber = d.commitments.localCommitIndex + 1 ,
24802468 nextRemoteRevocationNumber = d.commitments.remoteCommitIndex,
24812469 yourLastPerCommitmentSecret = PrivateKey (yourLastPerCommitmentSecret),
24822470 myCurrentPerCommitmentPoint = myCurrentPerCommitmentPoint,
@@ -2528,7 +2516,7 @@ class Channel(val nodeParams: NodeParams, val channelKeys: ChannelKeys, val wall
25282516 case _ =>
25292517 remoteNextCommitNonces = channelReestablish.nextCommitNonces
25302518 channelReestablish.nextFundingTxId_opt match {
2531- case Some (fundingTxId) if fundingTxId == d.signingSession.fundingTx.txId && channelReestablish.nextLocalCommitmentNumber == 0 =>
2519+ case Some (fundingTxId) if fundingTxId == d.signingSession.fundingTx.txId && channelReestablish.retransmitInteractiveTxCommitSig =>
25322520 // They haven't received our commit_sig: we retransmit it, and will send our tx_signatures once we've received
25332521 // their commit_sig or their tx_signatures (depending on who must send tx_signatures first).
25342522 val fundingParams = d.signingSession.fundingParams
@@ -2556,7 +2544,7 @@ class Channel(val nodeParams: NodeParams, val channelKeys: ChannelKeys, val wall
25562544 case Some (fundingTxId) =>
25572545 d.status match {
25582546 case DualFundingStatus .RbfWaitingForSigs (signingSession) if signingSession.fundingTx.txId == fundingTxId =>
2559- if (channelReestablish.nextLocalCommitmentNumber == 0 ) {
2547+ if (channelReestablish.retransmitInteractiveTxCommitSig ) {
25602548 // They haven't received our commit_sig: we retransmit it.
25612549 // We're also waiting for signatures from them, and will send our tx_signatures once we receive them.
25622550 val fundingParams = signingSession.fundingParams
@@ -2573,7 +2561,7 @@ class Channel(val nodeParams: NodeParams, val channelKeys: ChannelKeys, val wall
25732561 case _ if d.latestFundingTx.sharedTx.txId == fundingTxId =>
25742562 // We've already received their commit_sig and sent our tx_signatures. We retransmit our tx_signatures
25752563 // and our commit_sig if they haven't received it already.
2576- if (channelReestablish.nextLocalCommitmentNumber == 0 ) {
2564+ if (channelReestablish.retransmitInteractiveTxCommitSig ) {
25772565 val remoteNonce_opt = channelReestablish.currentCommitNonce_opt
25782566 d.commitments.latest.remoteCommit.sign(d.commitments.channelParams, d.commitments.latest.remoteCommitParams, channelKeys, d.commitments.latest.fundingTxIndex, d.commitments.latest.remoteFundingPubKey, d.commitments.latest.commitInput(channelKeys), d.commitments.latest.commitmentFormat, remoteNonce_opt) match {
25792567 case Left (e) => handleLocalError(e, d, Some (channelReestablish))
@@ -2611,7 +2599,7 @@ class Channel(val nodeParams: NodeParams, val channelKeys: ChannelKeys, val wall
26112599 channelReestablish.nextFundingTxId_opt match {
26122600 case Some (fundingTxId) if fundingTxId == d.commitments.latest.fundingTxId =>
26132601 d.commitments.latest.localFundingStatus.localSigs_opt match {
2614- case Some (txSigs) if channelReestablish.nextLocalCommitmentNumber == 0 =>
2602+ case Some (txSigs) if channelReestablish.retransmitInteractiveTxCommitSig =>
26152603 log.info(" re-sending commit_sig and tx_signatures for fundingTxIndex={} fundingTxId={}" , d.commitments.latest.fundingTxIndex, d.commitments.latest.fundingTxId)
26162604 val remoteNonce_opt = channelReestablish.currentCommitNonce_opt
26172605 d.commitments.latest.remoteCommit.sign(d.commitments.channelParams, d.commitments.latest.remoteCommitParams, channelKeys, d.commitments.latest.fundingTxIndex, d.commitments.latest.remoteFundingPubKey, d.commitments.latest.commitInput(channelKeys), d.commitments.latest.commitmentFormat, remoteNonce_opt) match {
@@ -2672,9 +2660,8 @@ class Channel(val nodeParams: NodeParams, val channelKeys: ChannelKeys, val wall
26722660 sendQueue = sendQueue ++ syncSuccess.retransmit
26732661
26742662 commitments1.remoteNextCommitInfo match {
2675- case Left (_) =>
2676- // we expect them to (re-)send the revocation immediately
2677- startSingleTimer(RevocationTimeout .toString, RevocationTimeout (commitments1.remoteCommitIndex, peer), nodeParams.channelConf.revocationTimeout)
2663+ // we expect them to (re-)send their revocation immediately
2664+ case Left (_) => startSingleTimer(RevocationTimeout .toString, RevocationTimeout (commitments1.remoteCommitIndex, peer), nodeParams.channelConf.revocationTimeout)
26782665 case _ => ()
26792666 }
26802667
@@ -3423,7 +3410,7 @@ class Channel(val nodeParams: NodeParams, val channelKeys: ChannelKeys, val wall
34233410 case Some (fundingTxId) =>
34243411 d.spliceStatus match {
34253412 case SpliceStatus .SpliceWaitingForSigs (signingSession) if signingSession.fundingTx.txId == fundingTxId =>
3426- if (channelReestablish.nextLocalCommitmentNumber == d.commitments.remoteCommitIndex ) {
3413+ if (channelReestablish.retransmitInteractiveTxCommitSig ) {
34273414 // They haven't received our commit_sig: we retransmit it.
34283415 // We're also waiting for signatures from them, and will send our tx_signatures once we receive them.
34293416 log.info(" re-sending commit_sig for splice attempt with fundingTxIndex={} fundingTxId={}" , signingSession.fundingTxIndex, signingSession.fundingTx.txId)
@@ -3440,7 +3427,7 @@ class Channel(val nodeParams: NodeParams, val channelKeys: ChannelKeys, val wall
34403427 case dfu : LocalFundingStatus .DualFundedUnconfirmedFundingTx =>
34413428 // We've already received their commit_sig and sent our tx_signatures. We retransmit our
34423429 // tx_signatures and our commit_sig if they haven't received it already.
3443- if (channelReestablish.nextLocalCommitmentNumber == d.commitments.remoteCommitIndex ) {
3430+ if (channelReestablish.retransmitInteractiveTxCommitSig ) {
34443431 log.info(" re-sending commit_sig and tx_signatures for fundingTxIndex={} fundingTxId={}" , d.commitments.latest.fundingTxIndex, d.commitments.latest.fundingTxId)
34453432 val remoteNonce_opt = channelReestablish.currentCommitNonce_opt
34463433 d.commitments.latest.remoteCommit.sign(d.commitments.channelParams, d.commitments.latest.remoteCommitParams, channelKeys, d.commitments.latest.fundingTxIndex, d.commitments.latest.remoteFundingPubKey, d.commitments.latest.commitInput(channelKeys), d.commitments.latest.commitmentFormat, remoteNonce_opt) match {
0 commit comments