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);
}
}
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());
}
// }
}
Aggregations