Skip to content

Commit

Permalink
multi: bump btcd dependency to fix JSON parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
guggero committed Sep 2, 2024
1 parent 8655542 commit 2792a8a
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 54 deletions.
8 changes: 1 addition & 7 deletions channeldb/migration_01_to_11/migration_11_invoices_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package migration_01_to_11

import (
"bytes"
"fmt"
"testing"
"time"

Expand Down Expand Up @@ -154,12 +153,7 @@ func signDigestCompact(hash []byte) ([]byte, error) {
privKey, _ := btcec.PrivKeyFromBytes(testPrivKeyBytes)

// ecdsa.SignCompact returns a pubkey-recoverable signature
sig, err := ecdsa.SignCompact(privKey, hash, isCompressedKey)
if err != nil {
return nil, fmt.Errorf("can't sign the hash: %w", err)
}

return sig, nil
return ecdsa.SignCompact(privKey, hash, isCompressedKey), nil
}

// getPayReq creates a payment request for the given net.
Expand Down
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require (
github.com/Yawning/aez v0.0.0-20211027044916-e49e68abd344
github.com/andybalholm/brotli v1.0.4
github.com/btcsuite/btcd v0.24.2-beta.rc1.0.20240625142744-cc26860b4026
github.com/btcsuite/btcd/btcec/v2 v2.3.3
github.com/btcsuite/btcd/btcec/v2 v2.3.4
github.com/btcsuite/btcd/btcutil v1.1.5
github.com/btcsuite/btcd/btcutil/psbt v1.1.8
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0
Expand Down Expand Up @@ -204,6 +204,8 @@ replace github.com/gogo/protobuf => github.com/gogo/protobuf v1.3.2
// allows us to specify that as an option.
replace google.golang.org/protobuf => github.com/lightninglabs/protobuf-go-hex-display v1.30.0-hex-display

replace github.com/btcsuite/btcd => github.com/guggero/btcd v0.20.1-beta.0.20240902133835-ed879eac20ec

// If you change this please also update .github/pull_request_template.md,
// docs/INSTALL.md and GO_IMAGE in lnrpc/gen_protos_docker.sh.
go 1.22.6
Expand Down
51 changes: 34 additions & 17 deletions go.sum

Large diffs are not rendered by default.

9 changes: 1 addition & 8 deletions invoices/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"crypto/rand"
"encoding/binary"
"encoding/hex"
"fmt"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -69,13 +68,7 @@ var (
testMessageSigner = zpay32.MessageSigner{
SignCompact: func(msg []byte) ([]byte, error) {
hash := chainhash.HashB(msg)
sig, err := ecdsa.SignCompact(testPrivKey, hash, true)
if err != nil {
return nil, fmt.Errorf("can't sign the "+
"message: %v", err)
}

return sig, nil
return ecdsa.SignCompact(testPrivKey, hash, true), nil
},
}

Expand Down
7 changes: 1 addition & 6 deletions invoices/test_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,7 @@ var (
testMessageSigner = zpay32.MessageSigner{
SignCompact: func(msg []byte) ([]byte, error) {
hash := chainhash.HashB(msg)
sig, err := ecdsa.SignCompact(testPrivKey, hash, true)
if err != nil {
return nil, fmt.Errorf("can't sign the "+
"message: %v", err)
}
return sig, nil
return ecdsa.SignCompact(testPrivKey, hash, true), nil
},
}

Expand Down
2 changes: 1 addition & 1 deletion keychain/btcwallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ func (b *BtcWalletKeyRing) SignMessageCompact(keyLoc KeyLocator,
} else {
digest = chainhash.HashB(msg)
}
return ecdsa.SignCompact(privKey, digest, true)
return ecdsa.SignCompact(privKey, digest, true), nil

Check failure on line 451 in keychain/btcwallet.go

View workflow job for this annotation

GitHub Actions / lint code

return with no blank line before (nlreturn)
}

// SignMessageSchnorr uses the Schnorr signature algorithm to sign the given
Expand Down
2 changes: 1 addition & 1 deletion keychain/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (p *PrivKeyMessageSigner) SignMessageCompact(msg []byte,
} else {
digest = chainhash.HashB(msg)
}
return ecdsa.SignCompact(p.privKey, digest, true)
return ecdsa.SignCompact(p.privKey, digest, true), nil

Check failure on line 88 in keychain/signer.go

View workflow job for this annotation

GitHub Actions / lint code

return with no blank line before (nlreturn)
}

var _ SingleKeyMessageSigner = (*PubKeyMessageSigner)(nil)
Expand Down
2 changes: 1 addition & 1 deletion lnrpc/invoicesrpc/addinvoice.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ func AddInvoice(ctx context.Context, cfg *AddInvoiceConfig,

return ecdsa.SignCompact(
ephemKey, chainhash.HashB(msg), true,
)
), nil
},
})
if err != nil {
Expand Down
5 changes: 1 addition & 4 deletions lnrpc/walletrpc/walletkit_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2647,10 +2647,7 @@ func (w *WalletKit) SignMessageWithAddr(_ context.Context,
"fetched from wallet database: %w", err)
}

sigBytes, err := ecdsa.SignCompact(privKey, digest, pubKey.Compressed())
if err != nil {
return nil, fmt.Errorf("failed to create signature: %w", err)
}
sigBytes := ecdsa.SignCompact(privKey, digest, pubKey.Compressed())

// Bitcoin signatures are base64 encoded (being compatible with
// bitcoin-core and btcd).
Expand Down
2 changes: 1 addition & 1 deletion lntest/mock/secretkeyring.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (s *SecretKeyRing) SignMessageCompact(_ keychain.KeyLocator,
} else {
digest = chainhash.HashB(msg)
}
return ecdsa.SignCompact(s.RootKey, digest, true)
return ecdsa.SignCompact(s.RootKey, digest, true), nil

Check failure on line 72 in lntest/mock/secretkeyring.go

View workflow job for this annotation

GitHub Actions / lint code

return with no blank line before (nlreturn)
}

// SignMessageSchnorr signs the passed message and ignores the KeyDescriptor.
Expand Down
9 changes: 2 additions & 7 deletions zpay32/invoice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,7 @@ var (
testMessageSigner = MessageSigner{
SignCompact: func(msg []byte) ([]byte, error) {
hash := chainhash.HashB(msg)
sig, err := ecdsa.SignCompact(testPrivKey, hash, true)
if err != nil {
return nil, fmt.Errorf("can't sign the "+
"message: %v", err)
}
return sig, nil
return ecdsa.SignCompact(testPrivKey, hash, true), nil
},
}

Expand Down Expand Up @@ -1042,7 +1037,7 @@ func TestInvoiceChecksumMalleability(t *testing.T) {
msgSigner := MessageSigner{
SignCompact: func(msg []byte) ([]byte, error) {
hash := chainhash.HashB(msg)
return ecdsa.SignCompact(privKey, hash, true)
return ecdsa.SignCompact(privKey, hash, true), nil
},
}
opts := []func(*Invoice){Description("test")}
Expand Down

0 comments on commit 2792a8a

Please sign in to comment.