Merge pull request #785 from nspcc-dev/feature/uint160_marshalling
util: JSONify uint160 using LE instead of BE
This commit is contained in:
commit
751e79d480
10 changed files with 19 additions and 58 deletions
|
@ -66,7 +66,9 @@ func (p *Parameter) MarshalJSON() ([]byte, error) {
|
|||
resultErr error
|
||||
)
|
||||
switch p.Type {
|
||||
case BoolType, StringType, Hash256Type, Hash160Type:
|
||||
case Hash160Type:
|
||||
resultRawValue, resultErr = json.Marshal(p.Value.(util.Uint160).Reverse()) // Hash160 should be marshaled in BE but default marshaler uses LE.
|
||||
case BoolType, StringType, Hash256Type:
|
||||
resultRawValue, resultErr = json.Marshal(p.Value)
|
||||
case IntegerType:
|
||||
val, ok := p.Value.(int64)
|
||||
|
@ -200,7 +202,7 @@ func (p *Parameter) UnmarshalJSON(data []byte) (err error) {
|
|||
if err = json.Unmarshal(r.Value, &h); err != nil {
|
||||
return
|
||||
}
|
||||
p.Value = h
|
||||
p.Value = h.Reverse() // Hash160 should be marshaled in BE but default marshaler uses LE.
|
||||
case Hash256Type:
|
||||
var h util.Uint256
|
||||
if err = json.Unmarshal(r.Value, &h); err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue