When forging the two noted operations, the Marshal function creates "metadata:null" in the resulting JSON. This produces a Unexpected object field metadata error when preapplying to the RPC node.
nonceRevelation := rpc.Content{
Kind: rpc.SEEDNONCEREVELATION,
Level: nonce.Level,
Nonce: nonce.SeedHashHex,
}
nonceRevelationBytes, err := forge.Encode(block.Hash, nonceRevelation)
if err != nil {
log.WithError(err).Error("Error Forging Nonce Reveal")
return
}
preapplyNonceRevealOp := rpc.PreapplyOperationsInput{
Blockhash: block.Hash,
Operations: []rpc.Operations{
{
Branch: block.Hash,
Contents: rpc.Contents{
nonceRevelation,
},
Protocol: block.Protocol,
Signature: signedNonceReveal.EDSig,
},
},
}
// Validate the operation against the node for any errors
preApplyResp, err := gt.PreapplyOperations(preapplyNonceRevealOp)
if err != nil {
log.WithError(err).Error("Could not preapply nonce reveal operation")
return
}
Output:
ERRO[2020-10-09T22:01:22Z] Could not preapply nonce reveal operation error="failed to preapply operation: response returned code 400 with body Failed to parse the request body: No case matched:\n At /kind, unexpected string instead of endorsement\n Unexpected object field metadata
Solution that worked for me, set metadata to omitempty:
// https://github.com/goat-systems/go-tezos/blob/6fecc940c49c88c9f7e7f600d3417f74e31b2252/rpc/block.go#L847
type SeedNonceRevelation struct {
Kind Kind `json:"kind"`
Level int `json:"level"`
Nonce string `json:"nonce"`
Metadata *SeedNonceRevelationMetadata `json:"metadata,omitempty"`
}
When forging the two noted operations, the Marshal function creates "metadata:null" in the resulting JSON. This produces a
Unexpected object field metadata
error when preapplying to the RPC node.Output:
Solution that worked for me, set metadata to omitempty: