lnwallet: fix race condition when forwarding by creating new pubkey
This commit fixes a race condition that would at times occur in the htlcswitch.TestChannelLinkBidirectionalOneHopPayments test case. A race condition would occur in the goroutine running ReceiveNewCommitment compared with the grouting that would obtain the snapshot in order to make a forwarding decision. We fix this by creating a new public key for each new commitment transaction such that we complete avoid the read/write race condition.
This commit is contained in:
1 file changed
+6
-2
+6
-2
@@ -1838,11 +1838,15 @@ func (lc *LightningChannel) ReceiveNewCommitment(rawSig []byte) error {
|
|||||||
|
|
||||||
// Ensure that the newly constructed commitment state has a valid
|
// Ensure that the newly constructed commitment state has a valid
|
||||||
// signature.
|
// signature.
|
||||||
theirMultiSigKey.Curve = btcec.S256()
|
verifyKey := btcec.PublicKey{
|
||||||
|
X: theirMultiSigKey.X,
|
||||||
|
Y: theirMultiSigKey.Y,
|
||||||
|
Curve: btcec.S256(),
|
||||||
|
}
|
||||||
sig, err := btcec.ParseSignature(rawSig, btcec.S256())
|
sig, err := btcec.ParseSignature(rawSig, btcec.S256())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
} else if !sig.Verify(sigHash, theirMultiSigKey) {
|
} else if !sig.Verify(sigHash, &verifyKey) {
|
||||||
return fmt.Errorf("invalid commitment signature")
|
return fmt.Errorf("invalid commitment signature")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user