Skip to content

Commit

Permalink
multi: Send empty VSP policy fields
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
matheusd committed Oct 14, 2024
1 parent 4adf892 commit a86d9f9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions internal/rpc/jsonrpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion wallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit a86d9f9

Please sign in to comment.