Search in sources :

Example 1 with FiatTransferStartedMessage

use of io.bitsquare.trade.protocol.trade.messages.FiatTransferStartedMessage in project bitsquare by bitsquare.

the class SendFiatTransferStartedMessage method run.

@Override
protected void run() {
    try {
        runInterceptHook();
        WalletService walletService = processModel.getWalletService();
        AddressEntry payoutAddressEntry = walletService.getOrCreateAddressEntry(processModel.getOffer().getId(), AddressEntry.Context.TRADE_PAYOUT);
        processModel.getP2PService().sendEncryptedMailboxMessage(trade.getTradingPeerNodeAddress(), processModel.tradingPeer.getPubKeyRing(), new FiatTransferStartedMessage(processModel.getId(), payoutAddressEntry.getAddressString(), processModel.getMyNodeAddress()), new SendMailboxMessageListener() {

            @Override
            public void onArrived() {
                log.debug("Message arrived at peer.");
                trade.setState(Trade.State.BUYER_SENT_FIAT_PAYMENT_INITIATED_MSG);
                complete();
            }

            @Override
            public void onStoredInMailbox() {
                log.debug("Message stored in mailbox.");
                trade.setState(Trade.State.BUYER_SENT_FIAT_PAYMENT_INITIATED_MSG);
                complete();
            }

            @Override
            public void onFault(String errorMessage) {
                appendToErrorMessage("FiatTransferStartedMessage sending failed");
                failed(errorMessage);
            }
        });
    } catch (Throwable t) {
        failed(t);
    }
}
Also used : AddressEntry(io.bitsquare.btc.AddressEntry) FiatTransferStartedMessage(io.bitsquare.trade.protocol.trade.messages.FiatTransferStartedMessage) SendMailboxMessageListener(io.bitsquare.p2p.messaging.SendMailboxMessageListener) WalletService(io.bitsquare.btc.WalletService)

Example 2 with FiatTransferStartedMessage

use of io.bitsquare.trade.protocol.trade.messages.FiatTransferStartedMessage in project bitsquare by bitsquare.

the class ProcessFiatTransferStartedMessage method run.

@Override
protected void run() {
    try {
        runInterceptHook();
        log.debug("current trade state " + trade.getState());
        FiatTransferStartedMessage message = (FiatTransferStartedMessage) processModel.getTradeMessage();
        checkTradeId(processModel.getId(), message);
        checkNotNull(message);
        processModel.tradingPeer.setPayoutAddressString(nonEmptyStringOf(message.buyerPayoutAddress));
        // update to the latest peer address of our peer if the message is correct
        trade.setTradingPeerNodeAddress(processModel.getTempTradingPeerNodeAddress());
        removeMailboxMessageAfterProcessing();
        trade.setState(Trade.State.SELLER_RECEIVED_FIAT_PAYMENT_INITIATED_MSG);
        complete();
    } catch (Throwable t) {
        failed(t);
    }
}
Also used : FiatTransferStartedMessage(io.bitsquare.trade.protocol.trade.messages.FiatTransferStartedMessage)

Aggregations

FiatTransferStartedMessage (io.bitsquare.trade.protocol.trade.messages.FiatTransferStartedMessage)2 AddressEntry (io.bitsquare.btc.AddressEntry)1 WalletService (io.bitsquare.btc.WalletService)1 SendMailboxMessageListener (io.bitsquare.p2p.messaging.SendMailboxMessageListener)1