Search in sources :

Example 1 with CounterCurrencyTransferStartedMessage

use of bisq.core.trade.messages.CounterCurrencyTransferStartedMessage in project bisq-core by bisq-network.

the class SellerAsMakerProtocol method doApplyMailboxMessage.

// /////////////////////////////////////////////////////////////////////////////////////////
// Mailbox
// /////////////////////////////////////////////////////////////////////////////////////////
@Override
public void doApplyMailboxMessage(NetworkEnvelope networkEnvelop, Trade trade) {
    this.trade = trade;
    NodeAddress peerNodeAddress = ((MailboxMessage) networkEnvelop).getSenderNodeAddress();
    if (networkEnvelop instanceof DepositTxPublishedMessage)
        handle((DepositTxPublishedMessage) networkEnvelop, peerNodeAddress);
    else if (networkEnvelop instanceof CounterCurrencyTransferStartedMessage)
        handle((CounterCurrencyTransferStartedMessage) networkEnvelop, peerNodeAddress);
    else
        log.error("We received an unhandled MailboxMessage" + networkEnvelop.toString());
}
Also used : CounterCurrencyTransferStartedMessage(bisq.core.trade.messages.CounterCurrencyTransferStartedMessage) SellerProcessCounterCurrencyTransferStartedMessage(bisq.core.trade.protocol.tasks.seller.SellerProcessCounterCurrencyTransferStartedMessage) MakerProcessDepositTxPublishedMessage(bisq.core.trade.protocol.tasks.maker.MakerProcessDepositTxPublishedMessage) DepositTxPublishedMessage(bisq.core.trade.messages.DepositTxPublishedMessage) NodeAddress(bisq.network.p2p.NodeAddress) MailboxMessage(bisq.network.p2p.MailboxMessage)

Example 2 with CounterCurrencyTransferStartedMessage

use of bisq.core.trade.messages.CounterCurrencyTransferStartedMessage in project bisq-core by bisq-network.

the class SellerAsTakerProtocol method doApplyMailboxMessage.

// /////////////////////////////////////////////////////////////////////////////////////////
// Mailbox
// /////////////////////////////////////////////////////////////////////////////////////////
@Override
public void doApplyMailboxMessage(NetworkEnvelope networkEnvelop, Trade trade) {
    this.trade = trade;
    if (networkEnvelop instanceof MailboxMessage) {
        NodeAddress peerNodeAddress = ((MailboxMessage) networkEnvelop).getSenderNodeAddress();
        if (networkEnvelop instanceof PublishDepositTxRequest)
            handle((PublishDepositTxRequest) networkEnvelop, peerNodeAddress);
        else if (networkEnvelop instanceof CounterCurrencyTransferStartedMessage)
            handle((CounterCurrencyTransferStartedMessage) networkEnvelop, peerNodeAddress);
        else
            log.error("We received an unhandled MailboxMessage" + networkEnvelop.toString());
    }
}
Also used : CounterCurrencyTransferStartedMessage(bisq.core.trade.messages.CounterCurrencyTransferStartedMessage) SellerProcessCounterCurrencyTransferStartedMessage(bisq.core.trade.protocol.tasks.seller.SellerProcessCounterCurrencyTransferStartedMessage) NodeAddress(bisq.network.p2p.NodeAddress) MailboxMessage(bisq.network.p2p.MailboxMessage) TakerProcessPublishDepositTxRequest(bisq.core.trade.protocol.tasks.taker.TakerProcessPublishDepositTxRequest) PublishDepositTxRequest(bisq.core.trade.messages.PublishDepositTxRequest)

Example 3 with CounterCurrencyTransferStartedMessage

use of bisq.core.trade.messages.CounterCurrencyTransferStartedMessage in project bisq-core by bisq-network.

the class SellerProcessCounterCurrencyTransferStartedMessage method run.

@Override
protected void run() {
    try {
        runInterceptHook();
        log.debug("current trade state " + trade.getState());
        CounterCurrencyTransferStartedMessage message = (CounterCurrencyTransferStartedMessage) processModel.getTradeMessage();
        Validator.checkTradeId(processModel.getOfferId(), message);
        checkNotNull(message);
        processModel.getTradingPeer().setPayoutAddressString(Validator.nonEmptyStringOf(message.getBuyerPayoutAddress()));
        processModel.getTradingPeer().setSignature(checkNotNull(message.getBuyerSignature()));
        // update to the latest peer address of our peer if the message is correct
        trade.setTradingPeerNodeAddress(processModel.getTempTradingPeerNodeAddress());
        trade.setCounterCurrencyTxId(message.getCounterCurrencyTxId());
        processModel.removeMailboxMessageAfterProcessing(trade);
        trade.setState(Trade.State.SELLER_RECEIVED_FIAT_PAYMENT_INITIATED_MSG);
        complete();
    } catch (Throwable t) {
        failed(t);
    }
}
Also used : CounterCurrencyTransferStartedMessage(bisq.core.trade.messages.CounterCurrencyTransferStartedMessage)

Example 4 with CounterCurrencyTransferStartedMessage

use of bisq.core.trade.messages.CounterCurrencyTransferStartedMessage in project bisq-core by bisq-network.

the class BuyerSendCounterCurrencyTransferStartedMessage method run.

@Override
protected void run() {
    try {
        runInterceptHook();
        BtcWalletService walletService = processModel.getBtcWalletService();
        final String id = processModel.getOfferId();
        AddressEntry payoutAddressEntry = walletService.getOrCreateAddressEntry(id, AddressEntry.Context.TRADE_PAYOUT);
        final CounterCurrencyTransferStartedMessage message = new CounterCurrencyTransferStartedMessage(id, payoutAddressEntry.getAddressString(), processModel.getMyNodeAddress(), processModel.getPayoutTxSignature(), trade.getCounterCurrencyTxId(), UUID.randomUUID().toString());
        log.info("Send message to peer. tradeId={}, message{}", id, message);
        trade.setState(Trade.State.BUYER_SENT_FIAT_PAYMENT_INITIATED_MSG);
        processModel.getP2PService().sendEncryptedMailboxMessage(trade.getTradingPeerNodeAddress(), processModel.getTradingPeer().getPubKeyRing(), message, new SendMailboxMessageListener() {

            @Override
            public void onArrived() {
                log.info("Message arrived at peer. tradeId={}", id);
                trade.setState(Trade.State.BUYER_SAW_ARRIVED_FIAT_PAYMENT_INITIATED_MSG);
                complete();
            }

            @Override
            public void onStoredInMailbox() {
                log.info("Message stored in mailbox. tradeId={}", id);
                trade.setState(Trade.State.BUYER_STORED_IN_MAILBOX_FIAT_PAYMENT_INITIATED_MSG);
                complete();
            }

            @Override
            public void onFault(String errorMessage) {
                log.error("sendEncryptedMailboxMessage failed. message=" + message);
                trade.setState(Trade.State.BUYER_SEND_FAILED_FIAT_PAYMENT_INITIATED_MSG);
                appendToErrorMessage("Sending message failed: message=" + message + "\nerrorMessage=" + errorMessage);
                failed(errorMessage);
            }
        });
    } catch (Throwable t) {
        failed(t);
    }
}
Also used : BtcWalletService(bisq.core.btc.wallet.BtcWalletService) AddressEntry(bisq.core.btc.AddressEntry) CounterCurrencyTransferStartedMessage(bisq.core.trade.messages.CounterCurrencyTransferStartedMessage) SendMailboxMessageListener(bisq.network.p2p.SendMailboxMessageListener)

Aggregations

CounterCurrencyTransferStartedMessage (bisq.core.trade.messages.CounterCurrencyTransferStartedMessage)4 SellerProcessCounterCurrencyTransferStartedMessage (bisq.core.trade.protocol.tasks.seller.SellerProcessCounterCurrencyTransferStartedMessage)2 MailboxMessage (bisq.network.p2p.MailboxMessage)2 NodeAddress (bisq.network.p2p.NodeAddress)2 AddressEntry (bisq.core.btc.AddressEntry)1 BtcWalletService (bisq.core.btc.wallet.BtcWalletService)1 DepositTxPublishedMessage (bisq.core.trade.messages.DepositTxPublishedMessage)1 PublishDepositTxRequest (bisq.core.trade.messages.PublishDepositTxRequest)1 MakerProcessDepositTxPublishedMessage (bisq.core.trade.protocol.tasks.maker.MakerProcessDepositTxPublishedMessage)1 TakerProcessPublishDepositTxRequest (bisq.core.trade.protocol.tasks.taker.TakerProcessPublishDepositTxRequest)1 SendMailboxMessageListener (bisq.network.p2p.SendMailboxMessageListener)1