Extract walletinfo for re-use

This commit is contained in:
jholdstock 2020-06-30 10:16:41 +01:00 committed by David Hill
parent b029d88fdb
commit aed1e5f5d4

View File

@ -99,8 +99,8 @@ func (w *WalletConnect) Clients(ctx context.Context, netParams *chaincfg.Params)
} }
// Verify dcrwallet is voting and unlocked. // Verify dcrwallet is voting and unlocked.
var walletInfo wallettypes.WalletInfoResult walletRPC := &WalletRPC{c, ctx}
err = c.Call(ctx, "walletinfo", &walletInfo) walletInfo, err := walletRPC.WalletInfo()
if err != nil { if err != nil {
log.Errorf("walletinfo check on dcrwallet '%s' failed: %v", c.String(), err) log.Errorf("walletinfo check on dcrwallet '%s' failed: %v", c.String(), err)
failedConnections++ failedConnections++
@ -119,13 +119,22 @@ func (w *WalletConnect) Clients(ctx context.Context, netParams *chaincfg.Params)
continue continue
} }
walletClients = append(walletClients, &WalletRPC{c, ctx}) walletClients = append(walletClients, walletRPC)
} }
return walletClients, failedConnections return walletClients, failedConnections
} }
func (c *WalletRPC) WalletInfo() (*wallettypes.WalletInfoResult, error) {
var walletInfo wallettypes.WalletInfoResult
err := c.Call(c.ctx, "walletinfo", &walletInfo)
if err != nil {
return nil, err
}
return &walletInfo, nil
}
func (c *WalletRPC) AddTicketForVoting(votingWIF, blockHash, txHex string) error { func (c *WalletRPC) AddTicketForVoting(votingWIF, blockHash, txHex string) error {
label := "imported" label := "imported"
rescan := false rescan := false