Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/rawtransaction.cpp
Show First 20 Lines • Show All 1,310 Lines • ▼ Show 20 Lines | static UniValue sendrawtransaction(const Config &config, | ||||
CMutableTransaction mtx; | CMutableTransaction mtx; | ||||
if (!DecodeHexTx(mtx, request.params[0].get_str())) { | if (!DecodeHexTx(mtx, request.params[0].get_str())) { | ||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed"); | throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed"); | ||||
} | } | ||||
CTransactionRef tx(MakeTransactionRef(std::move(mtx))); | CTransactionRef tx(MakeTransactionRef(std::move(mtx))); | ||||
const uint256 &txid = tx->GetId(); | const uint256 &txid = tx->GetId(); | ||||
bool fLimitFree = false; | |||||
Amount nMaxRawTxFee = maxTxFee; | Amount nMaxRawTxFee = maxTxFee; | ||||
if (request.params.size() > 1 && request.params[1].get_bool()) { | if (request.params.size() > 1 && request.params[1].get_bool()) { | ||||
nMaxRawTxFee = Amount::zero(); | nMaxRawTxFee = Amount::zero(); | ||||
} | } | ||||
{ // cs_main scope | { // cs_main scope | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
CCoinsViewCache &view = *pcoinsTip; | CCoinsViewCache &view = *pcoinsTip; | ||||
bool fHaveChain = false; | bool fHaveChain = false; | ||||
for (size_t o = 0; !fHaveChain && o < tx->vout.size(); o++) { | for (size_t o = 0; !fHaveChain && o < tx->vout.size(); o++) { | ||||
const Coin &existingCoin = view.AccessCoin(COutPoint(txid, o)); | const Coin &existingCoin = view.AccessCoin(COutPoint(txid, o)); | ||||
fHaveChain = !existingCoin.IsSpent(); | fHaveChain = !existingCoin.IsSpent(); | ||||
} | } | ||||
bool fHaveMempool = g_mempool.exists(txid); | bool fHaveMempool = g_mempool.exists(txid); | ||||
if (!fHaveMempool && !fHaveChain) { | if (!fHaveMempool && !fHaveChain) { | ||||
// Push to local node and sync with wallets. | // Push to local node and sync with wallets. | ||||
CValidationState state; | CValidationState state; | ||||
bool fMissingInputs; | bool fMissingInputs; | ||||
bool fLimitFree = false; | |||||
if (!AcceptToMemoryPool(config, g_mempool, state, std::move(tx), | if (!AcceptToMemoryPool(config, g_mempool, state, std::move(tx), | ||||
fLimitFree, &fMissingInputs, false, | fLimitFree, &fMissingInputs, false, | ||||
nMaxRawTxFee)) { | nMaxRawTxFee)) { | ||||
if (state.IsInvalid()) { | if (state.IsInvalid()) { | ||||
throw JSONRPCError(RPC_TRANSACTION_REJECTED, | throw JSONRPCError(RPC_TRANSACTION_REJECTED, | ||||
strprintf("%i: %s", | strprintf("%i: %s", | ||||
state.GetRejectCode(), | state.GetRejectCode(), | ||||
state.GetRejectReason())); | state.GetRejectReason())); | ||||
▲ Show 20 Lines • Show All 153 Lines • Show Last 20 Lines |