From b029d88fdbed81758d5bb1f323b678dba7a27019 Mon Sep 17 00:00:00 2001 From: jholdstock Date: Tue, 30 Jun 2020 10:04:12 +0100 Subject: [PATCH] Check dcrwallet network before calling walletinfo RPC --- rpc/dcrwallet.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/rpc/dcrwallet.go b/rpc/dcrwallet.go index 7656be5..037703e 100644 --- a/rpc/dcrwallet.go +++ b/rpc/dcrwallet.go @@ -84,6 +84,20 @@ func (w *WalletConnect) Clients(ctx context.Context, netParams *chaincfg.Params) continue } + // Verify dcrwallet is on the correct network. + var netID wire.CurrencyNet + err = c.Call(ctx, "getcurrentnet", &netID) + if err != nil { + log.Errorf("getcurrentnet check on dcrwallet '%s' failed: %v", c.String(), err) + failedConnections++ + continue + } + if netID != netParams.Net { + log.Errorf("dcrwallet '%s' running on %s, expected %s", c.String(), netID, netParams.Net) + failedConnections++ + continue + } + // Verify dcrwallet is voting and unlocked. var walletInfo wallettypes.WalletInfoResult err = c.Call(ctx, "walletinfo", &walletInfo) @@ -105,20 +119,6 @@ func (w *WalletConnect) Clients(ctx context.Context, netParams *chaincfg.Params) continue } - // Verify dcrwallet is on the correct network. - var netID wire.CurrencyNet - err = c.Call(ctx, "getcurrentnet", &netID) - if err != nil { - log.Errorf("getcurrentnet check on dcrwallet '%s' failed: %v", c.String(), err) - failedConnections++ - continue - } - if netID != netParams.Net { - log.Errorf("dcrwallet '%s' running on %s, expected %s", c.String(), netID, netParams.Net) - failedConnections++ - continue - } - walletClients = append(walletClients, &WalletRPC{c, ctx}) }