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,8 +3,8 @@ package lnwire
import (
"io"
"github.com/btcsuite/btcd/btcec"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
)
// AcceptChannel is the message Bob sends to Alice after she initiates the
@@ -3,7 +3,7 @@ package lnwire
import (
"io"
"github.com/btcsuite/btcd/btcec"
"github.com/btcsuite/btcd/btcec/v2"
)
// ChannelReestablish is a message sent between peers that have an existing
@@ -3,7 +3,7 @@ package lnwire
import (
"io"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcd/btcutil"
)
// ClosingSigned is sent by both parties to a channel once the channel is clear
@@ -3,7 +3,7 @@ package lnwire
import (
"io"
"github.com/btcsuite/btcd/btcec"
"github.com/btcsuite/btcd/btcec/v2"
)
// FundingLocked is the message that both parties to a new channel creation
+3 -3
View File
@@ -9,10 +9,10 @@ import (
"math"
"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/wire"
"github.com/btcsuite/btcutil"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/tor"
)
@@ -529,7 +529,7 @@ func ReadElement(r io.Reader, element interface{}) error {
return err
}
pubKey, err := btcec.ParsePubKey(b[:], btcec.S256())
pubKey, err := btcec.ParsePubKey(b[:])
if err != nil {
return err
}
+1 -1
View File
@@ -3,7 +3,7 @@ package lnwire
import (
"fmt"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcd/btcutil"
)
const (
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"fmt"
"net"
"github.com/btcsuite/btcd/btcec"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/wire"
)
+2 -2
View File
@@ -3,9 +3,9 @@ package lnwire
import (
"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/btcutil"
)
// FundingFlag represents the possible bit mask values for the ChannelFlags
@@ -3,7 +3,7 @@ package lnwire
import (
"io"
"github.com/btcsuite/btcd/btcec"
"github.com/btcsuite/btcd/btcec/v2"
)
// RevokeAndAck is sent by either side once a CommitSig message has been
+7 -7
View File
@@ -3,14 +3,14 @@ package lnwire
import (
"fmt"
"github.com/btcsuite/btcd/btcec"
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
"github.com/lightningnetwork/lnd/input"
)
// Sig is a fixed-sized ECDSA signature. Unlike Bitcoin, we use fixed sized
// signatures on the wire, instead of DER encoded signatures. This type
// 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
// 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
// is the second byte after R ends. 0x02 signifies a length-prefixed,
// 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]
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
// existing btcec.Signature.
// existing ecdsa.Signature.
func NewSigFromSignature(e input.Signature) (Sig, error) {
if e == nil {
return Sig{}, fmt.Errorf("cannot decode empty signature")
@@ -74,12 +74,12 @@ func NewSigFromSignature(e input.Signature) (Sig, error) {
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.
func (b *Sig) ToSignature() (*btcec.Signature, error) {
func (b *Sig) ToSignature() (*ecdsa.Signature, error) {
// Parse the signature with strict checks.
sigBytes := b.ToSignatureBytes()
sig, err := btcec.ParseDERSignature(sigBytes, btcec.S256())
sig, err := ecdsa.ParseDERSignature(sigBytes)
if err != nil {
return nil, err
}