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 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 15, 2024
1 parent 4adf892 commit 4ec0b8b
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 @@ -4687,6 +4687,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 @@ -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 4ec0b8b

Please sign in to comment.