mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Merge pull request #4489 from chimp1984/various-small-improvements
Various small improvements
This commit is contained in:
commit
e7d24efb4a
@ -20,7 +20,6 @@ package bisq.core.account.witness;
|
||||
import bisq.core.account.sign.SignedWitness;
|
||||
import bisq.core.account.sign.SignedWitnessService;
|
||||
import bisq.core.filter.FilterManager;
|
||||
import bisq.core.filter.PaymentAccountFilter;
|
||||
import bisq.core.locale.CurrencyUtil;
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.offer.Offer;
|
||||
@ -718,10 +717,8 @@ public class AccountAgeWitnessService {
|
||||
filterManager.isCurrencyBanned(dispute.getContract().getOfferPayload().getCurrencyCode()) ||
|
||||
filterManager.isPaymentMethodBanned(
|
||||
PaymentMethod.getPaymentMethodById(dispute.getContract().getPaymentMethodId())) ||
|
||||
filterManager.arePeersPaymentAccountDataBanned(dispute.getContract().getBuyerPaymentAccountPayload(),
|
||||
new PaymentAccountFilter[1]) ||
|
||||
filterManager.arePeersPaymentAccountDataBanned(dispute.getContract().getSellerPaymentAccountPayload(),
|
||||
new PaymentAccountFilter[1]) ||
|
||||
filterManager.arePeersPaymentAccountDataBanned(dispute.getContract().getBuyerPaymentAccountPayload()) ||
|
||||
filterManager.arePeersPaymentAccountDataBanned(dispute.getContract().getSellerPaymentAccountPayload()) ||
|
||||
filterManager.isWitnessSignerPubKeyBanned(
|
||||
Utils.HEX.encode(dispute.getContract().getBuyerPubKeyRing().getSignaturePubKeyBytes())) ||
|
||||
filterManager.isWitnessSignerPubKeyBanned(
|
||||
|
@ -371,24 +371,19 @@ public class FilterManager {
|
||||
return requireUpdateToNewVersion;
|
||||
}
|
||||
|
||||
public boolean arePeersPaymentAccountDataBanned(PaymentAccountPayload paymentAccountPayload,
|
||||
PaymentAccountFilter[] appliedPaymentAccountFilter) {
|
||||
public boolean arePeersPaymentAccountDataBanned(PaymentAccountPayload paymentAccountPayload) {
|
||||
return getFilter() != null &&
|
||||
getFilter().getBannedPaymentAccounts().stream()
|
||||
.filter(paymentAccountFilter -> paymentAccountFilter.getPaymentMethodId().equals(
|
||||
paymentAccountPayload.getPaymentMethodId()))
|
||||
.anyMatch(paymentAccountFilter -> {
|
||||
final boolean samePaymentMethodId = paymentAccountFilter.getPaymentMethodId().equals(
|
||||
paymentAccountPayload.getPaymentMethodId());
|
||||
if (samePaymentMethodId) {
|
||||
try {
|
||||
Method method = paymentAccountPayload.getClass().getMethod(paymentAccountFilter.getGetMethodName());
|
||||
String result = (String) method.invoke(paymentAccountPayload);
|
||||
appliedPaymentAccountFilter[0] = paymentAccountFilter;
|
||||
return result.toLowerCase().equals(paymentAccountFilter.getValue().toLowerCase());
|
||||
} catch (Throwable e) {
|
||||
log.error(e.getMessage());
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
Method method = paymentAccountPayload.getClass().getMethod(paymentAccountFilter.getGetMethodName());
|
||||
// We invoke getter methods (no args), e.g. getHolderName
|
||||
String valueFromInvoke = (String) method.invoke(paymentAccountPayload);
|
||||
return valueFromInvoke.equalsIgnoreCase(paymentAccountFilter.getValue());
|
||||
} catch (Throwable e) {
|
||||
log.error(e.getMessage());
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
@ -200,18 +200,19 @@ public class MultipleHolderNameDetection {
|
||||
|
||||
private Map<String, List<Dispute>> getAllDisputesByTraderMap() {
|
||||
Map<String, List<Dispute>> allDisputesByTraderMap = new HashMap<>();
|
||||
disputeManager.getDisputesAsObservableList()
|
||||
.forEach(dispute -> {
|
||||
disputeManager.getDisputesAsObservableList().stream()
|
||||
.filter(dispute -> {
|
||||
Contract contract = dispute.getContract();
|
||||
PaymentAccountPayload paymentAccountPayload = isBuyer(dispute) ?
|
||||
contract.getBuyerPaymentAccountPayload() :
|
||||
contract.getSellerPaymentAccountPayload();
|
||||
if (paymentAccountPayload instanceof PayloadWithHolderName) {
|
||||
String traderPubKeyHash = getSigPubKeyHashAsHex(dispute);
|
||||
allDisputesByTraderMap.putIfAbsent(traderPubKeyHash, new ArrayList<>());
|
||||
List<Dispute> disputes = allDisputesByTraderMap.get(traderPubKeyHash);
|
||||
disputes.add(dispute);
|
||||
}
|
||||
return paymentAccountPayload instanceof PayloadWithHolderName;
|
||||
})
|
||||
.forEach(dispute -> {
|
||||
String traderPubKeyHash = getSigPubKeyHashAsHex(dispute);
|
||||
allDisputesByTraderMap.putIfAbsent(traderPubKeyHash, new ArrayList<>());
|
||||
List<Dispute> disputes = allDisputesByTraderMap.get(traderPubKeyHash);
|
||||
disputes.add(dispute);
|
||||
});
|
||||
return allDisputesByTraderMap;
|
||||
}
|
||||
|
@ -18,7 +18,6 @@
|
||||
package bisq.core.trade.protocol.tasks;
|
||||
|
||||
import bisq.core.filter.FilterManager;
|
||||
import bisq.core.filter.PaymentAccountFilter;
|
||||
import bisq.core.payment.payload.PaymentAccountPayload;
|
||||
import bisq.core.trade.Trade;
|
||||
|
||||
@ -42,9 +41,8 @@ public class ApplyFilter extends TradeTask {
|
||||
try {
|
||||
runInterceptHook();
|
||||
|
||||
final NodeAddress nodeAddress = processModel.getTempTradingPeerNodeAddress();
|
||||
NodeAddress nodeAddress = processModel.getTempTradingPeerNodeAddress();
|
||||
PaymentAccountPayload paymentAccountPayload = checkNotNull(processModel.getTradingPeer().getPaymentAccountPayload());
|
||||
final PaymentAccountFilter[] appliedPaymentAccountFilter = new PaymentAccountFilter[1];
|
||||
|
||||
FilterManager filterManager = processModel.getFilterManager();
|
||||
if (nodeAddress != null && filterManager.isNodeAddressBanned(nodeAddress)) {
|
||||
@ -56,13 +54,12 @@ public class ApplyFilter extends TradeTask {
|
||||
} else if (trade.getOffer() != null && filterManager.isCurrencyBanned(trade.getOffer().getCurrencyCode())) {
|
||||
failed("Currency is banned.\n" +
|
||||
"Currency code=" + trade.getOffer().getCurrencyCode());
|
||||
} else if (filterManager.isPaymentMethodBanned(trade.getOffer().getPaymentMethod())) {
|
||||
} else if (filterManager.isPaymentMethodBanned(checkNotNull(trade.getOffer()).getPaymentMethod())) {
|
||||
failed("Payment method is banned.\n" +
|
||||
"Payment method=" + trade.getOffer().getPaymentMethod().getId());
|
||||
} else if (filterManager.arePeersPaymentAccountDataBanned(paymentAccountPayload, appliedPaymentAccountFilter)) {
|
||||
} else if (filterManager.arePeersPaymentAccountDataBanned(paymentAccountPayload)) {
|
||||
failed("Other trader is banned by their trading account data.\n" +
|
||||
"paymentAccountPayload=" + paymentAccountPayload.getPaymentDetails() + "\n" +
|
||||
"banFilter=" + appliedPaymentAccountFilter[0].toString());
|
||||
"paymentAccountPayload=" + paymentAccountPayload.getPaymentDetails());
|
||||
} else if (filterManager.requireUpdateToNewVersionForTrading()) {
|
||||
failed("Your version of Bisq is not compatible for trading anymore. " +
|
||||
"Please update to the latest Bisq version at https://bisq.network/downloads.");
|
||||
|
@ -218,7 +218,7 @@ public class AccountAgeWitnessServiceTest {
|
||||
when(filterManager.isNodeAddressBanned(any())).thenReturn(false);
|
||||
when(filterManager.isCurrencyBanned(any())).thenReturn(false);
|
||||
when(filterManager.isPaymentMethodBanned(any())).thenReturn(false);
|
||||
when(filterManager.arePeersPaymentAccountDataBanned(any(), any())).thenReturn(false);
|
||||
when(filterManager.arePeersPaymentAccountDataBanned(any())).thenReturn(false);
|
||||
when(filterManager.isWitnessSignerPubKeyBanned(any())).thenReturn(false);
|
||||
|
||||
when(chargeBackRisk.hasChargebackRisk(any(), any())).thenReturn(true);
|
||||
|
@ -7,7 +7,7 @@ Bisq uses Git LFS to track certain large binary files. Follow the instructions a
|
||||
|
||||
$ git lfs version
|
||||
git-lfs/2.10.0 (GitHub; darwin amd64; go 1.13.6)
|
||||
|
||||
|
||||
|
||||
## Clone
|
||||
|
||||
@ -17,8 +17,9 @@ Bisq uses Git LFS to track certain large binary files. Follow the instructions a
|
||||
|
||||
## Build
|
||||
|
||||
You do _not_ need to install Gradle to complete the following command. The `gradlew` shell script will install it for you if necessary.
|
||||
You do _not_ need to install Gradle to complete the following command. The `gradlew` shell script will install it for you if necessary. Pull the lfs data first.
|
||||
|
||||
git lfs pull
|
||||
./gradlew build
|
||||
|
||||
If on Windows run `gradlew.bat build` instead.
|
||||
|
@ -48,6 +48,8 @@ import bisq.common.proto.network.NetworkEnvelope;
|
||||
import bisq.common.proto.network.NetworkProtoResolver;
|
||||
import bisq.common.util.Utilities;
|
||||
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
@ -283,12 +285,20 @@ public class Connection implements HasCapabilities, Runnable, MessageListener {
|
||||
bundleSender.schedule(() -> {
|
||||
if (!stopped) {
|
||||
synchronized (lock) {
|
||||
BundleOfEnvelopes current = queueOfBundles.poll();
|
||||
if (current != null && !stopped) {
|
||||
if (current.getEnvelopes().size() == 1) {
|
||||
protoOutputStream.writeEnvelope(current.getEnvelopes().get(0));
|
||||
} else {
|
||||
protoOutputStream.writeEnvelope(current);
|
||||
BundleOfEnvelopes bundle = queueOfBundles.poll();
|
||||
if (bundle != null && !stopped) {
|
||||
NetworkEnvelope envelope = bundle.getEnvelopes().size() == 1 ?
|
||||
bundle.getEnvelopes().get(0) :
|
||||
bundle;
|
||||
try {
|
||||
protoOutputStream.writeEnvelope(envelope);
|
||||
} catch (Throwable t) {
|
||||
log.error("Sending envelope of class {} to address {} " +
|
||||
"failed due {}",
|
||||
envelope.getClass().getSimpleName(),
|
||||
this.getPeersNodeAddressOptional(),
|
||||
t.toString());
|
||||
log.error("envelope: {}", envelope);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -876,7 +886,7 @@ public class Connection implements HasCapabilities, Runnable, MessageListener {
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
reportInvalidRequest(RuleViolation.INVALID_CLASS);
|
||||
} catch (ProtobufferException | NoClassDefFoundError e) {
|
||||
} catch (ProtobufferException | NoClassDefFoundError | InvalidProtocolBufferException e) {
|
||||
log.error(e.getMessage());
|
||||
e.printStackTrace();
|
||||
reportInvalidRequest(RuleViolation.INVALID_DATA_TYPE);
|
||||
|
Loading…
Reference in New Issue
Block a user