lnwallet: don't use persistent pointer to funding tx within channel state machine

This commit fixes a lingering bug that could at times cause
incompatibilities with other implementations when attempting a
cooperative channel close. Before this commit, we would use a pointer
to the funding txin everywhere. As a result, each time we made a new
state, or verified one, we would modify the sequence field of the main
txin of the commitment transaction. Due to this if we updated the
channel, then went to do a cooperative channel closure, the sequence of
the txin would still be set to the value we used as the state hint.

To remedy this, we now copy the txin each time when making the
commitment transaction, and also the cooperative closure transaction.
This avoids accidentally mutating the txin itself.

Fixes #502.
This commit is contained in:
Olaoluwa Osuntokun
2017-12-22 19:26:16 +01:00
parent 3f2a5241c1
commit 9777176d7d
6 changed files with 13 additions and 13 deletions

View File

@@ -154,7 +154,7 @@ func createTestChannel(alicePrivKey, bobPrivKey []byte,
aliceCommitTx, bobCommitTx, err := lnwallet.CreateCommitmentTxns(aliceAmount,
bobAmount, &aliceCfg, &bobCfg, aliceCommitPoint, bobCommitPoint,
fundingTxIn)
*fundingTxIn)
if err != nil {
return nil, nil, nil, nil, err
}