From 71e0d90876efd11e2a4aeb8f3f806c5a1fd54b42 Mon Sep 17 00:00:00 2001 From: Russell Yanofsky Date: Mon, 17 Apr 2017 13:55:43 -0400 Subject: Remove direct bitcoin calls from qt/bitcoin.cpp --- src/interface/node.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/interface/node.h (limited to 'src/interface/node.h') diff --git a/src/interface/node.h b/src/interface/node.h new file mode 100644 index 0000000000..b69ef160a3 --- /dev/null +++ b/src/interface/node.h @@ -0,0 +1,62 @@ +// Copyright (c) 2018 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_INTERFACE_NODE_H +#define BITCOIN_INTERFACE_NODE_H + +#include +#include +#include + +namespace interface { + +class Handler; + +//! Top-level interface for a bitcoin node (bitcoind process). +class Node +{ +public: + virtual ~Node() {} + + //! Set command line arguments. + virtual void parseParameters(int argc, const char* const argv[]) = 0; + + //! Load settings from configuration file. + virtual void readConfigFile(const std::string& conf_path) = 0; + + //! Choose network parameters. + virtual void selectParams(const std::string& network) = 0; + + //! Init logging. + virtual void initLogging() = 0; + + //! Init parameter interaction. + virtual void initParameterInteraction() = 0; + + //! Get warnings. + virtual std::string getWarnings(const std::string& type) = 0; + + //! Initialize app dependencies. + virtual bool baseInitialize() = 0; + + //! Start node. + virtual bool appInitMain() = 0; + + //! Stop node. + virtual void appShutdown() = 0; + + //! Start shutdown. + virtual void startShutdown() = 0; + + //! Register handler for init messages. + using InitMessageFn = std::function; + virtual std::unique_ptr handleInitMessage(InitMessageFn fn) = 0; +}; + +//! Return implementation of Node interface. +std::unique_ptr MakeNode(); + +} // namespace interface + +#endif // BITCOIN_INTERFACE_NODE_H -- cgit v1.2.3 From c0f2756be517feddacd7c6b89b9faa888b3fef8e Mon Sep 17 00:00:00 2001 From: Russell Yanofsky Date: Mon, 17 Apr 2017 14:23:14 -0400 Subject: Remove direct bitcoin calls from qt/optionsmodel.cpp --- src/interface/node.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/interface/node.h') diff --git a/src/interface/node.h b/src/interface/node.h index b69ef160a3..368bade28b 100644 --- a/src/interface/node.h +++ b/src/interface/node.h @@ -5,10 +5,14 @@ #ifndef BITCOIN_INTERFACE_NODE_H #define BITCOIN_INTERFACE_NODE_H +#include // For Network + #include #include #include +class proxyType; + namespace interface { class Handler; @@ -22,6 +26,12 @@ public: //! Set command line arguments. virtual void parseParameters(int argc, const char* const argv[]) = 0; + //! Set a command line argument if it doesn't already have a value + virtual bool softSetArg(const std::string& arg, const std::string& value) = 0; + + //! Set a command line boolean argument if it doesn't already have a value + virtual bool softSetBoolArg(const std::string& arg, bool value) = 0; + //! Load settings from configuration file. virtual void readConfigFile(const std::string& conf_path) = 0; @@ -49,6 +59,12 @@ public: //! Start shutdown. virtual void startShutdown() = 0; + //! Map port. + virtual void mapPort(bool use_upnp) = 0; + + //! Get proxy. + virtual bool getProxy(Network net, proxyType& proxy_info) = 0; + //! Register handler for init messages. using InitMessageFn = std::function; virtual std::unique_ptr handleInitMessage(InitMessageFn fn) = 0; -- cgit v1.2.3 From 3d619e9d3658e36cba4a19a5bed33e5538317b27 Mon Sep 17 00:00:00 2001 From: Russell Yanofsky Date: Mon, 17 Apr 2017 14:33:47 -0400 Subject: Remove direct bitcoin calls from qt/bitcoingui.cpp --- src/interface/node.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/interface/node.h') diff --git a/src/interface/node.h b/src/interface/node.h index 368bade28b..00304cce24 100644 --- a/src/interface/node.h +++ b/src/interface/node.h @@ -59,6 +59,9 @@ public: //! Start shutdown. virtual void startShutdown() = 0; + //! Return whether shutdown was requested. + virtual bool shutdownRequested() = 0; + //! Map port. virtual void mapPort(bool use_upnp) = 0; @@ -68,6 +71,18 @@ public: //! Register handler for init messages. using InitMessageFn = std::function; virtual std::unique_ptr handleInitMessage(InitMessageFn fn) = 0; + + //! Register handler for message box messages. + using MessageBoxFn = + std::function; + virtual std::unique_ptr handleMessageBox(MessageBoxFn fn) = 0; + + //! Register handler for question messages. + using QuestionFn = std::function; + virtual std::unique_ptr handleQuestion(QuestionFn fn) = 0; }; //! Return implementation of Node interface. -- cgit v1.2.3 From c2f672fb1960399389dea9cdd8f76d7156c2c88b Mon Sep 17 00:00:00 2001 From: Russell Yanofsky Date: Mon, 17 Apr 2017 14:40:41 -0400 Subject: Remove direct bitcoin calls from qt/utilitydialog.cpp --- src/interface/node.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/interface/node.h') diff --git a/src/interface/node.h b/src/interface/node.h index 00304cce24..60ef9cce1b 100644 --- a/src/interface/node.h +++ b/src/interface/node.h @@ -5,6 +5,7 @@ #ifndef BITCOIN_INTERFACE_NODE_H #define BITCOIN_INTERFACE_NODE_H +#include // For HelpMessageMode #include // For Network #include @@ -62,6 +63,9 @@ public: //! Return whether shutdown was requested. virtual bool shutdownRequested() = 0; + //! Get help message string. + virtual std::string helpMessage(HelpMessageMode mode) = 0; + //! Map port. virtual void mapPort(bool use_upnp) = 0; -- cgit v1.2.3 From 5fba3af21e44ab7552c57782de430c1f4cfd6697 Mon Sep 17 00:00:00 2001 From: Russell Yanofsky Date: Mon, 17 Apr 2017 15:10:47 -0400 Subject: Remove direct bitcoin calls from qt/splashscreen.cpp --- src/interface/node.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/interface/node.h') diff --git a/src/interface/node.h b/src/interface/node.h index 60ef9cce1b..d1749871bf 100644 --- a/src/interface/node.h +++ b/src/interface/node.h @@ -17,6 +17,7 @@ class proxyType; namespace interface { class Handler; +class Wallet; //! Top-level interface for a bitcoin node (bitcoind process). class Node @@ -87,6 +88,14 @@ public: const std::string& caption, unsigned int style)>; virtual std::unique_ptr handleQuestion(QuestionFn fn) = 0; + + //! Register handler for progress messages. + using ShowProgressFn = std::function; + virtual std::unique_ptr handleShowProgress(ShowProgressFn fn) = 0; + + //! Register handler for load wallet messages. + using LoadWalletFn = std::function wallet)>; + virtual std::unique_ptr handleLoadWallet(LoadWalletFn fn) = 0; }; //! Return implementation of Node interface. -- cgit v1.2.3 From fe6f27e6ea68a139d3a98b30a53706008ef8b132 Mon Sep 17 00:00:00 2001 From: Russell Yanofsky Date: Mon, 17 Apr 2017 15:37:36 -0400 Subject: Remove direct bitcoin calls from qt/clientmodel.cpp --- src/interface/node.h | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) (limited to 'src/interface/node.h') diff --git a/src/interface/node.h b/src/interface/node.h index d1749871bf..5275030ca1 100644 --- a/src/interface/node.h +++ b/src/interface/node.h @@ -6,10 +6,13 @@ #define BITCOIN_INTERFACE_NODE_H #include // For HelpMessageMode +#include // For CConnman::NumConnections #include // For Network #include #include +#include +#include #include class proxyType; @@ -73,6 +76,48 @@ public: //! Get proxy. virtual bool getProxy(Network net, proxyType& proxy_info) = 0; + //! Get number of connections. + virtual size_t getNodeCount(CConnman::NumConnections flags) = 0; + + //! Get total bytes recv. + virtual int64_t getTotalBytesRecv() = 0; + + //! Get total bytes sent. + virtual int64_t getTotalBytesSent() = 0; + + //! Get mempool size. + virtual size_t getMempoolSize() = 0; + + //! Get mempool dynamic usage. + virtual size_t getMempoolDynamicUsage() = 0; + + //! Get header tip height and time. + virtual bool getHeaderTip(int& height, int64_t& block_time) = 0; + + //! Get num blocks. + virtual int getNumBlocks() = 0; + + //! Get last block time. + virtual int64_t getLastBlockTime() = 0; + + //! Get verification progress. + virtual double getVerificationProgress() = 0; + + //! Is initial block download. + virtual bool isInitialBlockDownload() = 0; + + //! Get reindex. + virtual bool getReindex() = 0; + + //! Get importing. + virtual bool getImporting() = 0; + + //! Set network active. + virtual void setNetworkActive(bool active) = 0; + + //! Get network active. + virtual bool getNetworkActive() = 0; + //! Register handler for init messages. using InitMessageFn = std::function; virtual std::unique_ptr handleInitMessage(InitMessageFn fn) = 0; @@ -96,6 +141,32 @@ public: //! Register handler for load wallet messages. using LoadWalletFn = std::function wallet)>; virtual std::unique_ptr handleLoadWallet(LoadWalletFn fn) = 0; + + //! Register handler for number of connections changed messages. + using NotifyNumConnectionsChangedFn = std::function; + virtual std::unique_ptr handleNotifyNumConnectionsChanged(NotifyNumConnectionsChangedFn fn) = 0; + + //! Register handler for network active messages. + using NotifyNetworkActiveChangedFn = std::function; + virtual std::unique_ptr handleNotifyNetworkActiveChanged(NotifyNetworkActiveChangedFn fn) = 0; + + //! Register handler for notify alert messages. + using NotifyAlertChangedFn = std::function; + virtual std::unique_ptr handleNotifyAlertChanged(NotifyAlertChangedFn fn) = 0; + + //! Register handler for ban list messages. + using BannedListChangedFn = std::function; + virtual std::unique_ptr handleBannedListChanged(BannedListChangedFn fn) = 0; + + //! Register handler for block tip messages. + using NotifyBlockTipFn = + std::function; + virtual std::unique_ptr handleNotifyBlockTip(NotifyBlockTipFn fn) = 0; + + //! Register handler for header tip messages. + using NotifyHeaderTipFn = + std::function; + virtual std::unique_ptr handleNotifyHeaderTip(NotifyHeaderTipFn fn) = 0; }; //! Return implementation of Node interface. -- cgit v1.2.3 From e0b66a3b7c5d3a079636d61fcf611bb6b36c7bc1 Mon Sep 17 00:00:00 2001 From: Russell Yanofsky Date: Mon, 17 Apr 2017 15:57:19 -0400 Subject: Remove direct bitcoin calls from qt/peertablemodel.cpp --- src/interface/node.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/interface/node.h') diff --git a/src/interface/node.h b/src/interface/node.h index 5275030ca1..6288487032 100644 --- a/src/interface/node.h +++ b/src/interface/node.h @@ -14,8 +14,12 @@ #include #include #include +#include +#include +class CNodeStats; class proxyType; +struct CNodeStateStats; namespace interface { @@ -79,6 +83,10 @@ public: //! Get number of connections. virtual size_t getNodeCount(CConnman::NumConnections flags) = 0; + //! Get stats for connected nodes. + using NodesStats = std::vector>; + virtual bool getNodesStats(NodesStats& stats) = 0; + //! Get total bytes recv. virtual int64_t getTotalBytesRecv() = 0; -- cgit v1.2.3 From 3034a462a5d30144cf0ec801d07f0c8c36d560f3 Mon Sep 17 00:00:00 2001 From: Russell Yanofsky Date: Mon, 17 Apr 2017 16:02:44 -0400 Subject: Remove direct bitcoin calls from qt/bantablemodel.cpp --- src/interface/node.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/interface/node.h') diff --git a/src/interface/node.h b/src/interface/node.h index 6288487032..880232d9e7 100644 --- a/src/interface/node.h +++ b/src/interface/node.h @@ -5,6 +5,7 @@ #ifndef BITCOIN_INTERFACE_NODE_H #define BITCOIN_INTERFACE_NODE_H +#include // For banmap_t #include // For HelpMessageMode #include // For CConnman::NumConnections #include // For Network @@ -87,6 +88,9 @@ public: using NodesStats = std::vector>; virtual bool getNodesStats(NodesStats& stats) = 0; + //! Get ban map entries. + virtual bool getBanned(banmap_t& banmap) = 0; + //! Get total bytes recv. virtual int64_t getTotalBytesRecv() = 0; -- cgit v1.2.3 From 582daf6d22da5394d02a12003b9542d9f5865ae2 Mon Sep 17 00:00:00 2001 From: Russell Yanofsky Date: Mon, 17 Apr 2017 16:38:51 -0400 Subject: Remove direct bitcoin calls from qt/rpcconsole.cpp --- src/interface/node.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/interface/node.h') diff --git a/src/interface/node.h b/src/interface/node.h index 880232d9e7..aeac1d6215 100644 --- a/src/interface/node.h +++ b/src/interface/node.h @@ -19,6 +19,8 @@ #include class CNodeStats; +class RPCTimerInterface; +class UniValue; class proxyType; struct CNodeStateStats; @@ -91,6 +93,15 @@ public: //! Get ban map entries. virtual bool getBanned(banmap_t& banmap) = 0; + //! Ban node. + virtual bool ban(const CNetAddr& net_addr, BanReason reason, int64_t ban_time_offset) = 0; + + //! Unban node. + virtual bool unban(const CSubNet& ip) = 0; + + //! Disconnect node. + virtual bool disconnect(NodeId id) = 0; + //! Get total bytes recv. virtual int64_t getTotalBytesRecv() = 0; @@ -130,6 +141,18 @@ public: //! Get network active. virtual bool getNetworkActive() = 0; + //! Execute rpc command. + virtual UniValue executeRpc(const std::string& command, const UniValue& params, const std::string& uri) = 0; + + //! List rpc commands. + virtual std::vector listRpcCommands() = 0; + + //! Set RPC timer interface if unset. + virtual void rpcSetTimerInterfaceIfUnset(RPCTimerInterface* iface) = 0; + + //! Unset RPC timer interface. + virtual void rpcUnsetTimerInterface(RPCTimerInterface* iface) = 0; + //! Register handler for init messages. using InitMessageFn = std::function; virtual std::unique_ptr handleInitMessage(InitMessageFn fn) = 0; -- cgit v1.2.3 From a0704a8996bb950ae3c4d5b5a30e9dfe34cde1d3 Mon Sep 17 00:00:00 2001 From: Russell Yanofsky Date: Mon, 17 Apr 2017 18:56:44 -0400 Subject: Remove most direct bitcoin calls from qt/walletmodel.cpp --- src/interface/node.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/interface/node.h') diff --git a/src/interface/node.h b/src/interface/node.h index aeac1d6215..b0d435695e 100644 --- a/src/interface/node.h +++ b/src/interface/node.h @@ -6,6 +6,7 @@ #define BITCOIN_INTERFACE_NODE_H #include // For banmap_t +#include // For CAmount #include // For HelpMessageMode #include // For CConnman::NumConnections #include // For Network @@ -141,6 +142,12 @@ public: //! Get network active. virtual bool getNetworkActive() = 0; + //! Get tx confirm target. + virtual unsigned int getTxConfirmTarget() = 0; + + //! Get max tx fee. + virtual CAmount getMaxTxFee() = 0; + //! Execute rpc command. virtual UniValue executeRpc(const std::string& command, const UniValue& params, const std::string& uri) = 0; @@ -153,6 +160,9 @@ public: //! Unset RPC timer interface. virtual void rpcUnsetTimerInterface(RPCTimerInterface* iface) = 0; + //! Return interfaces for accessing wallets (if any). + virtual std::vector> getWallets() = 0; + //! Register handler for init messages. using InitMessageFn = std::function; virtual std::unique_ptr handleInitMessage(InitMessageFn fn) = 0; -- cgit v1.2.3 From 827de038ab6fa58aa3d46151eb2f8dc6add7743e Mon Sep 17 00:00:00 2001 From: Russell Yanofsky Date: Mon, 17 Apr 2017 19:46:08 -0400 Subject: Remove direct bitcoin calls from qt/coincontroldialog.cpp --- src/interface/node.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/interface/node.h') diff --git a/src/interface/node.h b/src/interface/node.h index b0d435695e..606d1238e0 100644 --- a/src/interface/node.h +++ b/src/interface/node.h @@ -19,10 +19,13 @@ #include #include +class CCoinControl; +class CFeeRate; class CNodeStats; class RPCTimerInterface; class UniValue; class proxyType; +enum class FeeReason; struct CNodeStateStats; namespace interface { @@ -145,9 +148,27 @@ public: //! Get tx confirm target. virtual unsigned int getTxConfirmTarget() = 0; + //! Get required fee. + virtual CAmount getRequiredFee(unsigned int tx_bytes) = 0; + + //! Get minimum fee. + virtual CAmount getMinimumFee(unsigned int tx_bytes, + const CCoinControl& coin_control, + int* returned_target, + FeeReason* reason) = 0; + //! Get max tx fee. virtual CAmount getMaxTxFee() = 0; + //! Estimate smart fee. + virtual CFeeRate estimateSmartFee(int num_blocks, bool conservative, int* returned_target = nullptr) = 0; + + //! Get dust relay fee. + virtual CFeeRate getDustRelayFee() = 0; + + //! Get pay tx fee. + virtual CFeeRate getPayTxFee() = 0; + //! Execute rpc command. virtual UniValue executeRpc(const std::string& command, const UniValue& params, const std::string& uri) = 0; -- cgit v1.2.3 From 3cab2ce5f9e159ad5a2e9ed682f28121b5248580 Mon Sep 17 00:00:00 2001 From: Russell Yanofsky Date: Fri, 23 Mar 2018 17:14:39 -0400 Subject: Remove direct bitcoin calls from qt/paymentserver.cpp --- src/interface/node.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/interface/node.h') diff --git a/src/interface/node.h b/src/interface/node.h index 606d1238e0..a31105f6f8 100644 --- a/src/interface/node.h +++ b/src/interface/node.h @@ -54,6 +54,9 @@ public: //! Choose network parameters. virtual void selectParams(const std::string& network) = 0; + //! Get network name. + virtual std::string getNetwork() = 0; + //! Init logging. virtual void initLogging() = 0; -- cgit v1.2.3 From 58845587e11140e81f087a74c3db76a4d1fc3a1a Mon Sep 17 00:00:00 2001 From: Russell Yanofsky Date: Tue, 18 Apr 2017 16:42:30 -0400 Subject: Remove direct bitcoin calls from qt transaction table files --- src/interface/node.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/interface/node.h') diff --git a/src/interface/node.h b/src/interface/node.h index a31105f6f8..c73f45a1b0 100644 --- a/src/interface/node.h +++ b/src/interface/node.h @@ -22,6 +22,7 @@ class CCoinControl; class CFeeRate; class CNodeStats; +class Coin; class RPCTimerInterface; class UniValue; class proxyType; @@ -66,6 +67,9 @@ public: //! Get warnings. virtual std::string getWarnings(const std::string& type) = 0; + // Get log flags. + virtual uint32_t getLogCategories() = 0; + //! Initialize app dependencies. virtual bool baseInitialize() = 0; @@ -184,6 +188,9 @@ public: //! Unset RPC timer interface. virtual void rpcUnsetTimerInterface(RPCTimerInterface* iface) = 0; + //! Get unspent outputs associated with a transaction. + virtual bool getUnspentOutput(const COutPoint& output, Coin& coin) = 0; + //! Return interfaces for accessing wallets (if any). virtual std::vector> getWallets() = 0; -- cgit v1.2.3 From 56f33ca349b3721a15fce3bf0b6d4fd7fd788970 Mon Sep 17 00:00:00 2001 From: Russell Yanofsky Date: Thu, 20 Apr 2017 12:28:58 -0400 Subject: Remove direct bitcoin calls from qt/sendcoinsdialog.cpp --- src/interface/node.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/interface/node.h') diff --git a/src/interface/node.h b/src/interface/node.h index c73f45a1b0..6ae7f9e46c 100644 --- a/src/interface/node.h +++ b/src/interface/node.h @@ -173,9 +173,15 @@ public: //! Get dust relay fee. virtual CFeeRate getDustRelayFee() = 0; + //! Get fallback fee. + virtual CFeeRate getFallbackFee() = 0; + //! Get pay tx fee. virtual CFeeRate getPayTxFee() = 0; + //! Set pay tx fee. + virtual void setPayTxFee(CFeeRate rate) = 0; + //! Execute rpc command. virtual UniValue executeRpc(const std::string& command, const UniValue& params, const std::string& uri) = 0; -- cgit v1.2.3