mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-20 02:12:00 +01:00
Prevent that a dev arbitrator can be published on Mainnet
This commit is contained in:
parent
5f9d59143e
commit
4c2f06f0be
@ -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,6 +62,8 @@ public class ArbitratorService {
|
||||
|
||||
public void addArbitrator(Arbitrator arbitrator, final ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) {
|
||||
log.debug("addArbitrator arbitrator.hashCode() " + arbitrator.hashCode());
|
||||
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());
|
||||
@ -66,6 +71,10 @@ public class ArbitratorService {
|
||||
} else {
|
||||
errorMessageHandler.handleErrorMessage("Add arbitrator failed");
|
||||
}
|
||||
} else {
|
||||
log.error("Attempt to publish dev arbitrator on mainnet.");
|
||||
errorMessageHandler.handleErrorMessage("Add arbitrator failed. Attempt to publish dev arbitrator on mainnet.");
|
||||
}
|
||||
}
|
||||
|
||||
public void removeArbitrator(Arbitrator arbitrator, ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) {
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user