lnwallet: fix bug in deriveMusig2Shachain

In this commit, we fix a bug in the `deriveMusig2Shachain` function
where it didn't actually use the passed in revocation root as part of
the hmac invocation.

We also modify the function to be more generally useable as well, as now
the caller can just pass in the revocation root things should be derived
from.
This commit is contained in:
Olaoluwa Osuntokun committed 2023-08-22 16:31:44 -07:00
1 parent 83f1bd4717
commit d2bc4f29e1
3 files changed
+19 -13

No files matched your search

+3 -11
View File
@@ -1396,17 +1396,9 @@ func NewLightningChannel(signer input.Signer,
logPrefix := fmt.Sprintf("ChannelPoint(%v):", state.FundingOutpoint)
// In order to obtain the revocation root hash to create the taproot
// revocation, we'll encode the producer into a buffer, then use that
// to derive the shachain root needed.
var rootHashBuf bytes.Buffer
if err := state.RevocationProducer.Encode(&rootHashBuf); err != nil {
return nil, fmt.Errorf("unable to encode producer: %v", err)
}
revRootHash := chainhash.HashH(rootHashBuf.Bytes())
taprootNonceProducer, err := deriveMusig2Shachain(revRootHash)
taprootNonceProducer, err := deriveMusig2Shachain(
state.RevocationProducer,
)
if err != nil {
return nil, fmt.Errorf("unable to derive shachain: %v", err)
}