Skip to content

Commit

Permalink
Remove redundant wallet check.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeGruffins committed Jun 11, 2020
1 parent 53cbf2d commit 8cca9c2
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 14 deletions.
11 changes: 3 additions & 8 deletions client/rpcserver/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,15 +401,10 @@ func handleWithdraw(s *RPCServer, params *RawParams) *msgjson.ResponsePayload {
return usage(withdrawRoute, err)
}
defer form.AppPass.Clear()
if s.core.WalletState(form.AssetID) == nil {
errMsg := fmt.Sprintf("error withdrawing: %s wallet does not exist",
dex.BipIDSymbol(form.AssetID))
resErr := msgjson.NewError(msgjson.RPCWalletExistsError, errMsg)
return createResponse(withdrawRoute, nil, resErr)
}
coin, err := s.core.Withdraw(form.AppPass, form.AssetID, form.Value)
coin, err := s.core.Withdraw(form.AppPass, form.AssetID, form.Value, form.Address)
if err != nil {
resErr := msgjson.NewError(msgjson.RPCWithdrawError, err.Error())
errMsg := fmt.Sprintf("unable to withdraw: %v", err)
resErr := msgjson.NewError(msgjson.RPCWithdrawError, errMsg)
return createResponse(withdrawRoute, nil, resErr)
}
res := coin.String()
Expand Down
4 changes: 0 additions & 4 deletions client/rpcserver/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -762,10 +762,6 @@ func TestHandleWithdraw(t *testing.T) {
walletState: &core.WalletState{},
coin: tCoin{},
wantErrCode: -1,
}, {
name: "wallet doesn't exist",
params: params,
wantErrCode: msgjson.RPCWalletExistsError,
}, {
name: "core.Withdraw error",
params: params,
Expand Down
2 changes: 1 addition & 1 deletion client/rpcserver/rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type ClientCore interface {
Trade(appPass []byte, form *core.TradeForm) (order *core.Order, err error)
WalletState(assetID uint32) (walletState *core.WalletState)
Wallets() (walletsStates []*core.WalletState)
Withdraw(appPass []byte, assetID uint32, value uint64) (asset.Coin, error)
Withdraw(appPass []byte, assetID uint32, value uint64, addr string) (asset.Coin, error)
}

// marketSyncer is used to synchronize market subscriptions. The marketSyncer
Expand Down
2 changes: 1 addition & 1 deletion client/rpcserver/rpcserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (c *TCore) Wallets() []*core.WalletState {
func (c *TCore) WalletState(assetID uint32) *core.WalletState {
return c.walletState
}
func (c *TCore) Withdraw(pw []byte, assetID uint32, value uint64) (asset.Coin, error) {
func (c *TCore) Withdraw(pw []byte, assetID uint32, value uint64, addr string) (asset.Coin, error) {
return c.coin, c.withdrawErr
}

Expand Down

0 comments on commit 8cca9c2

Please sign in to comment.