From eb72d300bc263706a72e459ea975abfa0467f2dc Mon Sep 17 00:00:00 2001 From: KonradStaniec Date: Thu, 4 Jan 2024 17:11:46 +0100 Subject: [PATCH] Fix signet supprot (#87) --- utils/utils.go | 2 ++ walletcontroller/client.go | 20 +++++++------------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/utils/utils.go b/utils/utils.go index c323c13..fe6f1f5 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -18,6 +18,8 @@ func GetBtcNetworkParams(network string) (*chaincfg.Params, error) { return &chaincfg.RegressionNetParams, nil case "simnet": return &chaincfg.SimNetParams, nil + case "signet": + return &chaincfg.SigNetParams, nil default: return nil, fmt.Errorf("unknown network %s", network) } diff --git a/walletcontroller/client.go b/walletcontroller/client.go index 404b37a..1510ace 100644 --- a/walletcontroller/client.go +++ b/walletcontroller/client.go @@ -6,9 +6,9 @@ import ( "github.com/babylonchain/btc-staker/stakercfg" "github.com/babylonchain/btc-staker/types" - "github.com/babylonchain/btc-staker/utils" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcutil" + "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/rpcclient" "github.com/btcsuite/btcd/txscript" @@ -38,6 +38,7 @@ func NewRpcWalletController(scfg *stakercfg.Config) (*RpcWalletController, error scfg.ActiveNetParams.Name, scfg.WalletConfig.WalletPass, scfg.BtcNodeBackendConfig.ActiveWalletBackend, + &scfg.ActiveNetParams, // TODO for now just disable tls true, ) @@ -50,22 +51,15 @@ func NewRpcWalletControllerFromArgs( network string, walletPassphrase string, nodeBackend types.SupportedWalletBackend, + params *chaincfg.Params, disableTls bool, ) (*RpcWalletController, error) { - params, err := utils.GetBtcNetworkParams(network) - - if err != nil { - return nil, err - } - connCfg := &rpcclient.ConnConfig{ - Host: host, - User: user, - Pass: pass, - Params: network, - DisableTLS: disableTls, - + Host: host, + User: user, + Pass: pass, + DisableTLS: disableTls, DisableConnectOnNew: true, DisableAutoReconnect: false, // we use post mode as it sure it works with either bitcoind or btcwallet