From e9ca010084c58d404b9ba4159da5cb58d02955f6 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Wed, 25 Jul 2018 22:36:51 -0700 Subject: [PATCH] Correctly parse optional top parameter to getsnapshot --- src/rpcmisc.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 45b70444b..b15b3083d 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -1019,13 +1019,12 @@ UniValue komodo_snapshot(int top); UniValue getsnapshot(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); int64_t total; int top = 0; + UniValue result(UniValue::VOBJ); int64_t total; int32_t top = 0; if (params.size() > 0 && !params[0].isNull()) { - top = params[0].get_str(); - fprintf(stderr, "top=%s\n",top); - if (top <= 0) - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, top must be a positive integer"); + top = atoi(params[0].get_str().c_str()); + if (top <= 0) + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, top must be a positive integer"); } if ( fHelp || params.size() > 1)