Skip to content

Commit

Permalink
Merge #6594: refactor: polish CoinJoin interface, use WalletLoader
Browse files Browse the repository at this point in the history
…in Dash wallet initialization code, introduce new RPC `coinjoin status`

68cec8d refactor: use `interfaces::WalletLoader` in Dash-specific wallet init (Kittywhiskers Van Gogh)
c9c5275 refactor: get rid of `DashPostChainstateSetup()` (Kittywhiskers Van Gogh)
6502e54 refactor: use `CoinJoin::Loader` in `InitCoinJoinSettings` (Kittywhiskers Van Gogh)
0d8de73 refactor: make `WalletContext::coinjoin_loader` a pointer (Kittywhiskers Van Gogh)
0760ae0 fix: resolve undefined reference linking error in `bench_dash` (Kittywhiskers Van Gogh)
846dc67 refactor: initialize CoinJoin loader in `WalletInit::Construct()` (Kittywhiskers Van Gogh)
b14e55f chore: fix `MakeWallet` argument list in dummy wallet (Kittywhiskers Van Gogh)
b3ac5cf refactor: place `ArgsManager` before `interfaces::CoinJoin::Loader` (Kittywhiskers Van Gogh)
73671dd refactor: fold `InitCoinJoinSettings` calls into `CoinJoin::Loader` (Kittywhiskers Van Gogh)
27f8d9c refactor: defer accessing `CoinJoinWalletManager` to interface call (Kittywhiskers Van Gogh)
398e9c3 refactor: stop exposing `CoinJoinWalletManager` from `CoinJoin::Loader` (Kittywhiskers Van Gogh)
48fccdd refactor: introduce `coinjoin status` for information on mix sessions (Kittywhiskers Van Gogh)

Pull request description:

  ## Motivation

  Since [bitcoin#22219](bitcoin#22219) (introduced in [dash#6568](#6568)), the workarounds implemented for allowing the backport of [bitcoin#19101](bitcoin#19101) (a part of [dash#6529](#6529)) no longer work. A major reason for this is the initialization order assumed in [dash#6529](#6529) is no longer holds true, requiring a rework of CoinJoin interfaces. This pull request aims to do that.

  ## Additional Information

  * Dependency for #6529

  * To allow for dropping `walletman()` from `CoinJoin::Loader`, both `CoinJoin::Loader` and `CoinJoin::Client` (accessible through `CoinJoin::Loader::GetClient()`) need to account for all potential usage.

    To that end, `CoinJoin::Client::get{JsonInfo, SessionStatuses}()` have been implemented.

    * Though some invocations of `CCoinJoinClientSession` functions cannot (or rather, should not) be available through the interface (like `DoAutomaticDenominating()`).

    * To take care of one such invocation (in `coinjoin start`, [source](https://github.com/dashpay/dash/blob/5c1a6270a73ea7025879ee0485be5095b3bc142b/src/rpc/coinjoin.cpp#L135-L136)), it has been removed altogether. `coinjoin start` will now behave like the "Start CoinJoin" button in Dash Qt and won't try to get ahead of the scheduler and start denomination.

      * The loss of status information in fail cases due to this, has been made up for with a new RPC, `coinjoin status`, that will report status information during any active mix session (as opposed to earlier behavior where such information was only made available when starting a mix session through `coinjoin start` and encountering a fail state).

  * `CoinJoin::Loader` and `WalletLoader` rely on each other as

    * `CoinJoin::Loader::{Add,Remove}Wallet()` needs to be able to run `WalletInitInterface::InitCoinJoinSettings()`, which in turn needs to be able enumerate through all available wallets ([source](https://github.com/dashpay/dash/blob/5c1a6270a73ea7025879ee0485be5095b3bc142b/src/wallet/init.cpp#L207)), currently doing so through the global wallet context but eventually through `WalletLoader` when said globals are no longer available (post-[bitcoin#19101](bitcoin#19101))

    * `WalletLoader` needs  `CoinJoin::Loader` to load ([source](https://github.com/dashpay/dash/blob/5c1a6270a73ea7025879ee0485be5095b3bc142b/src/wallet/interfaces.cpp#601)) and restore ([source](https://github.com/dashpay/dash/blob/5c1a6270a73ea7025879ee0485be5095b3bc142b/src/wallet/interfaces.cpp#L607)) wallets as `CWallet` needs access to `CoinJoin::Loader` in order to call `CoinJoin::Loader::{Add,Remove}Wallet()` ([source](https://github.com/dashpay/dash/blob/5c1a6270a73ea7025879ee0485be5095b3bc142b/src/wallet/wallet.cpp#L3516), [source](https://github.com/dashpay/dash/blob/5c1a6270a73ea7025879ee0485be5095b3bc142b/src/wallet/wallet.cpp#L148))

    This interdependent relationship has currently been floating along by passing a const ref of the smart pointer ([source](https://github.com/dashpay/dash/blob/5c1a6270a73ea7025879ee0485be5095b3bc142b/src/interfaces/init.h#L37)), which makes for cumbersome but workable code but in combination with [bitcoin#22219](bitcoin#22219), it breaks [bitcoin#19101](bitcoin#19101) as it forces us to definitively initialize both `WalletLoader` and `CoinJoin::Loader` _before_ we get to initialize CoinJoin logic.

    To work around this, instead of requiring a fully initialized `CoinJoinWalletManager` to create a `CoinJoin::Loader`, we instead take `NodeContext` and defer resolving `CoinJoinWalletManager` to when interface calls are made.

  * By moving the initialization of the CoinJoin loader from `AppInitMain()` to `WalletInit::Construct()`, the linker was unhappy with trying to emit `bench_dash` (see error below). This was remedied by linking `libbitcoin_wallet` with `libtest_util`.

    <details>

    <summary>Linker error:</summary>

      ```
        AR       libbitcoin_server.a
        CXXLD    dashd
        CXXLD    test/test_dash
        CXXLD    bench/bench_dash
        CXXLD    qt/dash-qt
        CXXLD    qt/test/test_dash-qt
    /usr/bin/ld: libtest_util.a(libtest_util_a-setup_common.o): in function `DashPostChainstateSetup(NodeContext&)':
    /src/dash/src/test/util/setup_common.cpp:127:(.text+0x1a8e): undefined reference to `interfaces::MakeCoinJoinLoader(NodeContext&)'
    collect2: error: ld returned 1 exit status
    make[2]: *** [Makefile:7354: bench/bench_dash] Error 1
    make[2]: *** Waiting for unfinished jobs....
    make[2]: Leaving directory '/src/dash/src'
    make[1]: *** [Makefile:20648: all-recursive] Error 1
    make[1]: Leaving directory '/src/dash/src'
    make: *** [Makefile:797: all-recursive] Error 1
    ```

    </details>

  * [bitcoin#22219](bitcoin#22219) removes a `WalletInit::Construct()` call from `setup_common.cpp` ([source](029572d#diff-6a8ef76c60f30a6ca67d9f0e478fd02989c4b7fbc4c3116f80e13d873d5775e6L195-L198)), which is necessary since `WalletInit::Construct()` now relies on `node.init` ([source](https://github.com/dashpay/dash/blob/5c1a6270a73ea7025879ee0485be5095b3bc142b/src/wallet/init.cpp#L191)).

    This isn't so much a problem for tests that use `WalletTestingSetup` or `InitWalletDirTestingSetup` but creates problems for tests based on `TestChain100Setup` ([source](https://github.com/dashpay/dash/blob/5c1a6270a73ea7025879ee0485be5095b3bc142b/src/wallet/test/coinjoin_tests.cpp#L128), [source](https://github.com/dashpay/dash/blob/5c1a6270a73ea7025879ee0485be5095b3bc142b/src/wallet/test/wallet_tests.cpp#L205)), which is a specialization of `TestingSetup` that in turn, used to initialize `coinjoin_loader` ([source](https://github.com/dashpay/dash/blob/5c1a6270a73ea7025879ee0485be5095b3bc142b/src/test/util/setup_common.cpp#L127)) but since initialization has been moved to `WalletInit::Construct()` in line with `Init::makeWalletLoader()`, it is not done automatically anymore.

    To work around this, `WalletInit::Construct()`-like code has been introduced to initialize both `coinjoin_loader` and `wallet_loader` ([source](https://github.com/kwvg/dash/blob/038619d284c457610ebbf833991298469c3e9a3d/src/test/util/setup_common.cpp#L320-L329)).

  ## Breaking Changes

  * `coinjoin start` will no longer report errors from mix sessions. To see the status of mix sessions, a new RPC, `coinjoin status`, is available in its place.

  ## Checklist

  - [x] I have performed a self-review of my own code
  - [x] I have commented my code, particularly in hard-to-understand areas
  - [x] I have added or updated relevant unit/integration/functional/e2e tests
  - [x] I have made corresponding changes to the documentation
  - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

ACKs for top commit:
  UdjinM6:
    utACK 68cec8d
  PastaPastaPasta:
    utACK 68cec8d

Tree-SHA512: 17ffc8f79ff19ffee9874787bf9cf982c8059c566475ed78634c3870506a24020f969c35ed6d23748fea0f993d9e646929d523c9c441fad27ea5eaf4b9438303
  • Loading branch information
PastaPastaPasta committed Feb 25, 2025
2 parents b4e2269 + 68cec8d commit a73024d
Show file tree
Hide file tree
Showing 30 changed files with 249 additions and 150 deletions.
7 changes: 7 additions & 0 deletions doc/release-notes-6594.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Updated RPCs
------------

* `coinjoin status` is a new RPC that reports the status message of all running mix
sessions.
* `coinjoin start` will no longer report errors from mix sessions, users are recommended
to query the status of mix sessions using `coinjoin status` instead.
3 changes: 3 additions & 0 deletions src/Makefile.test_util.include
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ LIBTEST_UTIL += $(LIBBITCOIN_SERVER)
LIBTEST_UTIL += $(LIBBITCOIN_COMMON)
LIBTEST_UTIL += $(LIBBITCOIN_UTIL)
LIBTEST_UTIL += $(LIBBITCOIN_CRYPTO_BASE)
if ENABLE_WALLET
LIBTEST_UTIL += $(LIBBITCOIN_WALLET)
endif
33 changes: 14 additions & 19 deletions src/coinjoin/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,17 +350,18 @@ bilingual_str CCoinJoinClientSession::GetStatus(bool fWaitForBlock) const
}
}

bilingual_str CCoinJoinClientManager::GetStatuses()
std::vector<std::string> CCoinJoinClientManager::GetStatuses() const
{
bilingual_str strStatus;
bool fWaitForBlock = WaitForAnotherBlock();

AssertLockNotHeld(cs_deqsessions);

bool fWaitForBlock{WaitForAnotherBlock()};
std::vector<std::string> ret;

LOCK(cs_deqsessions);
for (const auto& session : deqSessions) {
strStatus = strStatus + session.GetStatus(fWaitForBlock) + Untranslated("; ");
ret.push_back(session.GetStatus(fWaitForBlock).original);
}
return strStatus;
return ret;
}

std::string CCoinJoinClientManager::GetSessionDenoms()
Expand Down Expand Up @@ -1914,14 +1915,11 @@ void CCoinJoinClientManager::GetJsonInfo(UniValue& obj) const

void CoinJoinWalletManager::Add(const std::shared_ptr<CWallet>& wallet)
{
{
LOCK(cs_wallet_manager_map);
m_wallet_manager_map.try_emplace(wallet->GetName(),
std::make_unique<CCoinJoinClientManager>(wallet, *this, m_dmnman, m_mn_metaman,
m_mn_sync, m_isman, m_queueman,
m_is_masternode));
}
g_wallet_init_interface.InitCoinJoinSettings(*this);
LOCK(cs_wallet_manager_map);
m_wallet_manager_map.try_emplace(wallet->GetName(),
std::make_unique<CCoinJoinClientManager>(wallet, *this, m_dmnman, m_mn_metaman,
m_mn_sync, m_isman, m_queueman,
m_is_masternode));
}

void CoinJoinWalletManager::DoMaintenance(CConnman& connman)
Expand All @@ -1933,11 +1931,8 @@ void CoinJoinWalletManager::DoMaintenance(CConnman& connman)
}

void CoinJoinWalletManager::Remove(const std::string& name) {
{
LOCK(cs_wallet_manager_map);
m_wallet_manager_map.erase(name);
}
g_wallet_init_interface.InitCoinJoinSettings(*this);
LOCK(cs_wallet_manager_map);
m_wallet_manager_map.erase(name);
}

void CoinJoinWalletManager::Flush(const std::string& name)
Expand Down
2 changes: 1 addition & 1 deletion src/coinjoin/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ class CCoinJoinClientManager
bool IsMixing() const;
void ResetPool() EXCLUSIVE_LOCKS_REQUIRED(!cs_deqsessions);

bilingual_str GetStatuses() EXCLUSIVE_LOCKS_REQUIRED(!cs_deqsessions);
std::vector<std::string> GetStatuses() const EXCLUSIVE_LOCKS_REQUIRED(!cs_deqsessions);
std::string GetSessionDenoms() EXCLUSIVE_LOCKS_REQUIRED(!cs_deqsessions);

bool GetMixingMasternodesInfo(std::vector<CDeterministicMNCPtr>& vecDmnsRet) const EXCLUSIVE_LOCKS_REQUIRED(!cs_deqsessions);
Expand Down
55 changes: 43 additions & 12 deletions src/coinjoin/interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@
#include <interfaces/coinjoin.h>

#include <coinjoin/client.h>
#include <coinjoin/context.h>
#include <coinjoin/options.h>
#include <node/context.h>
#include <util/check.h>
#include <wallet/wallet.h>
#include <walletinitinterface.h>

#include <univalue.h>

#include <memory>
#include <string>
Expand Down Expand Up @@ -37,10 +44,18 @@ class CoinJoinClientImpl : public interfaces::CoinJoin::Client
{
return m_clientman.nCachedNumBlocks;
}
void getJsonInfo(UniValue& obj) override
{
return m_clientman.GetJsonInfo(obj);
}
std::string getSessionDenoms() override
{
return m_clientman.GetSessionDenoms();
}
std::vector<std::string> getSessionStatuses() override
{
return m_clientman.GetStatuses();
}
void setCachedBlocks(int nCachedBlocks) override
{
m_clientman.nCachedNumBlocks = nCachedBlocks;
Expand All @@ -61,35 +76,51 @@ class CoinJoinClientImpl : public interfaces::CoinJoin::Client

class CoinJoinLoaderImpl : public interfaces::CoinJoin::Loader
{
CoinJoinWalletManager& m_walletman;
private:
CoinJoinWalletManager& walletman()
{
return *Assert(Assert(m_node.cj_ctx)->walletman);
}

interfaces::WalletLoader& wallet_loader()
{
return *Assert(m_node.wallet_loader);
}

public:
explicit CoinJoinLoaderImpl(CoinJoinWalletManager& walletman)
: m_walletman(walletman) {}
explicit CoinJoinLoaderImpl(NodeContext& node) :
m_node(node)
{
// Enablement will be re-evaluated when a wallet is added or removed
CCoinJoinClientOptions::SetEnabled(false);
}

void AddWallet(const std::shared_ptr<CWallet>& wallet) override { m_walletman.Add(wallet); }
void AddWallet(const std::shared_ptr<CWallet>& wallet) override
{
walletman().Add(wallet);
g_wallet_init_interface.InitCoinJoinSettings(*this, wallet_loader());
}
void RemoveWallet(const std::string& name) override
{
m_walletman.Remove(name);
walletman().Remove(name);
g_wallet_init_interface.InitCoinJoinSettings(*this, wallet_loader());
}
void FlushWallet(const std::string& name) override
{
m_walletman.Flush(name);
walletman().Flush(name);
}
std::unique_ptr<interfaces::CoinJoin::Client> GetClient(const std::string& name) override
{
auto clientman = m_walletman.Get(name);
auto clientman = walletman().Get(name);
return clientman ? std::make_unique<CoinJoinClientImpl>(*clientman) : nullptr;
}
CoinJoinWalletManager& walletman() override
{
return m_walletman;
}

NodeContext& m_node;
};

} // namespace
} // namespace coinjoin

namespace interfaces {
std::unique_ptr<CoinJoin::Loader> MakeCoinJoinLoader(CoinJoinWalletManager& walletman) { return std::make_unique<coinjoin::CoinJoinLoaderImpl>(walletman); }
std::unique_ptr<CoinJoin::Loader> MakeCoinJoinLoader(NodeContext& node) { return std::make_unique<coinjoin::CoinJoinLoaderImpl>(node); }
} // namespace interfaces
14 changes: 10 additions & 4 deletions src/dummywallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Chain;
class Handler;
class Wallet;
class WalletClient;
class WalletLoader;
namespace CoinJoin {
class Loader;
} // namespcae CoinJoin
Expand All @@ -28,8 +29,8 @@ class DummyWalletInit : public WalletInitInterface {
void Construct(NodeContext& node) const override {LogPrintf("No wallet support compiled in!\n");}

// Dash Specific WalletInitInterface InitCoinJoinSettings
void AutoLockMasternodeCollaterals() const override {}
void InitCoinJoinSettings(const CoinJoinWalletManager& cjwalletman) const override {}
void AutoLockMasternodeCollaterals(interfaces::WalletLoader& wallet_loader) const override {}
void InitCoinJoinSettings(interfaces::CoinJoin::Loader& coinjoin_loader, interfaces::WalletLoader& wallet_loader) const override {}
bool InitAutoBackup() const override {return true;}
};

Expand Down Expand Up @@ -80,12 +81,17 @@ const WalletInitInterface& g_wallet_init_interface = DummyWalletInit();

namespace interfaces {

std::unique_ptr<Wallet> MakeWallet(const std::shared_ptr<CWallet>& wallet, const CoinJoinWalletManager& cjwalletman)
std::unique_ptr<CoinJoin::Loader> MakeCoinJoinLoader(NodeContext& node)
{
throw std::logic_error("Wallet function called in non-wallet build.");
}

std::unique_ptr<WalletClient> MakeWalletLoader(Chain& chain, const std::unique_ptr<interfaces::CoinJoin::Loader>& coinjoin_loader, ArgsManager& args)
std::unique_ptr<Wallet> MakeWallet(const std::shared_ptr<CWallet>& wallet)
{
throw std::logic_error("Wallet function called in non-wallet build.");
}

std::unique_ptr<WalletClient> MakeWalletLoader(Chain& chain, ArgsManager& args, interfaces::CoinJoin::Loader& coinjoin_loader)
{
throw std::logic_error("Wallet function called in non-wallet build.");
}
Expand Down
10 changes: 5 additions & 5 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2028,11 +2028,6 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
node.mn_activeman.get(), *node.mn_sync, *node.llmq_ctx->isman, node.peerman,
!ignores_incoming_txs);

#ifdef ENABLE_WALLET
node.coinjoin_loader = interfaces::MakeCoinJoinLoader(*node.cj_ctx->walletman);
g_wallet_init_interface.InitCoinJoinSettings(*node.cj_ctx->walletman);
#endif // ENABLE_WALLET

// ********************************************************* Step 7d: Setup other Dash services

bool fLoadCacheFiles = !(fReindex || fReindexChainState) && (chainman.ActiveChain().Tip() != nullptr);
Expand Down Expand Up @@ -2207,6 +2202,11 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
chainman.m_load_block = std::thread(&util::TraceThread, "loadblk", [=, &args, &chainman, &node] {
ThreadImport(chainman, *node.dmnman, *g_ds_notification_interface, vImportFiles, node.mn_activeman.get(), args);
});
#ifdef ENABLE_WALLET
if (!args.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) {
g_wallet_init_interface.AutoLockMasternodeCollaterals(*node.wallet_loader);
}
#endif // ENABLE_WALLET

// Wait for genesis block to be processed
{
Expand Down
10 changes: 8 additions & 2 deletions src/init/bitcoin-node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <interfaces/chain.h>
#include <interfaces/coinjoin.h>
#include <interfaces/echo.h>
#include <interfaces/init.h>
#include <interfaces/ipc.h>
#include <interfaces/node.h>
#include <interfaces/wallet.h>
#include <node/context.h>
#include <util/check.h>
#include <util/system.h>

#include <memory>
Expand All @@ -29,9 +31,13 @@ class BitcoinNodeInit : public interfaces::Init
}
std::unique_ptr<interfaces::Node> makeNode() override { return interfaces::MakeNode(m_node); }
std::unique_ptr<interfaces::Chain> makeChain() override { return interfaces::MakeChain(m_node); }
std::unique_ptr<interfaces::WalletLoader> makeWalletLoader(interfaces::Chain& chain, const std::unique_ptr<interfaces::CoinJoin::Loader>& loader) override
std::unique_ptr<interfaces::CoinJoin::Loader> makeCoinJoinLoader() override
{
return MakeWalletLoader(chain, loader, *Assert(m_node.args));
return interfaces::MakeCoinJoinLoader(m_node);
}
std::unique_ptr<interfaces::WalletLoader> makeWalletLoader(interfaces::Chain& chain, interfaces::CoinJoin::Loader& coinjoin_loader) override
{
return MakeWalletLoader(chain, *Assert(m_node.args), coinjoin_loader);
}
std::unique_ptr<interfaces::Echo> makeEcho() override { return interfaces::MakeEcho(); }
interfaces::Ipc* ipc() override { return m_ipc.get(); }
Expand Down
10 changes: 8 additions & 2 deletions src/init/bitcoind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <interfaces/chain.h>
#include <interfaces/coinjoin.h>
#include <interfaces/echo.h>
#include <interfaces/init.h>
#include <interfaces/node.h>
#include <interfaces/wallet.h>
#include <node/context.h>
#include <util/check.h>
#include <util/system.h>

#include <memory>
Expand All @@ -24,9 +26,13 @@ class BitcoindInit : public interfaces::Init
}
std::unique_ptr<interfaces::Node> makeNode() override { return interfaces::MakeNode(m_node); }
std::unique_ptr<interfaces::Chain> makeChain() override { return interfaces::MakeChain(m_node); }
std::unique_ptr<interfaces::WalletLoader> makeWalletLoader(interfaces::Chain& chain, const std::unique_ptr<interfaces::CoinJoin::Loader>& loader) override
std::unique_ptr<interfaces::CoinJoin::Loader> makeCoinJoinLoader() override
{
return MakeWalletLoader(chain, loader, *Assert(m_node.args));
return interfaces::MakeCoinJoinLoader(m_node);
}
std::unique_ptr<interfaces::WalletLoader> makeWalletLoader(interfaces::Chain& chain, interfaces::CoinJoin::Loader& coinjoin_loader) override
{
return MakeWalletLoader(chain, *Assert(m_node.args), coinjoin_loader);
}
std::unique_ptr<interfaces::Echo> makeEcho() override { return interfaces::MakeEcho(); }
NodeContext& m_node;
Expand Down
10 changes: 7 additions & 3 deletions src/interfaces/coinjoin.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@

#include <memory>
#include <string>
#include <vector>

class CoinJoinWalletManager;
class CWallet;
struct NodeContext;

class UniValue;

namespace interfaces {
namespace CoinJoin {
Expand All @@ -21,6 +24,8 @@ class Client
virtual void resetCachedBlocks() = 0;
virtual void resetPool() = 0;
virtual int getCachedBlocks() = 0;
virtual void getJsonInfo(UniValue& obj) = 0;
virtual std::vector<std::string> getSessionStatuses() = 0;
virtual std::string getSessionDenoms() = 0;
virtual void setCachedBlocks(int nCachedBlocks) = 0;
virtual void disableAutobackups() = 0;
Expand All @@ -38,11 +43,10 @@ class Loader
virtual void RemoveWallet(const std::string&) = 0;
virtual void FlushWallet(const std::string&) = 0;
virtual std::unique_ptr<CoinJoin::Client> GetClient(const std::string&) = 0;
virtual CoinJoinWalletManager& walletman() = 0;
};
} // namespace CoinJoin

std::unique_ptr<CoinJoin::Loader> MakeCoinJoinLoader(CoinJoinWalletManager& walletman);
std::unique_ptr<CoinJoin::Loader> MakeCoinJoinLoader(NodeContext& node);

} // namespace interfaces

Expand Down
4 changes: 3 additions & 1 deletion src/interfaces/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <interfaces/chain.h>
#include <interfaces/coinjoin.h>
#include <interfaces/echo.h>
#include <interfaces/init.h>
#include <interfaces/node.h>
Expand All @@ -11,7 +12,8 @@
namespace interfaces {
std::unique_ptr<Node> Init::makeNode() { return {}; }
std::unique_ptr<Chain> Init::makeChain() { return {}; }
std::unique_ptr<WalletLoader> Init::makeWalletLoader(Chain& chain, const std::unique_ptr<CoinJoin::Loader>&) { return {}; }
std::unique_ptr<CoinJoin::Loader> Init::makeCoinJoinLoader() { return {}; }
std::unique_ptr<WalletLoader> Init::makeWalletLoader(Chain& chain, CoinJoin::Loader& coinjoin_loader) { return {}; }
std::unique_ptr<Echo> Init::makeEcho() { return {}; }
Ipc* Init::ipc() { return nullptr; }
} // namespace interfaces
11 changes: 5 additions & 6 deletions src/interfaces/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ class Echo;
class Ipc;
class Node;
class WalletLoader;

namespace CoinJoin
{
class Loader;
}
namespace CoinJoin {
class Loader;
} // namespace CoinJoin

//! Initial interface created when a process is first started, and used to give
//! and get access to other interfaces (Node, Chain, Wallet, etc).
Expand All @@ -34,7 +32,8 @@ class Init
virtual ~Init() = default;
virtual std::unique_ptr<Node> makeNode();
virtual std::unique_ptr<Chain> makeChain();
virtual std::unique_ptr<interfaces::WalletLoader> makeWalletLoader(interfaces::Chain&, const std::unique_ptr<CoinJoin::Loader>&);
virtual std::unique_ptr<CoinJoin::Loader> makeCoinJoinLoader();
virtual std::unique_ptr<interfaces::WalletLoader> makeWalletLoader(interfaces::Chain&, CoinJoin::Loader&);
virtual std::unique_ptr<Echo> makeEcho();
virtual Ipc* ipc();
};
Expand Down
Loading

0 comments on commit a73024d

Please sign in to comment.