MCPcopy Create free account
hub / github.com/LUX-Core/lux / AcceptToMemoryPool

Function AcceptToMemoryPool

src/main.cpp:986–1434  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

984
985
986bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState& state, const CTransaction& tx, bool fLimitFree, bool* pfMissingInputs, list<CTransactionRef>* plTxnReplaced, bool fRejectInsaneFee, bool ignoreFees)
987{
988 const uint256 hash = tx.GetHash();
989 AssertLockHeld(cs_main);
990 if (pfMissingInputs) {
991 *pfMissingInputs = false;
992 }
993 if (!CheckTransaction(tx, state))
994 return error("%s: CheckTransaction: %s, %s", __func__, hash.ToString(), FormatStateMessage(state));
995
996 // Coinbase is only valid in a block, not as a loose transaction
997 if (tx.IsCoinBase())
998 return state.DoS(100, error("AcceptToMemoryPool: : coinbase as individual tx"), REJECT_INVALID, "coinbase");
999
1000 //Coinstake is also only valid in a block, not as a loose transaction
1001 if (tx.IsCoinStake())
1002 return state.DoS(100, error("AcceptToMemoryPool: coinstake as individual tx"),
1003 REJECT_INVALID, "coinstake");
1004
1005 const CChainParams& chainParams = Params();
1006 // Reject transactions with witness before segregated witness activates (override with -prematurewitness)
1007 bool witnessEnabled = IsWitnessEnabled(chainActive.Tip(), chainParams.GetConsensus());
1008 if (!GetBoolArg("-prematurewitness", false) && tx.HasWitness() && !witnessEnabled) {
1009 return state.DoS(0, false, REJECT_NONSTANDARD, "no-witness-yet", true);
1010 }
1011
1012 // Rather not work on nonstandard transactions (unless -testnet/-regtest)
1013 string reason;
1014 if (fRequireStandard && !IsStandardTx(tx, reason, witnessEnabled))
1015 return state.DoS(0,
1016 error("AcceptToMemoryPool : nonstandard transaction: %s", reason),
1017 REJECT_NONSTANDARD, reason);
1018
1019 if (!IsFinalTx(tx, chainActive.Height() + 1))
1020 return state.DoS(0, error("AcceptToMemoryPool: non-final"), REJECT_NONSTANDARD, "non-final");
1021
1022 // is it already in the memory pool?
1023 if (pool.exists(hash))
1024 return false;
1025
1026 // ----------- INSTANTX transaction scanning -----------
1027
1028 for (const CTxIn& in : tx.vin) {
1029 if (mapLockedInputs.count(in.prevout)) {
1030 if (mapLockedInputs[in.prevout] != tx.GetHash()) {
1031 return state.DoS(0,
1032 error("AcceptToMemoryPool : conflicts with existing transaction lock: %s", reason),
1033 REJECT_INVALID, "tx-lock-conflict");
1034 }
1035 }
1036 }
1037 // Mempool blocking code
1038 const char *mempoolbanname;
1039 BOOST_FOREACH(const CTxOut& txout, tx.vout) {
1040 mempoolbanname = txout.scriptPubKey.IsMempoolbanned();
1041 if (mempoolbanname) {
1042 LogPrintf("AcceptToMemoryPool : not accepting transaction %s with mempoolbanned output (%s)\n", tx.GetHash().ToString().c_str(), mempoolbanname);
1043 return error("AcceptToMemoryPool : not accepting transaction %s with mempoolbanned output (%s)\n", tx.GetHash().ToString().c_str(), mempoolbanname);

Callers 6

ProcessInstantXFunction · 0.85
AcceptToMemoryPoolMethod · 0.85
sendrawtransactionFunction · 0.85
DisconnectTipFunction · 0.85
ProcessMessageFunction · 0.85

Calls 15

errorFunction · 0.85
FormatStateMessageFunction · 0.85
IsWitnessEnabledFunction · 0.85
GetBoolArgFunction · 0.85
IsStandardTxFunction · 0.85
IsFinalTxFunction · 0.85
CheckSequenceLocksFunction · 0.85
AreInputsStandardFunction · 0.85
IsWitnessStandardFunction · 0.85
GetTransactionSigOpCostFunction · 0.85
CheckSenderScriptFunction · 0.85
GetArgFunction · 0.85

Tested by

no test coverage detected