Skip to content

Commit

Permalink
Merge pull request #4958 from chimp1984/disable-tx-broadcast-if-conne…
Browse files Browse the repository at this point in the history
…cted-to-local-node

Do not use tx broadcast to mempool nodes if a local btc nodes is used
  • Loading branch information
sqrrm committed Dec 16, 2020
2 parents f61e62c + 59cfb2d commit 2532816
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/bisq/core/app/BisqSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public BisqSetup(DomainInitialisation domainInitialisation,
this.localBitcoinNode = localBitcoinNode;
this.appStartupState = appStartupState;

MemPoolSpaceTxBroadcaster.init(socks5ProxyProvider, preferences);
MemPoolSpaceTxBroadcaster.init(socks5ProxyProvider, preferences, localBitcoinNode);
}

///////////////////////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package bisq.core.btc.wallet.http;

import bisq.core.btc.nodes.LocalBitcoinNode;
import bisq.core.user.Preferences;

import bisq.network.Socks5ProxyProvider;
Expand Down Expand Up @@ -50,13 +51,16 @@
public class MemPoolSpaceTxBroadcaster {
private static Socks5ProxyProvider socks5ProxyProvider;
private static Preferences preferences;
private static LocalBitcoinNode localBitcoinNode;
private static final ListeningExecutorService executorService = Utilities.getListeningExecutorService(
"MemPoolSpaceTxBroadcaster", 3, 5, 10 * 60);

public static void init(Socks5ProxyProvider socks5ProxyProvider,
Preferences preferences) {
Preferences preferences,
LocalBitcoinNode localBitcoinNode) {
MemPoolSpaceTxBroadcaster.socks5ProxyProvider = socks5ProxyProvider;
MemPoolSpaceTxBroadcaster.preferences = preferences;
MemPoolSpaceTxBroadcaster.localBitcoinNode = localBitcoinNode;
}

public static void broadcastTx(Transaction tx) {
Expand All @@ -65,6 +69,12 @@ public static void broadcastTx(Transaction tx) {
return;
}

if (localBitcoinNode.shouldBeUsed()) {
log.info("A localBitcoinNode is detected and used. For privacy reasons we do not use the tx " +
"broadcast to mempool nodes in that case.");
return;
}

if (socks5ProxyProvider == null) {
log.warn("We got broadcastTx called before init was called.");
return;
Expand Down

0 comments on commit 2532816

Please sign in to comment.