9
9
#include < interfaces/handler.h>
10
10
#include < policy/fees.h>
11
11
#include < primitives/transaction.h>
12
+ #include < rpc/server.h>
12
13
#include < script/standard.h>
13
14
#include < support/allocators/secure.h>
14
15
#include < sync.h>
15
16
#include < ui_interface.h>
16
17
#include < uint256.h>
17
18
#include < util/check.h>
19
+ #include < util/ref.h>
18
20
#include < util/system.h>
21
+ #include < wallet/context.h>
19
22
#include < wallet/feebumper.h>
20
23
#include < wallet/fees.h>
21
24
#include < wallet/ismine.h>
@@ -783,17 +786,27 @@ class WalletClientImpl : public ChainClient
783
786
{
784
787
public:
785
788
WalletClientImpl (Chain& chain, std::vector<std::string> wallet_filenames)
786
- : m_chain(chain), m_wallet_filenames(std::move(wallet_filenames))
789
+ : m_wallet_filenames(std::move(wallet_filenames))
787
790
{
791
+ m_context.chain = &chain;
788
792
}
789
793
void registerRpcs () override
790
794
{
791
- g_rpc_chain = &m_chain;
792
- RegisterHDWalletRPCCommands (m_chain, m_rpc_handlers);
793
- return RegisterWalletRPCCommands (m_chain, m_rpc_handlers);
795
+ for (const CRPCCommand& command : GetHDWalletRPCCommands ()) {
796
+ m_rpc_commands.emplace_back (command.category , command.name , [this , &command](const JSONRPCRequest& request, UniValue& result, bool last_handler) {
797
+ return command.actor ({request, m_context}, result, last_handler);
798
+ }, command.argNames , command.unique_id );
799
+ m_rpc_handlers.emplace_back (m_context.chain ->handleRpc (m_rpc_commands.back ()));
800
+ }
801
+ for (const CRPCCommand& command : GetWalletRPCCommands ()) {
802
+ m_rpc_commands.emplace_back (command.category , command.name , [this , &command](const JSONRPCRequest& request, UniValue& result, bool last_handler) {
803
+ return command.actor ({request, m_context}, result, last_handler);
804
+ }, command.argNames , command.unique_id );
805
+ m_rpc_handlers.emplace_back (m_context.chain ->handleRpc (m_rpc_commands.back ()));
806
+ }
794
807
}
795
- bool verify () override { return VerifyWallets (m_chain , m_wallet_filenames); }
796
- bool load () override { return LoadWallets (m_chain , m_wallet_filenames); }
808
+ bool verify () override { return VerifyWallets (*m_context. chain , m_wallet_filenames); }
809
+ bool load () override { return LoadWallets (*m_context. chain , m_wallet_filenames); }
797
810
void start (CScheduler& scheduler) override { return StartWallets (scheduler); }
798
811
void flush () override { return FlushWallets (); }
799
812
void stop () override { return StopWallets (); }
@@ -808,9 +821,10 @@ class WalletClientImpl : public ChainClient
808
821
}
809
822
~WalletClientImpl () override { UnloadWallets (); }
810
823
811
- Chain& m_chain ;
824
+ WalletContext m_context ;
812
825
std::vector<std::string> m_wallet_filenames;
813
826
std::vector<std::unique_ptr<Handler>> m_rpc_handlers;
827
+ std::list<CRPCCommand> m_rpc_commands;
814
828
};
815
829
816
830
} // namespace
0 commit comments