Skip to content

Commit a5f5a2c

Browse files
committed
[rpc] Fix fVerbose parsing (remove excess if cases).
1 parent 26efc22 commit a5f5a2c

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

src/rpc/rawtransaction.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -141,19 +141,7 @@ UniValue getrawtransaction(const JSONRPCRequest& request)
141141
// Accept either a bool (true) or a num (>=1) to indicate verbose output.
142142
bool fVerbose = false;
143143
if (!request.params[1].isNull()) {
144-
if (request.params[1].isNum()) {
145-
if (request.params[1].get_int() != 0) {
146-
fVerbose = true;
147-
}
148-
}
149-
else if(request.params[1].isBool()) {
150-
if(request.params[1].isTrue()) {
151-
fVerbose = true;
152-
}
153-
}
154-
else {
155-
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid type provided. Verbose parameter must be a boolean.");
156-
}
144+
fVerbose = request.params[1].isNum() ? (request.params[1].get_int() != 0) : request.params[1].get_bool();
157145
}
158146

159147
CTransactionRef tx;

test/functional/rawtransactions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,13 @@ def run_test(self):
188188
assert_equal(self.nodes[0].getrawtransaction(txHash, True)["hex"], rawTxSigned['hex'])
189189

190190
# 6. invalid parameters - supply txid and string "Flase"
191-
assert_raises_rpc_error(-3,"Invalid type", self.nodes[0].getrawtransaction, txHash, "Flase")
191+
assert_raises_rpc_error(-1,"not a boolean", self.nodes[0].getrawtransaction, txHash, "Flase")
192192

193193
# 7. invalid parameters - supply txid and empty array
194-
assert_raises_rpc_error(-3,"Invalid type", self.nodes[0].getrawtransaction, txHash, [])
194+
assert_raises_rpc_error(-1,"not a boolean", self.nodes[0].getrawtransaction, txHash, [])
195195

196196
# 8. invalid parameters - supply txid and empty dict
197-
assert_raises_rpc_error(-3,"Invalid type", self.nodes[0].getrawtransaction, txHash, {})
197+
assert_raises_rpc_error(-1,"not a boolean", self.nodes[0].getrawtransaction, txHash, {})
198198

199199
inputs = [ {'txid' : "1d1d4e24ed99057e84c3f80fd8fbec79ed9e1acee37da269356ecea000000000", 'vout' : 1, 'sequence' : 1000}]
200200
outputs = { self.nodes[0].getnewaddress() : 1 }

0 commit comments

Comments
 (0)