|
13 | 13 | #include <key_io.h>
|
14 | 14 | #include <keystore.h>
|
15 | 15 | #include <merkleblock.h>
|
16 |
| -#include <net.h> |
| 16 | +#include <node/transaction.h> |
17 | 17 | #include <policy/policy.h>
|
18 | 18 | #include <policy/rbf.h>
|
19 | 19 | #include <primitives/transaction.h>
|
|
24 | 24 | #include <script/script_error.h>
|
25 | 25 | #include <script/sign.h>
|
26 | 26 | #include <script/standard.h>
|
27 |
| -#include <txmempool.h> |
28 | 27 | #include <uint256.h>
|
29 | 28 | #include <util/strencodings.h>
|
30 | 29 | #include <validation.h>
|
31 | 30 | #include <validationinterface.h>
|
32 | 31 |
|
33 |
| -#include <future> |
34 | 32 | #include <stdint.h>
|
35 | 33 |
|
36 | 34 | #include <univalue.h>
|
@@ -1041,76 +1039,17 @@ static UniValue sendrawtransaction(const JSONRPCRequest& request)
|
1041 | 1039 | },
|
1042 | 1040 | }.ToString());
|
1043 | 1041 |
|
1044 |
| - std::promise<void> promise; |
1045 |
| - |
1046 | 1042 | RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL});
|
1047 | 1043 |
|
1048 | 1044 | // parse hex string from parameter
|
1049 | 1045 | CMutableTransaction mtx;
|
1050 | 1046 | if (!DecodeHexTx(mtx, request.params[0].get_str()))
|
1051 | 1047 | throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
|
1052 | 1048 | CTransactionRef tx(MakeTransactionRef(std::move(mtx)));
|
1053 |
| - const uint256& hashTx = tx->GetHash(); |
1054 |
| - |
1055 |
| - CAmount nMaxRawTxFee = maxTxFee; |
1056 |
| - if (!request.params[1].isNull() && request.params[1].get_bool()) |
1057 |
| - nMaxRawTxFee = 0; |
1058 |
| - |
1059 |
| - { // cs_main scope |
1060 |
| - LOCK(cs_main); |
1061 |
| - CCoinsViewCache &view = *pcoinsTip; |
1062 |
| - bool fHaveChain = false; |
1063 |
| - for (size_t o = 0; !fHaveChain && o < tx->vout.size(); o++) { |
1064 |
| - const Coin& existingCoin = view.AccessCoin(COutPoint(hashTx, o)); |
1065 |
| - fHaveChain = !existingCoin.IsSpent(); |
1066 |
| - } |
1067 |
| - bool fHaveMempool = mempool.exists(hashTx); |
1068 |
| - if (!fHaveMempool && !fHaveChain) { |
1069 |
| - // push to local node and sync with wallets |
1070 |
| - CValidationState state; |
1071 |
| - bool fMissingInputs; |
1072 |
| - if (!AcceptToMemoryPool(mempool, state, std::move(tx), &fMissingInputs, |
1073 |
| - nullptr /* plTxnReplaced */, false /* bypass_limits */, nMaxRawTxFee)) { |
1074 |
| - if (state.IsInvalid()) { |
1075 |
| - throw JSONRPCError(RPC_TRANSACTION_REJECTED, FormatStateMessage(state)); |
1076 |
| - } else { |
1077 |
| - if (fMissingInputs) { |
1078 |
| - throw JSONRPCError(RPC_TRANSACTION_ERROR, "Missing inputs"); |
1079 |
| - } |
1080 |
| - throw JSONRPCError(RPC_TRANSACTION_ERROR, FormatStateMessage(state)); |
1081 |
| - } |
1082 |
| - } else { |
1083 |
| - // If wallet is enabled, ensure that the wallet has been made aware |
1084 |
| - // of the new transaction prior to returning. This prevents a race |
1085 |
| - // where a user might call sendrawtransaction with a transaction |
1086 |
| - // to/from their wallet, immediately call some wallet RPC, and get |
1087 |
| - // a stale result because callbacks have not yet been processed. |
1088 |
| - CallFunctionInValidationInterfaceQueue([&promise] { |
1089 |
| - promise.set_value(); |
1090 |
| - }); |
1091 |
| - } |
1092 |
| - } else if (fHaveChain) { |
1093 |
| - throw JSONRPCError(RPC_TRANSACTION_ALREADY_IN_CHAIN, "transaction already in block chain"); |
1094 |
| - } else { |
1095 |
| - // Make sure we don't block forever if re-sending |
1096 |
| - // a transaction already in mempool. |
1097 |
| - promise.set_value(); |
1098 |
| - } |
1099 |
| - |
1100 |
| - } // cs_main |
1101 |
| - |
1102 |
| - promise.get_future().wait(); |
1103 |
| - |
1104 |
| - if(!g_connman) |
1105 |
| - throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled"); |
1106 |
| - |
1107 |
| - CInv inv(MSG_TX, hashTx); |
1108 |
| - g_connman->ForEachNode([&inv](CNode* pnode) |
1109 |
| - { |
1110 |
| - pnode->PushInventory(inv); |
1111 |
| - }); |
1112 | 1049 |
|
1113 |
| - return hashTx.GetHex(); |
| 1050 | + bool allowhighfees = false; |
| 1051 | + if (!request.params[1].isNull()) allowhighfees = request.params[1].get_bool(); |
| 1052 | + return BroadcastTransaction(tx, allowhighfees).GetHex(); |
1114 | 1053 | }
|
1115 | 1054 |
|
1116 | 1055 | static UniValue testmempoolaccept(const JSONRPCRequest& request)
|
|
0 commit comments