aboutsummaryrefslogtreecommitdiffstats
path: root/console
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2017-05-02 19:42:55 +0800
committerFelix Lange <fjl@twurst.com>2017-05-02 19:42:55 +0800
commit32db5716816ef6fddb0d943fc0083c89127e8533 (patch)
tree439e02ad1e42ae0a20193cb006742d01fc443a8e /console
parentf9be9a2302dd73fe3cc792167d65f24c7b7d35c4 (diff)
downloaddexon-32db5716816ef6fddb0d943fc0083c89127e8533.tar
dexon-32db5716816ef6fddb0d943fc0083c89127e8533.tar.gz
dexon-32db5716816ef6fddb0d943fc0083c89127e8533.tar.bz2
dexon-32db5716816ef6fddb0d943fc0083c89127e8533.tar.lz
dexon-32db5716816ef6fddb0d943fc0083c89127e8533.tar.xz
dexon-32db5716816ef6fddb0d943fc0083c89127e8533.tar.zst
dexon-32db5716816ef6fddb0d943fc0083c89127e8533.zip
console: avoid float64 when remarshaling parameters
With Go 1.7, encoding/json marshals float64 using scientific notation ("10e+6"), but Go's int and *big.Int decoders don't accept such numbers. This change disables use of float64 to avoid the problem.
Diffstat (limited to 'console')
-rw-r--r--console/bridge.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/console/bridge.go b/console/bridge.go
index 6db54eb21..75be68188 100644
--- a/console/bridge.go
+++ b/console/bridge.go
@@ -20,6 +20,7 @@ import (
"encoding/json"
"fmt"
"io"
+ "strings"
"time"
"github.com/ethereum/go-ethereum/log"
@@ -240,17 +241,19 @@ func (b *bridge) Send(call otto.FunctionCall) (response otto.Value) {
throwJSException(err.Error())
}
var (
- rawReq = []byte(reqVal.String())
+ rawReq = reqVal.String()
+ dec = json.NewDecoder(strings.NewReader(rawReq))
reqs []jsonrpcCall
batch bool
)
+ dec.UseNumber() // avoid float64s
if rawReq[0] == '[' {
batch = true
- json.Unmarshal(rawReq, &reqs)
+ dec.Decode(&reqs)
} else {
batch = false
reqs = make([]jsonrpcCall, 1)
- json.Unmarshal(rawReq, &reqs[0])
+ dec.Decode(&reqs[0])
}
// Execute the requests.