From fab8333bd24f2cde54bb5020da99ecd273e9e4e6 Mon Sep 17 00:00:00 2001 From: Nick Johnson Date: Tue, 25 Sep 2018 15:32:40 +0100 Subject: [PATCH] Add support for JSON decimal integer block numbers --- rpc/types.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rpc/types.go b/rpc/types.go index d74c27eeee..2505aaa4ae 100644 --- a/rpc/types.go +++ b/rpc/types.go @@ -20,6 +20,7 @@ import ( "fmt" "math" "reflect" + "strconv" "strings" "sync" @@ -135,6 +136,11 @@ func (bn *BlockNumber) UnmarshalJSON(data []byte) error { input := strings.TrimSpace(string(data)) if len(input) >= 2 && input[0] == '"' && input[len(input)-1] == '"' { input = input[1 : len(input)-1] + } else { + // Integer block number + value, err := strconv.Atoi(string(data)) + *bn = BlockNumber(value) + return err } switch input {