Skip to content

Commit

Permalink
Restart DCR RPC wallet on reconfigure to different wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
martonp committed Apr 26, 2024
1 parent ba94e7b commit ba1fdea
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions client/asset/dcr/rpcwallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,24 +288,25 @@ func (w *rpcWallet) Reconfigure(ctx context.Context, cfg *asset.WalletConfig, ne
}
}

if walletCfg.ActivelyUsed {
a, err := stdaddr.DecodeAddress(currentAddress, w.chainParams)
if err != nil {
return false, err
}
var depositAccount string
if rpcCfg.UnmixedAccount != "" {
depositAccount = rpcCfg.UnmixedAccount
} else {
depositAccount = rpcCfg.PrimaryAccount
}
owns, err := newWallet.AccountOwnsAddress(ctx, a, depositAccount)
if err != nil {
return false, err
}
if !owns {
a, err := stdaddr.DecodeAddress(currentAddress, w.chainParams)
if err != nil {
return false, err
}
var depositAccount string
if rpcCfg.UnmixedAccount != "" {
depositAccount = rpcCfg.UnmixedAccount
} else {
depositAccount = rpcCfg.PrimaryAccount
}
owns, err := newWallet.AccountOwnsAddress(ctx, a, depositAccount)
if err != nil {
return false, err
}
if !owns {
if walletCfg.ActivelyUsed {
return false, errors.New("cannot reconfigure to different wallet while there are active trades")
}
return true, nil
}

w.rpcMtx.Lock()
Expand Down

0 comments on commit ba1fdea

Please sign in to comment.