@@ -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)
@@ -2371,7 +2371,7 @@ class Channel(val nodeParams: NodeParams, val channelKeys: ChannelKeys, val wall
23712371 case Event (INPUT_RECONNECTED (r, localInit, remoteInit), d : DATA_WAIT_FOR_DUAL_FUNDING_SIGNED ) =>
23722372 activeConnection = r
23732373 val myFirstPerCommitmentPoint = channelKeys.commitmentPoint(0 )
2374- val nextFundingTlv : Set [ChannelReestablishTlv ] = Set (ChannelReestablishTlv .NextFundingTlv (d.signingSession.fundingTxId))
2374+ val nextFundingTlv = Set [ChannelReestablishTlv ](ChannelReestablishTlv .NextFundingTlv (d.signingSession.fundingTxId, d.signingSession.retransmitRemoteCommitSig ))
23752375 val nonceTlvs = d.signingSession.fundingParams.commitmentFormat match {
23762376 case _ : SegwitV0CommitmentFormat => Set .empty
23772377 case _ : SimpleTaprootChannelCommitmentFormat =>
@@ -2389,7 +2389,7 @@ class Channel(val nodeParams: NodeParams, val channelKeys: ChannelKeys, val wall
23892389 }
23902390 val channelReestablish = ChannelReestablish (
23912391 channelId = d.channelId,
2392- nextLocalCommitmentNumber = d.signingSession.nextLocalCommitmentNumber ,
2392+ nextLocalCommitmentNumber = 1 ,
23932393 nextRemoteRevocationNumber = 0 ,
23942394 yourLastPerCommitmentSecret = PrivateKey (ByteVector32 .Zeroes ),
23952395 myCurrentPerCommitmentPoint = myFirstPerCommitmentPoint,
@@ -2403,31 +2403,19 @@ class Channel(val nodeParams: NodeParams, val channelKeys: ChannelKeys, val wall
24032403 val remotePerCommitmentSecrets = d.commitments.remotePerCommitmentSecrets
24042404 val yourLastPerCommitmentSecret = remotePerCommitmentSecrets.lastIndex.flatMap(remotePerCommitmentSecrets.getHash).getOrElse(ByteVector32 .Zeroes )
24052405 val myCurrentPerCommitmentPoint = channelKeys.commitmentPoint(d.commitments.localCommitIndex)
2406- // If we disconnected while signing a funding transaction, we may need our peer to retransmit their commit_sig.
2407- val nextLocalCommitmentNumber = d match {
2408- case d : DATA_WAIT_FOR_DUAL_FUNDING_CONFIRMED => d.status match {
2409- case DualFundingStatus .RbfWaitingForSigs (status) => status.nextLocalCommitmentNumber
2410- case _ => d.commitments.localCommitIndex + 1
2411- }
2412- case d : DATA_NORMAL => d.spliceStatus match {
2413- case SpliceStatus .SpliceWaitingForSigs (status) => status.nextLocalCommitmentNumber
2414- case _ => d.commitments.localCommitIndex + 1
2415- }
2416- case _ => d.commitments.localCommitIndex + 1
2417- }
2418- // If we disconnected while signing a funding transaction, we may need our peer to (re)transmit their tx_signatures.
2406+ // If we disconnected while signing a funding transaction, we may need our peer to (re)transmit their tx_signatures and commit_sig.
24192407 val rbfTlv : Set [ChannelReestablishTlv ] = d match {
24202408 case d : DATA_WAIT_FOR_DUAL_FUNDING_CONFIRMED => d.status match {
2421- case DualFundingStatus .RbfWaitingForSigs (status) => Set (ChannelReestablishTlv .NextFundingTlv (status.fundingTx.txId))
2409+ case DualFundingStatus .RbfWaitingForSigs (status) => Set (ChannelReestablishTlv .NextFundingTlv (status.fundingTx.txId, status.retransmitRemoteCommitSig ))
24222410 case _ => d.latestFundingTx.sharedTx match {
2423- case _ : InteractiveTxBuilder .PartiallySignedSharedTransaction => Set (ChannelReestablishTlv .NextFundingTlv (d.latestFundingTx.sharedTx.txId))
2411+ case _ : InteractiveTxBuilder .PartiallySignedSharedTransaction => Set (ChannelReestablishTlv .NextFundingTlv (d.latestFundingTx.sharedTx.txId, retransmitCommitSig = false ))
24242412 case _ : InteractiveTxBuilder .FullySignedSharedTransaction => Set .empty
24252413 }
24262414 }
24272415 case d : DATA_NORMAL => d.spliceStatus match {
2428- case SpliceStatus .SpliceWaitingForSigs (status) => Set (ChannelReestablishTlv .NextFundingTlv (status.fundingTx.txId))
2416+ case SpliceStatus .SpliceWaitingForSigs (status) => Set (ChannelReestablishTlv .NextFundingTlv (status.fundingTx.txId, status.retransmitRemoteCommitSig ))
24292417 case _ => d.commitments.latest.localFundingStatus match {
2430- case LocalFundingStatus .DualFundedUnconfirmedFundingTx (fundingTx : PartiallySignedSharedTransaction , _, _, _) => Set (ChannelReestablishTlv .NextFundingTlv (fundingTx.txId))
2418+ case LocalFundingStatus .DualFundedUnconfirmedFundingTx (fundingTx : PartiallySignedSharedTransaction , _, _, _) => Set (ChannelReestablishTlv .NextFundingTlv (fundingTx.txId, retransmitCommitSig = false ))
24312419 case _ => Set .empty
24322420 }
24332421 }
@@ -2477,7 +2465,7 @@ class Channel(val nodeParams: NodeParams, val channelKeys: ChannelKeys, val wall
24772465
24782466 val channelReestablish = ChannelReestablish (
24792467 channelId = d.channelId,
2480- nextLocalCommitmentNumber = nextLocalCommitmentNumber ,
2468+ nextLocalCommitmentNumber = d.commitments.localCommitIndex + 1 ,
24812469 nextRemoteRevocationNumber = d.commitments.remoteCommitIndex,
24822470 yourLastPerCommitmentSecret = PrivateKey (yourLastPerCommitmentSecret),
24832471 myCurrentPerCommitmentPoint = myCurrentPerCommitmentPoint,
@@ -2529,7 +2517,7 @@ class Channel(val nodeParams: NodeParams, val channelKeys: ChannelKeys, val wall
25292517 case _ =>
25302518 remoteNextCommitNonces = channelReestablish.nextCommitNonces
25312519 channelReestablish.nextFundingTxId_opt match {
2532- case Some (fundingTxId) if fundingTxId == d.signingSession.fundingTx.txId && channelReestablish.nextLocalCommitmentNumber == 0 =>
2520+ case Some (fundingTxId) if fundingTxId == d.signingSession.fundingTx.txId && channelReestablish.retransmitInteractiveTxCommitSig =>
25332521 // They haven't received our commit_sig: we retransmit it, and will send our tx_signatures once we've received
25342522 // their commit_sig or their tx_signatures (depending on who must send tx_signatures first).
25352523 val fundingParams = d.signingSession.fundingParams
@@ -2557,7 +2545,7 @@ class Channel(val nodeParams: NodeParams, val channelKeys: ChannelKeys, val wall
25572545 case Some (fundingTxId) =>
25582546 d.status match {
25592547 case DualFundingStatus .RbfWaitingForSigs (signingSession) if signingSession.fundingTx.txId == fundingTxId =>
2560- if (channelReestablish.nextLocalCommitmentNumber == 0 ) {
2548+ if (channelReestablish.retransmitInteractiveTxCommitSig ) {
25612549 // They haven't received our commit_sig: we retransmit it.
25622550 // We're also waiting for signatures from them, and will send our tx_signatures once we receive them.
25632551 val fundingParams = signingSession.fundingParams
@@ -2574,7 +2562,7 @@ class Channel(val nodeParams: NodeParams, val channelKeys: ChannelKeys, val wall
25742562 case _ if d.latestFundingTx.sharedTx.txId == fundingTxId =>
25752563 // We've already received their commit_sig and sent our tx_signatures. We retransmit our tx_signatures
25762564 // and our commit_sig if they haven't received it already.
2577- if (channelReestablish.nextLocalCommitmentNumber == 0 ) {
2565+ if (channelReestablish.retransmitInteractiveTxCommitSig ) {
25782566 val remoteNonce_opt = channelReestablish.currentCommitNonce_opt
25792567 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 {
25802568 case Left (e) => handleLocalError(e, d, Some (channelReestablish))
@@ -2612,7 +2600,7 @@ class Channel(val nodeParams: NodeParams, val channelKeys: ChannelKeys, val wall
26122600 channelReestablish.nextFundingTxId_opt match {
26132601 case Some (fundingTxId) if fundingTxId == d.commitments.latest.fundingTxId =>
26142602 d.commitments.latest.localFundingStatus.localSigs_opt match {
2615- case Some (txSigs) if channelReestablish.nextLocalCommitmentNumber == 0 =>
2603+ case Some (txSigs) if channelReestablish.retransmitInteractiveTxCommitSig =>
26162604 log.info(" re-sending commit_sig and tx_signatures for fundingTxIndex={} fundingTxId={}" , d.commitments.latest.fundingTxIndex, d.commitments.latest.fundingTxId)
26172605 val remoteNonce_opt = channelReestablish.currentCommitNonce_opt
26182606 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 {
@@ -2673,9 +2661,8 @@ class Channel(val nodeParams: NodeParams, val channelKeys: ChannelKeys, val wall
26732661 sendQueue = sendQueue ++ syncSuccess.retransmit
26742662
26752663 commitments1.remoteNextCommitInfo match {
2676- case Left (_) =>
2677- // we expect them to (re-)send the revocation immediately
2678- startSingleTimer(RevocationTimeout .toString, RevocationTimeout (commitments1.remoteCommitIndex, peer), nodeParams.channelConf.revocationTimeout)
2664+ // we expect them to (re-)send their revocation immediately
2665+ case Left (_) => startSingleTimer(RevocationTimeout .toString, RevocationTimeout (commitments1.remoteCommitIndex, peer), nodeParams.channelConf.revocationTimeout)
26792666 case _ => ()
26802667 }
26812668
@@ -3399,7 +3386,7 @@ class Channel(val nodeParams: NodeParams, val channelKeys: ChannelKeys, val wall
33993386 case Some (fundingTxId) =>
34003387 d.spliceStatus match {
34013388 case SpliceStatus .SpliceWaitingForSigs (signingSession) if signingSession.fundingTx.txId == fundingTxId =>
3402- if (channelReestablish.nextLocalCommitmentNumber == d.commitments.remoteCommitIndex ) {
3389+ if (channelReestablish.retransmitInteractiveTxCommitSig ) {
34033390 // They haven't received our commit_sig: we retransmit it.
34043391 // We're also waiting for signatures from them, and will send our tx_signatures once we receive them.
34053392 log.info(" re-sending commit_sig for splice attempt with fundingTxIndex={} fundingTxId={}" , signingSession.fundingTxIndex, signingSession.fundingTx.txId)
@@ -3416,7 +3403,7 @@ class Channel(val nodeParams: NodeParams, val channelKeys: ChannelKeys, val wall
34163403 case dfu : LocalFundingStatus .DualFundedUnconfirmedFundingTx =>
34173404 // We've already received their commit_sig and sent our tx_signatures. We retransmit our
34183405 // tx_signatures and our commit_sig if they haven't received it already.
3419- if (channelReestablish.nextLocalCommitmentNumber == d.commitments.remoteCommitIndex ) {
3406+ if (channelReestablish.retransmitInteractiveTxCommitSig ) {
34203407 log.info(" re-sending commit_sig and tx_signatures for fundingTxIndex={} fundingTxId={}" , d.commitments.latest.fundingTxIndex, d.commitments.latest.fundingTxId)
34213408 val remoteNonce_opt = channelReestablish.currentCommitNonce_opt
34223409 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