aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/rawtransaction.cpp
diff options
context:
space:
mode:
authorGlenn Willen <[email protected]>2019-02-09 20:51:33 -0800
committerGlenn Willen <[email protected]>2019-02-11 14:08:04 -0800
commitbd0dbe8763fc3029cf96531c9ccaba280b939445 (patch)
treef9ac966b3363bec18db36714ffc37ec3c36dd4be /src/rpc/rawtransaction.cpp
parentMove PSBT definitions and code to separate files (diff)
downloaddiscoin-bd0dbe8763fc3029cf96531c9ccaba280b939445.tar.xz
discoin-bd0dbe8763fc3029cf96531c9ccaba280b939445.zip
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.
Diffstat (limited to 'src/rpc/rawtransaction.cpp')
-rw-r--r--src/rpc/rawtransaction.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp
index 03e38739a..bc836614a 100644
--- a/src/rpc/rawtransaction.cpp
+++ b/src/rpc/rawtransaction.cpp
@@ -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)