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 committed 2022-03-09 19:02:37 +01:00
1 parent 8ee9fc837b
commit 7dfe4018ce
350 files changed
+2421 -1289

No files matched your search

+3 -3
View File
@@ -8,8 +8,8 @@ import (
"sync" "sync"
"time" "time"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
) )
@@ -731,7 +731,7 @@ func (a *Agent) executeDirective(directive AttachmentDirective) {
// We'll start out by attempting to connect to the peer in order to // We'll start out by attempting to connect to the peer in order to
// begin the funding workflow. // begin the funding workflow.
nodeID := directive.NodeID nodeID := directive.NodeID
pub, err := btcec.ParsePubKey(nodeID[:], btcec.S256()) pub, err := btcec.ParsePubKey(nodeID[:])
if err != nil { if err != nil {
log.Errorf("Unable to parse pubkey %x: %v", nodeID, err) log.Errorf("Unable to parse pubkey %x: %v", nodeID, err)
return return
+1 -1
View File
@@ -1,7 +1,7 @@
package autopilot package autopilot
import ( import (
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcd/btcutil"
) )
// AgentConstraints is an interface the agent will query to determine what // AgentConstraints is an interface the agent will query to determine what
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
) )
+2 -2
View File
@@ -8,9 +8,9 @@ import (
"testing" "testing"
"time" "time"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
) )
type moreChansResp struct { type moreChansResp struct {
+2 -2
View File
@@ -3,8 +3,8 @@ package autopilot
import ( import (
"testing" "testing"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
+1 -1
View File
@@ -3,7 +3,7 @@ package autopilot
import ( import (
"fmt" "fmt"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcd/btcutil"
) )
// WeightedHeuristic is a tuple that associates a weight to an // WeightedHeuristic is a tuple that associates a weight to an
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"sync" "sync"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcd/btcutil"
) )
// ExternalScoreAttachment is an implementation of the AttachmentHeuristic // ExternalScoreAttachment is an implementation of the AttachmentHeuristic
+3 -3
View File
@@ -3,14 +3,14 @@ package autopilot_test
import ( import (
"testing" "testing"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/lightningnetwork/lnd/autopilot" "github.com/lightningnetwork/lnd/autopilot"
) )
// randKey returns a random public key. // randKey returns a random public key.
func randKey() (*btcec.PublicKey, error) { func randKey() (*btcec.PublicKey, error) {
priv, err := btcec.NewPrivateKey(btcec.S256()) priv, err := btcec.NewPrivateKey()
if err != nil { if err != nil {
return nil, err return nil, err
} }
+12 -10
View File
@@ -2,14 +2,15 @@ package autopilot
import ( import (
"bytes" "bytes"
"math/big" "encoding/hex"
"net" "net"
"sort" "sort"
"sync/atomic" "sync/atomic"
"time" "time"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcd/btcec/v2/ecdsa"
"github.com/btcsuite/btcd/btcutil"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/kvdb"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
@@ -17,12 +18,13 @@ import (
) )
var ( var (
testSig = &btcec.Signature{ testRBytes, _ = hex.DecodeString("8ce2bc69281ce27da07e6683571319d18e949ddfa2965fb6caa1bf0314f882d7")
R: new(big.Int), testSBytes, _ = hex.DecodeString("299105481d63e0f4bc2a88121167221b6700d72a0ead154c03be696a292d24ae")
S: new(big.Int), testRScalar = new(btcec.ModNScalar)
} testSScalar = new(btcec.ModNScalar)
_, _ = testSig.R.SetString("63724406601629180062774974542967536251589935445068131219452686511677818569431", 10) _ = testRScalar.SetByteSlice(testRBytes)
_, _ = testSig.S.SetString("18801056069249825825291287104931333862866033135609736119018462340006816851118", 10) _ = testSScalar.SetByteSlice(testSBytes)
testSig = ecdsa.NewSignature(testRScalar, testSScalar)
chanIDCounter uint64 // To be used atomically. chanIDCounter uint64 // To be used atomically.
) )
@@ -344,7 +346,7 @@ func randChanID() lnwire.ShortChannelID {
// randKey returns a random public key. // randKey returns a random public key.
func randKey() (*btcec.PublicKey, error) { func randKey() (*btcec.PublicKey, error) {
priv, err := btcec.NewPrivateKey(btcec.S256()) priv, err := btcec.NewPrivateKey()
if err != nil { if err != nil {
return nil, err return nil, err
} }
+1 -1
View File
@@ -3,7 +3,7 @@ package autopilot_test
import ( import (
"testing" "testing"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/lightningnetwork/lnd/autopilot" "github.com/lightningnetwork/lnd/autopilot"
) )
+2 -2
View File
@@ -3,9 +3,9 @@ package autopilot
import ( import (
"net" "net"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
) )
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"sync" "sync"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
+2 -2
View File
@@ -4,8 +4,8 @@ import (
prand "math/rand" prand "math/rand"
"time" "time"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcd/btcutil"
) )
// minMedianChanSizeFraction determines the minimum size a channel must have to // minMedianChanSizeFraction determines the minimum size a channel must have to
+3 -5
View File
@@ -8,8 +8,8 @@ import (
"testing" "testing"
"time" "time"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
) )
@@ -252,9 +252,7 @@ func TestPrefAttachmentSelectGreedyAllocation(t *testing.T) {
t1.Fatalf("unable to create channel: %v", err) t1.Fatalf("unable to create channel: %v", err)
} }
peerPubBytes := edge1.Peer.PubKey() peerPubBytes := edge1.Peer.PubKey()
peerPub, err := btcec.ParsePubKey( peerPub, err := btcec.ParsePubKey(peerPubBytes[:])
peerPubBytes[:], btcec.S256(),
)
if err != nil { if err != nil {
t.Fatalf("unable to parse pubkey: %v", err) t.Fatalf("unable to parse pubkey: %v", err)
} }
+1 -1
View File
@@ -3,7 +3,7 @@ package autopilot
import ( import (
"runtime" "runtime"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcd/btcutil"
) )
// TopCentrality is a simple greedy technique to create connections to nodes // TopCentrality is a simple greedy technique to create connections to nodes
+2 -2
View File
@@ -3,8 +3,8 @@ package autopilot
import ( import (
"testing" "testing"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
+1 -1
View File
@@ -1,9 +1,9 @@
package blockcache package blockcache
import ( import (
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/lightninglabs/neutrino/cache" "github.com/lightninglabs/neutrino/cache"
"github.com/lightninglabs/neutrino/cache/lru" "github.com/lightninglabs/neutrino/cache/lru"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"
+1 -1
View File
@@ -6,9 +6,9 @@ import (
"sync" "sync"
"testing" "testing"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/lightninglabs/neutrino/cache" "github.com/lightninglabs/neutrino/cache"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
+1 -1
View File
@@ -7,7 +7,7 @@ import (
"net" "net"
"time" "time"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/tor" "github.com/lightningnetwork/lnd/tor"
+5 -25
View File
@@ -10,7 +10,7 @@ import (
"math" "math"
"time" "time"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"
"golang.org/x/crypto/chacha20poly1305" "golang.org/x/crypto/chacha20poly1305"
"golang.org/x/crypto/hkdf" "golang.org/x/crypto/hkdf"
@@ -63,7 +63,7 @@ var (
// ephemeralGen is the default ephemeral key generator, used to derive a // ephemeralGen is the default ephemeral key generator, used to derive a
// unique ephemeral key for each brontide handshake. // unique ephemeral key for each brontide handshake.
ephemeralGen = func() (*btcec.PrivateKey, error) { ephemeralGen = func() (*btcec.PrivateKey, error) {
return btcec.NewPrivateKey(btcec.S256()) return btcec.NewPrivateKey()
} }
) )
@@ -500,7 +500,7 @@ func (b *Machine) RecvActOne(actOne [ActOneSize]byte) error {
copy(p[:], actOne[34:]) copy(p[:], actOne[34:])
// e // e
b.remoteEphemeral, err = btcec.ParsePubKey(e[:], btcec.S256()) b.remoteEphemeral, err = btcec.ParsePubKey(e[:])
if err != nil { if err != nil {
return err return err
} }
@@ -578,7 +578,7 @@ func (b *Machine) RecvActTwo(actTwo [ActTwoSize]byte) error {
copy(p[:], actTwo[34:]) copy(p[:], actTwo[34:])
// e // e
b.remoteEphemeral, err = btcec.ParsePubKey(e[:], btcec.S256()) b.remoteEphemeral, err = btcec.ParsePubKey(e[:])
if err != nil { if err != nil {
return err return err
} }
@@ -654,7 +654,7 @@ func (b *Machine) RecvActThree(actThree [ActThreeSize]byte) error {
if err != nil { if err != nil {
return err return err
} }
b.remoteStatic, err = btcec.ParsePubKey(remotePub, btcec.S256()) b.remoteStatic, err = btcec.ParsePubKey(remotePub)
if err != nil { if err != nil {
return err return err
} }
@@ -890,23 +890,3 @@ func (b *Machine) ReadBody(r io.Reader, buf []byte) ([]byte, error) {
// buffer to decode the plaintext. // buffer to decode the plaintext.
return b.recvCipher.Decrypt(nil, buf[:0], buf) return b.recvCipher.Decrypt(nil, buf[:0], buf)
} }
// SetCurveToNil sets the 'Curve' parameter to nil on the handshakeState keys.
// This allows us to log the Machine object without spammy log messages.
func (b *Machine) SetCurveToNil() {
if b.localStatic != nil {
b.localStatic.PubKey().Curve = nil
}
if b.localEphemeral != nil {
b.localEphemeral.PubKey().Curve = nil
}
if b.remoteStatic != nil {
b.remoteStatic.Curve = nil
}
if b.remoteEphemeral != nil {
b.remoteEphemeral.Curve = nil
}
}
+8 -8
View File
@@ -10,7 +10,7 @@ import (
"testing" "testing"
"testing/iotest" "testing/iotest"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/tor" "github.com/lightningnetwork/lnd/tor"
@@ -23,7 +23,7 @@ type maybeNetConn struct {
func makeListener() (*Listener, *lnwire.NetAddress, error) { func makeListener() (*Listener, *lnwire.NetAddress, error) {
// First, generate the long-term private keys for the brontide listener. // First, generate the long-term private keys for the brontide listener.
localPriv, err := btcec.NewPrivateKey(btcec.S256()) localPriv, err := btcec.NewPrivateKey()
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
@@ -56,7 +56,7 @@ func establishTestConnection() (net.Conn, net.Conn, func(), error) {
// Nos, generate the long-term private keys remote end of the connection // Nos, generate the long-term private keys remote end of the connection
// within our test. // within our test.
remotePriv, err := btcec.NewPrivateKey(btcec.S256()) remotePriv, err := btcec.NewPrivateKey()
if err != nil { if err != nil {
return nil, nil, nil, err return nil, nil, nil, err
} }
@@ -193,7 +193,7 @@ func TestConcurrentHandshakes(t *testing.T) {
// Now, construct a new private key and use the brontide dialer to // Now, construct a new private key and use the brontide dialer to
// connect to the listener. // connect to the listener.
remotePriv, err := btcec.NewPrivateKey(btcec.S256()) remotePriv, err := btcec.NewPrivateKey()
if err != nil { if err != nil {
t.Fatalf("unable to generate private key: %v", err) t.Fatalf("unable to generate private key: %v", err)
} }
@@ -326,7 +326,7 @@ func TestBolt0008TestVectors(t *testing.T) {
t.Fatalf("unable to decode hex: %v", err) t.Fatalf("unable to decode hex: %v", err)
} }
initiatorPriv, _ := btcec.PrivKeyFromBytes( initiatorPriv, _ := btcec.PrivKeyFromBytes(
btcec.S256(), initiatorKeyBytes, initiatorKeyBytes,
) )
initiatorKeyECDH := &keychain.PrivKeyECDH{PrivKey: initiatorPriv} initiatorKeyECDH := &keychain.PrivKeyECDH{PrivKey: initiatorPriv}
@@ -337,7 +337,7 @@ func TestBolt0008TestVectors(t *testing.T) {
t.Fatalf("unable to decode hex: %v", err) t.Fatalf("unable to decode hex: %v", err)
} }
responderPriv, responderPub := btcec.PrivKeyFromBytes( responderPriv, responderPub := btcec.PrivKeyFromBytes(
btcec.S256(), responderKeyBytes, responderKeyBytes,
) )
responderKeyECDH := &keychain.PrivKeyECDH{PrivKey: responderPriv} responderKeyECDH := &keychain.PrivKeyECDH{PrivKey: responderPriv}
@@ -353,7 +353,7 @@ func TestBolt0008TestVectors(t *testing.T) {
return nil, err return nil, err
} }
priv, _ := btcec.PrivKeyFromBytes(btcec.S256(), eBytes) priv, _ := btcec.PrivKeyFromBytes(eBytes)
return priv, nil return priv, nil
}) })
responderEphemeral := EphemeralGenerator(func() (*btcec.PrivateKey, error) { responderEphemeral := EphemeralGenerator(func() (*btcec.PrivateKey, error) {
@@ -364,7 +364,7 @@ func TestBolt0008TestVectors(t *testing.T) {
return nil, err return nil, err
} }
priv, _ := btcec.PrivKeyFromBytes(btcec.S256(), eBytes) priv, _ := btcec.PrivKeyFromBytes(eBytes)
return priv, nil return priv, nil
}) })
+1 -1
View File
@@ -194,7 +194,7 @@ func IsOutdated(cert *x509.Certificate, tlsExtraIPs,
// real PKI. // real PKI.
// //
// This function is adapted from https://github.com/btcsuite/btcd and // This function is adapted from https://github.com/btcsuite/btcd and
// https://github.com/btcsuite/btcutil // https://github.com/btcsuite/btcd/btcutil
func GenCertPair(org, certFile, keyFile string, tlsExtraIPs, func GenCertPair(org, certFile, keyFile string, tlsExtraIPs,
tlsExtraDomains []string, tlsDisableAutofill bool, tlsExtraDomains []string, tlsDisableAutofill bool,
certValidity time.Duration) error { certValidity time.Duration) error {
+1 -1
View File
@@ -7,11 +7,11 @@ import (
"sync/atomic" "sync/atomic"
"github.com/btcsuite/btcd/btcjson" "github.com/btcsuite/btcd/btcjson"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcwallet/chain" "github.com/btcsuite/btcwallet/chain"
"github.com/lightningnetwork/lnd/blockcache" "github.com/lightningnetwork/lnd/blockcache"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
+1 -1
View File
@@ -8,12 +8,12 @@ import (
"time" "time"
"github.com/btcsuite/btcd/btcjson" "github.com/btcsuite/btcd/btcjson"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/rpcclient" "github.com/btcsuite/btcd/rpcclient"
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/lightningnetwork/lnd/blockcache" "github.com/lightningnetwork/lnd/blockcache"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/queue" "github.com/lightningnetwork/lnd/queue"
+2 -2
View File
@@ -9,12 +9,12 @@ import (
"time" "time"
"github.com/btcsuite/btcd/btcjson" "github.com/btcsuite/btcd/btcjson"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/btcutil/gcs/builder"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/rpcclient" "github.com/btcsuite/btcd/rpcclient"
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcutil/gcs/builder"
"github.com/lightninglabs/neutrino" "github.com/lightninglabs/neutrino"
"github.com/lightninglabs/neutrino/headerfs" "github.com/lightninglabs/neutrino/headerfs"
"github.com/lightningnetwork/lnd/blockcache" "github.com/lightningnetwork/lnd/blockcache"
+1 -1
View File
@@ -12,11 +12,11 @@ import (
"testing" "testing"
"time" "time"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/integration/rpctest" "github.com/btcsuite/btcd/integration/rpctest"
"github.com/btcsuite/btcd/rpcclient" "github.com/btcsuite/btcd/rpcclient"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcwallet/chain" "github.com/btcsuite/btcwallet/chain"
_ "github.com/btcsuite/btcwallet/walletdb/bdb" // Required to auto-register the boltdb walletdb implementation. _ "github.com/btcsuite/btcwallet/walletdb/bdb" // Required to auto-register the boltdb walletdb implementation.
"github.com/lightninglabs/neutrino" "github.com/lightninglabs/neutrino"
+3 -3
View File
@@ -14,14 +14,14 @@ import (
"testing" "testing"
"time" "time"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcjson" "github.com/btcsuite/btcd/btcjson"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/integration/rpctest" "github.com/btcsuite/btcd/integration/rpctest"
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcwallet/chain" "github.com/btcsuite/btcwallet/chain"
"github.com/btcsuite/btcwallet/walletdb" "github.com/btcsuite/btcwallet/walletdb"
"github.com/lightninglabs/neutrino" "github.com/lightninglabs/neutrino"
@@ -42,7 +42,7 @@ var (
// randPubKeyHashScript generates a P2PKH script that pays to the public key of // randPubKeyHashScript generates a P2PKH script that pays to the public key of
// a randomly-generated private key. // a randomly-generated private key.
func randPubKeyHashScript() ([]byte, *btcec.PrivateKey, error) { func randPubKeyHashScript() ([]byte, *btcec.PrivateKey, error) {
privKey, err := btcec.NewPrivateKey(btcec.S256()) privKey, err := btcec.NewPrivateKey()
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
+1 -1
View File
@@ -7,10 +7,10 @@ import (
"sync" "sync"
"sync/atomic" "sync/atomic"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
) )
+1 -1
View File
@@ -6,9 +6,9 @@ import (
"testing" "testing"
"time" "time"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
+1 -1
View File
@@ -14,9 +14,9 @@ import (
"sync" "sync"
"time" "time"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/rpcclient" "github.com/btcsuite/btcd/rpcclient"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcwallet/chain" "github.com/btcsuite/btcwallet/chain"
"github.com/lightninglabs/neutrino" "github.com/lightninglabs/neutrino"
"github.com/lightningnetwork/lnd/blockcache" "github.com/lightningnetwork/lnd/blockcache"
+1 -1
View File
@@ -4,9 +4,9 @@ import (
"errors" "errors"
"time" "time"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcwallet/chain" "github.com/btcsuite/btcwallet/chain"
"github.com/btcsuite/btcwallet/waddrmgr" "github.com/btcsuite/btcwallet/waddrmgr"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
+6 -7
View File
@@ -2,13 +2,12 @@ package chanacceptor
import ( import (
"errors" "errors"
"math/big"
"testing" "testing"
"time" "time"
"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"
"github.com/btcsuite/btcutil"
"github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lnwallet/chancloser" "github.com/lightningnetwork/lnd/lnwallet/chancloser"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
@@ -126,10 +125,10 @@ func (c *channelAcceptorCtx) stop() {
// request in a goroutine and then asserts that we get the outcome we expect. // request in a goroutine and then asserts that we get the outcome we expect.
func (c *channelAcceptorCtx) queryAndAssert(queries map[*lnwire.OpenChannel]*ChannelAcceptResponse) { func (c *channelAcceptorCtx) queryAndAssert(queries map[*lnwire.OpenChannel]*ChannelAcceptResponse) {
var ( var (
node = &btcec.PublicKey{ node = btcec.NewPublicKey(
X: big.NewInt(1), new(btcec.FieldVal).SetInt(1),
Y: big.NewInt(1), new(btcec.FieldVal).SetInt(1),
} )
responses = make(chan struct{}) responses = make(chan struct{})
) )
+2 -2
View File
@@ -3,8 +3,8 @@ package chanacceptor
import ( import (
"errors" "errors"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
) )
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"fmt" "fmt"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
) )
+1 -1
View File
@@ -7,8 +7,8 @@ import (
"sync" "sync"
"time" "time"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcutil"
"github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lnwallet/chancloser" "github.com/lightningnetwork/lnd/lnwallet/chancloser"
+1 -1
View File
@@ -5,8 +5,8 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcutil"
"github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lnwallet/chancloser" "github.com/lightningnetwork/lnd/lnwallet/chancloser"
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"net" "net"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/kvdb"
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"net" "net"
"testing" "testing"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/kvdb"
+2 -2
View File
@@ -5,7 +5,7 @@ import (
"fmt" "fmt"
"testing" "testing"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"
) )
@@ -30,7 +30,7 @@ func (m *mockKeyRing) DeriveKey(keyLoc keychain.KeyLocator) (keychain.KeyDescrip
return keychain.KeyDescriptor{}, fmt.Errorf("fail") return keychain.KeyDescriptor{}, fmt.Errorf("fail")
} }
_, pub := btcec.PrivKeyFromBytes(btcec.S256(), testWalletPrivKey) _, pub := btcec.PrivKeyFromBytes(testWalletPrivKey)
return keychain.KeyDescriptor{ return keychain.KeyDescriptor{
PubKey: pub, PubKey: pub,
}, nil }, nil
+1 -1
View File
@@ -3,7 +3,7 @@ package chanbackup
import ( import (
"net" "net"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"
+1 -1
View File
@@ -6,7 +6,7 @@ import (
"net" "net"
"testing" "testing"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
) )
type mockChannelRestorer struct { type mockChannelRestorer struct {
+5 -7
View File
@@ -6,10 +6,10 @@ import (
"io" "io"
"net" "net"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
@@ -160,7 +160,7 @@ func NewSingle(channel *channeldb.OpenChannel,
// the backups plaintext don't carry any private information. When // the backups plaintext don't carry any private information. When
// we go to recover, we'll present this in order to derive the // we go to recover, we'll present this in order to derive the
// private key. // private key.
_, shaChainPoint := btcec.PrivKeyFromBytes(btcec.S256(), b.Bytes()) _, shaChainPoint := btcec.PrivKeyFromBytes(b.Bytes())
shaChainRootDesc = keychain.KeyDescriptor{ shaChainRootDesc = keychain.KeyDescriptor{
PubKey: shaChainPoint, PubKey: shaChainPoint,
@@ -369,13 +369,11 @@ func readRemoteKeyDesc(r io.Reader) (keychain.KeyDescriptor, error) {
return keychain.KeyDescriptor{}, err return keychain.KeyDescriptor{}, err
} }
keyDesc.PubKey, err = btcec.ParsePubKey(pub[:], btcec.S256()) keyDesc.PubKey, err = btcec.ParsePubKey(pub[:])
if err != nil { if err != nil {
return keychain.KeyDescriptor{}, err return keychain.KeyDescriptor{}, err
} }
keyDesc.PubKey.Curve = nil
return keyDesc, nil return keyDesc, nil
} }
@@ -480,7 +478,7 @@ func (s *Single) Deserialize(r io.Reader) error {
// been specified or not. // been specified or not.
if !bytes.Equal(shaChainPub[:], zeroPub[:]) { if !bytes.Equal(shaChainPub[:], zeroPub[:]) {
s.ShaChainRootDesc.PubKey, err = btcec.ParsePubKey( s.ShaChainRootDesc.PubKey, err = btcec.ParsePubKey(
shaChainPub[:], btcec.S256(), shaChainPub[:],
) )
if err != nil { if err != nil {
return err return err
+2 -6
View File
@@ -8,7 +8,7 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
@@ -101,15 +101,13 @@ func genRandomOpenChannelShell() (*channeldb.OpenChannel, error) {
return nil, err return nil, err
} }
_, pub := btcec.PrivKeyFromBytes(btcec.S256(), testPriv[:]) _, pub := btcec.PrivKeyFromBytes(testPriv[:])
var chanPoint wire.OutPoint var chanPoint wire.OutPoint
if _, err := rand.Read(chanPoint.Hash[:]); err != nil { if _, err := rand.Read(chanPoint.Hash[:]); err != nil {
return nil, err return nil, err
} }
pub.Curve = nil
chanPoint.Index = uint32(rand.Intn(math.MaxUint16)) chanPoint.Index = uint32(rand.Intn(math.MaxUint16))
var shaChainRoot [32]byte var shaChainRoot [32]byte
@@ -209,7 +207,6 @@ func TestSinglePackUnpack(t *testing.T) {
} }
singleChanBackup := NewSingle(channel, []net.Addr{addr1, addr2}) singleChanBackup := NewSingle(channel, []net.Addr{addr1, addr2})
singleChanBackup.RemoteNodePub.Curve = nil
keyRing := &mockKeyRing{} keyRing := &mockKeyRing{}
@@ -285,7 +282,6 @@ func TestSinglePackUnpack(t *testing.T) {
t.Fatalf("#%v unable to unpack single: %v", t.Fatalf("#%v unable to unpack single: %v",
i, err) i, err)
} }
unpackedSingle.RemoteNodePub.Curve = nil
assertSingleEqual(t, singleChanBackup, unpackedSingle) assertSingleEqual(t, singleChanBackup, unpackedSingle)
+5 -7
View File
@@ -2,11 +2,10 @@ package chanfitness
import ( import (
"errors" "errors"
"math/big"
"testing" "testing"
"time" "time"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/clock" "github.com/lightningnetwork/lnd/clock"
@@ -88,11 +87,10 @@ func TestStartStoreError(t *testing.T) {
// of uptime and lifespan requests, as they are tested in their own tests. // of uptime and lifespan requests, as they are tested in their own tests.
func TestMonitorChannelEvents(t *testing.T) { func TestMonitorChannelEvents(t *testing.T) {
var ( var (
pubKey = &btcec.PublicKey{ pubKey = btcec.NewPublicKey(
X: big.NewInt(0), new(btcec.FieldVal).SetInt(0),
Y: big.NewInt(1), new(btcec.FieldVal).SetInt(1),
Curve: btcec.S256(), )
}
chan1 = wire.OutPoint{Index: 1} chan1 = wire.OutPoint{Index: 1}
chan2 = wire.OutPoint{Index: 2} chan2 = wire.OutPoint{Index: 2}
+5 -7
View File
@@ -1,11 +1,10 @@
package chanfitness package chanfitness
import ( import (
"math/big"
"testing" "testing"
"time" "time"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
@@ -144,11 +143,10 @@ func (c *chanEventStoreTestCtx) newChannel() (route.Vertex, *btcec.PublicKey,
wire.OutPoint) { wire.OutPoint) {
// Create a pubkey for our channel peer. // Create a pubkey for our channel peer.
pubKey := &btcec.PublicKey{ pubKey := btcec.NewPublicKey(
X: big.NewInt(int64(c.testVarIdx)), new(btcec.FieldVal).SetInt(uint16(c.testVarIdx)),
Y: big.NewInt(int64(c.testVarIdx)), new(btcec.FieldVal).SetInt(uint16(c.testVarIdx)),
Curve: btcec.S256(), )
}
// Create vertex from our pubkey. // Create vertex from our pubkey.
vertex, err := route.NewVertexFromBytes(pubKey.SerializeCompressed()) vertex, err := route.NewVertexFromBytes(pubKey.SerializeCompressed())
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"net" "net"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/chanbackup" "github.com/lightningnetwork/lnd/chanbackup"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
+2 -2
View File
@@ -12,10 +12,10 @@ import (
"strings" "strings"
"sync" "sync"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/kvdb"
+5 -5
View File
@@ -8,10 +8,10 @@ import (
"runtime" "runtime"
"testing" "testing"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
_ "github.com/btcsuite/btcwallet/walletdb/bdb" _ "github.com/btcsuite/btcwallet/walletdb/bdb"
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/clock" "github.com/lightningnetwork/lnd/clock"
@@ -35,7 +35,7 @@ var (
0x48, 0x59, 0xe6, 0x96, 0x31, 0x13, 0xa1, 0x17, 0x48, 0x59, 0xe6, 0x96, 0x31, 0x13, 0xa1, 0x17,
0x2d, 0xe7, 0x93, 0xe4, 0x2d, 0xe7, 0x93, 0xe4,
} }
privKey, pubKey = btcec.PrivKeyFromBytes(btcec.S256(), key[:]) privKey, pubKey = btcec.PrivKeyFromBytes(key[:])
wireSig, _ = lnwire.NewSigFromSignature(testSig) wireSig, _ = lnwire.NewSigFromSignature(testSig)
@@ -412,7 +412,7 @@ func TestOpenChannelPutGetDelete(t *testing.T) {
// We'll also test that the channel is properly able to hot swap the // We'll also test that the channel is properly able to hot swap the
// next revocation for the state machine. This tests the initial // next revocation for the state machine. This tests the initial
// post-funding revocation exchange. // post-funding revocation exchange.
nextRevKey, err := btcec.NewPrivateKey(btcec.S256()) nextRevKey, err := btcec.NewPrivateKey()
if err != nil { if err != nil {
t.Fatalf("unable to create new private key: %v", err) t.Fatalf("unable to create new private key: %v", err)
} }
@@ -756,7 +756,7 @@ func TestChannelStateTransition(t *testing.T) {
// current uncollapsed revocation state to simulate a state transition // current uncollapsed revocation state to simulate a state transition
// by the remote party. // by the remote party.
channel.RemoteCurrentRevocation = channel.RemoteNextRevocation channel.RemoteCurrentRevocation = channel.RemoteNextRevocation
newPriv, err := btcec.NewPrivateKey(btcec.S256()) newPriv, err := btcec.NewPrivateKey()
if err != nil { if err != nil {
t.Fatalf("unable to generate key: %v", err) t.Fatalf("unable to generate key: %v", err)
} }
+4 -4
View File
@@ -7,10 +7,10 @@ import (
"io" "io"
"net" "net"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/shachain" "github.com/lightningnetwork/lnd/shachain"
@@ -346,7 +346,7 @@ func ReadElement(r io.Reader, element interface{}) error {
return err return err
} }
priv, _ := btcec.PrivKeyFromBytes(btcec.S256(), b[:]) priv, _ := btcec.PrivKeyFromBytes(b[:])
*e = priv *e = priv
case **btcec.PublicKey: case **btcec.PublicKey:
@@ -355,7 +355,7 @@ func ReadElement(r io.Reader, element interface{}) error {
return err return err
} }
pubKey, err := btcec.ParsePubKey(b[:], btcec.S256()) pubKey, err := btcec.ParsePubKey(b[:])
if err != nil { if err != nil {
return err return err
} }
+1 -1
View File
@@ -8,7 +8,7 @@ import (
"net" "net"
"os" "os"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/go-errors/errors" "github.com/go-errors/errors"
mig "github.com/lightningnetwork/lnd/channeldb/migration" mig "github.com/lightningnetwork/lnd/channeldb/migration"
+3 -5
View File
@@ -10,10 +10,10 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/kvdb"
@@ -300,15 +300,13 @@ func genRandomChannelShell() (*ChannelShell, error) {
return nil, err return nil, err
} }
_, pub := btcec.PrivKeyFromBytes(btcec.S256(), testPriv[:]) _, pub := btcec.PrivKeyFromBytes(testPriv[:])
var chanPoint wire.OutPoint var chanPoint wire.OutPoint
if _, err := rand.Read(chanPoint.Hash[:]); err != nil { if _, err := rand.Read(chanPoint.Hash[:]); err != nil {
return nil, err return nil, err
} }
pub.Curve = nil
chanPoint.Index = uint32(rand.Intn(math.MaxUint16)) chanPoint.Index = uint32(rand.Intn(math.MaxUint16))
chanStatus := ChanStatusDefault | ChanStatusRestored chanStatus := ChanStatusDefault | ChanStatusRestored
+1 -1
View File
@@ -7,7 +7,7 @@ import (
"io" "io"
"time" "time"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/kvdb"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
+25 -24
View File
@@ -14,11 +14,12 @@ import (
"sync" "sync"
"time" "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/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/lightningnetwork/lnd/batch" "github.com/lightningnetwork/lnd/batch"
"github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/kvdb"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
@@ -2660,7 +2661,7 @@ func (l *LightningNode) PubKey() (*btcec.PublicKey, error) {
return l.pubKey, nil return l.pubKey, nil
} }
key, err := btcec.ParsePubKey(l.PubKeyBytes[:], btcec.S256()) key, err := btcec.ParsePubKey(l.PubKeyBytes[:])
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -2674,8 +2675,8 @@ func (l *LightningNode) PubKey() (*btcec.PublicKey, error) {
// //
// NOTE: By having this method to access an attribute, we ensure we only need // NOTE: By having this method to access an attribute, we ensure we only need
// to fully deserialize the signature if absolutely necessary. // to fully deserialize the signature if absolutely necessary.
func (l *LightningNode) AuthSig() (*btcec.Signature, error) { func (l *LightningNode) AuthSig() (*ecdsa.Signature, error) {
return btcec.ParseSignature(l.AuthSigBytes, btcec.S256()) return ecdsa.ParseSignature(l.AuthSigBytes)
} }
// AddPubKey is a setter-link method that can be used to swap out the public // AddPubKey is a setter-link method that can be used to swap out the public
@@ -3104,7 +3105,7 @@ func (c *ChannelEdgeInfo) NodeKey1() (*btcec.PublicKey, error) {
return c.nodeKey1, nil return c.nodeKey1, nil
} }
key, err := btcec.ParsePubKey(c.NodeKey1Bytes[:], btcec.S256()) key, err := btcec.ParsePubKey(c.NodeKey1Bytes[:])
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -3126,7 +3127,7 @@ func (c *ChannelEdgeInfo) NodeKey2() (*btcec.PublicKey, error) {
return c.nodeKey2, nil return c.nodeKey2, nil
} }
key, err := btcec.ParsePubKey(c.NodeKey2Bytes[:], btcec.S256()) key, err := btcec.ParsePubKey(c.NodeKey2Bytes[:])
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -3146,7 +3147,7 @@ func (c *ChannelEdgeInfo) BitcoinKey1() (*btcec.PublicKey, error) {
return c.bitcoinKey1, nil return c.bitcoinKey1, nil
} }
key, err := btcec.ParsePubKey(c.BitcoinKey1Bytes[:], btcec.S256()) key, err := btcec.ParsePubKey(c.BitcoinKey1Bytes[:])
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -3166,7 +3167,7 @@ func (c *ChannelEdgeInfo) BitcoinKey2() (*btcec.PublicKey, error) {
return c.bitcoinKey2, nil return c.bitcoinKey2, nil
} }
key, err := btcec.ParsePubKey(c.BitcoinKey2Bytes[:], btcec.S256()) key, err := btcec.ParsePubKey(c.BitcoinKey2Bytes[:])
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -3249,28 +3250,28 @@ func (c *ChannelEdgeInfo) FetchOtherNode(tx kvdb.RTx,
// features. // features.
type ChannelAuthProof struct { type ChannelAuthProof struct {
// nodeSig1 is a cached instance of the first node signature. // nodeSig1 is a cached instance of the first node signature.
nodeSig1 *btcec.Signature nodeSig1 *ecdsa.Signature
// NodeSig1Bytes are the raw bytes of the first node signature encoded // NodeSig1Bytes are the raw bytes of the first node signature encoded
// in DER format. // in DER format.
NodeSig1Bytes []byte NodeSig1Bytes []byte
// nodeSig2 is a cached instance of the second node signature. // nodeSig2 is a cached instance of the second node signature.
nodeSig2 *btcec.Signature nodeSig2 *ecdsa.Signature
// NodeSig2Bytes are the raw bytes of the second node signature // NodeSig2Bytes are the raw bytes of the second node signature
// encoded in DER format. // encoded in DER format.
NodeSig2Bytes []byte NodeSig2Bytes []byte
// bitcoinSig1 is a cached instance of the first bitcoin signature. // bitcoinSig1 is a cached instance of the first bitcoin signature.
bitcoinSig1 *btcec.Signature bitcoinSig1 *ecdsa.Signature
// BitcoinSig1Bytes are the raw bytes of the first bitcoin signature // BitcoinSig1Bytes are the raw bytes of the first bitcoin signature
// encoded in DER format. // encoded in DER format.
BitcoinSig1Bytes []byte BitcoinSig1Bytes []byte
// bitcoinSig2 is a cached instance of the second bitcoin signature. // bitcoinSig2 is a cached instance of the second bitcoin signature.
bitcoinSig2 *btcec.Signature bitcoinSig2 *ecdsa.Signature
// BitcoinSig2Bytes are the raw bytes of the second bitcoin signature // BitcoinSig2Bytes are the raw bytes of the second bitcoin signature
// encoded in DER format. // encoded in DER format.
@@ -3283,12 +3284,12 @@ type ChannelAuthProof struct {
// //
// NOTE: By having this method to access an attribute, we ensure we only need // NOTE: By having this method to access an attribute, we ensure we only need
// to fully deserialize the signature if absolutely necessary. // to fully deserialize the signature if absolutely necessary.
func (c *ChannelAuthProof) Node1Sig() (*btcec.Signature, error) { func (c *ChannelAuthProof) Node1Sig() (*ecdsa.Signature, error) {
if c.nodeSig1 != nil { if c.nodeSig1 != nil {
return c.nodeSig1, nil return c.nodeSig1, nil
} }
sig, err := btcec.ParseSignature(c.NodeSig1Bytes, btcec.S256()) sig, err := ecdsa.ParseSignature(c.NodeSig1Bytes)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -3304,12 +3305,12 @@ func (c *ChannelAuthProof) Node1Sig() (*btcec.Signature, error) {
// //
// NOTE: By having this method to access an attribute, we ensure we only need // NOTE: By having this method to access an attribute, we ensure we only need
// to fully deserialize the signature if absolutely necessary. // to fully deserialize the signature if absolutely necessary.
func (c *ChannelAuthProof) Node2Sig() (*btcec.Signature, error) { func (c *ChannelAuthProof) Node2Sig() (*ecdsa.Signature, error) {
if c.nodeSig2 != nil { if c.nodeSig2 != nil {
return c.nodeSig2, nil return c.nodeSig2, nil
} }
sig, err := btcec.ParseSignature(c.NodeSig2Bytes, btcec.S256()) sig, err := ecdsa.ParseSignature(c.NodeSig2Bytes)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -3324,12 +3325,12 @@ func (c *ChannelAuthProof) Node2Sig() (*btcec.Signature, error) {
// //
// NOTE: By having this method to access an attribute, we ensure we only need // NOTE: By having this method to access an attribute, we ensure we only need
// to fully deserialize the signature if absolutely necessary. // to fully deserialize the signature if absolutely necessary.
func (c *ChannelAuthProof) BitcoinSig1() (*btcec.Signature, error) { func (c *ChannelAuthProof) BitcoinSig1() (*ecdsa.Signature, error) {
if c.bitcoinSig1 != nil { if c.bitcoinSig1 != nil {
return c.bitcoinSig1, nil return c.bitcoinSig1, nil
} }
sig, err := btcec.ParseSignature(c.BitcoinSig1Bytes, btcec.S256()) sig, err := ecdsa.ParseSignature(c.BitcoinSig1Bytes)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -3344,12 +3345,12 @@ func (c *ChannelAuthProof) BitcoinSig1() (*btcec.Signature, error) {
// //
// NOTE: By having this method to access an attribute, we ensure we only need // NOTE: By having this method to access an attribute, we ensure we only need
// to fully deserialize the signature if absolutely necessary. // to fully deserialize the signature if absolutely necessary.
func (c *ChannelAuthProof) BitcoinSig2() (*btcec.Signature, error) { func (c *ChannelAuthProof) BitcoinSig2() (*ecdsa.Signature, error) {
if c.bitcoinSig2 != nil { if c.bitcoinSig2 != nil {
return c.bitcoinSig2, nil return c.bitcoinSig2, nil
} }
sig, err := btcec.ParseSignature(c.BitcoinSig2Bytes, btcec.S256()) sig, err := ecdsa.ParseSignature(c.BitcoinSig2Bytes)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -3381,7 +3382,7 @@ type ChannelEdgePolicy struct {
SigBytes []byte SigBytes []byte
// sig is a cached fully parsed signature. // sig is a cached fully parsed signature.
sig *btcec.Signature sig *ecdsa.Signature
// ChannelID is the unique channel ID for the channel. The first 3 // ChannelID is the unique channel ID for the channel. The first 3
// bytes are the block height, the next 3 the index within the block, // bytes are the block height, the next 3 the index within the block,
@@ -3441,12 +3442,12 @@ type ChannelEdgePolicy struct {
// //
// NOTE: By having this method to access an attribute, we ensure we only need // NOTE: By having this method to access an attribute, we ensure we only need
// to fully deserialize the signature if absolutely necessary. // to fully deserialize the signature if absolutely necessary.
func (c *ChannelEdgePolicy) Signature() (*btcec.Signature, error) { func (c *ChannelEdgePolicy) Signature() (*ecdsa.Signature, error) {
if c.sig != nil { if c.sig != nil {
return c.sig, nil return c.sig, nil
} }
sig, err := btcec.ParseSignature(c.SigBytes, btcec.S256()) sig, err := ecdsa.ParseSignature(c.SigBytes)
if err != nil { if err != nil {
return nil, err return nil, err
} }
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"sync" "sync"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/kvdb"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/routing/route" "github.com/lightningnetwork/lnd/routing/route"
+14 -15
View File
@@ -3,12 +3,12 @@ package channeldb
import ( import (
"bytes" "bytes"
"crypto/sha256" "crypto/sha256"
"encoding/hex"
"errors" "errors"
"fmt" "fmt"
"image/color" "image/color"
"io/ioutil" "io/ioutil"
"math" "math"
"math/big"
prand "math/rand" prand "math/rand"
"net" "net"
"os" "os"
@@ -18,10 +18,11 @@ import (
"testing" "testing"
"time" "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/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/kvdb"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
@@ -36,12 +37,13 @@ var (
"[2001:db8:85a3:0:0:8a2e:370:7334]:80") "[2001:db8:85a3:0:0:8a2e:370:7334]:80")
testAddrs = []net.Addr{testAddr, anotherAddr} testAddrs = []net.Addr{testAddr, anotherAddr}
testSig = &btcec.Signature{ testRBytes, _ = hex.DecodeString("8ce2bc69281ce27da07e6683571319d18e949ddfa2965fb6caa1bf0314f882d7")
R: new(big.Int), testSBytes, _ = hex.DecodeString("299105481d63e0f4bc2a88121167221b6700d72a0ead154c03be696a292d24ae")
S: new(big.Int), testRScalar = new(btcec.ModNScalar)
} testSScalar = new(btcec.ModNScalar)
_, _ = testSig.R.SetString("63724406601629180062774974542967536251589935445068131219452686511677818569431", 10) _ = testRScalar.SetByteSlice(testRBytes)
_, _ = testSig.S.SetString("18801056069249825825291287104931333862866033135609736119018462340006816851118", 10) _ = testSScalar.SetByteSlice(testSBytes)
testSig = ecdsa.NewSignature(testRScalar, testSScalar)
testFeatures = lnwire.NewFeatureVector( testFeatures = lnwire.NewFeatureVector(
lnwire.NewRawFeatureVector(lnwire.GossipQueriesRequired), lnwire.NewRawFeatureVector(lnwire.GossipQueriesRequired),
@@ -114,7 +116,7 @@ func createLightningNode(db kvdb.Backend, priv *btcec.PrivateKey) (*LightningNod
} }
func createTestVertex(db kvdb.Backend) (*LightningNode, error) { func createTestVertex(db kvdb.Backend) (*LightningNode, error) {
priv, err := btcec.NewPrivateKey(btcec.S256()) priv, err := btcec.NewPrivateKey()
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -3491,15 +3493,12 @@ func TestLightningNodeSigVerification(t *testing.T) {
} }
// Create private key and sign the data with it. // Create private key and sign the data with it.
priv, err := btcec.NewPrivateKey(btcec.S256()) priv, err := btcec.NewPrivateKey()
if err != nil { if err != nil {
t.Fatalf("unable to crete priv key: %v", err) t.Fatalf("unable to crete priv key: %v", err)
} }
sign, err := priv.Sign(data[:]) sign := ecdsa.Sign(priv, data[:])
if err != nil {
t.Fatalf("unable to sign: %v", err)
}
// Sanity check that the signature checks out. // Sanity check that the signature checks out.
if !sign.Verify(data[:], priv.PubKey()) { if !sign.Verify(data[:], priv.PubKey()) {
@@ -3,8 +3,8 @@ package lnwire
import ( import (
"io" "io"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcd/btcutil"
) )
// AcceptChannel is the message Bob sends to Alice after she initiates the // AcceptChannel is the message Bob sends to Alice after she initiates the
@@ -3,7 +3,7 @@ package lnwire
import ( import (
"io" "io"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
) )
// ChannelReestablish is a message sent between peers that have an existing // ChannelReestablish is a message sent between peers that have an existing
@@ -3,7 +3,7 @@ package lnwire
import ( import (
"io" "io"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcd/btcutil"
) )
// ClosingSigned is sent by both parties to a channel once the channel is clear // ClosingSigned is sent by both parties to a channel once the channel is clear
@@ -3,7 +3,7 @@ package lnwire
import ( import (
"io" "io"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
) )
// FundingLocked is the message that both parties to a new channel creation // FundingLocked is the message that both parties to a new channel creation
+3 -3
View File
@@ -9,10 +9,10 @@ import (
"math" "math"
"net" "net"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/go-errors/errors" "github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/tor" "github.com/lightningnetwork/lnd/tor"
) )
@@ -529,7 +529,7 @@ func ReadElement(r io.Reader, element interface{}) error {
return err return err
} }
pubKey, err := btcec.ParsePubKey(b[:], btcec.S256()) pubKey, err := btcec.ParsePubKey(b[:])
if err != nil { if err != nil {
return err return err
} }
+1 -1
View File
@@ -3,7 +3,7 @@ package lnwire
import ( import (
"fmt" "fmt"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcd/btcutil"
) )
const ( const (
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"net" "net"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
) )
+2 -2
View File
@@ -3,9 +3,9 @@ package lnwire
import ( import (
"io" "io"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcutil"
) )
// FundingFlag represents the possible bit mask values for the ChannelFlags // FundingFlag represents the possible bit mask values for the ChannelFlags
@@ -3,7 +3,7 @@ package lnwire
import ( import (
"io" "io"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
) )
// RevokeAndAck is sent by either side once a CommitSig message has been // RevokeAndAck is sent by either side once a CommitSig message has been
+7 -7
View File
@@ -3,14 +3,14 @@ package lnwire
import ( import (
"fmt" "fmt"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2/ecdsa"
"github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/input"
) )
// Sig is a fixed-sized ECDSA signature. Unlike Bitcoin, we use fixed sized // Sig is a fixed-sized ECDSA signature. Unlike Bitcoin, we use fixed sized
// signatures on the wire, instead of DER encoded signatures. This type // signatures on the wire, instead of DER encoded signatures. This type
// provides several methods to convert to/from a regular Bitcoin DER encoded // provides several methods to convert to/from a regular Bitcoin DER encoded
// signature (raw bytes and *btcec.Signature). // signature (raw bytes and *ecdsa.Signature).
type Sig [64]byte type Sig [64]byte
// NewSigFromRawSignature returns a Sig from a Bitcoin raw signature encoded in // NewSigFromRawSignature returns a Sig from a Bitcoin raw signature encoded in
@@ -27,7 +27,7 @@ func NewSigFromRawSignature(sig []byte) (Sig, error) {
// which means the length of R is the 4th byte and the length of S // which means the length of R is the 4th byte and the length of S
// is the second byte after R ends. 0x02 signifies a length-prefixed, // is the second byte after R ends. 0x02 signifies a length-prefixed,
// zero-padded, big-endian bigint. 0x30 signifies a DER signature. // zero-padded, big-endian bigint. 0x30 signifies a DER signature.
// See the Serialize() method for btcec.Signature for details. // See the Serialize() method for ecdsa.Signature for details.
rLen := sig[3] rLen := sig[3]
sLen := sig[5+rLen] sLen := sig[5+rLen]
@@ -64,7 +64,7 @@ func NewSigFromRawSignature(sig []byte) (Sig, error) {
} }
// NewSigFromSignature creates a new signature as used on the wire, from an // NewSigFromSignature creates a new signature as used on the wire, from an
// existing btcec.Signature. // existing ecdsa.Signature.
func NewSigFromSignature(e input.Signature) (Sig, error) { func NewSigFromSignature(e input.Signature) (Sig, error) {
if e == nil { if e == nil {
return Sig{}, fmt.Errorf("cannot decode empty signature") return Sig{}, fmt.Errorf("cannot decode empty signature")
@@ -74,12 +74,12 @@ func NewSigFromSignature(e input.Signature) (Sig, error) {
return NewSigFromRawSignature(e.Serialize()) return NewSigFromRawSignature(e.Serialize())
} }
// ToSignature converts the fixed-sized signature to a btcec.Signature objects // ToSignature converts the fixed-sized signature to a ecdsa.Signature objects
// which can be used for signature validation checks. // which can be used for signature validation checks.
func (b *Sig) ToSignature() (*btcec.Signature, error) { func (b *Sig) ToSignature() (*ecdsa.Signature, error) {
// Parse the signature with strict checks. // Parse the signature with strict checks.
sigBytes := b.ToSignatureBytes() sigBytes := b.ToSignatureBytes()
sig, err := btcec.ParseDERSignature(sigBytes, btcec.S256()) sig, err := ecdsa.ParseDERSignature(sigBytes)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -5,10 +5,10 @@ import (
"encoding/binary" "encoding/binary"
"io" "io"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21" lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"
) )
@@ -6,10 +6,10 @@ import (
"fmt" "fmt"
"io" "io"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21" lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21"
"github.com/lightningnetwork/lnd/channeldb/migration21/common" "github.com/lightningnetwork/lnd/channeldb/migration21/common"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"
@@ -317,7 +317,7 @@ func ReadElement(r io.Reader, element interface{}) error {
return err return err
} }
priv, _ := btcec.PrivKeyFromBytes(btcec.S256(), b[:]) priv, _ := btcec.PrivKeyFromBytes(b[:])
*e = priv *e = priv
case **btcec.PublicKey: case **btcec.PublicKey:
@@ -326,7 +326,7 @@ func ReadElement(r io.Reader, element interface{}) error {
return err return err
} }
pubKey, err := btcec.ParsePubKey(b[:], btcec.S256()) pubKey, err := btcec.ParsePubKey(b[:])
if err != nil { if err != nil {
return err return err
} }
+3 -3
View File
@@ -5,10 +5,10 @@ import (
"fmt" "fmt"
"io" "io"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21" lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21"
"github.com/lightningnetwork/lnd/channeldb/migration21/common" "github.com/lightningnetwork/lnd/channeldb/migration21/common"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"
@@ -276,7 +276,7 @@ func ReadElement(r io.Reader, element interface{}) error {
return err return err
} }
pubKey, err := btcec.ParsePubKey(b[:], btcec.S256()) pubKey, err := btcec.ParsePubKey(b[:])
if err != nil { if err != nil {
return err return err
} }
+11 -19
View File
@@ -2,12 +2,13 @@ package migration21
import ( import (
"bytes" "bytes"
"encoding/hex"
"fmt" "fmt"
"math/big"
"reflect" "reflect"
"testing" "testing"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
@@ -27,16 +28,17 @@ var (
0x1e, 0xb, 0x4c, 0xf9, 0x9e, 0xc5, 0x8c, 0xe9, 0x1e, 0xb, 0x4c, 0xf9, 0x9e, 0xc5, 0x8c, 0xe9,
} }
_, pubKey = btcec.PrivKeyFromBytes(btcec.S256(), key[:]) _, pubKey = btcec.PrivKeyFromBytes(key[:])
wireSig, _ = lnwire.NewSigFromSignature(testSig) wireSig, _ = lnwire.NewSigFromSignature(testSig)
testSig = &btcec.Signature{ testRBytes, _ = hex.DecodeString("8ce2bc69281ce27da07e6683571319d18e949ddfa2965fb6caa1bf0314f882d7")
R: new(big.Int), testSBytes, _ = hex.DecodeString("299105481d63e0f4bc2a88121167221b6700d72a0ead154c03be696a292d24ae")
S: new(big.Int), testRScalar = new(btcec.ModNScalar)
} testSScalar = new(btcec.ModNScalar)
_, _ = testSig.R.SetString("63724406601629180062774974542967536251589935445068131219452686511677818569431", 10) _ = testRScalar.SetByteSlice(testRBytes)
_, _ = testSig.S.SetString("18801056069249825825291287104931333862866033135609736119018462340006816851118", 10) _ = testSScalar.SetByteSlice(testSBytes)
testSig = ecdsa.NewSignature(testRScalar, testSScalar)
testTx = &wire.MsgTx{ testTx = &wire.MsgTx{
Version: 1, Version: 1,
@@ -390,16 +392,6 @@ func TestMigrateDatabaseWireMessages(t *testing.T) {
return err return err
} }
testChanCloseSummary.RemotePub.Curve = nil
testChanCloseSummary.RemoteCurrentRevocation.Curve = nil
testChanCloseSummary.RemoteNextRevocation.Curve = nil
testChanCloseSummary.LastChanSyncMsg.LocalUnrevokedCommitPoint.Curve = nil
newChanCloseSummary.RemotePub.Curve = nil
newChanCloseSummary.RemoteCurrentRevocation.Curve = nil
newChanCloseSummary.RemoteNextRevocation.Curve = nil
newChanCloseSummary.LastChanSyncMsg.LocalUnrevokedCommitPoint.Curve = nil
if !reflect.DeepEqual( if !reflect.DeepEqual(
newChanCloseSummary, testChanCloseSummary, newChanCloseSummary, testChanCloseSummary,
) { ) {
+3 -3
View File
@@ -9,10 +9,10 @@ import (
"math/rand" "math/rand"
"testing" "testing"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21" lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21"
mig "github.com/lightningnetwork/lnd/channeldb/migration_01_to_11" mig "github.com/lightningnetwork/lnd/channeldb/migration_01_to_11"
"github.com/lightningnetwork/lnd/channeldb/migtest" "github.com/lightningnetwork/lnd/channeldb/migtest"
@@ -62,7 +62,7 @@ var (
}, },
LockTime: 5, LockTime: 5,
} }
_, pubKey = btcec.PrivKeyFromBytes(btcec.S256(), key[:]) _, pubKey = btcec.PrivKeyFromBytes(key[:])
) )
// TestMigrateFwdPkgCleanup asserts that the migration will delete all the // TestMigrateFwdPkgCleanup asserts that the migration will delete all the
+2 -2
View File
@@ -8,10 +8,10 @@ import (
"strings" "strings"
"sync" "sync"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21" lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/shachain" "github.com/lightningnetwork/lnd/shachain"
+3 -3
View File
@@ -6,10 +6,10 @@ import (
"math/rand" "math/rand"
"os" "os"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
_ "github.com/btcsuite/btcwallet/walletdb/bdb" _ "github.com/btcsuite/btcwallet/walletdb/bdb"
lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21" lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"
@@ -60,7 +60,7 @@ var (
}, },
LockTime: 5, LockTime: 5,
} }
privKey, pubKey = btcec.PrivKeyFromBytes(btcec.S256(), key[:]) privKey, pubKey = btcec.PrivKeyFromBytes(key[:])
) )
// makeTestDB creates a new instance of the ChannelDB for testing purposes. A // makeTestDB creates a new instance of the ChannelDB for testing purposes. A
+4 -4
View File
@@ -6,10 +6,10 @@ import (
"io" "io"
"net" "net"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21" lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/shachain" "github.com/lightningnetwork/lnd/shachain"
@@ -324,7 +324,7 @@ func ReadElement(r io.Reader, element interface{}) error {
return err return err
} }
priv, _ := btcec.PrivKeyFromBytes(btcec.S256(), b[:]) priv, _ := btcec.PrivKeyFromBytes(b[:])
*e = priv *e = priv
case **btcec.PublicKey: case **btcec.PublicKey:
@@ -333,7 +333,7 @@ func ReadElement(r io.Reader, element interface{}) error {
return err return err
} }
pubKey, err := btcec.ParsePubKey(b[:], btcec.S256()) pubKey, err := btcec.ParsePubKey(b[:])
if err != nil { if err != nil {
return err return err
} }
+3 -3
View File
@@ -9,10 +9,10 @@ import (
"net" "net"
"time" "time"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21" lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21"
"github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/kvdb"
) )
@@ -384,7 +384,7 @@ func (l *LightningNode) PubKey() (*btcec.PublicKey, error) {
return l.pubKey, nil return l.pubKey, nil
} }
key, err := btcec.ParsePubKey(l.PubKeyBytes[:], btcec.S256()) key, err := btcec.ParsePubKey(l.PubKeyBytes[:])
if err != nil { if err != nil {
return nil, err return nil, err
} }
+11 -9
View File
@@ -1,13 +1,14 @@
package migration_01_to_11 package migration_01_to_11
import ( import (
"encoding/hex"
"image/color" "image/color"
"math/big"
prand "math/rand" prand "math/rand"
"net" "net"
"time" "time"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21" lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21"
) )
@@ -18,12 +19,13 @@ var (
"[2001:db8:85a3:0:0:8a2e:370:7334]:80") "[2001:db8:85a3:0:0:8a2e:370:7334]:80")
testAddrs = []net.Addr{testAddr, anotherAddr} testAddrs = []net.Addr{testAddr, anotherAddr}
testSig = &btcec.Signature{ testRBytes, _ = hex.DecodeString("8ce2bc69281ce27da07e6683571319d18e949ddfa2965fb6caa1bf0314f882d7")
R: new(big.Int), testSBytes, _ = hex.DecodeString("299105481d63e0f4bc2a88121167221b6700d72a0ead154c03be696a292d24ae")
S: new(big.Int), testRScalar = new(btcec.ModNScalar)
} testSScalar = new(btcec.ModNScalar)
_, _ = testSig.R.SetString("63724406601629180062774974542967536251589935445068131219452686511677818569431", 10) _ = testRScalar.SetByteSlice(testRBytes)
_, _ = testSig.S.SetString("18801056069249825825291287104931333862866033135609736119018462340006816851118", 10) _ = testSScalar.SetByteSlice(testSBytes)
testSig = ecdsa.NewSignature(testRScalar, testSScalar)
testFeatures = lnwire.NewFeatureVector(nil, nil) testFeatures = lnwire.NewFeatureVector(nil, nil)
) )
@@ -48,7 +50,7 @@ func createLightningNode(db *DB, priv *btcec.PrivateKey) (*LightningNode, error)
} }
func createTestVertex(db *DB) (*LightningNode, error) { func createTestVertex(db *DB) (*LightningNode, error) {
priv, err := btcec.NewPrivateKey(btcec.S256()) priv, err := btcec.NewPrivateKey()
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -6,7 +6,8 @@ import (
"testing" "testing"
"time" "time"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
bitcoinCfg "github.com/btcsuite/btcd/chaincfg" bitcoinCfg "github.com/btcsuite/btcd/chaincfg"
"github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/kvdb"
"github.com/lightningnetwork/lnd/zpay32" "github.com/lightningnetwork/lnd/zpay32"
@@ -150,12 +151,10 @@ func signDigestCompact(hash []byte) ([]byte, error) {
// Should the signature reference a compressed public key or not. // Should the signature reference a compressed public key or not.
isCompressedKey := true isCompressedKey := true
privKey, _ := btcec.PrivKeyFromBytes(btcec.S256(), testPrivKeyBytes) privKey, _ := btcec.PrivKeyFromBytes(testPrivKeyBytes)
// btcec.SignCompact returns a pubkey-recoverable signature // ecdsa.SignCompact returns a pubkey-recoverable signature
sig, err := btcec.SignCompact( sig, err := ecdsa.SignCompact(privKey, hash, isCompressedKey)
btcec.S256(), privKey, hash, isCompressedKey,
)
if err != nil { if err != nil {
return nil, fmt.Errorf("can't sign the hash: %v", err) return nil, fmt.Errorf("can't sign the hash: %v", err)
} }
+2 -2
View File
@@ -6,7 +6,7 @@ import (
"encoding/binary" "encoding/binary"
"fmt" "fmt"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21" lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21"
"github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/kvdb"
) )
@@ -839,7 +839,7 @@ func MigrateOutgoingPayments(tx kvdb.RwTx) error {
// Since we don't have the session key for old payments, we // Since we don't have the session key for old payments, we
// create a random one to be able to serialize the attempt // create a random one to be able to serialize the attempt
// info. // info.
priv, _ := btcec.NewPrivateKey(btcec.S256()) priv, _ := btcec.NewPrivateKey()
s := &PaymentAttemptInfo{ s := &PaymentAttemptInfo{
PaymentID: 0, // unknown. PaymentID: 0, // unknown.
SessionKey: priv, // unknown. SessionKey: priv, // unknown.
@@ -10,7 +10,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
"github.com/go-errors/errors" "github.com/go-errors/errors"
lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21" lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21"
@@ -440,8 +440,6 @@ func TestMigrateOptionalChannelCloseSummaryFields(t *testing.T) {
dbChan := dbChannels[0] dbChan := dbChannels[0]
if !reflect.DeepEqual(dbChan, test.closeSummary) { if !reflect.DeepEqual(dbChan, test.closeSummary) {
dbChan.RemotePub.Curve = nil
test.closeSummary.RemotePub.Curve = nil
t.Fatalf("not equal: %v vs %v", t.Fatalf("not equal: %v vs %v",
spew.Sdump(dbChan), spew.Sdump(dbChan),
spew.Sdump(test.closeSummary)) spew.Sdump(test.closeSummary))
+1 -1
View File
@@ -9,7 +9,7 @@ import (
"sort" "sort"
"time" "time"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21" lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21"
"github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/kvdb"
@@ -6,12 +6,12 @@ import (
"math/rand" "math/rand"
"time" "time"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21" lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21"
) )
var ( var (
priv, _ = btcec.NewPrivateKey(btcec.S256()) priv, _ = btcec.NewPrivateKey()
pub = priv.PubKey() pub = priv.PubKey()
) )
+2 -4
View File
@@ -9,7 +9,7 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
sphinx "github.com/lightningnetwork/lightning-onion" sphinx "github.com/lightningnetwork/lightning-onion"
lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21" lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21"
"github.com/lightningnetwork/lnd/record" "github.com/lightningnetwork/lnd/record"
@@ -246,9 +246,7 @@ func (r *Route) ToSphinxPath() (*sphinx.PaymentPath, error) {
// to an OnionHop with matching per-hop payload within the path as used // to an OnionHop with matching per-hop payload within the path as used
// by the sphinx package. // by the sphinx package.
for i, hop := range r.Hops { for i, hop := range r.Hops {
pub, err := btcec.ParsePubKey( pub, err := btcec.ParsePubKey(hop.PubKeyBytes[:])
hop.PubKeyBytes[:], btcec.S256(),
)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -8,11 +8,12 @@ import (
"strings" "strings"
"time" "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/btcutil/bech32"
"github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcutil/bech32"
lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21" lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21"
) )
@@ -112,8 +113,7 @@ func Decode(invoice string, net *chaincfg.Params) (*Invoice, error) {
} else { } else {
headerByte := recoveryID + 27 + 4 headerByte := recoveryID + 27 + 4
compactSign := append([]byte{headerByte}, sig[:]...) compactSign := append([]byte{headerByte}, sig[:]...)
pubkey, _, err := btcec.RecoverCompact(btcec.S256(), pubkey, _, err := ecdsa.RecoverCompact(compactSign, hash)
compactSign, hash)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -350,7 +350,7 @@ func parseDestination(data []byte) (*btcec.PublicKey, error) {
return nil, err return nil, err
} }
return btcec.ParsePubKey(base256Data, btcec.S256()) return btcec.ParsePubKey(base256Data)
} }
// parseExpiry converts the data (encoded in base32) into the expiry time. // parseExpiry converts the data (encoded in base32) into the expiry time.
@@ -452,7 +452,7 @@ func parseRouteHint(data []byte) ([]HopHint, error) {
for len(base256Data) > 0 { for len(base256Data) > 0 {
hopHint := HopHint{} hopHint := HopHint{}
hopHint.NodeID, err = btcec.ParsePubKey(base256Data[:33], btcec.S256()) hopHint.NodeID, err = btcec.ParsePubKey(base256Data[:33])
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -1,6 +1,6 @@
package zpay32 package zpay32
import "github.com/btcsuite/btcd/btcec" import "github.com/btcsuite/btcd/btcec/v2"
const ( const (
// DefaultFinalCLTVDelta is the default value to be used as the final // DefaultFinalCLTVDelta is the default value to be used as the final
@@ -5,9 +5,9 @@ import (
"fmt" "fmt"
"time" "time"
"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"
"github.com/btcsuite/btcutil"
lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21" lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21"
) )
@@ -103,7 +103,7 @@ type MessageSigner struct {
// SignCompact signs the passed hash with the node's privkey. The // SignCompact signs the passed hash with the node's privkey. The
// returned signature should be 65 bytes, where the last 64 are the // returned signature should be 65 bytes, where the last 64 are the
// compact signature, and the first one is a header byte. This is the // compact signature, and the first one is a header byte. This is the
// format returned by btcec.SignCompact. // format returned by ecdsa.SignCompact.
SignCompact func(hash []byte) ([]byte, error) SignCompact func(hash []byte) ([]byte, error)
} }
+2 -2
View File
@@ -6,7 +6,7 @@ import (
"io" "io"
"time" "time"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
@@ -68,7 +68,7 @@ func NewHtlcAttemptInfo(attemptID uint64, sessionKey *btcec.PrivateKey,
func (h *HTLCAttemptInfo) SessionKey() *btcec.PrivateKey { func (h *HTLCAttemptInfo) SessionKey() *btcec.PrivateKey {
if h.cachedSessionKey == nil { if h.cachedSessionKey == nil {
h.cachedSessionKey, _ = btcec.PrivKeyFromBytes( h.cachedSessionKey, _ = btcec.PrivKeyFromBytes(
btcec.S256(), h.sessionKey[:], h.sessionKey[:],
) )
} }
+2 -2
View File
@@ -6,7 +6,7 @@ import (
"net" "net"
"time" "time"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/kvdb"
) )
@@ -298,7 +298,7 @@ func deserializeLinkNode(r io.Reader) (*LinkNode, error) {
if _, err := io.ReadFull(r, pub[:]); err != nil { if _, err := io.ReadFull(r, pub[:]); err != nil {
return nil, err return nil, err
} }
node.IdentityPub, err = btcec.ParsePubKey(pub[:], btcec.S256()) node.IdentityPub, err = btcec.ParsePubKey(pub[:])
if err != nil { if err != nil {
return nil, err return nil, err
} }
+4 -4
View File
@@ -6,7 +6,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
) )
@@ -23,8 +23,8 @@ func TestLinkNodeEncodeDecode(t *testing.T) {
// First we'll create some initial data to use for populating our test // First we'll create some initial data to use for populating our test
// LinkNode instances. // LinkNode instances.
_, pub1 := btcec.PrivKeyFromBytes(btcec.S256(), key[:]) _, pub1 := btcec.PrivKeyFromBytes(key[:])
_, pub2 := btcec.PrivKeyFromBytes(btcec.S256(), rev[:]) _, pub2 := btcec.PrivKeyFromBytes(rev[:])
addr1, err := net.ResolveTCPAddr("tcp", "10.0.0.1:9000") addr1, err := net.ResolveTCPAddr("tcp", "10.0.0.1:9000")
if err != nil { if err != nil {
t.Fatalf("unable to create test addr: %v", err) t.Fatalf("unable to create test addr: %v", err)
@@ -120,7 +120,7 @@ func TestDeleteLinkNode(t *testing.T) {
cdb := fullDB.ChannelStateDB() cdb := fullDB.ChannelStateDB()
_, pubKey := btcec.PrivKeyFromBytes(btcec.S256(), key[:]) _, pubKey := btcec.PrivKeyFromBytes(key[:])
addr := &net.TCPAddr{ addr := &net.TCPAddr{
IP: net.ParseIP("127.0.0.1"), IP: net.ParseIP("127.0.0.1"),
Port: 1337, Port: 1337,
+2 -2
View File
@@ -8,7 +8,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcwallet/walletdb" "github.com/btcsuite/btcwallet/walletdb"
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/kvdb"
@@ -19,7 +19,7 @@ import (
) )
var ( var (
priv, _ = btcec.NewPrivateKey(btcec.S256()) priv, _ = btcec.NewPrivateKey()
pub = priv.PubKey() pub = priv.PubKey()
testHop1 = &route.Hop{ testHop1 = &route.Hop{
+1 -1
View File
@@ -5,9 +5,9 @@ import (
"errors" "errors"
"io" "io"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/kvdb"
"github.com/lightningnetwork/lnd/tlv" "github.com/lightningnetwork/lnd/tlv"
) )
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"math" "math"
"net" "net"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/lightningnetwork/lnd/chanbackup" "github.com/lightningnetwork/lnd/chanbackup"
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"strconv" "strconv"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/lightningnetwork/lnd/lnrpc/routerrpc" "github.com/lightningnetwork/lnd/lnrpc/routerrpc"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/routing/route" "github.com/lightningnetwork/lnd/routing/route"
+1 -1
View File
@@ -14,9 +14,9 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lnwallet/chanfunding" "github.com/lightningnetwork/lnd/lnwallet/chanfunding"
"github.com/urfave/cli" "github.com/urfave/cli"
+1 -1
View File
@@ -14,7 +14,7 @@ import (
"strings" "strings"
"time" "time"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/jedib0t/go-pretty/v6/table" "github.com/jedib0t/go-pretty/v6/table"
"github.com/jedib0t/go-pretty/v6/text" "github.com/jedib0t/go-pretty/v6/text"
"github.com/lightninglabs/protobuf-hex-display/jsonpb" "github.com/lightninglabs/protobuf-hex-display/jsonpb"
+1 -1
View File
@@ -7,7 +7,7 @@ import (
"path" "path"
"strings" "strings"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/lightningnetwork/lnd/lncfg" "github.com/lightningnetwork/lnd/lncfg"
"github.com/urfave/cli" "github.com/urfave/cli"
"gopkg.in/macaroon.v2" "gopkg.in/macaroon.v2"
+1 -1
View File
@@ -12,7 +12,7 @@ import (
"strings" "strings"
"syscall" "syscall"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/lightningnetwork/lnd/build" "github.com/lightningnetwork/lnd/build"
"github.com/lightningnetwork/lnd/lncfg" "github.com/lightningnetwork/lnd/lncfg"
"github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lnrpc"
+1 -1
View File
@@ -19,8 +19,8 @@ import (
"strings" "strings"
"time" "time"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcutil"
flags "github.com/jessevdk/go-flags" flags "github.com/jessevdk/go-flags"
"github.com/lightninglabs/neutrino" "github.com/lightninglabs/neutrino"
"github.com/lightningnetwork/lnd/autopilot" "github.com/lightningnetwork/lnd/autopilot"
+1 -1
View File
@@ -5,9 +5,9 @@ import (
"io" "io"
"sync" "sync"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/sweep" "github.com/lightningnetwork/lnd/sweep"
+1 -1
View File
@@ -9,10 +9,10 @@ import (
"sync" "sync"
"github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/blockchain"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
+11 -10
View File
@@ -19,11 +19,11 @@ import (
"testing" "testing"
"time" "time"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/go-errors/errors" "github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
@@ -432,7 +432,7 @@ func initBreachedOutputs() error {
bo := &breachedOutputs[i] bo := &breachedOutputs[i]
// Parse the sign descriptor's pubkey. // Parse the sign descriptor's pubkey.
pubkey, err := btcec.ParsePubKey(breachKeys[i], btcec.S256()) pubkey, err := btcec.ParsePubKey(breachKeys[i])
if err != nil { if err != nil {
return fmt.Errorf("unable to parse pubkey: %v", return fmt.Errorf("unable to parse pubkey: %v",
breachKeys[i]) breachKeys[i])
@@ -1216,7 +1216,7 @@ func TestBreachCreateJusticeTx(t *testing.T) {
// to the justice tx, not that we create a valid spend, so we just set // to the justice tx, not that we create a valid spend, so we just set
// some params making the script generation succeed. // some params making the script generation succeed.
aliceKeyPriv, _ := btcec.PrivKeyFromBytes( aliceKeyPriv, _ := btcec.PrivKeyFromBytes(
btcec.S256(), channels.AlicesPrivKey, channels.AlicesPrivKey,
) )
alicePubKey := aliceKeyPriv.PubKey() alicePubKey := aliceKeyPriv.PubKey()
@@ -2164,8 +2164,7 @@ func createTestArbiter(t *testing.T, contractBreaches chan *ContractBreachEvent,
return NewRetributionStore(db) return NewRetributionStore(db)
}) })
aliceKeyPriv, _ := btcec.PrivKeyFromBytes(btcec.S256(), aliceKeyPriv, _ := btcec.PrivKeyFromBytes(channels.AlicesPrivKey)
channels.AlicesPrivKey)
signer := &mock.SingleSigner{Privkey: aliceKeyPriv} signer := &mock.SingleSigner{Privkey: aliceKeyPriv}
// Assemble our test arbiter. // Assemble our test arbiter.
@@ -2199,10 +2198,12 @@ func createTestArbiter(t *testing.T, contractBreaches chan *ContractBreachEvent,
// initiator. // initiator.
func createInitChannels(revocationWindow int) (*lnwallet.LightningChannel, *lnwallet.LightningChannel, func(), error) { func createInitChannels(revocationWindow int) (*lnwallet.LightningChannel, *lnwallet.LightningChannel, func(), error) {
aliceKeyPriv, aliceKeyPub := btcec.PrivKeyFromBytes(btcec.S256(), aliceKeyPriv, aliceKeyPub := btcec.PrivKeyFromBytes(
channels.AlicesPrivKey) channels.AlicesPrivKey,
bobKeyPriv, bobKeyPub := btcec.PrivKeyFromBytes(btcec.S256(), )
channels.BobsPrivKey) bobKeyPriv, bobKeyPub := btcec.PrivKeyFromBytes(
channels.BobsPrivKey,
)
channelCapacity, err := btcutil.NewAmount(10) channelCapacity, err := btcutil.NewAmount(10)
if err != nil { if err != nil {
+2 -2
View File
@@ -6,7 +6,7 @@ import (
"fmt" "fmt"
"io" "io"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec/v2/ecdsa"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
@@ -1209,7 +1209,7 @@ func decodeSignDetails(r io.Reader) (*input.SignDetails, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
sig, err := btcec.ParseDERSignature(rawSig, btcec.S256()) sig, err := ecdsa.ParseDERSignature(rawSig)
if err != nil { if err != nil {
return nil, err return nil, err
} }
Loaded 100 of 350 files, more files were not shown because too many files have changed in this diff. Show more