aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rpc/blockchain.cpp7
-rwxr-xr-xtest/functional/rpc_blockchain.py3
2 files changed, 7 insertions, 3 deletions
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
index f27e9af0d9..d88e75891d 100644
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -936,10 +936,11 @@ static RPCHelpMan getblock()
int verbosity = 1;
if (!request.params[1].isNull()) {
- if(request.params[1].isNum())
- verbosity = request.params[1].get_int();
- else
+ if (request.params[1].isBool()) {
verbosity = request.params[1].get_bool() ? 1 : 0;
+ } else {
+ verbosity = request.params[1].get_int();
+ }
}
CBlock block;
diff --git a/test/functional/rpc_blockchain.py b/test/functional/rpc_blockchain.py
index 821409ccc1..ac53a280b4 100755
--- a/test/functional/rpc_blockchain.py
+++ b/test/functional/rpc_blockchain.py
@@ -410,6 +410,9 @@ class BlockchainTest(BitcoinTestFramework):
self.log.info("Test that getblock with verbosity 2 still works with pruned Undo data")
datadir = get_datadir_path(self.options.tmpdir, 0)
+ self.log.info("Test that getblock with invalid verbosity type returns proper error message")
+ assert_raises_rpc_error(-1, "JSON value is not an integer as expected", node.getblock, blockhash, "2")
+
def move_block_file(old, new):
old_path = os.path.join(datadir, self.chain, 'blocks', old)
new_path = os.path.join(datadir, self.chain, 'blocks', new)