From 1d2a4143558a963a8d4939aed55f2abd125333a3 Mon Sep 17 00:00:00 2001 From: jholdstock Date: Mon, 9 Sep 2024 13:03:17 +0100 Subject: [PATCH] jsonrpc: Use correct change account when mixing. 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. --- internal/rpc/jsonrpc/methods.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/rpc/jsonrpc/methods.go b/internal/rpc/jsonrpc/methods.go index 0aa7f81b6..222b98619 100644 --- a/internal/rpc/jsonrpc/methods.go +++ b/internal/rpc/jsonrpc/methods.go @@ -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 { @@ -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)