Mamy Ratsimbazafy 2020-10-07 12:09:36 +02:00 committed by GitHub
parent dff46c991d
commit 99455437ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -86,7 +86,13 @@ proc fromJson*(n: JsonNode, argName: string, result: var int64) =
proc fromJson*(n: JsonNode, argName: string, result: var uint64) =
n.kind.expect(JInt, argName)
result = n.getInt().uint64
let asInt = n.getInt()
# signed -> unsigned conversions are unchecked
# https://github.com/nim-lang/RFCs/issues/175
if asInt < 0:
raise newException(
ValueError, "JSON-RPC input is an unexpected negative value")
result = uint64(asInt)
proc fromJson*(n: JsonNode, argName: string, result: var ref int64) =
n.kind.expect(JInt, argName)