multi: use btcd's btcec/v2 and btcutil modules

This commit was previously split into the following parts to ease
review:
 - 2d746f68: replace imports
 - 4008f0fd: use ecdsa.Signature
 - 849e33d1: remove btcec.S256()
 - b8f6ebbd: use v2 library correctly
 - fa80bca9: bump go modules
This commit is contained in:
Oliver Gugger
2022-02-23 14:48:00 +01:00
parent 8ee9fc837b
commit 7dfe4018ce
350 changed files with 2421 additions and 1289 deletions

View File

@@ -1,7 +1,8 @@
package mock
import (
"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/lightningnetwork/lnd/keychain"
)
@@ -45,7 +46,7 @@ func (s *SecretKeyRing) ECDH(_ keychain.KeyDescriptor,
// SignMessage signs the passed message and ignores the KeyDescriptor.
func (s *SecretKeyRing) SignMessage(_ keychain.KeyLocator,
msg []byte, doubleHash bool) (*btcec.Signature, error) {
msg []byte, doubleHash bool) (*ecdsa.Signature, error) {
var digest []byte
if doubleHash {
@@ -53,7 +54,7 @@ func (s *SecretKeyRing) SignMessage(_ keychain.KeyLocator,
} else {
digest = chainhash.HashB(msg)
}
return s.RootKey.Sign(digest)
return ecdsa.Sign(s.RootKey, digest), nil
}
// SignMessageCompact signs the passed message.
@@ -66,5 +67,5 @@ func (s *SecretKeyRing) SignMessageCompact(_ keychain.KeyLocator,
} else {
digest = chainhash.HashB(msg)
}
return btcec.SignCompact(btcec.S256(), s.RootKey, digest, true)
return ecdsa.SignCompact(s.RootKey, digest, true)
}

View File

@@ -3,7 +3,8 @@ package mock
import (
"fmt"
"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/txscript"
"github.com/btcsuite/btcd/wire"
@@ -82,7 +83,7 @@ func (s *SingleSigner) SignOutputRaw(tx *wire.MsgTx,
return nil, err
}
return btcec.ParseDERSignature(sig[:len(sig)-1], btcec.S256())
return ecdsa.ParseDERSignature(sig[:len(sig)-1])
}
// ComputeInputScript computes an input script with the stored private key
@@ -116,7 +117,7 @@ func (s *SingleSigner) ComputeInputScript(tx *wire.MsgTx,
// SignMessage takes a public key and a message and only signs the message
// with the stored private key if the public key matches the private key.
func (s *SingleSigner) SignMessage(keyLoc keychain.KeyLocator,
msg []byte, doubleHash bool) (*btcec.Signature, error) {
msg []byte, doubleHash bool) (*ecdsa.Signature, error) {
mockKeyLoc := s.KeyLoc
if s.KeyLoc.IsEmpty() {
@@ -133,10 +134,5 @@ func (s *SingleSigner) SignMessage(keyLoc keychain.KeyLocator,
} else {
digest = chainhash.HashB(msg)
}
sign, err := s.Privkey.Sign(digest)
if err != nil {
return nil, fmt.Errorf("can't sign the message: %v", err)
}
return sign, nil
return ecdsa.Sign(s.Privkey, digest), nil
}

View File

@@ -5,13 +5,13 @@ import (
"sync/atomic"
"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/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/hdkeychain"
"github.com/btcsuite/btcutil/psbt"
"github.com/btcsuite/btcwallet/waddrmgr"
"github.com/btcsuite/btcwallet/wallet/txauthor"
"github.com/btcsuite/btcwallet/wtxmgr"