Search in sources :

Example 1 with Arbitrator

use of io.bisq.core.arbitration.Arbitrator in project bisq-api by mrosseel.

the class BisqProxy method registerArbitrator.

public void registerArbitrator(List<String> languageCodes) {
    // TODO most of this code is dupplication of ArbitratorRegistrationViewModel.onRegister
    final String privKeyString = useDevPrivilegeKeys ? DevEnv.DEV_PRIVILEGE_PRIV_KEY : null;
    // TODO hm, are we going to send private key over http?
    if (null == privKeyString) {
        throw new RuntimeException("Missing private key");
    }
    ECKey registrationKey = arbitratorManager.getRegistrationKey(privKeyString);
    if (null == registrationKey) {
        throw new RuntimeException("Missing registration key");
    }
    AddressEntry arbitratorDepositAddressEntry = btcWalletService.getOrCreateAddressEntry(AddressEntry.Context.ARBITRATOR);
    String registrationSignature = arbitratorManager.signStorageSignaturePubKey(registrationKey);
    Arbitrator arbitrator = new Arbitrator(p2PService.getAddress(), arbitratorDepositAddressEntry.getPubKey(), arbitratorDepositAddressEntry.getAddressString(), keyRing.getPubKeyRing(), new ArrayList<>(languageCodes), new Date().getTime(), registrationKey.getPubKey(), registrationSignature, null, null, null);
    // TODO I don't know how to deal with those callbacks in order to send response back
    arbitratorManager.addArbitrator(arbitrator, () -> System.out.println("Arbi registered"), message -> System.out.println("Error when registering arbi: " + message));
}
Also used : AddressEntry(io.bisq.core.btc.AddressEntry) ECKey(org.bitcoinj.core.ECKey) Arbitrator(io.bisq.core.arbitration.Arbitrator)

Example 2 with Arbitrator

use of io.bisq.core.arbitration.Arbitrator in project bisq-api by mrosseel.

the class BisqProxy method selectArbitrator.

public Collection<Arbitrator> selectArbitrator(String arbitratorAddress) {
    final Arbitrator arbitrator = getArbitratorByAddress(arbitratorAddress);
    if (null == arbitrator) {
        throw new NotFoundException("Arbitrator not found: " + arbitratorAddress);
    }
    if (!arbitratorIsTrader(arbitrator)) {
        user.addAcceptedArbitrator(arbitrator);
        user.addAcceptedMediator(ArbitratorManager.getMediator(arbitrator));
        return user.getAcceptedArbitrators();
    }
    throw new ValidationException("You cannot select yourself as an arbitrator");
}
Also used : ValidationException(javax.validation.ValidationException) Arbitrator(io.bisq.core.arbitration.Arbitrator)

Example 3 with Arbitrator

use of io.bisq.core.arbitration.Arbitrator in project bisq-api by mrosseel.

the class BisqProxy method deselectArbitrator.

public Collection<Arbitrator> deselectArbitrator(String arbitratorAddress) {
    final Arbitrator arbitrator = getArbitratorByAddress(arbitratorAddress);
    if (null == arbitrator) {
        throw new NotFoundException("Arbitrator not found: " + arbitratorAddress);
    }
    user.removeAcceptedArbitrator(arbitrator);
    user.removeAcceptedMediator(ArbitratorManager.getMediator(arbitrator));
    return user.getAcceptedArbitrators();
}
Also used : Arbitrator(io.bisq.core.arbitration.Arbitrator)

Aggregations

Arbitrator (io.bisq.core.arbitration.Arbitrator)3 AddressEntry (io.bisq.core.btc.AddressEntry)1 ValidationException (javax.validation.ValidationException)1 ECKey (org.bitcoinj.core.ECKey)1