Search in sources :

Example 6 with PubKeyRing

use of bisq.common.crypto.PubKeyRing in project bisq-core by bisq-network.

the class DisputeManager method sendDisputeDirectMessage.

// traders send msg to the arbitrator or arbitrator to 1 trader (trader to trader is not allowed)
public DisputeCommunicationMessage sendDisputeDirectMessage(Dispute dispute, String text, ArrayList<Attachment> attachments) {
    DisputeCommunicationMessage disputeCommunicationMessage = new DisputeCommunicationMessage(dispute.getTradeId(), dispute.getTraderPubKeyRing().hashCode(), isTrader(dispute), text, null, p2PService.getAddress(), new Date().getTime(), false, false, UUID.randomUUID().toString());
    disputeCommunicationMessage.addAllAttachments(attachments);
    PubKeyRing receiverPubKeyRing = null;
    NodeAddress peerNodeAddress = null;
    if (isTrader(dispute)) {
        dispute.addDisputeMessage(disputeCommunicationMessage);
        receiverPubKeyRing = dispute.getArbitratorPubKeyRing();
        peerNodeAddress = dispute.getContract().getArbitratorNodeAddress();
    } else if (isArbitrator(dispute)) {
        if (!disputeCommunicationMessage.isSystemMessage())
            dispute.addDisputeMessage(disputeCommunicationMessage);
        receiverPubKeyRing = dispute.getTraderPubKeyRing();
        Contract contract = dispute.getContract();
        if (contract.getBuyerPubKeyRing().equals(receiverPubKeyRing))
            peerNodeAddress = contract.getBuyerNodeAddress();
        else
            peerNodeAddress = contract.getSellerNodeAddress();
    } else {
        log.error("That must not happen. Trader cannot communicate to other trader.");
    }
    if (receiverPubKeyRing != null) {
        log.trace("sendDisputeDirectMessage to peerAddress " + peerNodeAddress);
        p2PService.sendEncryptedMailboxMessage(peerNodeAddress, receiverPubKeyRing, disputeCommunicationMessage, new SendMailboxMessageListener() {

            @Override
            public void onArrived() {
                log.info("Message arrived at peer. tradeId={}", disputeCommunicationMessage.getTradeId());
                disputeCommunicationMessage.setArrived(true);
            }

            @Override
            public void onStoredInMailbox() {
                log.info("Message stored in mailbox. tradeId={}", disputeCommunicationMessage.getTradeId());
                disputeCommunicationMessage.setStoredInMailbox(true);
            }

            @Override
            public void onFault(String errorMessage) {
                log.error("sendEncryptedMailboxMessage failed. disputeCommunicationMessage=" + disputeCommunicationMessage);
            }
        });
    }
    return disputeCommunicationMessage;
}
Also used : PubKeyRing(bisq.common.crypto.PubKeyRing) NodeAddress(bisq.network.p2p.NodeAddress) SendMailboxMessageListener(bisq.network.p2p.SendMailboxMessageListener) Contract(bisq.core.trade.Contract) DisputeCommunicationMessage(bisq.core.arbitration.messages.DisputeCommunicationMessage) Date(java.util.Date)

Aggregations

PubKeyRing (bisq.common.crypto.PubKeyRing)6 NodeAddress (bisq.network.p2p.NodeAddress)4 SendMailboxMessageListener (bisq.network.p2p.SendMailboxMessageListener)3 Date (java.util.Date)3 Dispute (bisq.core.arbitration.Dispute)2 DisputeCommunicationMessage (bisq.core.arbitration.messages.DisputeCommunicationMessage)2 Contract (bisq.core.trade.Contract)2 Popup (bisq.desktop.main.overlays.popups.Popup)2 PeerOpenedDisputeMessage (bisq.core.arbitration.messages.PeerOpenedDisputeMessage)1 PeerPublishedDisputePayoutTxMessage (bisq.core.arbitration.messages.PeerPublishedDisputePayoutTxMessage)1 AccountAgeWitnessService (bisq.core.payment.AccountAgeWitnessService)1 PaymentAccountPayload (bisq.core.payment.payload.PaymentAccountPayload)1 BuyerTrade (bisq.core.trade.BuyerTrade)1 SellerTrade (bisq.core.trade.SellerTrade)1 Trade (bisq.core.trade.Trade)1 TradingPeer (bisq.core.trade.protocol.TradingPeer)1 AutoTooltipLabel (bisq.desktop.components.AutoTooltipLabel)1 InputTextField (bisq.desktop.components.InputTextField)1 SendPrivateNotificationWindow (bisq.desktop.main.overlays.windows.SendPrivateNotificationWindow)1 ArrayList (java.util.ArrayList)1