Check dcrwallet network before calling walletinfo RPC

This commit is contained in:
jholdstock 2020-06-30 10:04:12 +01:00 committed by David Hill
parent 70ba1adc93
commit b029d88fdb

View File

@ -84,6 +84,20 @@ func (w *WalletConnect) Clients(ctx context.Context, netParams *chaincfg.Params)
continue 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. // Verify dcrwallet is voting and unlocked.
var walletInfo wallettypes.WalletInfoResult var walletInfo wallettypes.WalletInfoResult
err = c.Call(ctx, "walletinfo", &walletInfo) err = c.Call(ctx, "walletinfo", &walletInfo)
@ -105,20 +119,6 @@ func (w *WalletConnect) Clients(ctx context.Context, netParams *chaincfg.Params)
continue 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}) walletClients = append(walletClients, &WalletRPC{c, ctx})
} }