Search in sources :

Example 1 with OffererTrade

use of io.bitsquare.trade.OffererTrade in project bitsquare by bitsquare.

the class ProcessDepositTxPublishedMessage method run.

@Override
protected void run() {
    try {
        runInterceptHook();
        log.debug("current trade state " + trade.getState());
        DepositTxPublishedMessage message = (DepositTxPublishedMessage) processModel.getTradeMessage();
        checkTradeId(processModel.getId(), message);
        checkNotNull(message);
        checkArgument(message.depositTx != null);
        // To access tx confidence we need to add that tx into our wallet.
        Transaction transactionFromSerializedTx = processModel.getWalletService().getTransactionFromSerializedTx(message.depositTx);
        // update with full tx
        trade.setDepositTx(processModel.getTradeWalletService().addTransactionToWallet(transactionFromSerializedTx));
        if (trade instanceof OffererTrade)
            processModel.getOpenOfferManager().closeOpenOffer(trade.getOffer());
        // update to the latest peer address of our peer if the message is correct
        trade.setTradingPeerNodeAddress(processModel.getTempTradingPeerNodeAddress());
        removeMailboxMessageAfterProcessing();
        trade.setState(Trade.State.OFFERER_RECEIVED_DEPOSIT_TX_PUBLISHED_MSG);
        complete();
    } catch (Throwable t) {
        failed(t);
    }
}
Also used : Transaction(org.bitcoinj.core.Transaction) DepositTxPublishedMessage(io.bitsquare.trade.protocol.trade.messages.DepositTxPublishedMessage) OffererTrade(io.bitsquare.trade.OffererTrade)

Example 2 with OffererTrade

use of io.bitsquare.trade.OffererTrade in project bitsquare by bitsquare.

the class TradeProtocol method cleanupTradable.

private void cleanupTradable() {
    Trade.State tradeState = trade.getState();
    log.debug("cleanupTradable tradeState=" + tradeState);
    boolean isOffererTrade = trade instanceof OffererTrade;
    if (isOffererTrade && (tradeState == Trade.State.OFFERER_SENT_PUBLISH_DEPOSIT_TX_REQUEST || tradeState == Trade.State.DEPOSIT_SEEN_IN_NETWORK))
        processModel.getOpenOfferManager().closeOpenOffer(trade.getOffer());
    //boolean isTakerTrade = trade instanceof TakerTrade;
    // if (isTakerTrade) {
    TradeManager tradeManager = processModel.getTradeManager();
    if (tradeState.getPhase() == Trade.Phase.PREPARATION) {
        tradeManager.removePreparedTrade(trade);
    } else if (tradeState.getPhase() == Trade.Phase.TAKER_FEE_PAID) {
        tradeManager.addTradeToFailedTrades(trade);
        processModel.getWalletService().swapAnyTradeEntryContextToAvailableEntry(trade.getId());
    }
// }
}
Also used : TradeManager(io.bitsquare.trade.TradeManager) OffererTrade(io.bitsquare.trade.OffererTrade) Trade(io.bitsquare.trade.Trade) OffererTrade(io.bitsquare.trade.OffererTrade)

Aggregations

OffererTrade (io.bitsquare.trade.OffererTrade)2 Trade (io.bitsquare.trade.Trade)1 TradeManager (io.bitsquare.trade.TradeManager)1 DepositTxPublishedMessage (io.bitsquare.trade.protocol.trade.messages.DepositTxPublishedMessage)1 Transaction (org.bitcoinj.core.Transaction)1