lnwallet: Split tx generation code out of fetchCommitmentView.
This moves the commitment transaction generation code out of fetchCommitmentView into createCommitmentTx. Aside from being a pretty clean logical split, this allows the transaction generation code to be unit tested more effectively.
This commit is contained in:
1 parent
bd497438af
commit
7c1ae8bda3
2 files changed
+137
-123
No files matched your search
@@ -1046,30 +1046,21 @@ func SingleTweakBytes(commitPoint, basePoint *btcec.PublicKey) []byte {
|
||||
// TODO(roasbeef): should be using double-scalar mult here
|
||||
func TweakPubKey(basePoint, commitPoint *btcec.PublicKey) *btcec.PublicKey {
|
||||
tweakBytes := SingleTweakBytes(commitPoint, basePoint)
|
||||
tweakX, tweakY := btcec.S256().ScalarBaseMult(tweakBytes)
|
||||
|
||||
// TODO(roasbeef): check that both passed on curve?
|
||||
|
||||
x, y := btcec.S256().Add(basePoint.X, basePoint.Y, tweakX, tweakY)
|
||||
|
||||
return &btcec.PublicKey{
|
||||
X: x,
|
||||
Y: y,
|
||||
Curve: btcec.S256(),
|
||||
}
|
||||
return TweakPubKeyWithTweak(basePoint, tweakBytes)
|
||||
}
|
||||
|
||||
// TweakPubKeyWithTweak is the exact same as the TweakPubKey function, however
|
||||
// it accepts the raw tweak bytes directly rather than the commitment point.
|
||||
func TweakPubKeyWithTweak(pubKey *btcec.PublicKey, tweakBytes []byte) *btcec.PublicKey {
|
||||
tweakX, tweakY := btcec.S256().ScalarBaseMult(tweakBytes)
|
||||
|
||||
x, y := btcec.S256().Add(pubKey.X, pubKey.Y, tweakX, tweakY)
|
||||
curve := btcec.S256()
|
||||
tweakX, tweakY := curve.ScalarBaseMult(tweakBytes)
|
||||
|
||||
// TODO(roasbeef): check that both passed on curve?
|
||||
x, y := curve.Add(pubKey.X, pubKey.Y, tweakX, tweakY)
|
||||
return &btcec.PublicKey{
|
||||
X: x,
|
||||
Y: y,
|
||||
Curve: btcec.S256(),
|
||||
Curve: curve,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user