From e682c18860397811814b49446b7437b0e86f0324 Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Fri, 22 Nov 2024 08:54:00 -0800 Subject: [PATCH] chore: upgrade bitcoin-core to 28.0 (#3191) * chore: upgrade bitcoin-core to 27.2 * Upgrade to 28.0 --- contrib/localnet/docker-compose.yml | 4 +++- e2e/runner/setup_bitcoin.go | 33 +++++++++++++++++++++++------ 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/contrib/localnet/docker-compose.yml b/contrib/localnet/docker-compose.yml index e0078230e7..4e044fc0cf 100644 --- a/contrib/localnet/docker-compose.yml +++ b/contrib/localnet/docker-compose.yml @@ -195,7 +195,7 @@ services: ipv4_address: 172.20.0.102 bitcoin: - image: ghcr.io/zeta-chain/ruimarinho-bitcoin-core:22 # version 23 is not working with btcd 0.22.0 due to change in createwallet rpc + image: ghcr.io/zeta-chain/bitcoin-core-docker:28.0 container_name: bitcoin hostname: bitcoin networks: @@ -210,6 +210,8 @@ services: -rpcbind=0.0.0.0 -rpcauth=smoketest:63acf9b8dccecce914d85ff8c044b78b$$5892f9bbc84f4364e79f0970039f88bdd823f168d4acc76099ab97b14a766a99 -txindex=1 + -deprecatedrpc=create_bdb + -deprecatedrpc=warnings solana: image: solana-local:latest diff --git a/e2e/runner/setup_bitcoin.go b/e2e/runner/setup_bitcoin.go index 88d516e1b7..b349e14639 100644 --- a/e2e/runner/setup_bitcoin.go +++ b/e2e/runner/setup_bitcoin.go @@ -2,11 +2,11 @@ package runner import ( "encoding/hex" + "encoding/json" "time" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/rpcclient" "github.com/stretchr/testify/require" ) @@ -35,7 +35,7 @@ func (r *E2ERunner) SetupBitcoinAccounts(createWallet bool) { }() // setup deployer address - r.SetupBtcAddress(r.Name, createWallet) + r.SetupBtcAddress(createWallet) // import the TSS address to index TSS utxos and transactions err := r.BtcRPCClient.ImportAddress(r.BTCTSSAddress.EncodeAddress()) @@ -70,21 +70,40 @@ func (r *E2ERunner) GetBtcAddress() (*btcutil.AddressWitnessPubKeyHash, *btcutil } // SetupBtcAddress setups the deployer Bitcoin address -func (r *E2ERunner) SetupBtcAddress(name string, setupWallet bool) { +func (r *E2ERunner) SetupBtcAddress(createWallet bool) { // set the deployer address address, privkeyWIF := r.GetBtcAddress() r.BTCDeployerAddress = address - r.Logger.Info("BTCDeployerAddress: %s, %v", r.BTCDeployerAddress.EncodeAddress(), setupWallet) + r.Logger.Info("BTCDeployerAddress: %s, %v", r.BTCDeployerAddress.EncodeAddress(), createWallet) // import the deployer private key as a Bitcoin node wallet - if setupWallet { - _, err := r.BtcRPCClient.CreateWallet(r.Name, rpcclient.WithCreateWalletBlank()) + if createWallet { + // we must use a raw request as the rpcclient does not expose the + // descriptors arg which must be set to false + // https://github.com/btcsuite/btcd/issues/2179 + // https://developer.bitcoin.org/reference/rpc/createwallet.html + args := []interface{}{ + r.Name, // wallet_name + false, // disable_private_keys + true, // blank + "", // passphrase + false, // avoid_reuse + false, // descriptors + true, // load_on_startup + } + argsRawMsg := []json.RawMessage{} + for _, arg := range args { + encodedArg, err := json.Marshal(arg) + require.NoError(r, err) + argsRawMsg = append(argsRawMsg, encodedArg) + } + _, err := r.BtcRPCClient.RawRequest("createwallet", argsRawMsg) if err != nil { require.ErrorContains(r, err, "Database already exists") } - err = r.BtcRPCClient.ImportPrivKeyRescan(privkeyWIF, name, true) + err = r.BtcRPCClient.ImportPrivKeyRescan(privkeyWIF, r.Name, true) require.NoError(r, err, "failed to execute ImportPrivKeyRescan") } }