diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -871,7 +871,9 @@ // Parse the prevtxs array ParsePrevouts(request.params[2], &keystore, coins); - return SignTransaction(mtx, &keystore, coins, request.params[3]); + UniValue result(UniValue::VOBJ); + SignTransaction(mtx, &keystore, coins, request.params[3], result); + return result; } static UniValue sendrawtransaction(const Config &config, diff --git a/src/rpc/rawtransaction_util.h b/src/rpc/rawtransaction_util.h --- a/src/rpc/rawtransaction_util.h +++ b/src/rpc/rawtransaction_util.h @@ -24,12 +24,11 @@ * @param coins Map of unspent outputs - coins in mempool and current * chain UTXO set, may be extended by previous txns outputs after call * @param hashType The signature hash type - * @returns JSON object with details of signed transaction + * @param result JSON object where signed transaction results accumulate */ -UniValue SignTransaction(CMutableTransaction &mtx, - const SigningProvider *keystore, - std::map &coins, - const UniValue &hashType); +void SignTransaction(CMutableTransaction &mtx, const SigningProvider *keystore, + std::map &coins, const UniValue &hashType, + UniValue &result); /** * Parse a prevtxs UniValue array and get the map of coins from it diff --git a/src/rpc/rawtransaction_util.cpp b/src/rpc/rawtransaction_util.cpp --- a/src/rpc/rawtransaction_util.cpp +++ b/src/rpc/rawtransaction_util.cpp @@ -254,10 +254,9 @@ } } -UniValue SignTransaction(CMutableTransaction &mtx, - const SigningProvider *keystore, - std::map &coins, - const UniValue &hashType) { +void SignTransaction(CMutableTransaction &mtx, const SigningProvider *keystore, + std::map &coins, const UniValue &hashType, + UniValue &result) { SigHashType sigHashType = ParseSighashString(hashType); if (!sigHashType.hasForkId()) { throw JSONRPCError(RPC_INVALID_PARAMETER, @@ -313,12 +312,12 @@ bool fComplete = vErrors.empty(); - UniValue result(UniValue::VOBJ); result.pushKV("hex", EncodeHexTx(CTransaction(mtx))); result.pushKV("complete", fComplete); if (!vErrors.empty()) { + if (result.exists("errors")) { + vErrors.push_backV(result["errors"].getValues()); + } result.pushKV("errors", vErrors); } - - return result; } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3894,8 +3894,10 @@ // Parse the prevtxs array ParsePrevouts(request.params[1], nullptr, coins); - return SignTransaction(mtx, &*pwallet->GetLegacyScriptPubKeyMan(), coins, - request.params[2]); + UniValue result(UniValue::VOBJ); + SignTransaction(mtx, &*pwallet->GetLegacyScriptPubKeyMan(), coins, + request.params[2], result); + return result; } UniValue rescanblockchain(const Config &config, const JSONRPCRequest &request) {