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:
Oliver Gugger
2022-02-23 14:48:00 +01:00
parent 8ee9fc837b
commit 7dfe4018ce
350 changed files with 2421 additions and 1289 deletions

View File

@@ -10,7 +10,6 @@ import (
"fmt"
"io/ioutil"
"math"
"math/big"
"net"
"os"
"reflect"
@@ -18,10 +17,11 @@ import (
"testing"
"time"
"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/wire"
"github.com/btcsuite/btcutil"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/htlcswitch"
"github.com/lightningnetwork/lnd/kvdb"
@@ -87,12 +87,13 @@ var (
)
var (
testSig = &btcec.Signature{
R: new(big.Int),
S: new(big.Int),
}
_, _ = testSig.R.SetString("63724406601629180062774974542967536251589935445068131219452686511677818569431", 10)
_, _ = testSig.S.SetString("18801056069249825825291287104931333862866033135609736119018462340006816851118", 10)
testRBytes, _ = hex.DecodeString("8ce2bc69281ce27da07e6683571319d18e949ddfa2965fb6caa1bf0314f882d7")
testSBytes, _ = hex.DecodeString("299105481d63e0f4bc2a88121167221b6700d72a0ead154c03be696a292d24ae")
testRScalar = new(btcec.ModNScalar)
testSScalar = new(btcec.ModNScalar)
_ = testRScalar.SetByteSlice(testRBytes)
_ = testSScalar.SetByteSlice(testSBytes)
testSig = ecdsa.NewSignature(testRScalar, testSScalar)
testAuthProof = channeldb.ChannelAuthProof{
NodeSig1Bytes: testSig.Serialize(),
@@ -259,7 +260,7 @@ func parseTestGraph(useCache bool, path string) (*testGraphInstance, error) {
}
if len(privBytes) > 0 {
key, derivedPub := btcec.PrivKeyFromBytes(
btcec.S256(), privBytes,
privBytes,
)
if !bytes.Equal(
@@ -564,8 +565,7 @@ func createTestGraphFromChannels(useCache bool, testChannels []*testChannel,
0, 0, 0, 0, 0, 0, 0, nodeIndex + 1,
}
privKey, pubKey := btcec.PrivKeyFromBytes(btcec.S256(),
keyBytes)
privKey, pubKey := btcec.PrivKeyFromBytes(keyBytes)
if features == nil {
features = lnwire.EmptyFeatureVector()
@@ -1213,7 +1213,7 @@ func runPathFindingWithAdditionalEdges(t *testing.T, useCache bool) {
if err != nil {
t.Fatalf("unable to decode public key: %v", err)
}
dogePubKey, err := btcec.ParsePubKey(dogePubKeyBytes, btcec.S256())
dogePubKey, err := btcec.ParsePubKey(dogePubKeyBytes)
if err != nil {
t.Fatalf("unable to parse public key from bytes: %v", err)
}