Skip to content

Commit 00dfb2a

Browse files
committed
Remove uses of g_connman in wallet code
This commit does not change behavior.
1 parent cc3836e commit 00dfb2a

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

src/Makefile.am

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,16 +562,20 @@ bitcoin_wallet_LDADD = \
562562
$(LIBBITCOIN_WALLET_TOOL) \
563563
$(LIBBITCOIN_WALLET) \
564564
$(LIBBITCOIN_SERVER) \
565+
$(LIBBITCOIN_WALLET) \
566+
$(LIBBITCOIN_SERVER) \
565567
$(LIBBITCOIN_COMMON) \
566568
$(LIBBITCOIN_CONSENSUS) \
567569
$(LIBBITCOIN_UTIL) \
568570
$(LIBBITCOIN_CRYPTO) \
571+
$(LIBBITCOIN_ZMQ) \
569572
$(LIBLEVELDB) \
570573
$(LIBLEVELDB_SSE42) \
571574
$(LIBMEMENV) \
572-
$(LIBSECP256K1)
575+
$(LIBSECP256K1) \
576+
$(LIBUNIVALUE)
573577

574-
bitcoin_wallet_LDADD += $(BOOST_LIBS) $(BDB_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS)
578+
bitcoin_wallet_LDADD += $(BOOST_LIBS) $(BDB_LIBS) $(CRYPTO_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(MINIUPNPC_LIBS) $(ZMQ_LIBS)
575579
#
576580

577581
# bitcoinconsensus library #

src/Makefile.bench.include

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ nodist_bench_bench_bitcoin_SOURCES = $(GENERATED_BENCH_FILES)
3737
bench_bench_bitcoin_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CLFAGS) $(EVENT_PTHREADS_CFLAGS) -I$(builddir)/bench/
3838
bench_bench_bitcoin_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
3939
bench_bench_bitcoin_LDADD = \
40+
$(LIBBITCOIN_WALLET) \
41+
$(LIBBITCOIN_SERVER) \
4042
$(LIBBITCOIN_WALLET) \
4143
$(LIBBITCOIN_SERVER) \
4244
$(LIBBITCOIN_COMMON) \
@@ -57,7 +59,7 @@ if ENABLE_WALLET
5759
bench_bench_bitcoin_SOURCES += bench/coin_selection.cpp
5860
endif
5961

60-
bench_bench_bitcoin_LDADD += $(BOOST_LIBS) $(BDB_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS)
62+
bench_bench_bitcoin_LDADD += $(BOOST_LIBS) $(BDB_LIBS) $(CRYPTO_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(MINIUPNPC_LIBS)
6163
bench_bench_bitcoin_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
6264

6365
CLEAN_BITCOIN_BENCH = bench/*.gcda bench/*.gcno $(GENERATED_BENCH_FILES)

src/interfaces/chain.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <chain.h>
88
#include <chainparams.h>
9+
#include <net.h>
910
#include <policy/fees.h>
1011
#include <policy/policy.h>
1112
#include <policy/rbf.h>
@@ -229,6 +230,7 @@ class ChainImpl : public Chain
229230
return ::mempool.GetMinFee(gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000);
230231
}
231232
bool getPruneMode() override { return ::fPruneMode; }
233+
bool p2pEnabled() override { return g_connman != nullptr; }
232234
};
233235

234236
} // namespace

src/interfaces/chain.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ class Chain
158158

159159
//! Check if pruning is enabled.
160160
virtual bool getPruneMode() = 0;
161+
162+
//! Check if p2p enabled.
163+
virtual bool p2pEnabled() = 0;
161164
};
162165

163166
//! Interface to let node manage chain clients (wallets, or maybe tools for

src/wallet/rpcwallet.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ static CTransactionRef SendMoney(interfaces::Chain::Lock& locked_chain, CWallet
318318
if (nValue > curBalance)
319319
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Insufficient funds");
320320

321-
if (pwallet->GetBroadcastTransactions() && !g_connman) {
321+
if (pwallet->GetBroadcastTransactions() && !pwallet->chain().p2pEnabled()) {
322322
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
323323
}
324324

@@ -858,7 +858,7 @@ static UniValue sendmany(const JSONRPCRequest& request)
858858
auto locked_chain = pwallet->chain().lock();
859859
LOCK(pwallet->cs_wallet);
860860

861-
if (pwallet->GetBroadcastTransactions() && !g_connman) {
861+
if (pwallet->GetBroadcastTransactions() && !pwallet->chain().p2pEnabled()) {
862862
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
863863
}
864864

@@ -2690,7 +2690,7 @@ static UniValue resendwallettransactions(const JSONRPCRequest& request)
26902690
}.ToString()
26912691
);
26922692

2693-
if (!g_connman)
2693+
if (!pwallet->chain().p2pEnabled())
26942694
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
26952695

26962696
auto locked_chain = pwallet->chain().lock();

0 commit comments

Comments
 (0)