Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade bitcoin-core to 28.0 #3191

Merged
merged 2 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion contrib/localnet/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:27.2
container_name: bitcoin
hostname: bitcoin
networks:
Expand All @@ -210,6 +210,7 @@ services:
-rpcbind=0.0.0.0
-rpcauth=smoketest:63acf9b8dccecce914d85ff8c044b78b$$5892f9bbc84f4364e79f0970039f88bdd823f168d4acc76099ab97b14a766a99
-txindex=1
-deprecatedrpc=create_bdb

solana:
image: solana-local:latest
Expand Down
33 changes: 26 additions & 7 deletions e2e/runner/setup_bitcoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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")
}
}
Loading