Repository: lightningnetwork/lnd (Go)

Issue:
[bug]: Unable to run lnd 0.18.3rc2 with bitcoin core v28.0rc1
### Background

I am getting an error after unlocking lnd:

```
Sep 01 16:32:46 bitcoin-mainnet lnd[423674]: 2024-09-01 16:32:46.792 [ERR] LTND: unable to create partial chain control: unable to determine if bitcoind is pruned: unable to detect bitcoind version: json: cannot unmarshal array into Go struct field GetNetworkInfoResult.warnings of type string
Sep 01 16:32:46 bitcoin-mainnet lnd[423674]: 2024-09-01 16:32:46.792 [ERR] LTND: Shutting down because error in main method: error creating wallet config: unable to create partial chain control: unable to determine if bitcoind is pruned: unable to detect bitcoind version: json: cannot unmarshal array into Go struct field GetNetworkInfoResult.warnings of type string
```

### Your environment

* lnd v0.18.3-beta.rc2
* Linux 6.1.0-21-amd64 Debian 6.1.90-1 (2024-05-03) x86_64 
* Bitcoin v28.0rc1


### Steps to reproduce

I upgraded bitcoin core from v27.0 to v28.0rc1, while lnd was still on v0.18.0, got the error as describe above. Then I upgraded lnd to v0.18.3rc2 and still got the same error.

### Expected behaviour

LND should run with bitcoin core v28.0

### Actual behaviour

LND cannot start using bitcoin core v28.0 as backend



Discussion:
Thanks a lot for testing with the RC! This was broken by https://github.com/bitcoin/bitcoin/pull/29845. I've created a fix here: https://github.com/btcsuite/btcd/pull/2245.
Please also open an issue on the Bitcoin Core when something like this happens... :-)
I would be useful to know if the current Lnd master branch works now that  https://github.com/barebitcoin/btcd/pull/4 was merged (I don't see a new Lnd tag).
We still need to bump the version of the btcd package so current master won't work.
Bitcoin Core v28.0 will be released very soon(tm).
Hello, will this fix be applied with LND v18.4 before Bitcoin Core v28 is released?

I still don't see any precompiled binaries for LND v18.4, but I do see precompiled binaries for Bitcoin Core v28....
@twofaktor LND v0.18.4 isn't released yet. 
> @twofaktor LND v0.18.4 isn't released yet.

I know, and that worries me since it seems that Bitcoin Core v28 will be released earlier than LND v0.18.4, and LND v018.3 is not compatible with Bitcoin Core v28...
+1 to this issue 
Trying to run lnd v 0.18.3-beta with btc core v28.0 and getting the original thread error
chain set to testnet3

Have any temporary measures been found to overcome the fault?
You have to enable the deprecated warnings rpc on bitcoin core using: `-deprecatedrpc=warnings`



Patch:
diff --git a/go.mod b/go.mod
index 4aeea380868..60af5fb3deb 100644
--- a/go.mod
+++ b/go.mod
@@ -4,8 +4,8 @@ require (
 	github.com/NebulousLabs/go-upnp v0.0.0-20180202185039-29b680b06c82
 	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 v0.24.3-0.20240921052913-67b8efd3ba53
+	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
diff --git a/go.sum b/go.sum
index 59e0c9faf40..312b2257807 100644
--- a/go.sum
+++ b/go.sum
@@ -73,12 +73,12 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r
 github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
 github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M=
 github.com/btcsuite/btcd v0.23.5-0.20231215221805-96c9fd8078fd/go.mod h1:nm3Bko6zh6bWP60UxwoT5LzdGJsQJaPo6HjduXq9p6A=
-github.com/btcsuite/btcd v0.24.2-beta.rc1.0.20240625142744-cc26860b4026 h1:s8/96vQSj05bqLl9RyM/eMX8gLtiayEj520TVE4YGy0=
-github.com/btcsuite/btcd v0.24.2-beta.rc1.0.20240625142744-cc26860b4026/go.mod h1:5C8ChTkl5ejr3WHj8tkQSCmydiMEPB0ZhQhehpq7Dgg=
+github.com/btcsuite/btcd v0.24.3-0.20240921052913-67b8efd3ba53 h1:XOZ/wRGHkKv0AqxfDks5IkzaQ1Ge6fq322ZOOG5VIkU=
+github.com/btcsuite/btcd v0.24.3-0.20240921052913-67b8efd3ba53/go.mod h1:zHK7t7sw8XbsCkD64WePHE3r3k9/XoGAcf6mXV14c64=
 github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA=
 github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE=
-github.com/btcsuite/btcd/btcec/v2 v2.3.3 h1:6+iXlDKE8RMtKsvK0gshlXIuPbyWM/h84Ensb7o3sC0=
-github.com/btcsuite/btcd/btcec/v2 v2.3.3/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
+github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ=
+github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
 github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A=
 github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE=
 github.com/btcsuite/btcd/btcutil v1.1.5 h1:+wER79R5670vs/ZusMTF1yTcRYE5GUsFbdjdisflzM8=
diff --git a/keychain/btcwallet.go b/keychain/btcwallet.go
index 0df679df999..677de20da34 100644
--- a/keychain/btcwallet.go
+++ b/keychain/btcwallet.go
@@ -448,7 +448,8 @@ func (b *BtcWalletKeyRing) SignMessageCompact(keyLoc KeyLocator,
 	} else {
 		digest = chainhash.HashB(msg)
 	}
-	return ecdsa.SignCompact(privKey, digest, true)
+
+	return ecdsa.SignCompact(privKey, digest, true), nil
 }
 
 // SignMessageSchnorr uses the Schnorr signature algorithm to sign the given
diff --git a/keychain/signer.go b/keychain/signer.go
index 9605e72ec1f..fa2b70762df 100644
--- a/keychain/signer.go
+++ b/keychain/signer.go
@@ -85,7 +85,8 @@ 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
 }
 
 var _ SingleKeyMessageSigner = (*PubKeyMessageSigner)(nil)
diff --git a/lnrpc/invoicesrpc/addinvoice.go b/lnrpc/invoicesrpc/addinvoice.go
index dcb1bef71ee..df274f2da79 100644
--- a/lnrpc/invoicesrpc/addinvoice.go
+++ b/lnrpc/invoicesrpc/addinvoice.go
@@ -587,7 +587,7 @@ func AddInvoice(ctx context.Context, cfg *AddInvoiceConfig,
 
 			return ecdsa.SignCompact(
 				ephemKey, chainhash.HashB(msg), true,
-			)
+			), nil
 		},
 	})
 	if err != nil {
diff --git a/lnrpc/walletrpc/walletkit_server.go b/lnrpc/walletrpc/walletkit_server.go
index 5ed33cdc8b9..6f35c2ebbe5 100644
--- a/lnrpc/walletrpc/walletkit_server.go
+++ b/lnrpc/walletrpc/walletkit_server.go
@@ -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).


Test patch:
diff --git a/channeldb/migration_01_to_11/migration_11_invoices_test.go b/channeldb/migration_01_to_11/migration_11_invoices_test.go
index 553a8cfeeec..55c188bd953 100644
--- a/channeldb/migration_01_to_11/migration_11_invoices_test.go
+++ b/channeldb/migration_01_to_11/migration_11_invoices_test.go
@@ -2,7 +2,6 @@ package migration_01_to_11
 
 import (
 	"bytes"
-	"fmt"
 	"testing"
 	"time"
 
@@ -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.
diff --git a/invoices/test_utils.go b/invoices/test_utils.go
index c6e226083d1..b21804346c5 100644
--- a/invoices/test_utils.go
+++ b/invoices/test_utils.go
@@ -4,7 +4,6 @@ import (
 	"crypto/rand"
 	"encoding/binary"
 	"encoding/hex"
-	"fmt"
 	"sync"
 	"testing"
 	"time"
@@ -69,11 +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)
-			}
+			sig := ecdsa.SignCompact(testPrivKey, hash, true)
 
 			return sig, nil
 		},
diff --git a/invoices/test_utils_test.go b/invoices/test_utils_test.go
index fe69cad6f1a..509b92d85cf 100644
--- a/invoices/test_utils_test.go
+++ b/invoices/test_utils_test.go
@@ -122,12 +122,8 @@ 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
 		},
 	}
 
diff --git a/lntest/mock/secretkeyring.go b/lntest/mock/secretkeyring.go
index 56c0fac9489..a5a39cc729b 100644
--- a/lntest/mock/secretkeyring.go
+++ b/lntest/mock/secretkeyring.go
@@ -69,7 +69,8 @@ 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
 }
 
 // SignMessageSchnorr signs the passed message and ignores the KeyDescriptor.
diff --git a/zpay32/invoice_test.go b/zpay32/invoice_test.go
index d982a14a2b4..de59422aba3 100644
--- a/zpay32/invoice_test.go
+++ b/zpay32/invoice_test.go
@@ -105,12 +105,8 @@ 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
 		},
 	}
 
@@ -1043,7 +1039,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")}