multi: use btcd's btcec/v2 and btcutil modules
This commit was previously split into the following parts to ease review: - 2d746f68: replace imports - 4008f0fd: use ecdsa.Signature - 849e33d1: remove btcec.S256() - b8f6ebbd: use v2 library correctly - fa80bca9: bump go modules
This commit is contained in:
350 files changed
+2421
-1289
No files matched your search
@@ -6,8 +6,8 @@ import (
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/htlcswitch"
|
||||
"github.com/lightningnetwork/lnd/kvdb"
|
||||
|
||||
@@ -6,9 +6,9 @@ import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
bitcoinCfg "github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcutil"
|
||||
sphinx "github.com/lightningnetwork/lightning-onion"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/htlcswitch"
|
||||
@@ -38,13 +38,13 @@ var (
|
||||
func init() {
|
||||
// Generate a fresh key for our sphinx router.
|
||||
var err error
|
||||
sphinxPrivKey, err = btcec.NewPrivateKey(btcec.S256())
|
||||
sphinxPrivKey, err = btcec.NewPrivateKey()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// And another, whose public key will serve as the test ephemeral key.
|
||||
testEphemeralPriv, err := btcec.NewPrivateKey(btcec.S256())
|
||||
testEphemeralPriv, err := btcec.NewPrivateKey()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
sphinx "github.com/lightningnetwork/lightning-onion"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
)
|
||||
@@ -165,7 +165,7 @@ func (s *SphinxErrorEncrypter) Decode(r io.Reader) error {
|
||||
}
|
||||
|
||||
var err error
|
||||
s.EphemeralKey, err = btcec.ParsePubKey(ephemeral[:], btcec.S256())
|
||||
s.EphemeralKey, err = btcec.ParsePubKey(ephemeral[:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"io"
|
||||
"sync"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
sphinx "github.com/lightningnetwork/lightning-onion"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
)
|
||||
|
||||
+1
-1
@@ -9,9 +9,9 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btclog"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/go-errors/errors"
|
||||
"github.com/lightningnetwork/lnd/build"
|
||||
|
||||
+2
-21
@@ -14,10 +14,10 @@ import (
|
||||
"testing"
|
||||
"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/wire"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/go-errors/errors"
|
||||
sphinx "github.com/lightningnetwork/lightning-onion"
|
||||
@@ -70,25 +70,6 @@ func (c *concurrentTester) Fatalf(format string, args ...interface{}) {
|
||||
// setting the 'Curve" parameter to nil. Doing this avoids printing out each of
|
||||
// the field elements in the curve parameters for secp256k1.
|
||||
func messageToString(msg lnwire.Message) string {
|
||||
switch m := msg.(type) {
|
||||
case *lnwire.RevokeAndAck:
|
||||
m.NextRevocationKey.Curve = nil
|
||||
case *lnwire.AcceptChannel:
|
||||
m.FundingKey.Curve = nil
|
||||
m.RevocationPoint.Curve = nil
|
||||
m.PaymentPoint.Curve = nil
|
||||
m.DelayedPaymentPoint.Curve = nil
|
||||
m.FirstCommitmentPoint.Curve = nil
|
||||
case *lnwire.OpenChannel:
|
||||
m.FundingKey.Curve = nil
|
||||
m.RevocationPoint.Curve = nil
|
||||
m.PaymentPoint.Curve = nil
|
||||
m.DelayedPaymentPoint.Curve = nil
|
||||
m.FirstCommitmentPoint.Curve = nil
|
||||
case *lnwire.FundingLocked:
|
||||
m.NextPerCommitmentPoint.Curve = nil
|
||||
}
|
||||
|
||||
return spew.Sdump(msg)
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/clock"
|
||||
|
||||
+3
-3
@@ -14,9 +14,9 @@ import (
|
||||
"testing"
|
||||
"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/btcutil"
|
||||
"github.com/go-errors/errors"
|
||||
sphinx "github.com/lightningnetwork/lightning-onion"
|
||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||
@@ -610,7 +610,7 @@ func (s *mockServer) PubKey() [33]byte {
|
||||
}
|
||||
|
||||
func (s *mockServer) IdentityKey() *btcec.PublicKey {
|
||||
pubkey, _ := btcec.ParsePubKey(s.id[:], btcec.S256())
|
||||
pubkey, _ := btcec.ParsePubKey(s.id[:])
|
||||
return pubkey
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/htlcswitch/hodl"
|
||||
|
||||
+14
-14
@@ -5,9 +5,9 @@ import (
|
||||
crand "crypto/rand"
|
||||
"crypto/sha256"
|
||||
"encoding/binary"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math/big"
|
||||
"net"
|
||||
"os"
|
||||
"runtime"
|
||||
@@ -16,10 +16,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/go-errors/errors"
|
||||
sphinx "github.com/lightningnetwork/lightning-onion"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
@@ -45,16 +46,15 @@ var (
|
||||
bobPrivKey = []byte("bob priv key")
|
||||
carolPrivKey = []byte("carol priv key")
|
||||
|
||||
testSig = &btcec.Signature{
|
||||
R: new(big.Int),
|
||||
S: new(big.Int),
|
||||
}
|
||||
wireSig, _ = lnwire.NewSigFromSignature(testSig)
|
||||
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)
|
||||
|
||||
_, _ = testSig.R.SetString("6372440660162918006277497454296753625158993"+
|
||||
"5445068131219452686511677818569431", 10)
|
||||
_, _ = testSig.S.SetString("1880105606924982582529128710493133386286603"+
|
||||
"3135609736119018462340006816851118", 10)
|
||||
wireSig, _ = lnwire.NewSigFromSignature(testSig)
|
||||
|
||||
testBatchTimeout = 50 * time.Millisecond
|
||||
)
|
||||
@@ -128,8 +128,8 @@ func createTestChannel(alicePrivKey, bobPrivKey []byte,
|
||||
chanID lnwire.ShortChannelID) (*testLightningChannel,
|
||||
*testLightningChannel, func(), error) {
|
||||
|
||||
aliceKeyPriv, aliceKeyPub := btcec.PrivKeyFromBytes(btcec.S256(), alicePrivKey)
|
||||
bobKeyPriv, bobKeyPub := btcec.PrivKeyFromBytes(btcec.S256(), bobPrivKey)
|
||||
aliceKeyPriv, aliceKeyPub := btcec.PrivKeyFromBytes(alicePrivKey)
|
||||
bobKeyPriv, bobKeyPub := btcec.PrivKeyFromBytes(bobPrivKey)
|
||||
|
||||
channelCapacity := aliceAmount + bobAmount
|
||||
csvTimeoutAlice := uint32(5)
|
||||
|
||||
Reference in new issue
Block a user