Skip to content

Commit

Permalink
Merge pull request #4736 from jmacxx/add_autoconf_service_filter
Browse files Browse the repository at this point in the history
Admin filter for auto-confirmation service addresses
  • Loading branch information
ripcurlx authored Nov 2, 2020
2 parents 89620a0 + 15b8e72 commit 9ab6545
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 10 deletions.
24 changes: 17 additions & 7 deletions core/src/main/java/bisq/core/filter/Filter.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
private final List<String> bannedOfferIds;
private final List<String> bannedNodeAddress;
private final List<String> bannedAutoConfExplorers;
private final List<PaymentAccountFilter> bannedPaymentAccounts;
private final List<String> bannedCurrencies;
private final List<String> bannedPaymentMethods;
Expand Down Expand Up @@ -115,7 +116,8 @@ static Filter cloneWithSig(Filter filter, String signatureAsBase64) {
signatureAsBase64,
filter.getSignerPubKeyAsHex(),
filter.getBannedPrivilegedDevPubKeys(),
filter.isDisableAutoConf());
filter.isDisableAutoConf(),
filter.getBannedAutoConfExplorers());
}

// Used for signature verification as we created the sig without the signatureAsBase64 field we set it to null again
Expand Down Expand Up @@ -143,7 +145,8 @@ static Filter cloneWithoutSig(Filter filter) {
null,
filter.getSignerPubKeyAsHex(),
filter.getBannedPrivilegedDevPubKeys(),
filter.isDisableAutoConf());
filter.isDisableAutoConf(),
filter.getBannedAutoConfExplorers());
}

public Filter(List<String> bannedOfferIds,
Expand All @@ -166,7 +169,8 @@ public Filter(List<String> bannedOfferIds,
PublicKey ownerPubKey,
String signerPubKeyAsHex,
List<String> bannedPrivilegedDevPubKeys,
boolean disableAutoConf) {
boolean disableAutoConf,
List<String> bannedAutoConfExplorers) {
this(bannedOfferIds,
bannedNodeAddress,
bannedPaymentAccounts,
Expand All @@ -190,7 +194,8 @@ public Filter(List<String> bannedOfferIds,
null,
signerPubKeyAsHex,
bannedPrivilegedDevPubKeys,
disableAutoConf);
disableAutoConf,
bannedAutoConfExplorers);
}


Expand Down Expand Up @@ -222,7 +227,8 @@ public Filter(List<String> bannedOfferIds,
@Nullable String signatureAsBase64,
String signerPubKeyAsHex,
List<String> bannedPrivilegedDevPubKeys,
boolean disableAutoConf) {
boolean disableAutoConf,
List<String> bannedAutoConfExplorers) {
this.bannedOfferIds = bannedOfferIds;
this.bannedNodeAddress = bannedNodeAddress;
this.bannedPaymentAccounts = bannedPaymentAccounts;
Expand All @@ -247,6 +253,7 @@ public Filter(List<String> bannedOfferIds,
this.signerPubKeyAsHex = signerPubKeyAsHex;
this.bannedPrivilegedDevPubKeys = bannedPrivilegedDevPubKeys;
this.disableAutoConf = disableAutoConf;
this.bannedAutoConfExplorers = bannedAutoConfExplorers;

// ownerPubKeyBytes can be null when called from tests
if (ownerPubKeyBytes != null) {
Expand Down Expand Up @@ -283,7 +290,8 @@ public protobuf.StoragePayload toProtoMessage() {
.setSignerPubKeyAsHex(signerPubKeyAsHex)
.setCreationDate(creationDate)
.addAllBannedPrivilegedDevPubKeys(bannedPrivilegedDevPubKeys)
.setDisableAutoConf(disableAutoConf);
.setDisableAutoConf(disableAutoConf)
.addAllBannedAutoConfExplorers(bannedAutoConfExplorers);

Optional.ofNullable(signatureAsBase64).ifPresent(builder::setSignatureAsBase64);
Optional.ofNullable(extraDataMap).ifPresent(builder::putAllExtraData);
Expand Down Expand Up @@ -320,7 +328,8 @@ public static Filter fromProto(protobuf.Filter proto) {
proto.getSignatureAsBase64(),
proto.getSignerPubKeyAsHex(),
ProtoUtil.protocolStringListToList(proto.getBannedPrivilegedDevPubKeysList()),
proto.getDisableAutoConf()
proto.getDisableAutoConf(),
ProtoUtil.protocolStringListToList(proto.getBannedAutoConfExplorersList())
);
}

Expand Down Expand Up @@ -361,6 +370,7 @@ public String toString() {
",\n creationDate=" + creationDate +
",\n extraDataMap=" + extraDataMap +
",\n disableAutoConf=" + disableAutoConf +
",\n bannedAutoConfExplorers=" + bannedAutoConfExplorers +
"\n}";
}
}
6 changes: 6 additions & 0 deletions core/src/main/java/bisq/core/filter/FilterManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,12 @@ public boolean isNodeAddressBanned(NodeAddress nodeAddress) {
.anyMatch(e -> e.equals(nodeAddress.getFullAddress()));
}

public boolean isAutoConfExplorerBanned(String address) {
return getFilter() != null &&
getFilter().getBannedAutoConfExplorers().stream()
.anyMatch(e -> e.equals(address));
}

public boolean requireUpdateToNewVersionForTrading() {
if (getFilter() == null) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package bisq.core.trade.txproof.xmr;

import bisq.core.filter.FilterManager;
import bisq.core.locale.Res;
import bisq.core.support.dispute.Dispute;
import bisq.core.support.dispute.mediation.MediationManager;
Expand Down Expand Up @@ -54,6 +55,7 @@ class XmrTxProofRequestsPerTrade implements AssetTxProofRequestsPerTrade {
private final Trade trade;
private final AutoConfirmSettings autoConfirmSettings;
private final MediationManager mediationManager;
private final FilterManager filterManager;
private final RefundManager refundManager;
private final Socks5ProxyProvider socks5ProxyProvider;

Expand All @@ -74,11 +76,13 @@ class XmrTxProofRequestsPerTrade implements AssetTxProofRequestsPerTrade {
Trade trade,
AutoConfirmSettings autoConfirmSettings,
MediationManager mediationManager,
FilterManager filterManager,
RefundManager refundManager) {
this.socks5ProxyProvider = socks5ProxyProvider;
this.trade = trade;
this.autoConfirmSettings = autoConfirmSettings;
this.mediationManager = mediationManager;
this.filterManager = filterManager;
this.refundManager = refundManager;
}

Expand Down Expand Up @@ -140,6 +144,10 @@ public void requestFromAllServices(Consumer<AssetTxProofResult> resultHandler, F
numRequiredSuccessResults = serviceAddresses.size();

for (String serviceAddress : serviceAddresses) {
if (filterManager.isAutoConfExplorerBanned(serviceAddress)) {
log.warn("Filtered out auto-confirmation address: {}", serviceAddress);
continue; // #4683: filter for auto-confirm explorers
}
XmrTxProofModel model = new XmrTxProofModel(trade, serviceAddress, autoConfirmSettings);
XmrTxProofRequest request = new XmrTxProofRequest(socks5ProxyProvider, model);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ private void startRequests(SellerTrade trade) {
trade,
autoConfirmSettings,
mediationManager,
filterManager,
refundManager);
servicesByTradeId.put(trade.getId(), service);
service.requestFromAllServices(
Expand Down
1 change: 1 addition & 0 deletions core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2595,6 +2595,7 @@ filterWindow.btcNode=Filtered Bitcoin nodes (comma sep. addresses + port)
filterWindow.preventPublicBtcNetwork=Prevent usage of public Bitcoin network
filterWindow.disableDao=Disable DAO
filterWindow.disableAutoConf=Disable auto-confirm
filterWindow.autoConfExplorers=Filtered auto-confirm explorers (comma sep. addresses)
filterWindow.disableDaoBelowVersion=Min. version required for DAO
filterWindow.disableTradeBelowVersion=Min. version required for trading
filterWindow.add=Add filter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ public void testRoundtripFull() {
null,
null,
null,
false));
false,
Lists.newArrayList()));

vo.setRegisteredArbitrator(ArbitratorTest.getArbitratorMock());
vo.setRegisteredMediator(MediatorTest.getMediatorMock());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ private static Filter filterWithReceivers(List<String> btcFeeReceiverAddresses)
null,
null,
null,
false);
false,
Lists.newArrayList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ private void addContent() {
Res.get("filterWindow.disableTradeBelowVersion"));
InputTextField bannedPrivilegedDevPubKeysTF = addTopLabelInputTextField(gridPane, ++rowIndex,
Res.get("filterWindow.bannedPrivilegedDevPubKeys")).second;
InputTextField autoConfExplorersTF = addTopLabelInputTextField(gridPane, ++rowIndex,
Res.get("filterWindow.autoConfExplorers")).second;

Filter filter = filterManager.getDevFilter();
if (filter != null) {
Expand All @@ -178,6 +180,7 @@ private void addContent() {
setupFieldFromList(priceRelayNodesTF, filter.getPriceRelayNodes());
setupFieldFromList(btcNodesTF, filter.getBtcNodes());
setupFieldFromList(bannedPrivilegedDevPubKeysTF, filter.getBannedPrivilegedDevPubKeys());
setupFieldFromList(autoConfExplorersTF, filter.getBannedAutoConfExplorers());

preventPublicBtcNetworkCheckBox.setSelected(filter.isPreventPublicBtcNetwork());
disableDaoCheckBox.setSelected(filter.isDisableDao());
Expand Down Expand Up @@ -215,7 +218,8 @@ private void addContent() {
filterManager.getOwnerPubKey(),
signerPubKeyAsHex,
readAsList(bannedPrivilegedDevPubKeysTF),
disableAutoConfCheckBox.isSelected()
disableAutoConfCheckBox.isSelected(),
readAsList(autoConfExplorersTF)
);

// We remove first the old filter
Expand Down
1 change: 1 addition & 0 deletions proto/src/main/proto/pb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,7 @@ message Filter {
string signer_pub_key_as_hex = 22;
repeated string bannedPrivilegedDevPubKeys = 23;
bool disable_auto_conf = 24;
repeated string banned_auto_conf_explorers = 25;
}

// Deprecated
Expand Down

0 comments on commit 9ab6545

Please sign in to comment.