Open ori-shem-tov opened 4 years ago
Need to better understand what needs to be done here.
The issue seems to be that, when encoding to JSON, if a field is an array of bytes [][]byte
, then the field is converted, in JSON to an array of base64 strings but the name of the field is not changed.
Then, when decoding from JSON, the array of strings is interpreted as an array of string []string
, instead of decoding it into an array of bytes.
I think the best solution may be to use the same trick as for encoding bytes ([]byte
): change the name of the field to xxx:b64
.
Note that ideally, this should work for arrays of arrays of bytes too and so on ([][][]byte
, [][][][]byte
, ....).
Subject of the issue
When decoding and re-encoding a transaction containing an array of bytes with msgpacktool, the re-encoded transaction is different from the original one. The issue seems to be that when decoding to JSON, arrays of bytes are encoded to arrays of base64 strings. But when encoding, these arrays of base64 strings are directly considered arrays of bytes.
Your environment
macOS Catalina 10.15.6
Steps to reproduce
Here is an example where this creates an issue:
goal clerk dryrun -t txn
on the transaction and it should pass.msgpacktool -d -b32 < txn > txn.decoded
msgpacktool -e -b32 < txn.decoded > txn2
goal clerk dryrun -t txn2
Expected behaviour
dryrun should pass
Actual behaviour
dryrun fails