diff --git a/core/src/main/java/io/bisq/core/arbitration/ArbitratorService.java b/core/src/main/java/io/bisq/core/arbitration/ArbitratorService.java index bc5d937b72..e11a802530 100644 --- a/core/src/main/java/io/bisq/core/arbitration/ArbitratorService.java +++ b/core/src/main/java/io/bisq/core/arbitration/ArbitratorService.java @@ -17,8 +17,11 @@ package io.bisq.core.arbitration; +import io.bisq.common.app.DevEnv; import io.bisq.common.handlers.ErrorMessageHandler; import io.bisq.common.handlers.ResultHandler; +import io.bisq.common.util.Utilities; +import io.bisq.core.app.BisqEnvironment; import io.bisq.network.p2p.NodeAddress; import io.bisq.network.p2p.P2PService; import io.bisq.network.p2p.storage.HashMapChangedListener; @@ -59,12 +62,18 @@ public class ArbitratorService { public void addArbitrator(Arbitrator arbitrator, final ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) { log.debug("addArbitrator arbitrator.hashCode() " + arbitrator.hashCode()); - boolean result = p2PService.addData(arbitrator, true); - if (result) { - log.trace("Add arbitrator to network was successful. Arbitrator.hashCode() = " + arbitrator.hashCode()); - resultHandler.handleResult(); + if (!BisqEnvironment.getBaseCurrencyNetwork().isMainnet() || + !Utilities.encodeToHex(arbitrator.getRegistrationPubKey()).equals(DevEnv.DEV_PRIVILEGE_PUB_KEY)) { + boolean result = p2PService.addData(arbitrator, true); + if (result) { + log.trace("Add arbitrator to network was successful. Arbitrator.hashCode() = " + arbitrator.hashCode()); + resultHandler.handleResult(); + } else { + errorMessageHandler.handleErrorMessage("Add arbitrator failed"); + } } else { - errorMessageHandler.handleErrorMessage("Add arbitrator failed"); + log.error("Attempt to publish dev arbitrator on mainnet."); + errorMessageHandler.handleErrorMessage("Add arbitrator failed. Attempt to publish dev arbitrator on mainnet."); } } diff --git a/core/src/main/java/io/bisq/core/trade/protocol/tasks/VerifyPeersAgeWitnessAge.java b/core/src/main/java/io/bisq/core/trade/protocol/tasks/VerifyPeersAgeWitnessAge.java new file mode 100644 index 0000000000..29c617c25a --- /dev/null +++ b/core/src/main/java/io/bisq/core/trade/protocol/tasks/VerifyPeersAgeWitnessAge.java @@ -0,0 +1,66 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package io.bisq.core.trade.protocol.tasks; + +import io.bisq.common.taskrunner.TaskRunner; +import io.bisq.core.payment.AccountAgeWitness; +import io.bisq.core.payment.payload.PaymentAccountPayload; +import io.bisq.core.trade.Trade; +import io.bisq.core.trade.protocol.tasks.TradeTask; +import lombok.extern.slf4j.Slf4j; + +import java.security.PublicKey; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + +@Slf4j +public class VerifyPeersAgeWitnessAge extends TradeTask { + + @SuppressWarnings({"WeakerAccess", "unused"}) + public VerifyPeersAgeWitnessAge(TaskRunner taskHandler, Trade trade) { + super(taskHandler, trade); + } + + @Override + protected void run() { + try { + runInterceptHook(); + + final PaymentAccountPayload paymentAccountPayload = checkNotNull(processModel.getTradingPeer().getPaymentAccountPayload() + , "Peers paymentAccountPayload must not be null"); + + byte[] peersAgeWitnessInputData = null; + AccountAgeWitness witness = null; + byte[] peersSalt = null; + PublicKey peersPublicKey = null; + int nonce = 0; + byte[] signatureOfNonce = null; + + checkArgument(processModel.getAccountAgeWitnessService().verifyAgeWitness(peersAgeWitnessInputData, + witness, + peersSalt, + peersPublicKey, + nonce, + signatureOfNonce), "verifyOffersAccountAgeWitness failed"); + complete(); + } catch (Throwable t) { + failed(t); + } + } +}