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:
parent
9dd5af4990
commit
5dd7b157a0
@ -1838,11 +1838,15 @@ func (lc *LightningChannel) ReceiveNewCommitment(rawSig []byte) error {
|
||||
|
||||
// Ensure that the newly constructed commitment state has a valid
|
||||
// signature.
|
||||
theirMultiSigKey.Curve = btcec.S256()
|
||||
verifyKey := btcec.PublicKey{
|
||||
X: theirMultiSigKey.X,
|
||||
Y: theirMultiSigKey.Y,
|
||||
Curve: btcec.S256(),
|
||||
}
|
||||
sig, err := btcec.ParseSignature(rawSig, btcec.S256())
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !sig.Verify(sigHash, theirMultiSigKey) {
|
||||
} else if !sig.Verify(sigHash, &verifyKey) {
|
||||
return fmt.Errorf("invalid commitment signature")
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user