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

+1 -1
View File
@@ -5,9 +5,9 @@ import (
"errors"
"fmt"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcwallet/chain"
"github.com/lightninglabs/neutrino"
"github.com/lightninglabs/neutrino/headerfs"
+3 -3
View File
@@ -9,13 +9,13 @@ import (
"sync"
"time"
"github.com/btcsuite/btcd/btcec"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/btcutil/hdkeychain"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcutil/hdkeychain"
"github.com/btcsuite/btcwallet/chain"
"github.com/btcsuite/btcwallet/waddrmgr"
base "github.com/btcsuite/btcwallet/wallet"
+4 -4
View File
@@ -4,10 +4,10 @@ import (
"bytes"
"fmt"
"github.com/btcsuite/btcd/btcec"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/btcutil/psbt"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcutil/psbt"
"github.com/btcsuite/btcwallet/waddrmgr"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/lnwallet"
@@ -244,7 +244,7 @@ func maybeTweakPrivKeyPsbt(unknowns []*psbt.Unknown,
if bytes.Equal(u.Key, PsbtKeyTypeInputSignatureTweakDouble) {
doubleTweakKey, _ := btcec.PrivKeyFromBytes(
btcec.S256(), u.Value,
u.Value,
)
return input.DeriveRevocationPrivKey(
privKey, doubleTweakKey,
+5 -5
View File
@@ -7,12 +7,12 @@ import (
"fmt"
"testing"
"github.com/btcsuite/btcd/btcec"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/btcutil/psbt"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcutil/psbt"
"github.com/btcsuite/btcwallet/waddrmgr"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/keychain"
@@ -29,7 +29,7 @@ var (
"aca5",
)
testCommitSecret, testCommitPoint = btcec.PrivKeyFromBytes(
btcec.S256(), testCommitSecretBytes,
testCommitSecretBytes,
)
remoteRevocationBasePubKeyBytes, _ = hex.DecodeString(
@@ -37,7 +37,7 @@ var (
"7359fb",
)
remoteRevocationBasePubKey, _ = btcec.ParsePubKey(
remoteRevocationBasePubKeyBytes, btcec.S256(),
remoteRevocationBasePubKeyBytes,
)
testTweakSingle, _ = hex.DecodeString(
+7 -12
View File
@@ -3,15 +3,15 @@ package btcwallet
import (
"fmt"
"github.com/btcsuite/btcd/btcec"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/btcutil/hdkeychain"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcutil/hdkeychain"
"github.com/btcsuite/btcwallet/waddrmgr"
"github.com/btcsuite/btcwallet/walletdb"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lnwallet"
@@ -367,7 +367,7 @@ func (b *BtcWallet) SignOutputRaw(tx *wire.MsgTx,
}
// Chop off the sighash flag at the end of the signature.
return btcec.ParseDERSignature(sig[:len(sig)-1], btcec.S256())
return ecdsa.ParseDERSignature(sig[:len(sig)-1])
}
// ComputeInputScript generates a complete InputScript for the passed
@@ -412,7 +412,7 @@ var _ input.Signer = (*BtcWallet)(nil)
//
// NOTE: This is a part of the MessageSigner interface.
func (b *BtcWallet) SignMessage(keyLoc keychain.KeyLocator,
msg []byte, doubleHash bool) (*btcec.Signature, error) {
msg []byte, doubleHash bool) (*ecdsa.Signature, error) {
// First attempt to fetch the private key which corresponds to the
// specified public key.
@@ -430,12 +430,7 @@ func (b *BtcWallet) SignMessage(keyLoc keychain.KeyLocator,
} else {
msgDigest = chainhash.HashB(msg)
}
sign, err := privKey.Sign(msgDigest)
if err != nil {
return nil, errors.Errorf("unable sign the message: %v", err)
}
return sign, nil
return ecdsa.Sign(privKey, msgDigest), nil
}
// A compile time check to ensure that BtcWallet implements the MessageSigner
+2 -2
View File
@@ -7,10 +7,10 @@ import (
"testing"
"time"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/btcutil/hdkeychain"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/integration/rpctest"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcutil/hdkeychain"
"github.com/btcsuite/btcwallet/chain"
"github.com/lightningnetwork/lnd/blockcache"
"github.com/lightningnetwork/lnd/lnwallet"
+1 -1
View File
@@ -12,8 +12,8 @@ import (
"sync"
"time"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/rpcclient"
"github.com/btcsuite/btcutil"
)
const (
+1 -1
View File
@@ -8,7 +8,7 @@ import (
"strings"
"testing"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcd/btcutil"
"github.com/stretchr/testify/require"
)
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"fmt"
"github.com/btcsuite/btcd/blockchain"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcd/btcutil"
)
const (
+1 -1
View File
@@ -4,10 +4,10 @@ import (
"bytes"
"fmt"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/htlcswitch"
"github.com/lightningnetwork/lnd/labels"
+1 -1
View File
@@ -1,8 +1,8 @@
package chanfunding
import (
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
)
+2 -2
View File
@@ -3,9 +3,9 @@ package chanfunding
import (
"fmt"
"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/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/keychain"
)
+1 -1
View File
@@ -3,9 +3,9 @@ package chanfunding
import (
"fmt"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
)
+1 -1
View File
@@ -5,8 +5,8 @@ import (
"regexp"
"testing"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
"github.com/stretchr/testify/require"
+3 -3
View File
@@ -6,12 +6,12 @@ import (
"fmt"
"sync"
"github.com/btcsuite/btcd/btcec"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/btcutil/psbt"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcutil/psbt"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/keychain"
)
+11 -11
View File
@@ -10,12 +10,12 @@ import (
"testing"
"time"
"github.com/btcsuite/btcd/btcec"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/btcutil/psbt"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcutil/psbt"
"github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/keychain"
@@ -54,8 +54,8 @@ func TestPsbtIntent(t *testing.T) {
// negotiating with the remote peer and they accept. By accepting, they
// send over their multisig key that's going to be used for the funding
// output. With that known, we can start crafting a PSBT.
_, localPubkey := btcec.PrivKeyFromBytes(btcec.S256(), localPrivkey)
_, remotePubkey := btcec.PrivKeyFromBytes(btcec.S256(), remotePrivkey)
_, localPubkey := btcec.PrivKeyFromBytes(localPrivkey)
_, remotePubkey := btcec.PrivKeyFromBytes(remotePrivkey)
psbtIntent.BindKeys(
&keychain.KeyDescriptor{PubKey: localPubkey}, remotePubkey,
)
@@ -197,8 +197,8 @@ func TestPsbtIntentBasePsbt(t *testing.T) {
// Generate the funding multisig keys and the address so we can compare
// it to the output of the intent.
_, localPubkey := btcec.PrivKeyFromBytes(btcec.S256(), localPrivkey)
_, remotePubkey := btcec.PrivKeyFromBytes(btcec.S256(), remotePrivkey)
_, localPubkey := btcec.PrivKeyFromBytes(localPrivkey)
_, remotePubkey := btcec.PrivKeyFromBytes(remotePrivkey)
// Make sure the output script address is correct.
script, _, err := input.GenFundingPkScript(
localPubkey.SerializeCompressed(),
@@ -474,8 +474,8 @@ func TestPsbtVerify(t *testing.T) {
psbtIntent := intent.(*PsbtIntent)
// Bind our test keys to get the funding parameters.
_, localPubkey := btcec.PrivKeyFromBytes(btcec.S256(), localPrivkey)
_, remotePubkey := btcec.PrivKeyFromBytes(btcec.S256(), remotePrivkey)
_, localPubkey := btcec.PrivKeyFromBytes(localPrivkey)
_, remotePubkey := btcec.PrivKeyFromBytes(remotePrivkey)
psbtIntent.BindKeys(
&keychain.KeyDescriptor{PubKey: localPubkey}, remotePubkey,
)
@@ -642,8 +642,8 @@ func TestPsbtFinalize(t *testing.T) {
psbtIntent := intent.(*PsbtIntent)
// Bind our test keys to get the funding parameters.
_, localPubkey := btcec.PrivKeyFromBytes(btcec.S256(), localPrivkey)
_, remotePubkey := btcec.PrivKeyFromBytes(btcec.S256(), remotePrivkey)
_, localPubkey := btcec.PrivKeyFromBytes(localPrivkey)
_, remotePubkey := btcec.PrivKeyFromBytes(remotePrivkey)
psbtIntent.BindKeys(
&keychain.KeyDescriptor{PubKey: localPubkey}, remotePubkey,
)
+3 -3
View File
@@ -4,11 +4,11 @@ import (
"fmt"
"math"
"github.com/btcsuite/btcd/btcec"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/btcutil/txsort"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcutil/txsort"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/keychain"
)
+13 -17
View File
@@ -11,13 +11,14 @@ import (
"sync"
"github.com/btcsuite/btcd/blockchain"
"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/txsort"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btclog"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcutil/txsort"
"github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/build"
"github.com/lightningnetwork/lnd/chainntnfs"
@@ -303,7 +304,7 @@ type PaymentDescriptor struct {
// local node. This signature is generated by the remote node and
// stored by the local node in the case that local node needs to
// broadcast their commitment transaction.
sig *btcec.Signature
sig *ecdsa.Signature
// addCommitHeight[Remote|Local] encodes the height of the commitment
// which included this HTLC on either the remote or local commitment
@@ -2297,7 +2298,7 @@ func NewBreachRetribution(chanState *channeldb.OpenChannel, stateNum uint64,
return nil, err
}
commitmentSecret, commitmentPoint := btcec.PrivKeyFromBytes(
btcec.S256(), revocationPreimage[:],
revocationPreimage[:],
)
// With the commitment point generated, we can now generate the four
@@ -4105,7 +4106,7 @@ func genHtlcSigValidationJobs(localCommitmentView *commitment,
var (
htlcIndex uint64
sigHash func() ([]byte, error)
sig *btcec.Signature
sig *ecdsa.Signature
err error
)
@@ -4421,16 +4422,13 @@ func (lc *LightningChannel) ReceiveNewCommitment(commitSig lnwire.Sig,
// While the HTLC verification jobs are proceeding asynchronously,
// we'll ensure that the newly constructed commitment state has a valid
// signature.
verifyKey := btcec.PublicKey{
X: lc.channelState.RemoteChanCfg.MultiSigKey.PubKey.X,
Y: lc.channelState.RemoteChanCfg.MultiSigKey.PubKey.Y,
Curve: btcec.S256(),
}
verifyKey := lc.channelState.RemoteChanCfg.MultiSigKey.PubKey
cSig, err := commitSig.ToSignature()
if err != nil {
return err
}
if !cSig.Verify(sigHash, &verifyKey) {
if !cSig.Verify(sigHash, verifyKey) {
close(cancelChan)
// If we fail to validate their commitment signature, we'll
@@ -5485,9 +5483,7 @@ func (lc *LightningChannel) getSignedCommitTx() (*wire.MsgTx, error) {
localCommit := lc.channelState.LocalCommitment
commitTx := localCommit.CommitTx.Copy()
theirSig, err := btcec.ParseDERSignature(
localCommit.CommitSig, btcec.S256(),
)
theirSig, err := ecdsa.ParseDERSignature(localCommit.CommitSig)
if err != nil {
return nil, err
}
@@ -5906,7 +5902,7 @@ func newOutgoingHtlcResolution(signer input.Signer,
InputIndex: 0,
}
htlcSig, err := btcec.ParseDERSignature(htlc.Signature, btcec.S256())
htlcSig, err := ecdsa.ParseDERSignature(htlc.Signature)
if err != nil {
return nil, err
}
@@ -6041,7 +6037,7 @@ func newIncomingHtlcResolution(signer input.Signer,
InputIndex: 0,
}
htlcSig, err := btcec.ParseDERSignature(htlc.Signature, btcec.S256())
htlcSig, err := ecdsa.ParseDERSignature(htlc.Signature)
if err != nil {
return nil, err
}
+3 -3
View File
@@ -12,10 +12,10 @@ import (
"testing/quick"
"github.com/btcsuite/btcd/blockchain"
"github.com/btcsuite/btcd/btcec"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/txscript"
"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"
@@ -4415,7 +4415,7 @@ func TestChanSyncFailure(t *testing.T) {
}
p := bobSyncMsg.LocalUnrevokedCommitPoint.SerializeCompressed()
p[4] ^= 0x01
modCommitPoint, err := btcec.ParsePubKey(p, btcec.S256())
modCommitPoint, err := btcec.ParsePubKey(p)
if err != nil {
t.Fatalf("unable to parse pubkey: %v", err)
}
+1 -1
View File
@@ -4,9 +4,9 @@ import (
"bytes"
"fmt"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/lightningnetwork/lnd/lnwire"
)
+7 -10
View File
@@ -4,11 +4,12 @@ import (
"bytes"
"testing"
"github.com/btcsuite/btcd/btcec"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/lnwire"
)
@@ -27,8 +28,8 @@ var (
0x69, 0x49, 0x18, 0x83, 0x31, 0x98, 0x47, 0x53,
}
alicePriv, alicePub = btcec.PrivKeyFromBytes(btcec.S256(), aliceKey[:])
bobPriv, bobPub = btcec.PrivKeyFromBytes(btcec.S256(), bobKey[:])
alicePriv, alicePub = btcec.PrivKeyFromBytes(aliceKey[:])
bobPriv, bobPub = btcec.PrivKeyFromBytes(bobKey[:])
)
// channelTestCtx holds shared context that will be used in all tests cases
@@ -106,9 +107,7 @@ func newChannelTestCtx(chanSize int64) (*channelTestCtx, error) {
return nil, err
}
aliceSig, err := btcec.ParseDERSignature(
aliceSigRaw, btcec.S256(),
)
aliceSig, err := ecdsa.ParseDERSignature(aliceSigRaw)
if err != nil {
return nil, err
}
@@ -121,9 +120,7 @@ func newChannelTestCtx(chanSize int64) (*channelTestCtx, error) {
return nil, err
}
bobSig, err := btcec.ParseDERSignature(
bobSigRaw, btcec.S256(),
)
bobSig, err := ecdsa.ParseDERSignature(bobSigRaw)
if err != nil {
return nil, err
}
+2 -2
View File
@@ -4,10 +4,10 @@ import (
"fmt"
"github.com/btcsuite/btcd/blockchain"
"github.com/btcsuite/btcd/btcec"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
+1 -1
View File
@@ -4,8 +4,8 @@ import (
"errors"
"fmt"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcutil"
"github.com/lightningnetwork/lnd/lnwire"
)
+6 -5
View File
@@ -6,12 +6,13 @@ import (
"sync"
"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/hdkeychain"
"github.com/btcsuite/btcd/btcutil/psbt"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcutil/hdkeychain"
"github.com/btcsuite/btcutil/psbt"
"github.com/btcsuite/btcwallet/waddrmgr"
"github.com/btcsuite/btcwallet/wallet/txauthor"
"github.com/btcsuite/btcwallet/wtxmgr"
@@ -468,7 +469,7 @@ type MessageSigner interface {
// be found, then an error will be returned. The actual digest signed is
// the single or double SHA-256 of the passed message.
SignMessage(keyLoc keychain.KeyLocator, msg []byte,
doubleHash bool) (*btcec.Signature, error)
doubleHash bool) (*ecdsa.Signature, error)
}
// WalletDriver represents a "driver" for a particular concrete
+1 -1
View File
@@ -1,9 +1,9 @@
package lnwallet
import (
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/mempool"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/lnwire"
)
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"fmt"
"testing"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcd/btcutil"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/stretchr/testify/require"
+2 -2
View File
@@ -5,10 +5,10 @@ import (
"net"
"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/wire"
"github.com/btcsuite/btcutil"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/keychain"
+8 -7
View File
@@ -9,12 +9,13 @@ import (
"io/ioutil"
"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/hdkeychain"
"github.com/btcsuite/btcd/btcutil/psbt"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcutil/hdkeychain"
"github.com/btcsuite/btcutil/psbt"
basewallet "github.com/btcsuite/btcwallet/wallet"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/keychain"
@@ -420,7 +421,7 @@ func (r *RPCKeyRing) ECDH(keyDesc keychain.KeyDescriptor,
//
// NOTE: This method is part of the keychain.MessageSignerRing interface.
func (r *RPCKeyRing) SignMessage(keyLoc keychain.KeyLocator,
msg []byte, doubleHash bool) (*btcec.Signature, error) {
msg []byte, doubleHash bool) (*ecdsa.Signature, error) {
ctxt, cancel := context.WithTimeout(context.Background(), r.rpcTimeout)
defer cancel()
@@ -697,7 +698,7 @@ func (r *RPCKeyRing) remoteSign(tx *wire.MsgTx, signDesc *input.SignDescriptor,
// The remote signer always adds the sighash type, so we need to account
// for that.
if len(sigWithSigHash.Signature) < btcec.MinSigLen+1 {
if len(sigWithSigHash.Signature) < ecdsa.MinSigLen+1 {
return nil, fmt.Errorf("remote signer returned invalid "+
"partial signature: signature too short with %d bytes",
len(sigWithSigHash.Signature))
@@ -706,7 +707,7 @@ func (r *RPCKeyRing) remoteSign(tx *wire.MsgTx, signDesc *input.SignDescriptor,
// Parse the signature, but chop off the last byte which is the sighash
// type.
sig := sigWithSigHash.Signature[0 : len(sigWithSigHash.Signature)-1]
return btcec.ParseDERSignature(sig, btcec.S256())
return ecdsa.ParseDERSignature(sig)
}
// connectRPC tries to establish an RPC connection to the given host:port with
+3 -2
View File
@@ -4,7 +4,8 @@ import (
"fmt"
"sync"
"github.com/btcsuite/btcd/btcec"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
"github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/lnwire"
@@ -35,7 +36,7 @@ type VerifyJob struct {
// Sig is the raw signature generated using the above public key. This
// is the signature to be verified.
Sig *btcec.Signature
Sig *ecdsa.Signature
// SigHash is a function closure generates the sighashes that the
// passed signature is known to have signed.
+5 -6
View File
@@ -17,8 +17,9 @@ import (
"testing"
"time"
"github.com/btcsuite/btcd/btcec"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcjson"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/integration/rpctest"
@@ -26,7 +27,6 @@ import (
"github.com/btcsuite/btcd/rpcclient"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcwallet/chain"
"github.com/btcsuite/btcwallet/walletdb"
_ "github.com/btcsuite/btcwallet/walletdb/bdb"
@@ -81,8 +81,8 @@ var (
netParams = &chaincfg.RegressionNetParams
chainHash = netParams.GenesisHash
_, alicePub = btcec.PrivKeyFromBytes(btcec.S256(), testHdSeed[:])
_, bobPub = btcec.PrivKeyFromBytes(btcec.S256(), bobsPrivKey)
_, alicePub = btcec.PrivKeyFromBytes(testHdSeed[:])
_, bobPub = btcec.PrivKeyFromBytes(bobsPrivKey)
// The number of confirmations required to consider any created channel
// open.
@@ -2001,8 +2001,7 @@ func testSignOutputUsingTweaks(r *rpctest.Harness,
// we'll generate a commitment pre-image, then derive a revocation key
// and single tweak from that.
commitPreimage := bytes.Repeat([]byte{2}, 32)
commitSecret, commitPoint := btcec.PrivKeyFromBytes(btcec.S256(),
commitPreimage)
commitSecret, commitPoint := btcec.PrivKeyFromBytes(commitPreimage)
revocationKey := input.DeriveRevocationPubkey(pubKey.PubKey, commitPoint)
commitTweak := input.SingleTweakBytes(commitPoint, pubKey.PubKey)
+6 -6
View File
@@ -10,10 +10,10 @@ import (
"net"
"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/wire"
"github.com/btcsuite/btcutil"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/keychain"
@@ -138,14 +138,14 @@ func CreateTestChannels(chanType channeldb.ChannelType) (
copy(key[:], testWalletPrivKey[:])
key[0] ^= byte(i + 1)
aliceKey, _ := btcec.PrivKeyFromBytes(btcec.S256(), key)
aliceKey, _ := btcec.PrivKeyFromBytes(key)
aliceKeys = append(aliceKeys, aliceKey)
key = make([]byte, len(bobsPrivKey))
copy(key[:], bobsPrivKey)
key[0] ^= byte(i + 1)
bobKey, _ := btcec.PrivKeyFromBytes(btcec.S256(), key)
bobKey, _ := btcec.PrivKeyFromBytes(key)
bobKeys = append(bobKeys, bobKey)
}
@@ -450,7 +450,7 @@ func pubkeyFromHex(keyHex string) (*btcec.PublicKey, error) {
if err != nil {
return nil, err
}
return btcec.ParsePubKey(bytes, btcec.S256())
return btcec.ParsePubKey(bytes)
}
// privkeyFromHex parses a Bitcoin private key from a hex encoded string.
@@ -459,7 +459,7 @@ func privkeyFromHex(keyHex string) (*btcec.PrivateKey, error) {
if err != nil {
return nil, err
}
key, _ := btcec.PrivKeyFromBytes(btcec.S256(), bytes)
key, _ := btcec.PrivKeyFromBytes(bytes)
return key, nil
}
+2 -2
View File
@@ -4,9 +4,9 @@ import (
"encoding/binary"
"fmt"
"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/lightningnetwork/lnd/channeldb"
)
+6 -6
View File
@@ -15,11 +15,11 @@ 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/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/keychain"
@@ -511,15 +511,15 @@ func testSpendValidation(t *testing.T, tweakless bool) {
// Each side currently has 1 BTC within the channel, with a total
// channel capacity of 2BTC.
aliceKeyPriv, aliceKeyPub := btcec.PrivKeyFromBytes(
btcec.S256(), testWalletPrivKey,
testWalletPrivKey,
)
bobKeyPriv, bobKeyPub := btcec.PrivKeyFromBytes(
btcec.S256(), bobsPrivKey,
bobsPrivKey,
)
revocationPreimage := testHdSeed.CloneBytes()
commitSecret, commitPoint := btcec.PrivKeyFromBytes(
btcec.S256(), revocationPreimage,
revocationPreimage,
)
revokePubKey := input.DeriveRevocationPubkey(bobKeyPub, commitPoint)
@@ -783,7 +783,7 @@ func createTestChannelsForVectors(tc *testContext, chanType channeldb.ChannelTyp
&remoteDummy1, &remoteDummy2, &localDummy1, &localDummy2,
}
for _, keyRef := range generateKeys {
privkey, err := btcec.NewPrivateKey(btcec.S256())
privkey, err := btcec.NewPrivateKey()
require.NoError(t, err)
*keyRef = privkey
}
+4 -4
View File
@@ -11,14 +11,14 @@ import (
"sync/atomic"
"github.com/btcsuite/btcd/blockchain"
"github.com/btcsuite/btcd/btcec"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/btcutil/psbt"
"github.com/btcsuite/btcd/btcutil/txsort"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcutil/psbt"
"github.com/btcsuite/btcutil/txsort"
"github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/input"