mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-05-18 07:50:38 +02:00
Merge #17999: refactor: Add ChainClient setMockTime, getWallets methods
3ce16ad2f91d1e2edc7e7bdc5a19f72aa8c3e739 refactor: Use psbt forward declaration (Russell Yanofsky) 1dde238f2c21a0cc9bada10a2449cf9c6b2178ad Add ChainClient setMockTime, getWallets methods (Russell Yanofsky) Pull request description: This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/projects/10). These changes are needed to set mock times, and get wallet interface pointers correctly when wallet code is running in a different process from node code in #10102 ACKs for top commit: MarcoFalke: re-ACK 3ce16ad2f91d1e2edc7e7bdc5a19f72aa8c3e739 🔙 promag: Code review ACK 3ce16ad2f91d1e2edc7e7bdc5a19f72aa8c3e739. Tree-SHA512: 6c093bfcd68adf5858a1aade4361cdb7fb015496673504ac7a93d0bd2595215047184551d6fd526baa27782331cd2819ce45c4cf923b205ce93ac29e485b5dd8
This commit is contained in:
commit
99d6a5be8b
@ -283,6 +283,12 @@ public:
|
|||||||
|
|
||||||
//! Shut down client.
|
//! Shut down client.
|
||||||
virtual void stop() = 0;
|
virtual void stop() = 0;
|
||||||
|
|
||||||
|
//! Set mock time.
|
||||||
|
virtual void setMockTime(int64_t time) = 0;
|
||||||
|
|
||||||
|
//! Return interfaces for accessing wallets (if any).
|
||||||
|
virtual std::vector<std::unique_ptr<Wallet>> getWallets() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Return implementation of Chain interface.
|
//! Return implementation of Chain interface.
|
||||||
|
@ -253,8 +253,9 @@ public:
|
|||||||
std::vector<std::unique_ptr<Wallet>> getWallets() override
|
std::vector<std::unique_ptr<Wallet>> getWallets() override
|
||||||
{
|
{
|
||||||
std::vector<std::unique_ptr<Wallet>> wallets;
|
std::vector<std::unique_ptr<Wallet>> wallets;
|
||||||
for (const std::shared_ptr<CWallet>& wallet : GetWallets()) {
|
for (auto& client : m_context.chain_clients) {
|
||||||
wallets.emplace_back(MakeWallet(wallet));
|
auto client_wallets = client->getWallets();
|
||||||
|
std::move(client_wallets.begin(), client_wallets.end(), std::back_inserter(wallets));
|
||||||
}
|
}
|
||||||
return wallets;
|
return wallets;
|
||||||
}
|
}
|
||||||
|
@ -519,6 +519,15 @@ public:
|
|||||||
void start(CScheduler& scheduler) override { return StartWallets(scheduler); }
|
void start(CScheduler& scheduler) override { return StartWallets(scheduler); }
|
||||||
void flush() override { return FlushWallets(); }
|
void flush() override { return FlushWallets(); }
|
||||||
void stop() override { return StopWallets(); }
|
void stop() override { return StopWallets(); }
|
||||||
|
void setMockTime(int64_t time) override { return SetMockTime(time); }
|
||||||
|
std::vector<std::unique_ptr<Wallet>> getWallets() override
|
||||||
|
{
|
||||||
|
std::vector<std::unique_ptr<Wallet>> wallets;
|
||||||
|
for (const auto& wallet : GetWallets()) {
|
||||||
|
wallets.emplace_back(MakeWallet(wallet));
|
||||||
|
}
|
||||||
|
return wallets;
|
||||||
|
}
|
||||||
~WalletClientImpl() override { UnloadWallets(); }
|
~WalletClientImpl() override { UnloadWallets(); }
|
||||||
|
|
||||||
Chain& m_chain;
|
Chain& m_chain;
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <psbt.h>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
@ -26,12 +25,13 @@ class CCoinControl;
|
|||||||
class CFeeRate;
|
class CFeeRate;
|
||||||
class CKey;
|
class CKey;
|
||||||
class CWallet;
|
class CWallet;
|
||||||
enum isminetype : unsigned int;
|
|
||||||
enum class FeeReason;
|
enum class FeeReason;
|
||||||
typedef uint8_t isminefilter;
|
|
||||||
|
|
||||||
enum class OutputType;
|
enum class OutputType;
|
||||||
|
enum class TransactionError;
|
||||||
|
enum isminetype : unsigned int;
|
||||||
struct CRecipient;
|
struct CRecipient;
|
||||||
|
struct PartiallySignedTransaction;
|
||||||
|
typedef uint8_t isminefilter;
|
||||||
|
|
||||||
namespace interfaces {
|
namespace interfaces {
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include <interfaces/handler.h>
|
#include <interfaces/handler.h>
|
||||||
#include <interfaces/node.h>
|
#include <interfaces/node.h>
|
||||||
#include <key_io.h>
|
#include <key_io.h>
|
||||||
|
#include <psbt.h>
|
||||||
#include <ui_interface.h>
|
#include <ui_interface.h>
|
||||||
#include <util/system.h> // for GetBoolArg
|
#include <util/system.h> // for GetBoolArg
|
||||||
#include <wallet/coincontrol.h>
|
#include <wallet/coincontrol.h>
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
#include <httpserver.h>
|
#include <httpserver.h>
|
||||||
|
#include <interfaces/chain.h>
|
||||||
#include <key_io.h>
|
#include <key_io.h>
|
||||||
#include <node/context.h>
|
#include <node/context.h>
|
||||||
#include <outputtype.h>
|
#include <outputtype.h>
|
||||||
@ -363,7 +364,13 @@ static UniValue setmocktime(const JSONRPCRequest& request)
|
|||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
|
||||||
RPCTypeCheck(request.params, {UniValue::VNUM});
|
RPCTypeCheck(request.params, {UniValue::VNUM});
|
||||||
SetMockTime(request.params[0].get_int64());
|
int64_t time = request.params[0].get_int64();
|
||||||
|
SetMockTime(time);
|
||||||
|
if (g_rpc_node) {
|
||||||
|
for (const auto& chain_client : g_rpc_node->chain_clients) {
|
||||||
|
chain_client->setMockTime(time);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return NullUniValue;
|
return NullUniValue;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user