From 6335ad4f96843110b94599dd33d5dbade0d8c613 Mon Sep 17 00:00:00 2001 From: jholdstock Date: Wed, 16 Oct 2024 09:44:04 +0100 Subject: [PATCH] client: Send empty maps instead of nil. --- client/client.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/client/client.go b/client/client.go index b1797fdb..16462d73 100644 --- a/client/client.go +++ b/client/client.go @@ -66,6 +66,15 @@ func (c *Client) FeeAddress(ctx context.Context, req types.FeeAddressRequest, func (c *Client) PayFee(ctx context.Context, req types.PayFeeRequest, commitmentAddr stdaddr.Address) (*types.PayFeeResponse, error) { + // TSpendPolicy and TreasuryPolicy are optional but must be an empty map + // rather than nil. + if req.TSpendPolicy == nil { + req.TSpendPolicy = map[string]string{} + } + if req.TreasuryPolicy == nil { + req.TreasuryPolicy = map[string]string{} + } + requestBody, err := json.Marshal(req) if err != nil { return nil, err @@ -110,6 +119,15 @@ func (c *Client) TicketStatus(ctx context.Context, req types.TicketStatusRequest func (c *Client) SetVoteChoices(ctx context.Context, req types.SetVoteChoicesRequest, commitmentAddr stdaddr.Address) (*types.SetVoteChoicesResponse, error) { + // TSpendPolicy and TreasuryPolicy are optional but must be an empty map + // rather than nil. + if req.TSpendPolicy == nil { + req.TSpendPolicy = map[string]string{} + } + if req.TreasuryPolicy == nil { + req.TreasuryPolicy = map[string]string{} + } + requestBody, err := json.Marshal(req) if err != nil { return nil, err