refactor: Replace isTrue with get_bool

This makes the code more robust, see previous commit.

In general replacing isTrue with get_bool is not equivalent because
get_bool can throw exceptions, but in this case, exceptions won't happen
because of RPCTypeCheck() and isNull() checks in the preceding code.
This commit is contained in:
MarcoFalke committed 2022-12-07 17:56:49 +01:00
1 parent fa2cc5d1d6
commit fa0153e609
1 file changed
+2 -2
+2 -2
View File
@@ -304,7 +304,7 @@ static RPCHelpMan createrawtransaction()
std::optional<bool> rbf; std::optional<bool> rbf;
if (!request.params[3].isNull()) { if (!request.params[3].isNull()) {
rbf = request.params[3].isTrue(); rbf = request.params[3].get_bool();
} }
CMutableTransaction rawTx = ConstructTransaction(request.params[0], request.params[1], request.params[2], rbf); CMutableTransaction rawTx = ConstructTransaction(request.params[0], request.params[1], request.params[2], rbf);
@@ -1449,7 +1449,7 @@ static RPCHelpMan createpsbt()
std::optional<bool> rbf; std::optional<bool> rbf;
if (!request.params[3].isNull()) { if (!request.params[3].isNull()) {
rbf = request.params[3].isTrue(); rbf = request.params[3].get_bool();
} }
CMutableTransaction rawTx = ConstructTransaction(request.params[0], request.params[1], request.params[2], rbf); CMutableTransaction rawTx = ConstructTransaction(request.params[0], request.params[1], request.params[2], rbf);