Browse Source

[rpc] Fix fVerbose parsing (remove excess if cases).

0.16
Karl-Johan Alm 7 years ago committed by Karl-Johan Alm
parent
commit
a5f5a2ce53
No known key found for this signature in database
GPG Key ID: 57AF762DB3353322
  1. 14
      src/rpc/rawtransaction.cpp
  2. 6
      test/functional/rawtransactions.py

14
src/rpc/rawtransaction.cpp

@ -141,19 +141,7 @@ UniValue getrawtransaction(const JSONRPCRequest& request) @@ -141,19 +141,7 @@ UniValue getrawtransaction(const JSONRPCRequest& request)
// Accept either a bool (true) or a num (>=1) to indicate verbose output.
bool fVerbose = false;
if (!request.params[1].isNull()) {
if (request.params[1].isNum()) {
if (request.params[1].get_int() != 0) {
fVerbose = true;
}
}
else if(request.params[1].isBool()) {
if(request.params[1].isTrue()) {
fVerbose = true;
}
}
else {
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid type provided. Verbose parameter must be a boolean.");
}
fVerbose = request.params[1].isNum() ? (request.params[1].get_int() != 0) : request.params[1].get_bool();
}
CTransactionRef tx;

6
test/functional/rawtransactions.py

@ -188,13 +188,13 @@ class RawTransactionsTest(BitcoinTestFramework): @@ -188,13 +188,13 @@ class RawTransactionsTest(BitcoinTestFramework):
assert_equal(self.nodes[0].getrawtransaction(txHash, True)["hex"], rawTxSigned['hex'])
# 6. invalid parameters - supply txid and string "Flase"
assert_raises_rpc_error(-3,"Invalid type", self.nodes[0].getrawtransaction, txHash, "Flase")
assert_raises_rpc_error(-1,"not a boolean", self.nodes[0].getrawtransaction, txHash, "Flase")
# 7. invalid parameters - supply txid and empty array
assert_raises_rpc_error(-3,"Invalid type", self.nodes[0].getrawtransaction, txHash, [])
assert_raises_rpc_error(-1,"not a boolean", self.nodes[0].getrawtransaction, txHash, [])
# 8. invalid parameters - supply txid and empty dict
assert_raises_rpc_error(-3,"Invalid type", self.nodes[0].getrawtransaction, txHash, {})
assert_raises_rpc_error(-1,"not a boolean", self.nodes[0].getrawtransaction, txHash, {})
inputs = [ {'txid' : "1d1d4e24ed99057e84c3f80fd8fbec79ed9e1acee37da269356ecea000000000", 'vout' : 1, 'sequence' : 1000}]
outputs = { self.nodes[0].getnewaddress() : 1 }

Loading…
Cancel
Save