Skip to content

Commit

Permalink
jsonrpc: Use correct change account when mixing.
Browse files Browse the repository at this point in the history
This fixes a bug where the change from a ticket purchase was always sent
back to the purchasing account, regardless of whether mixing is enabled
and a different change account has been configured.
  • Loading branch information
jholdstock authored and jrick committed Sep 9, 2024
1 parent 1ee8d2e commit 1d2a414
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion internal/rpc/jsonrpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -3351,6 +3351,8 @@ func (s *Server) purchaseTicket(ctx context.Context, icmd any) (any, error) {
var mixedAccount uint32
var mixedAccountBranch uint32
var mixedSplitAccount uint32
// Use purchasing account as change account by default (overridden below if
// mixing is enabled).
var changeAccount = account

if s.cfg.Mixing {
Expand All @@ -3370,7 +3372,7 @@ func (s *Server) purchaseTicket(ctx context.Context, icmd any) (any, error) {
return nil, rpcErrorf(dcrjson.ErrRPCInvalidParameter,
"CSPP Server set, but error on mixedSplitAccount: %v", err)
}
_, err = w.AccountNumber(ctx, s.cfg.MixChangeAccount)
changeAccount, err = w.AccountNumber(ctx, s.cfg.MixChangeAccount)
if err != nil {
return nil, rpcErrorf(dcrjson.ErrRPCInvalidParameter,
"CSPP Server set, but error on changeAccount: %v", err)
Expand Down

0 comments on commit 1d2a414

Please sign in to comment.