Skip to content

Commit

Permalink
Ignore duplicate dual-funding signatures (#2770)
Browse files Browse the repository at this point in the history
If our peer sends us some `tx_signatures` that we already received, we
can safely ignore them.
  • Loading branch information
t-bast authored Nov 3, 2023
1 parent a3d90ad commit 5b11f76
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,9 @@ trait ChannelOpenDualFunded extends DualFundingHandlers with ErrorHandlers {
val d1 = DATA_WAIT_FOR_DUAL_FUNDING_CONFIRMED(commitments1, d.localPushAmount, d.remotePushAmount, d.waitingSince, d.lastChecked, RbfStatus.NoRbf, d.deferred)
stay() using d1 storing() sending signingSession1.localSigs calling publishFundingTx(signingSession1.fundingTx)
}
case _ if d.commitments.all.exists(_.fundingTxId == txSigs.txId) =>
log.debug("ignoring tx_signatures that we already received for txId={}", txSigs.txId)
stay()
case _ =>
log.debug("rejecting unexpected tx_signatures for txId={}", txSigs.txId)
reportRbfFailure(d.rbfStatus, UnexpectedFundingSignatures(d.channelId))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,30 @@ class WaitForDualFundingConfirmedStateSpec extends TestKitBaseClass with Fixture

val aliceSigs = alice.stateData.asInstanceOf[DATA_WAIT_FOR_DUAL_FUNDING_CONFIRMED].latestFundingTx.sharedTx.localSigs
alice2bob.forward(bob, aliceSigs)
bob2alice.expectMsgType[TxAbort]
bob2alice.expectNoMessage(100 millis)

val bobSigs = bob.stateData.asInstanceOf[DATA_WAIT_FOR_DUAL_FUNDING_CONFIRMED].latestFundingTx.sharedTx.localSigs
bob2alice.forward(alice, bobSigs)
alice2bob.expectMsgType[TxAbort]
alice2bob.expectNoMessage(100 millis)

assert(alice.stateName == WAIT_FOR_DUAL_FUNDING_CONFIRMED)
assert(bob.stateName == WAIT_FOR_DUAL_FUNDING_CONFIRMED)
}

test("recv TxSignatures (duplicate, rbf attempt)", Tag(ChannelStateTestsTags.DualFunding)) { f =>
import f._

val aliceSigs = alice.stateData.asInstanceOf[DATA_WAIT_FOR_DUAL_FUNDING_CONFIRMED].latestFundingTx.sharedTx.localSigs
val bobSigs = bob.stateData.asInstanceOf[DATA_WAIT_FOR_DUAL_FUNDING_CONFIRMED].latestFundingTx.sharedTx.localSigs
val rbfTx = testBumpFundingFees(f)

alice2bob.forward(bob, aliceSigs)
alice2bob.forward(bob, rbfTx.localSigs)
bob2alice.expectNoMessage(100 millis)

bob2alice.forward(alice, bobSigs)
bob2alice.forward(alice, rbfTx.remoteSigs)
alice2bob.expectNoMessage(100 millis)

assert(alice.stateName == WAIT_FOR_DUAL_FUNDING_CONFIRMED)
assert(bob.stateName == WAIT_FOR_DUAL_FUNDING_CONFIRMED)
Expand Down

0 comments on commit 5b11f76

Please sign in to comment.