Switch away from exceptions in refactored tx code

After refactoring general-purpose PSBT and transaction code out of RPC code,
for use in the GUI, it's no longer appropriate to throw exceptions. Instead we
now return bools for success, and take an output parameter for an error object.
We still use JSONRPCError() for the error objects, since only RPC callers
actually care about the error codes.
This commit is contained in:
Glenn Willen
2019-02-09 20:51:33 -08:00
parent c6c3d42a7d
commit bd0dbe8763
10 changed files with 159 additions and 24 deletions

View File

@@ -1050,7 +1050,14 @@ static UniValue sendrawtransaction(const JSONRPCRequest& request)
bool allowhighfees = false;
if (!request.params[1].isNull()) allowhighfees = request.params[1].get_bool();
return BroadcastTransaction(tx, allowhighfees).GetHex();
uint256 txid;
TransactionError err;
std::string err_string;
if (!BroadcastTransaction(tx, txid, err, err_string, allowhighfees)) {
throw JSONRPCTransactionError(err, err_string);
}
return txid.GetHex();
}
static UniValue testmempoolaccept(const JSONRPCRequest& request)