aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoss Nicoll <[email protected]>2021-06-12 16:35:29 +0100
committerGitHub <[email protected]>2021-06-12 16:35:29 +0100
commitefaf5335fde55daae6d5e789e6fb2b1defebf2e7 (patch)
treec7b34b633eab188030e7c679e1b6b595ddf75023
parentMerge pull request #2248 from rnicoll/1.21-count-type (diff)
parentRemove separate node and wallet contexts (diff)
downloaddiscoin-efaf5335fde55daae6d5e789e6fb2b1defebf2e7.tar.xz
discoin-efaf5335fde55daae6d5e789e6fb2b1defebf2e7.zip
Merge pull request #2259 from rnicoll/1.21-node-context
Add node context to wallet RPC request object
-rw-r--r--src/interfaces/wallet.cpp8
-rw-r--r--src/interfaces/wallet.h2
-rw-r--r--src/wallet/context.h5
-rw-r--r--src/wallet/init.cpp2
-rw-r--r--src/wallet/test/init_test_fixture.cpp2
-rw-r--r--src/wallet/test/wallet_test_fixture.h2
6 files changed, 14 insertions, 7 deletions
diff --git a/src/interfaces/wallet.cpp b/src/interfaces/wallet.cpp
index f68016b55..4124bc786 100644
--- a/src/interfaces/wallet.cpp
+++ b/src/interfaces/wallet.cpp
@@ -7,6 +7,7 @@
#include <amount.h>
#include <interfaces/chain.h>
#include <interfaces/handler.h>
+#include <node/context.h>
#include <policy/fees.h>
#include <primitives/transaction.h>
#include <rpc/server.h>
@@ -489,8 +490,9 @@ public:
class WalletClientImpl : public WalletClient
{
public:
- WalletClientImpl(Chain& chain, ArgsManager& args)
+ WalletClientImpl(NodeContext& node, Chain& chain, ArgsManager& args)
{
+ m_context.nodeContext = &node;
m_context.chain = &chain;
m_context.args = &args;
}
@@ -566,9 +568,9 @@ public:
std::unique_ptr<Wallet> MakeWallet(const std::shared_ptr<CWallet>& wallet) { return wallet ? MakeUnique<WalletImpl>(wallet) : nullptr; }
-std::unique_ptr<WalletClient> MakeWalletClient(Chain& chain, ArgsManager& args)
+std::unique_ptr<WalletClient> MakeWalletClient(NodeContext& node, ArgsManager& args)
{
- return MakeUnique<WalletClientImpl>(chain, args);
+ return MakeUnique<WalletClientImpl>(node, *node.chain, args);
}
} // namespace interfaces
diff --git a/src/interfaces/wallet.h b/src/interfaces/wallet.h
index 6ccfd7fc2..5f93b8264 100644
--- a/src/interfaces/wallet.h
+++ b/src/interfaces/wallet.h
@@ -411,7 +411,7 @@ std::unique_ptr<Wallet> MakeWallet(const std::shared_ptr<CWallet>& wallet);
//! Return implementation of ChainClient interface for a wallet client. This
//! function will be undefined in builds where ENABLE_WALLET is false.
-std::unique_ptr<WalletClient> MakeWalletClient(Chain& chain, ArgsManager& args);
+std::unique_ptr<WalletClient> MakeWalletClient(NodeContext& node, ArgsManager& args);
} // namespace interfaces
diff --git a/src/wallet/context.h b/src/wallet/context.h
index a83591154..8e96c8933 100644
--- a/src/wallet/context.h
+++ b/src/wallet/context.h
@@ -5,6 +5,8 @@
#ifndef BITCOIN_WALLET_CONTEXT_H
#define BITCOIN_WALLET_CONTEXT_H
+#include <node/context.h>
+
class ArgsManager;
namespace interfaces {
class Chain;
@@ -24,6 +26,9 @@ struct WalletContext {
interfaces::Chain* chain{nullptr};
ArgsManager* args{nullptr};
+ //! Dogecoin: getauxwork is a wallet RPC but actually needs the NodeContext.
+ NodeContext* nodeContext{nullptr};
+
//! Declare default constructor and destructor that are not inline, so code
//! instantiating the WalletContext struct doesn't need to #include class
//! definitions for smart pointer and container members.
diff --git a/src/wallet/init.cpp b/src/wallet/init.cpp
index 8b2ef191f..8078b8b43 100644
--- a/src/wallet/init.cpp
+++ b/src/wallet/init.cpp
@@ -107,7 +107,7 @@ void WalletInit::Construct(NodeContext& node) const
LogPrintf("Wallet disabled!\n");
return;
}
- auto wallet_client = interfaces::MakeWalletClient(*node.chain, args);
+ auto wallet_client = interfaces::MakeWalletClient(node, args);
node.wallet_client = wallet_client.get();
node.chain_clients.emplace_back(std::move(wallet_client));
}
diff --git a/src/wallet/test/init_test_fixture.cpp b/src/wallet/test/init_test_fixture.cpp
index c80310045..155cd9ce6 100644
--- a/src/wallet/test/init_test_fixture.cpp
+++ b/src/wallet/test/init_test_fixture.cpp
@@ -10,7 +10,7 @@
InitWalletDirTestingSetup::InitWalletDirTestingSetup(const std::string& chainName) : BasicTestingSetup(chainName)
{
- m_wallet_client = MakeWalletClient(*m_chain, *Assert(m_node.args));
+ m_wallet_client = interfaces::MakeWalletClient(m_node, *Assert(m_node.args));
std::string sep;
sep += fs::path::preferred_separator;
diff --git a/src/wallet/test/wallet_test_fixture.h b/src/wallet/test/wallet_test_fixture.h
index ba8a5ff1f..2ce616be0 100644
--- a/src/wallet/test/wallet_test_fixture.h
+++ b/src/wallet/test/wallet_test_fixture.h
@@ -21,7 +21,7 @@ struct WalletTestingSetup : public TestingSetup {
explicit WalletTestingSetup(const std::string& chainName = CBaseChainParams::MAIN);
std::unique_ptr<interfaces::Chain> m_chain = interfaces::MakeChain(m_node);
- std::unique_ptr<interfaces::WalletClient> m_wallet_client = interfaces::MakeWalletClient(*m_chain, *Assert(m_node.args));
+ std::unique_ptr<interfaces::WalletClient> m_wallet_client = interfaces::MakeWalletClient(m_node, *Assert(m_node.args));
CWallet m_wallet;
std::unique_ptr<interfaces::Handler> m_chain_notifications_handler;
};