|
|
|
@ -1149,14 +1149,21 @@ bool MemPoolAccept::SubmitPackage(const ATMPArgs& args, std::vector<Workspace>&
|
|
|
|
|
// make sure we haven't exceeded max mempool size.
|
|
|
|
|
LimitMempoolSize(m_pool, m_active_chainstate.CoinsTip());
|
|
|
|
|
|
|
|
|
|
std::vector<uint256> all_package_wtxids;
|
|
|
|
|
all_package_wtxids.reserve(workspaces.size());
|
|
|
|
|
std::transform(workspaces.cbegin(), workspaces.cend(), std::back_inserter(all_package_wtxids),
|
|
|
|
|
[](const auto& ws) { return ws.m_ptx->GetWitnessHash(); });
|
|
|
|
|
// Find the wtxids of the transactions that made it into the mempool. Allow partial submission,
|
|
|
|
|
// but don't report success unless they all made it into the mempool.
|
|
|
|
|
for (Workspace& ws : workspaces) {
|
|
|
|
|
const auto effective_feerate = args.m_package_feerates ? ws.m_package_feerate :
|
|
|
|
|
CFeeRate{ws.m_modified_fees, static_cast<uint32_t>(ws.m_vsize)};
|
|
|
|
|
const auto effective_feerate_wtxids = args.m_package_feerates ? all_package_wtxids :
|
|
|
|
|
std::vector<uint256>({ws.m_ptx->GetWitnessHash()});
|
|
|
|
|
if (m_pool.exists(GenTxid::Wtxid(ws.m_ptx->GetWitnessHash()))) {
|
|
|
|
|
results.emplace(ws.m_ptx->GetWitnessHash(),
|
|
|
|
|
MempoolAcceptResult::Success(std::move(ws.m_replaced_transactions), ws.m_vsize, ws.m_base_fees, effective_feerate));
|
|
|
|
|
MempoolAcceptResult::Success(std::move(ws.m_replaced_transactions), ws.m_vsize,
|
|
|
|
|
ws.m_base_fees, effective_feerate, effective_feerate_wtxids));
|
|
|
|
|
GetMainSignals().TransactionAddedToMempool(ws.m_ptx, m_pool.GetAndIncrementSequence());
|
|
|
|
|
} else {
|
|
|
|
|
all_submitted = false;
|
|
|
|
@ -1185,16 +1192,19 @@ MempoolAcceptResult MemPoolAccept::AcceptSingleTransaction(const CTransactionRef
|
|
|
|
|
if (!ConsensusScriptChecks(args, ws)) return MempoolAcceptResult::Failure(ws.m_state);
|
|
|
|
|
|
|
|
|
|
const CFeeRate effective_feerate{ws.m_modified_fees, static_cast<uint32_t>(ws.m_vsize)};
|
|
|
|
|
const std::vector<uint256> single_wtxid{ws.m_ptx->GetWitnessHash()};
|
|
|
|
|
// Tx was accepted, but not added
|
|
|
|
|
if (args.m_test_accept) {
|
|
|
|
|
return MempoolAcceptResult::Success(std::move(ws.m_replaced_transactions), ws.m_vsize, ws.m_base_fees, effective_feerate);
|
|
|
|
|
return MempoolAcceptResult::Success(std::move(ws.m_replaced_transactions), ws.m_vsize,
|
|
|
|
|
ws.m_base_fees, effective_feerate, single_wtxid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!Finalize(args, ws)) return MempoolAcceptResult::Failure(ws.m_state);
|
|
|
|
|
|
|
|
|
|
GetMainSignals().TransactionAddedToMempool(ptx, m_pool.GetAndIncrementSequence());
|
|
|
|
|
|
|
|
|
|
return MempoolAcceptResult::Success(std::move(ws.m_replaced_transactions), ws.m_vsize, ws.m_base_fees, effective_feerate);
|
|
|
|
|
return MempoolAcceptResult::Success(std::move(ws.m_replaced_transactions), ws.m_vsize, ws.m_base_fees,
|
|
|
|
|
effective_feerate, single_wtxid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PackageMempoolAcceptResult MemPoolAccept::AcceptMultipleTransactions(const std::vector<CTransactionRef>& txns, ATMPArgs& args)
|
|
|
|
@ -1252,6 +1262,10 @@ PackageMempoolAcceptResult MemPoolAccept::AcceptMultipleTransactions(const std::
|
|
|
|
|
return PackageMempoolAcceptResult(package_state, package_feerate, std::move(results));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::vector<uint256> all_package_wtxids;
|
|
|
|
|
all_package_wtxids.reserve(workspaces.size());
|
|
|
|
|
std::transform(workspaces.cbegin(), workspaces.cend(), std::back_inserter(all_package_wtxids),
|
|
|
|
|
[](const auto& ws) { return ws.m_ptx->GetWitnessHash(); });
|
|
|
|
|
for (Workspace& ws : workspaces) {
|
|
|
|
|
ws.m_package_feerate = package_feerate;
|
|
|
|
|
if (!PolicyScriptChecks(args, ws)) {
|
|
|
|
@ -1263,11 +1277,12 @@ PackageMempoolAcceptResult MemPoolAccept::AcceptMultipleTransactions(const std::
|
|
|
|
|
if (args.m_test_accept) {
|
|
|
|
|
const auto effective_feerate = args.m_package_feerates ? ws.m_package_feerate :
|
|
|
|
|
CFeeRate{ws.m_modified_fees, static_cast<uint32_t>(ws.m_vsize)};
|
|
|
|
|
// When test_accept=true, transactions that pass PolicyScriptChecks are valid because there are
|
|
|
|
|
// no further mempool checks (passing PolicyScriptChecks implies passing ConsensusScriptChecks).
|
|
|
|
|
const auto effective_feerate_wtxids = args.m_package_feerates ? all_package_wtxids :
|
|
|
|
|
std::vector<uint256>{ws.m_ptx->GetWitnessHash()};
|
|
|
|
|
results.emplace(ws.m_ptx->GetWitnessHash(),
|
|
|
|
|
MempoolAcceptResult::Success(std::move(ws.m_replaced_transactions),
|
|
|
|
|
ws.m_vsize, ws.m_base_fees, effective_feerate));
|
|
|
|
|
ws.m_vsize, ws.m_base_fees, effective_feerate,
|
|
|
|
|
effective_feerate_wtxids));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|