Search in sources :

Example 6 with Arbitrator

use of io.bitsquare.arbitration.Arbitrator in project bitsquare by bitsquare.

the class CreateOfferFeeTx method run.

@Override
protected void run() {
    try {
        runInterceptHook();
        NodeAddress selectedArbitratorNodeAddress = ArbitrationSelectionRule.select(model.user.getAcceptedArbitratorAddresses(), model.offer);
        log.debug("selectedArbitratorAddress " + selectedArbitratorNodeAddress);
        Arbitrator selectedArbitrator = model.user.getAcceptedArbitratorByAddress(selectedArbitratorNodeAddress);
        checkNotNull(selectedArbitrator, "selectedArbitrator must not be null at CreateOfferFeeTx");
        WalletService walletService = model.walletService;
        String id = model.offer.getId();
        Address fundingAddress = walletService.getOrCreateAddressEntry(id, AddressEntry.Context.OFFER_FUNDING).getAddress();
        Address reservedForTradeAddress = walletService.getOrCreateAddressEntry(id, AddressEntry.Context.RESERVED_FOR_TRADE).getAddress();
        Address changeAddress = walletService.getOrCreateAddressEntry(AddressEntry.Context.AVAILABLE).getAddress();
        Transaction transaction = model.tradeWalletService.createTradingFeeTx(fundingAddress, reservedForTradeAddress, changeAddress, model.reservedFundsForOffer, model.useSavingsWallet, FeePolicy.getCreateOfferFee(), selectedArbitrator.getBtcAddress());
        // We assume there will be no tx malleability. We add a check later in case the published offer has a different hash.
        // As the txId is part of the offer and therefore change the hash data we need to be sure to have no
        // tx malleability
        model.offer.setOfferFeePaymentTxID(transaction.getHashAsString());
        model.setTransaction(transaction);
        complete();
    } catch (Throwable t) {
        model.offer.setErrorMessage("An error occurred.\n" + "Error message:\n" + t.getMessage());
        failed(t);
    }
}
Also used : NodeAddress(io.bitsquare.p2p.NodeAddress) Address(org.bitcoinj.core.Address) Transaction(org.bitcoinj.core.Transaction) NodeAddress(io.bitsquare.p2p.NodeAddress) Arbitrator(io.bitsquare.arbitration.Arbitrator) WalletService(io.bitsquare.btc.WalletService)

Example 7 with Arbitrator

use of io.bitsquare.arbitration.Arbitrator in project bitsquare by bitsquare.

the class Trade method getArbitratorPubKey.

public byte[] getArbitratorPubKey() {
    // the client did not get delivered an arbitrator from the P2P network).
    if (arbitratorBtcPubKey == null) {
        Arbitrator arbitrator = processModel.getUser().getAcceptedArbitratorByAddress(arbitratorNodeAddress);
        checkNotNull(arbitrator, "arbitrator must not be null");
        arbitratorBtcPubKey = arbitrator.getBtcPubKey();
    }
    checkNotNull(arbitratorBtcPubKey, "ArbitratorPubKey must not be null");
    return arbitratorBtcPubKey;
}
Also used : Arbitrator(io.bitsquare.arbitration.Arbitrator)

Example 8 with Arbitrator

use of io.bitsquare.arbitration.Arbitrator in project bitsquare by bitsquare.

the class ArbitratorSelectionViewModel method updateAutoSelectArbitrators.

private void updateAutoSelectArbitrators() {
    if (preferences.getAutoSelectArbitrators()) {
        arbitratorListItems.stream().forEach(item -> {
            Arbitrator arbitrator = item.arbitrator;
            if (!isMyOwnRegisteredArbitrator(arbitrator)) {
                if (hasMatchingLanguage(arbitrator)) {
                    onAddArbitrator(arbitrator);
                    item.setIsSelected(true);
                } else {
                    onRemoveArbitrator(arbitrator);
                    item.setIsSelected(false);
                }
            } else {
                item.setIsSelected(false);
            }
        });
    }
}
Also used : Arbitrator(io.bitsquare.arbitration.Arbitrator)

Example 9 with Arbitrator

use of io.bitsquare.arbitration.Arbitrator in project bitsquare by bitsquare.

the class PendingTradesDataModel method doOpenDispute.

private void doOpenDispute(boolean isSupportTicket, Transaction depositTx) {
    Log.traceCall("depositTx=" + depositTx);
    byte[] depositTxSerialized = null;
    byte[] payoutTxSerialized = null;
    String depositTxHashAsString = null;
    String payoutTxHashAsString = null;
    if (depositTx != null) {
        depositTxSerialized = depositTx.bitcoinSerialize();
        depositTxHashAsString = depositTx.getHashAsString();
    } else {
        log.warn("depositTx is null");
    }
    Trade trade = getTrade();
    if (trade != null) {
        Transaction payoutTx = trade.getPayoutTx();
        if (payoutTx != null) {
            payoutTxSerialized = payoutTx.bitcoinSerialize();
            payoutTxHashAsString = payoutTx.getHashAsString();
        } else {
            log.debug("payoutTx is null at doOpenDispute");
        }
        final Arbitrator acceptedArbitratorByAddress = user.getAcceptedArbitratorByAddress(trade.getArbitratorNodeAddress());
        checkNotNull(acceptedArbitratorByAddress, "acceptedArbitratorByAddress must no tbe null");
        Dispute dispute = new Dispute(disputeManager.getDisputeStorage(), trade.getId(), // traderId
        keyRing.getPubKeyRing().hashCode(), trade.getOffer().getDirection() == Offer.Direction.BUY ? isOfferer : !isOfferer, isOfferer, keyRing.getPubKeyRing(), trade.getDate(), trade.getContract(), trade.getContractHash(), depositTxSerialized, payoutTxSerialized, depositTxHashAsString, payoutTxHashAsString, trade.getContractAsJson(), trade.getOffererContractSignature(), trade.getTakerContractSignature(), acceptedArbitratorByAddress.getPubKeyRing(), isSupportTicket);
        trade.setDisputeState(Trade.DisputeState.DISPUTE_REQUESTED);
        if (p2PService.isBootstrapped()) {
            sendOpenNewDisputeMessage(dispute, false);
        } else {
            new Popup().information("You need to wait until you are fully connected to the network.\n" + "That might take up to about 2 minutes at startup.").show();
        }
    } else {
        log.warn("trade is null at doOpenDispute");
    }
}
Also used : Trade(io.bitsquare.trade.Trade) BuyerTrade(io.bitsquare.trade.BuyerTrade) SellerTrade(io.bitsquare.trade.SellerTrade) Transaction(org.bitcoinj.core.Transaction) Popup(io.bitsquare.gui.main.overlays.popups.Popup) Dispute(io.bitsquare.arbitration.Dispute) Arbitrator(io.bitsquare.arbitration.Arbitrator)

Aggregations

Arbitrator (io.bitsquare.arbitration.Arbitrator)9 Transaction (org.bitcoinj.core.Transaction)3 AddressEntry (io.bitsquare.btc.AddressEntry)2 WalletService (io.bitsquare.btc.WalletService)2 Popup (io.bitsquare.gui.main.overlays.popups.Popup)2 NodeAddress (io.bitsquare.p2p.NodeAddress)2 Address (org.bitcoinj.core.Address)2 Dispute (io.bitsquare.arbitration.Dispute)1 UserThread (io.bitsquare.common.UserThread)1 Tuple2 (io.bitsquare.common.util.Tuple2)1 ActivatableViewAndModel (io.bitsquare.gui.common.view.ActivatableViewAndModel)1 FxmlView (io.bitsquare.gui.common.view.FxmlView)1 EnterPrivKeyWindow (io.bitsquare.gui.main.overlays.windows.EnterPrivKeyWindow)1 FormBuilder (io.bitsquare.gui.util.FormBuilder)1 ImageUtil (io.bitsquare.gui.util.ImageUtil)1 Layout (io.bitsquare.gui.util.Layout)1 LanguageUtil (io.bitsquare.locale.LanguageUtil)1 BuyerTrade (io.bitsquare.trade.BuyerTrade)1 SellerTrade (io.bitsquare.trade.SellerTrade)1 Trade (io.bitsquare.trade.Trade)1