From a86d9f9517ece3995c2d8df7ff9efaccc95b36cf Mon Sep 17 00:00:00 2001 From: Matheus Degiovani Date: Mon, 14 Oct 2024 09:54:31 -0300 Subject: [PATCH] multi: Send empty VSP policy fields This changes the call sites of VSP library functions to fill in missing policy choices with empty maps instead of nil maps. This fixes an issue where certain VSPs will fail to accept the policy calls because those fields are required by the API but not sent. --- internal/rpc/jsonrpc/methods.go | 12 +++++++++--- wallet/wallet.go | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/internal/rpc/jsonrpc/methods.go b/internal/rpc/jsonrpc/methods.go index 53b17f5c8..9e90fa3ed 100644 --- a/internal/rpc/jsonrpc/methods.go +++ b/internal/rpc/jsonrpc/methods.go @@ -3829,7 +3829,9 @@ func (s *Server) setTreasuryPolicy(ctx context.Context, icmd any) (any, error) { policyMap := map[string]string{ cmd.Key: cmd.Policy, } - err = s.updateVSPVoteChoices(ctx, w, ticketHash, nil, nil, policyMap) + choices := map[string]string{} + tspendPolicy := map[string]string{} + err = s.updateVSPVoteChoices(ctx, w, ticketHash, choices, tspendPolicy, policyMap) return nil, err } @@ -3963,7 +3965,9 @@ func (s *Server) setTSpendPolicy(ctx context.Context, icmd any) (any, error) { policyMap := map[string]string{ cmd.Hash: cmd.Policy, } - err = s.updateVSPVoteChoices(ctx, w, ticketHash, nil, policyMap, nil) + choices := map[string]string{} + treasuryPolicy := map[string]string{} + err = s.updateVSPVoteChoices(ctx, w, ticketHash, choices, policyMap, treasuryPolicy) return nil, err } @@ -4680,7 +4684,9 @@ func (s *Server) setVoteChoice(ctx context.Context, icmd any) (any, error) { } // Update voting preferences on VSPs if required. - err = s.updateVSPVoteChoices(ctx, w, ticketHash, choice, nil, nil) + tspendPolicy := map[string]string{} + treasuryPolicy := map[string]string{} + err = s.updateVSPVoteChoices(ctx, w, ticketHash, choice, tspendPolicy, treasuryPolicy) return nil, err } diff --git a/wallet/wallet.go b/wallet/wallet.go index 0f9dda294..2fd9bde22 100644 --- a/wallet/wallet.go +++ b/wallet/wallet.go @@ -408,7 +408,7 @@ func (w *Wallet) AgendaChoices(ctx context.Context, ticketHash *chainhash.Hash) const op errors.Op = "wallet.AgendaChoices" version, deployments := CurrentAgendas(w.chainParams) if len(deployments) == 0 { - return nil, 0, nil + return map[string]string{}, 0, nil } choices = make(map[string]string, len(deployments))