Skip to content

Commit

Permalink
[release-v2.0] multi: Send empty VSP policy fields
Browse files Browse the repository at this point in the history
This changes the 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.

Backport of 4ec0b8b.
  • Loading branch information
matheusd authored and jrick committed Nov 11, 2024
1 parent 01f1e12 commit 3bbc778
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions internal/rpc/jsonrpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -4823,6 +4823,18 @@ func (s *Server) setVoteChoice(ctx context.Context, icmd any) (any, error) {
func (s *Server) updateVSPVoteChoices(ctx context.Context, w *wallet.Wallet, ticketHash *chainhash.Hash,
choices map[string]string, tspendPolicy map[string]string, treasuryPolicy map[string]string) error {

// Ensure empty (as opposed to nil) choices on every category (required
// by the contract of the VSP API).
if choices == nil {
choices = map[string]string{}
}
if tspendPolicy == nil {
tspendPolicy = map[string]string{}
}
if treasuryPolicy == nil {
treasuryPolicy = map[string]string{}
}

if ticketHash != nil {
vspHost, err := w.VSPHostForTicket(ctx, ticketHash)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion wallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,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 3bbc778

Please sign in to comment.