multi: use btcd's btcec/v2 and btcutil modules
This commit was previously split into the following parts to ease review: - 2d746f68: replace imports - 4008f0fd: use ecdsa.Signature - 849e33d1: remove btcec.S256() - b8f6ebbd: use v2 library correctly - fa80bca9: bump go modules
This commit is contained in:
350 files changed
+2421
-1289
No files matched your search
+1
-1
@@ -1,9 +1,9 @@
|
||||
package input
|
||||
|
||||
import (
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
)
|
||||
|
||||
|
||||
+69
-49
@@ -4,12 +4,12 @@ import (
|
||||
"bytes"
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcutil"
|
||||
secp "github.com/decred/dcrd/dcrec/secp256k1/v4"
|
||||
"golang.org/x/crypto/ripemd160"
|
||||
)
|
||||
|
||||
@@ -1391,17 +1391,22 @@ func TweakPubKey(basePoint, commitPoint *btcec.PublicKey) *btcec.PublicKey {
|
||||
|
||||
// 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 {
|
||||
curve := btcec.S256()
|
||||
tweakX, tweakY := curve.ScalarBaseMult(tweakBytes)
|
||||
func TweakPubKeyWithTweak(pubKey *btcec.PublicKey,
|
||||
tweakBytes []byte) *btcec.PublicKey {
|
||||
|
||||
// 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: curve,
|
||||
}
|
||||
var (
|
||||
pubKeyJacobian btcec.JacobianPoint
|
||||
tweakJacobian btcec.JacobianPoint
|
||||
resultJacobian btcec.JacobianPoint
|
||||
)
|
||||
tweakKey := secp.PrivKeyFromBytes(tweakBytes)
|
||||
btcec.ScalarBaseMultNonConst(&tweakKey.Key, &tweakJacobian)
|
||||
|
||||
pubKey.AsJacobian(&pubKeyJacobian)
|
||||
btcec.AddNonConst(&pubKeyJacobian, &tweakJacobian, &resultJacobian)
|
||||
|
||||
resultJacobian.ToAffine()
|
||||
return btcec.NewPublicKey(&resultJacobian.X, &resultJacobian.Y)
|
||||
}
|
||||
|
||||
// TweakPrivKey tweaks the private key of a public base point given a per
|
||||
@@ -1414,15 +1419,16 @@ func TweakPubKeyWithTweak(pubKey *btcec.PublicKey, tweakBytes []byte) *btcec.Pub
|
||||
// * tweakPriv := basePriv + sha256(commitment || basePub) mod N
|
||||
//
|
||||
// Where N is the order of the sub-group.
|
||||
func TweakPrivKey(basePriv *btcec.PrivateKey, commitTweak []byte) *btcec.PrivateKey {
|
||||
func TweakPrivKey(basePriv *btcec.PrivateKey,
|
||||
commitTweak []byte) *btcec.PrivateKey {
|
||||
|
||||
// tweakInt := sha256(commitPoint || basePub)
|
||||
tweakInt := new(big.Int).SetBytes(commitTweak)
|
||||
tweakScalar := new(btcec.ModNScalar)
|
||||
tweakScalar.SetByteSlice(commitTweak)
|
||||
|
||||
tweakInt = tweakInt.Add(tweakInt, basePriv.D)
|
||||
tweakInt = tweakInt.Mod(tweakInt, btcec.S256().N)
|
||||
tweakScalar.Add(&basePriv.Key)
|
||||
|
||||
tweakPriv, _ := btcec.PrivKeyFromBytes(btcec.S256(), tweakInt.Bytes())
|
||||
return tweakPriv
|
||||
return &btcec.PrivateKey{Key: *tweakScalar}
|
||||
}
|
||||
|
||||
// DeriveRevocationPubkey derives the revocation public key given the
|
||||
@@ -1451,28 +1457,46 @@ func TweakPrivKey(basePriv *btcec.PrivateKey, commitTweak []byte) *btcec.Private
|
||||
// (commitSecret * sha256(commitPoint || revocationBase)) mod N
|
||||
//
|
||||
// Where N is the order of the sub-group.
|
||||
func DeriveRevocationPubkey(revokeBase, commitPoint *btcec.PublicKey) *btcec.PublicKey {
|
||||
func DeriveRevocationPubkey(revokeBase,
|
||||
commitPoint *btcec.PublicKey) *btcec.PublicKey {
|
||||
|
||||
// R = revokeBase * sha256(revocationBase || commitPoint)
|
||||
revokeTweakBytes := SingleTweakBytes(revokeBase, commitPoint)
|
||||
rX, rY := btcec.S256().ScalarMult(revokeBase.X, revokeBase.Y,
|
||||
revokeTweakBytes)
|
||||
revokeTweakScalar := new(btcec.ModNScalar)
|
||||
revokeTweakScalar.SetByteSlice(revokeTweakBytes)
|
||||
|
||||
var (
|
||||
revokeBaseJacobian btcec.JacobianPoint
|
||||
rJacobian btcec.JacobianPoint
|
||||
)
|
||||
revokeBase.AsJacobian(&revokeBaseJacobian)
|
||||
btcec.ScalarMultNonConst(
|
||||
revokeTweakScalar, &revokeBaseJacobian, &rJacobian,
|
||||
)
|
||||
|
||||
// C = commitPoint * sha256(commitPoint || revocationBase)
|
||||
commitTweakBytes := SingleTweakBytes(commitPoint, revokeBase)
|
||||
cX, cY := btcec.S256().ScalarMult(commitPoint.X, commitPoint.Y,
|
||||
commitTweakBytes)
|
||||
commitTweakScalar := new(btcec.ModNScalar)
|
||||
commitTweakScalar.SetByteSlice(commitTweakBytes)
|
||||
|
||||
var (
|
||||
commitPointJacobian btcec.JacobianPoint
|
||||
cJacobian btcec.JacobianPoint
|
||||
)
|
||||
commitPoint.AsJacobian(&commitPointJacobian)
|
||||
btcec.ScalarMultNonConst(
|
||||
commitTweakScalar, &commitPointJacobian, &cJacobian,
|
||||
)
|
||||
|
||||
// Now that we have the revocation point, we add this to their commitment
|
||||
// public key in order to obtain the revocation public key.
|
||||
//
|
||||
// P = R + C
|
||||
revX, revY := btcec.S256().Add(rX, rY, cX, cY)
|
||||
return &btcec.PublicKey{
|
||||
X: revX,
|
||||
Y: revY,
|
||||
Curve: btcec.S256(),
|
||||
}
|
||||
var resultJacobian btcec.JacobianPoint
|
||||
btcec.AddNonConst(&rJacobian, &cJacobian, &resultJacobian)
|
||||
|
||||
resultJacobian.ToAffine()
|
||||
return btcec.NewPublicKey(&resultJacobian.X, &resultJacobian.Y)
|
||||
}
|
||||
|
||||
// DeriveRevocationPrivKey derives the revocation private key given a node's
|
||||
@@ -1490,14 +1514,18 @@ func DeriveRevocationPrivKey(revokeBasePriv *btcec.PrivateKey,
|
||||
commitSecret *btcec.PrivateKey) *btcec.PrivateKey {
|
||||
|
||||
// r = sha256(revokeBasePub || commitPoint)
|
||||
revokeTweakBytes := SingleTweakBytes(revokeBasePriv.PubKey(),
|
||||
commitSecret.PubKey())
|
||||
revokeTweakInt := new(big.Int).SetBytes(revokeTweakBytes)
|
||||
revokeTweakBytes := SingleTweakBytes(
|
||||
revokeBasePriv.PubKey(), commitSecret.PubKey(),
|
||||
)
|
||||
revokeTweakScalar := new(btcec.ModNScalar)
|
||||
revokeTweakScalar.SetByteSlice(revokeTweakBytes)
|
||||
|
||||
// c = sha256(commitPoint || revokeBasePub)
|
||||
commitTweakBytes := SingleTweakBytes(commitSecret.PubKey(),
|
||||
revokeBasePriv.PubKey())
|
||||
commitTweakInt := new(big.Int).SetBytes(commitTweakBytes)
|
||||
commitTweakBytes := SingleTweakBytes(
|
||||
commitSecret.PubKey(), revokeBasePriv.PubKey(),
|
||||
)
|
||||
commitTweakScalar := new(btcec.ModNScalar)
|
||||
commitTweakScalar.SetByteSlice(commitTweakBytes)
|
||||
|
||||
// Finally to derive the revocation secret key we'll perform the
|
||||
// following operation:
|
||||
@@ -1508,14 +1536,12 @@ func DeriveRevocationPrivKey(revokeBasePriv *btcec.PrivateKey,
|
||||
// P = (G*a)*b + (G*c)*d
|
||||
// P = G*(a*b) + G*(c*d)
|
||||
// P = G*(a*b + c*d)
|
||||
revokeHalfPriv := revokeTweakInt.Mul(revokeTweakInt, revokeBasePriv.D)
|
||||
commitHalfPriv := commitTweakInt.Mul(commitTweakInt, commitSecret.D)
|
||||
revokeHalfPriv := revokeTweakScalar.Mul(&revokeBasePriv.Key)
|
||||
commitHalfPriv := commitTweakScalar.Mul(&commitSecret.Key)
|
||||
|
||||
revocationPriv := revokeHalfPriv.Add(revokeHalfPriv, commitHalfPriv)
|
||||
revocationPriv = revocationPriv.Mod(revocationPriv, btcec.S256().N)
|
||||
revocationPriv := revokeHalfPriv.Add(commitHalfPriv)
|
||||
|
||||
priv, _ := btcec.PrivKeyFromBytes(btcec.S256(), revocationPriv.Bytes())
|
||||
return priv
|
||||
return &btcec.PrivateKey{Key: *revocationPriv}
|
||||
}
|
||||
|
||||
// ComputeCommitmentPoint generates a commitment point given a commitment
|
||||
@@ -1523,11 +1549,5 @@ func DeriveRevocationPrivKey(revokeBasePriv *btcec.PrivateKey,
|
||||
// the key-ring and also to used as a tweak to derive new public+private keys
|
||||
// for the state.
|
||||
func ComputeCommitmentPoint(commitSecret []byte) *btcec.PublicKey {
|
||||
x, y := btcec.S256().ScalarBaseMult(commitSecret)
|
||||
|
||||
return &btcec.PublicKey{
|
||||
X: x,
|
||||
Y: y,
|
||||
Curve: btcec.S256(),
|
||||
}
|
||||
return secp.PrivKeyFromBytes(commitSecret).PubKey()
|
||||
}
|
||||
+29
-55
@@ -7,11 +7,12 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@@ -93,13 +94,11 @@ func TestRevocationKeyDerivation(t *testing.T) {
|
||||
// First, we'll generate a commitment point, and a commitment secret.
|
||||
// These will be used to derive the ultimate revocation keys.
|
||||
revocationPreimage := testHdSeed.CloneBytes()
|
||||
commitSecret, commitPoint := btcec.PrivKeyFromBytes(btcec.S256(),
|
||||
revocationPreimage)
|
||||
commitSecret, commitPoint := btcec.PrivKeyFromBytes(revocationPreimage)
|
||||
|
||||
// With the commitment secrets generated, we'll now create the base
|
||||
// keys we'll use to derive the revocation key from.
|
||||
basePriv, basePub := btcec.PrivKeyFromBytes(btcec.S256(),
|
||||
testWalletPrivKey)
|
||||
basePriv, basePub := btcec.PrivKeyFromBytes(testWalletPrivKey)
|
||||
|
||||
// With the point and key obtained, we can now derive the revocation
|
||||
// key itself.
|
||||
@@ -122,7 +121,7 @@ func TestTweakKeyDerivation(t *testing.T) {
|
||||
|
||||
// First, we'll generate a base public key that we'll be "tweaking".
|
||||
baseSecret := testHdSeed.CloneBytes()
|
||||
basePriv, basePub := btcec.PrivKeyFromBytes(btcec.S256(), baseSecret)
|
||||
basePriv, basePub := btcec.PrivKeyFromBytes(baseSecret)
|
||||
|
||||
// With the base key create, we'll now create a commitment point, and
|
||||
// from that derive the bytes we'll used to tweak the base public key.
|
||||
@@ -191,8 +190,7 @@ func TestHTLCSenderSpendValidation(t *testing.T) {
|
||||
// Next we'll the commitment secret for our commitment tx and also the
|
||||
// revocation key that we'll use as well.
|
||||
revokePreimage := testHdSeed.CloneBytes()
|
||||
commitSecret, commitPoint := btcec.PrivKeyFromBytes(btcec.S256(),
|
||||
revokePreimage)
|
||||
commitSecret, commitPoint := btcec.PrivKeyFromBytes(revokePreimage)
|
||||
|
||||
// Generate a payment preimage to be used below.
|
||||
paymentPreimage := revokePreimage
|
||||
@@ -201,10 +199,8 @@ func TestHTLCSenderSpendValidation(t *testing.T) {
|
||||
|
||||
// We'll also need some tests keys for alice and bob, and metadata of
|
||||
// the HTLC output.
|
||||
aliceKeyPriv, aliceKeyPub := btcec.PrivKeyFromBytes(btcec.S256(),
|
||||
testWalletPrivKey)
|
||||
bobKeyPriv, bobKeyPub := btcec.PrivKeyFromBytes(btcec.S256(),
|
||||
bobsPrivKey)
|
||||
aliceKeyPriv, aliceKeyPub := btcec.PrivKeyFromBytes(testWalletPrivKey)
|
||||
bobKeyPriv, bobKeyPub := btcec.PrivKeyFromBytes(bobsPrivKey)
|
||||
paymentAmt := btcutil.Amount(1 * 10e8)
|
||||
|
||||
aliceLocalKey := TweakPubKey(aliceKeyPub, commitPoint)
|
||||
@@ -228,7 +224,7 @@ func TestHTLCSenderSpendValidation(t *testing.T) {
|
||||
htlcOutput *wire.TxOut
|
||||
sweepTxSigHashes *txscript.TxSigHashes
|
||||
senderCommitTx, sweepTx *wire.MsgTx
|
||||
bobRecvrSig *btcec.Signature
|
||||
bobRecvrSig *ecdsa.Signature
|
||||
bobSigHash txscript.SigHashType
|
||||
)
|
||||
|
||||
@@ -310,9 +306,7 @@ func TestHTLCSenderSpendValidation(t *testing.T) {
|
||||
t.Fatalf("unable to generate alice signature: %v", err)
|
||||
}
|
||||
|
||||
bobRecvrSig, err = btcec.ParseDERSignature(
|
||||
bobSig.Serialize(), btcec.S256(),
|
||||
)
|
||||
bobRecvrSig, err = ecdsa.ParseDERSignature(bobSig.Serialize())
|
||||
if err != nil {
|
||||
t.Fatalf("unable to parse signature: %v", err)
|
||||
}
|
||||
@@ -593,8 +587,7 @@ func TestHTLCReceiverSpendValidation(t *testing.T) {
|
||||
// Next we'll the commitment secret for our commitment tx and also the
|
||||
// revocation key that we'll use as well.
|
||||
revokePreimage := testHdSeed.CloneBytes()
|
||||
commitSecret, commitPoint := btcec.PrivKeyFromBytes(btcec.S256(),
|
||||
revokePreimage)
|
||||
commitSecret, commitPoint := btcec.PrivKeyFromBytes(revokePreimage)
|
||||
|
||||
// Generate a payment preimage to be used below.
|
||||
paymentPreimage := revokePreimage
|
||||
@@ -603,10 +596,8 @@ func TestHTLCReceiverSpendValidation(t *testing.T) {
|
||||
|
||||
// We'll also need some tests keys for alice and bob, and metadata of
|
||||
// the HTLC output.
|
||||
aliceKeyPriv, aliceKeyPub := btcec.PrivKeyFromBytes(btcec.S256(),
|
||||
testWalletPrivKey)
|
||||
bobKeyPriv, bobKeyPub := btcec.PrivKeyFromBytes(btcec.S256(),
|
||||
bobsPrivKey)
|
||||
aliceKeyPriv, aliceKeyPub := btcec.PrivKeyFromBytes(testWalletPrivKey)
|
||||
bobKeyPriv, bobKeyPub := btcec.PrivKeyFromBytes(bobsPrivKey)
|
||||
paymentAmt := btcutil.Amount(1 * 10e8)
|
||||
cltvTimeout := uint32(8)
|
||||
|
||||
@@ -631,7 +622,7 @@ func TestHTLCReceiverSpendValidation(t *testing.T) {
|
||||
htlcOutput *wire.TxOut
|
||||
receiverCommitTx, sweepTx *wire.MsgTx
|
||||
sweepTxSigHashes *txscript.TxSigHashes
|
||||
aliceSenderSig *btcec.Signature
|
||||
aliceSenderSig *ecdsa.Signature
|
||||
aliceSigHash txscript.SigHashType
|
||||
)
|
||||
|
||||
@@ -709,8 +700,8 @@ func TestHTLCReceiverSpendValidation(t *testing.T) {
|
||||
t.Fatalf("unable to generate alice signature: %v", err)
|
||||
}
|
||||
|
||||
aliceSenderSig, err = btcec.ParseDERSignature(
|
||||
aliceSig.Serialize(), btcec.S256(),
|
||||
aliceSenderSig, err = ecdsa.ParseDERSignature(
|
||||
aliceSig.Serialize(),
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to parse signature: %v", err)
|
||||
@@ -994,14 +985,11 @@ func TestSecondLevelHtlcSpends(t *testing.T) {
|
||||
|
||||
// First we'll set up some initial key state for Alice and Bob that
|
||||
// will be used in the scripts we created below.
|
||||
aliceKeyPriv, aliceKeyPub := btcec.PrivKeyFromBytes(btcec.S256(),
|
||||
testWalletPrivKey)
|
||||
bobKeyPriv, bobKeyPub := btcec.PrivKeyFromBytes(btcec.S256(),
|
||||
bobsPrivKey)
|
||||
aliceKeyPriv, aliceKeyPub := btcec.PrivKeyFromBytes(testWalletPrivKey)
|
||||
bobKeyPriv, bobKeyPub := btcec.PrivKeyFromBytes(bobsPrivKey)
|
||||
|
||||
revokePreimage := testHdSeed.CloneBytes()
|
||||
commitSecret, commitPoint := btcec.PrivKeyFromBytes(
|
||||
btcec.S256(), revokePreimage)
|
||||
commitSecret, commitPoint := btcec.PrivKeyFromBytes(revokePreimage)
|
||||
|
||||
// As we're modeling this as Bob sweeping the HTLC on-chain from his
|
||||
// commitment transaction after a period of time, we'll be using a
|
||||
@@ -1205,17 +1193,11 @@ func TestLeaseSecondLevelHtlcSpends(t *testing.T) {
|
||||
|
||||
// First we'll set up some initial key state for Alice and Bob that
|
||||
// will be used in the scripts we created below.
|
||||
aliceKeyPriv, aliceKeyPub := btcec.PrivKeyFromBytes(
|
||||
btcec.S256(), testWalletPrivKey,
|
||||
)
|
||||
bobKeyPriv, bobKeyPub := btcec.PrivKeyFromBytes(
|
||||
btcec.S256(), bobsPrivKey,
|
||||
)
|
||||
aliceKeyPriv, aliceKeyPub := btcec.PrivKeyFromBytes(testWalletPrivKey)
|
||||
bobKeyPriv, bobKeyPub := btcec.PrivKeyFromBytes(bobsPrivKey)
|
||||
|
||||
revokePreimage := testHdSeed.CloneBytes()
|
||||
commitSecret, commitPoint := btcec.PrivKeyFromBytes(
|
||||
btcec.S256(), revokePreimage,
|
||||
)
|
||||
commitSecret, commitPoint := btcec.PrivKeyFromBytes(revokePreimage)
|
||||
|
||||
// As we're modeling this as Bob sweeping the HTLC on-chain from his
|
||||
// commitment transaction after a period of time, we'll be using a
|
||||
@@ -1440,18 +1422,12 @@ func TestLeaseCommmitSpendToSelf(t *testing.T) {
|
||||
|
||||
// Set up some initial key state for Alice and Bob that will be used in
|
||||
// the scripts we created below.
|
||||
aliceKeyPriv, aliceKeyPub := btcec.PrivKeyFromBytes(
|
||||
btcec.S256(), testWalletPrivKey,
|
||||
)
|
||||
bobKeyPriv, bobKeyPub := btcec.PrivKeyFromBytes(
|
||||
btcec.S256(), bobsPrivKey,
|
||||
)
|
||||
aliceKeyPriv, aliceKeyPub := btcec.PrivKeyFromBytes(testWalletPrivKey)
|
||||
bobKeyPriv, bobKeyPub := btcec.PrivKeyFromBytes(bobsPrivKey)
|
||||
|
||||
// We'll have Bob take the revocation path in some cases.
|
||||
revokePreimage := testHdSeed.CloneBytes()
|
||||
commitSecret, commitPoint := btcec.PrivKeyFromBytes(
|
||||
btcec.S256(), revokePreimage,
|
||||
)
|
||||
commitSecret, commitPoint := btcec.PrivKeyFromBytes(revokePreimage)
|
||||
revocationKey := DeriveRevocationPubkey(bobKeyPub, commitPoint)
|
||||
|
||||
// Construct the script enforced lease to_self commitment transaction
|
||||
@@ -1640,8 +1616,7 @@ func TestCommitSpendToRemoteConfirmed(t *testing.T) {
|
||||
|
||||
const outputVal = btcutil.Amount(2 * 10e8)
|
||||
|
||||
aliceKeyPriv, aliceKeyPub := btcec.PrivKeyFromBytes(btcec.S256(),
|
||||
testWalletPrivKey)
|
||||
aliceKeyPriv, aliceKeyPub := btcec.PrivKeyFromBytes(testWalletPrivKey)
|
||||
|
||||
txid, err := chainhash.NewHash(testHdSeed.CloneBytes())
|
||||
if err != nil {
|
||||
@@ -1751,7 +1726,7 @@ func TestLeaseCommitSpendToRemoteConfirmed(t *testing.T) {
|
||||
)
|
||||
|
||||
aliceKeyPriv, aliceKeyPub := btcec.PrivKeyFromBytes(
|
||||
btcec.S256(), testWalletPrivKey,
|
||||
testWalletPrivKey,
|
||||
)
|
||||
|
||||
txid, err := chainhash.NewHash(testHdSeed.CloneBytes())
|
||||
@@ -1889,8 +1864,7 @@ func TestSpendAnchor(t *testing.T) {
|
||||
const anchorSize = 294
|
||||
|
||||
// First we'll set up some initial key state for Alice.
|
||||
aliceKeyPriv, aliceKeyPub := btcec.PrivKeyFromBytes(btcec.S256(),
|
||||
testWalletPrivKey)
|
||||
aliceKeyPriv, aliceKeyPub := btcec.PrivKeyFromBytes(testWalletPrivKey)
|
||||
|
||||
// Create a fake anchor outpoint that we'll use to generate the
|
||||
// sweeping transaction.
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"errors"
|
||||
"io"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
@@ -159,9 +159,7 @@ func ReadSignDescriptor(r io.Reader, sd *SignDescriptor) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
sd.KeyDesc.PubKey, err = btcec.ParsePubKey(
|
||||
pubKeyBytes, btcec.S256(),
|
||||
)
|
||||
sd.KeyDesc.PubKey, err = btcec.ParsePubKey(pubKeyBytes)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -196,7 +194,7 @@ func ReadSignDescriptor(r io.Reader, sd *SignDescriptor) error {
|
||||
if len(doubleTweakBytes) == 0 {
|
||||
sd.DoubleTweak = nil
|
||||
} else {
|
||||
sd.DoubleTweak, _ = btcec.PrivKeyFromBytes(btcec.S256(), doubleTweakBytes)
|
||||
sd.DoubleTweak, _ = btcec.PrivKeyFromBytes(doubleTweakBytes)
|
||||
}
|
||||
|
||||
// Only one tweak should ever be set, fail if both are present.
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
@@ -96,7 +96,7 @@ func TestSignDescriptorSerialization(t *testing.T) {
|
||||
for i := 0; i < len(signDescriptors); i++ {
|
||||
// Parse pubkeys for each sign descriptor.
|
||||
sd := &signDescriptors[i]
|
||||
pubkey, err := btcec.ParsePubKey(keys[i], btcec.S256())
|
||||
pubkey, err := btcec.ParsePubKey(keys[i])
|
||||
if err != nil {
|
||||
t.Fatalf("unable to parse pubkey: %v", err)
|
||||
}
|
||||
|
||||
+4
-8
@@ -1,16 +1,15 @@
|
||||
package input_test
|
||||
|
||||
import (
|
||||
"math/big"
|
||||
"testing"
|
||||
|
||||
"github.com/btcsuite/btcd/blockchain"
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/input"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
@@ -37,12 +36,9 @@ var (
|
||||
testPreimage = make([]byte, 32)
|
||||
|
||||
// testPubkey is a pubkey used in script size calculation.
|
||||
testPubkey = &btcec.PublicKey{
|
||||
X: &big.Int{},
|
||||
Y: &big.Int{},
|
||||
}
|
||||
testPubkey = &btcec.PublicKey{}
|
||||
|
||||
testPrivkey, _ = btcec.PrivKeyFromBytes(btcec.S256(), make([]byte, 32))
|
||||
testPrivkey, _ = btcec.PrivKeyFromBytes(make([]byte, 32))
|
||||
|
||||
testTx = wire.NewMsgTx(2)
|
||||
|
||||
|
||||
+6
-5
@@ -5,12 +5,13 @@ import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcutil"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -74,7 +75,7 @@ func (m *MockSigner) SignOutputRaw(tx *wire.MsgTx,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return btcec.ParseDERSignature(sig[:len(sig)-1], btcec.S256())
|
||||
return ecdsa.ParseDERSignature(sig[:len(sig)-1])
|
||||
}
|
||||
|
||||
// ComputeInputScript generates a complete InputIndex for the passed transaction
|
||||
@@ -166,7 +167,7 @@ func pubkeyFromHex(keyHex string) (*btcec.PublicKey, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return btcec.ParsePubKey(bytes, btcec.S256())
|
||||
return btcec.ParsePubKey(bytes)
|
||||
}
|
||||
|
||||
// privkeyFromHex parses a Bitcoin private key from a hex encoded string.
|
||||
@@ -175,7 +176,7 @@ func privkeyFromHex(keyHex string) (*btcec.PrivateKey, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
key, _ := btcec.PrivKeyFromBytes(btcec.S256(), bytes)
|
||||
key, _ := btcec.PrivKeyFromBytes(bytes)
|
||||
return key, nil
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user