Skip to content

Commit

Permalink
[backport#15288] Remove uses of g_connman in wallet code
Browse files Browse the repository at this point in the history
Summary:
00dfb2a440b94a24b61cafb519fb122f6a0ae176 This commit does not change behavior. (Russell Yanofsky)

---

Depends on D5839

This is a partial backport of Core [[bitcoin/bitcoin#15288 | PR15288]]

Test Plan:
  ../configure --enable-deprecated-build-system --enable-werror --enable-debug --disable-wallet
  make check-recursive
  ../configure --enable-deprecated-build-system --enable-werror --enable-debug
  make check-recursive
  cmake .. -GNinja -DENABLE_WERROR=ON -DCMAKE_BUILD_TYPE=Debug -DBUILD_BITCOIN_WALLET=OFF
  ninja check-all
  cmake .. -GNinja -DENABLE_WERROR=ON -DCMAKE_BUILD_TYPE=Debug
  ninja check-all

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Subscribers: deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D5840
  • Loading branch information
ryanofsky authored and majcosta committed Apr 27, 2020
1 parent 622fa9f commit ce4499d
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -649,16 +649,20 @@ bitcoin_wallet_LDADD = \
$(LIBBITCOIN_WALLET_TOOL) \
$(LIBBITCOIN_WALLET) \
$(LIBBITCOIN_SERVER) \
$(LIBBITCOIN_WALLET) \
$(LIBBITCOIN_SERVER) \
$(LIBBITCOIN_COMMON) \
$(LIBBITCOIN_CONSENSUS) \
$(LIBBITCOIN_UTIL) \
$(LIBBITCOIN_CRYPTO) \
$(LIBBITCOIN_ZMQ) \
$(LIBLEVELDB) \
$(LIBLEVELDB_SSE42) \
$(LIBMEMENV) \
$(LIBSECP256K1)
$(LIBSECP256K1) \
$(LIBUNIVALUE)

bitcoin_wallet_LDADD += $(BOOST_LIBS) $(BDB_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS)
bitcoin_wallet_LDADD += $(BOOST_LIBS) $(BDB_LIBS) $(CRYPTO_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(MINIUPNPC_LIBS) $(ZMQ_LIBS)
#

# bitcoinconsensus library #
Expand Down
2 changes: 2 additions & 0 deletions src/Makefile.bench.include
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ nodist_bench_bench_bitcoin_SOURCES = $(GENERATED_BENCH_FILES)
bench_bench_bitcoin_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CLFAGS) $(EVENT_PTHREADS_CFLAGS) -I$(builddir)/bench/
bench_bench_bitcoin_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
bench_bench_bitcoin_LDADD = \
$(LIBBITCOIN_SERVER) \
$(LIBBITCOIN_WALLET) \
$(LIBBITCOIN_SERVER) \
$(LIBBITCOIN_WALLET) \
$(LIBBITCOIN_SERVER) \
Expand Down
2 changes: 2 additions & 0 deletions src/interfaces/chain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <chain.h>
#include <chainparams.h>
#include <net.h>
#include <policy/mempool.h>
#include <primitives/block.h>
#include <primitives/blockhash.h>
Expand Down Expand Up @@ -223,6 +224,7 @@ namespace {
unused_error_string);
}
bool getPruneMode() override { return ::fPruneMode; }
bool p2pEnabled() override { return g_connman != nullptr; }
};

} // namespace
Expand Down
3 changes: 3 additions & 0 deletions src/interfaces/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ class Chain {

//! Check if pruning is enabled.
virtual bool getPruneMode() = 0;

//! Check if p2p enabled.
virtual bool p2pEnabled() = 0;
};

//! Interface to let node manage chain clients (wallets, or maybe tools for
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ add_library(wallet
walletutil.cpp
)

target_link_libraries(wallet script univalue Event::event BerkeleyDB::CXX)
target_link_libraries(wallet zmq server script univalue Event::event BerkeleyDB::CXX)

# wallet-tool library
add_library(wallet-tool wallettool.cpp)
Expand Down
6 changes: 3 additions & 3 deletions src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ static CTransactionRef SendMoney(interfaces::Chain::Lock &locked_chain,
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Insufficient funds");
}

if (pwallet->GetBroadcastTransactions() && !g_connman) {
if (pwallet->GetBroadcastTransactions() && !pwallet->chain().p2pEnabled()) {
throw JSONRPCError(
RPC_CLIENT_P2P_DISABLED,
"Error: Peer-to-peer functionality missing or disabled");
Expand Down Expand Up @@ -1043,7 +1043,7 @@ static UniValue sendmany(const Config &config, const JSONRPCRequest &request) {
auto locked_chain = pwallet->chain().lock();
LOCK(pwallet->cs_wallet);

if (pwallet->GetBroadcastTransactions() && !g_connman) {
if (pwallet->GetBroadcastTransactions() && !pwallet->chain().p2pEnabled()) {
throw JSONRPCError(
RPC_CLIENT_P2P_DISABLED,
"Error: Peer-to-peer functionality missing or disabled");
Expand Down Expand Up @@ -3294,7 +3294,7 @@ static UniValue resendwallettransactions(const Config &config,
"Returns array of transaction ids that were re-broadcast.\n");
}

if (!g_connman) {
if (!pwallet->chain().p2pEnabled()) {
throw JSONRPCError(
RPC_CLIENT_P2P_DISABLED,
"Error: Peer-to-peer functionality missing or disabled");
Expand Down

0 comments on commit ce4499d

Please sign in to comment.