Skip to content

Commit

Permalink
chore: upgrade bitcoin-core to 28.0 (#3191)
Browse files Browse the repository at this point in the history
* chore: upgrade bitcoin-core to 27.2

* Upgrade to 28.0
  • Loading branch information
gartnera authored and swift1337 committed Dec 2, 2024
1 parent a87243a commit e682c18
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
4 changes: 3 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:28.0
container_name: bitcoin
hostname: bitcoin
networks:
Expand All @@ -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
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")
}
}

0 comments on commit e682c18

Please sign in to comment.