diff --git a/src/coinjoin/server.cpp b/src/coinjoin/server.cpp index 6b94fdea35ff5..382e95d7eb541 100644 --- a/src/coinjoin/server.cpp +++ b/src/coinjoin/server.cpp @@ -322,7 +322,7 @@ void CCoinJoinServer::CommitFinalTransaction() TRY_LOCK(cs_main, lockMain); TxValidationState validationState; mempool.PrioritiseTransaction(hashTx, 0.1 * COIN); - if (!lockMain || !AcceptToMemoryPool(::ChainstateActive(), mempool, validationState, finalTransaction, false /* bypass_limits */, DEFAULT_MAX_RAW_TX_FEE /* nAbsurdFee */)) { + if (!lockMain || !AcceptToMemoryPool(m_chainstate, mempool, validationState, finalTransaction, false /* bypass_limits */, DEFAULT_MAX_RAW_TX_FEE /* nAbsurdFee */)) { LogPrint(BCLog::COINJOIN, "CCoinJoinServer::CommitFinalTransaction -- AcceptToMemoryPool() error: Transaction not valid\n"); WITH_LOCK(cs_coinjoin, SetNull()); // not much we can do in this case, just notify clients @@ -455,7 +455,7 @@ void CCoinJoinServer::ConsumeCollateral(const CTransactionRef& txref) const { LOCK(cs_main); TxValidationState validationState; - if (!AcceptToMemoryPool(::ChainstateActive(), mempool, validationState, txref, false /* bypass_limits */, 0 /* nAbsurdFee */)) { + if (!AcceptToMemoryPool(m_chainstate, mempool, validationState, txref, false /* bypass_limits */, 0 /* nAbsurdFee */)) { LogPrint(BCLog::COINJOIN, "%s -- AcceptToMemoryPool failed\n", __func__); } else { connman.RelayTransaction(*txref); diff --git a/src/coinjoin/server.h b/src/coinjoin/server.h index 183cd3f32eabf..c2e54aef61ae3 100644 --- a/src/coinjoin/server.h +++ b/src/coinjoin/server.h @@ -8,6 +8,7 @@ #include #include +class CChainState; class CCoinJoinServer; class CTxMemPool; class PeerManager; @@ -22,8 +23,9 @@ extern std::unique_ptr coinJoinServer; class CCoinJoinServer : public CCoinJoinBaseSession, public CCoinJoinBaseManager { private: - CTxMemPool& mempool; + CChainState& m_chainstate; CConnman& connman; + CTxMemPool& mempool; const CMasternodeSync& m_mn_sync; // Mixing uses collateral transactions to trust parties entering the pool @@ -79,9 +81,10 @@ class CCoinJoinServer : public CCoinJoinBaseSession, public CCoinJoinBaseManager void SetNull() EXCLUSIVE_LOCKS_REQUIRED(cs_coinjoin); public: - explicit CCoinJoinServer(CTxMemPool& mempool, CConnman& _connman, const CMasternodeSync& mn_sync) : - mempool(mempool), + explicit CCoinJoinServer(CChainState& chainstate, CConnman& _connman, CTxMemPool& mempool, const CMasternodeSync& mn_sync) : + m_chainstate(chainstate), connman(_connman), + mempool(mempool), m_mn_sync(mn_sync), vecSessionCollaterals(), fUnitTest(false) diff --git a/src/init.cpp b/src/init.cpp index 365c0bad5c65e..0d10dc13ca488 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -2249,7 +2249,7 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc // ********************************************************* Step 10a: Setup CoinJoin - ::coinJoinServer = std::make_unique(*node.mempool, *node.connman, *::masternodeSync); + ::coinJoinServer = std::make_unique(chainman.ActiveChainstate(), *node.connman, *node.mempool, *::masternodeSync); #ifdef ENABLE_WALLET if (!ignores_incoming_txs) { ::coinJoinClientQueueManager = std::make_unique(*node.connman, *::masternodeSync); diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp index d1aa754965f7f..11a0defcffdac 100644 --- a/src/test/util/setup_common.cpp +++ b/src/test/util/setup_common.cpp @@ -99,6 +99,7 @@ void DashTestSetup(NodeContext& node) { CChainState& chainstate = Assert(node.chainman)->ActiveChainstate(); + ::coinJoinServer = std::make_unique(chainstate, *node.connman, *node.mempool, *::masternodeSync); ::deterministicMNManager = std::make_unique(chainstate, *node.connman, *node.evodb); node.llmq_ctx = std::make_unique(chainstate, *node.connman, *node.evodb, *sporkManager, *node.mempool, node.peerman, true, false); } @@ -109,6 +110,7 @@ void DashTestSetupClose(NodeContext& node) node.llmq_ctx->Stop(); node.llmq_ctx.reset(); ::deterministicMNManager.reset(); + ::coinJoinServer.reset(); } BasicTestingSetup::BasicTestingSetup(const std::string& chainName, const std::vector& extra_args) @@ -199,7 +201,6 @@ ChainTestingSetup::ChainTestingSetup(const std::string& chainName, const std::ve ::sporkManager = std::make_unique(); ::governance = std::make_unique(); ::masternodeSync = std::make_unique(*m_node.connman); - ::coinJoinServer = std::make_unique(*m_node.mempool, *m_node.connman, *::masternodeSync); #ifdef ENABLE_WALLET ::coinJoinClientQueueManager = std::make_unique(*m_node.connman, *::masternodeSync); #endif // ENABLE_WALLET @@ -222,7 +223,6 @@ ChainTestingSetup::~ChainTestingSetup() #ifdef ENABLE_WALLET ::coinJoinClientQueueManager.reset(); #endif // ENABLE_WALLET - ::coinJoinServer.reset(); ::masternodeSync.reset(); ::governance.reset(); ::sporkManager.reset();