diff --git a/cmd/kaspactl/main.go b/cmd/kaspactl/main.go index 458ec1c41..55c448ada 100644 --- a/cmd/kaspactl/main.go +++ b/cmd/kaspactl/main.go @@ -2,10 +2,11 @@ package main import ( "fmt" - "github.com/kaspanet/kaspad/infrastructure/network/netadapter/server/grpcserver/protowire" "os" "time" + "github.com/kaspanet/kaspad/infrastructure/network/netadapter/server/grpcserver/protowire" + "github.com/pkg/errors" "google.golang.org/protobuf/encoding/protojson" @@ -67,7 +68,7 @@ func postCommand(cfg *configFlags, client *grpcclient.GRPCClient, responseChan c if err != nil { printErrorAndExit(fmt.Sprintf("error posting the request to the RPC server: %s", err)) } - responseBytes, err := protojson.Marshal(response) + responseBytes, err := protojson.MarshalOptions{EmitUnpopulated: true}.Marshal(response) if err != nil { printErrorAndExit(errors.Wrapf(err, "error parsing the response from the RPC server").Error()) } @@ -92,6 +93,7 @@ func prettifyResponse(response string) string { marshalOptions := &protojson.MarshalOptions{} marshalOptions.Indent = " " + marshalOptions.EmitUnpopulated = true return marshalOptions.Format(kaspadMessage) } diff --git a/infrastructure/network/rpcclient/grpcclient/post.go b/infrastructure/network/rpcclient/grpcclient/post.go index 8247d708b..70ff30db0 100644 --- a/infrastructure/network/rpcclient/grpcclient/post.go +++ b/infrastructure/network/rpcclient/grpcclient/post.go @@ -21,7 +21,7 @@ func (c *GRPCClient) PostJSON(requestJSON string) (string, error) { if err != nil { return "", err } - responseBytes, err := protojson.Marshal(response) + responseBytes, err := protojson.MarshalOptions{EmitUnpopulated: true}.Marshal(response) if err != nil { return "", errors.Wrapf(err, "error parsing the response from the RPC server") }