diff --git a/binary/reflect.go b/binary/reflect.go index 25cf730c..a9702546 100644 --- a/binary/reflect.go +++ b/binary/reflect.go @@ -447,6 +447,9 @@ func writeReflectBinary(rv reflect.Value, rt reflect.Type, opts Options, w io.Wr rv, rt = rv.Elem(), rt.Elem() typeInfo = GetTypeInfo(rt) if !rv.IsValid() { + // For better compatibility with other languages, + // as far as tendermint/binary is concerned, + // pointers to nil values are the same as nil. WriteByte(0x00, w, n, err) return } @@ -845,6 +848,9 @@ func writeReflectJSON(rv reflect.Value, rt reflect.Type, w io.Writer, n *int64, rv, rt = rv.Elem(), rt.Elem() typeInfo = GetTypeInfo(rt) if !rv.IsValid() { + // For better compatibility with other languages, + // as far as tendermint/binary is concerned, + // pointers to nil values are the same as nil. WriteTo([]byte("null"), w, n, err) return }