use of io.bitsquare.trade.protocol.trade.messages.PublishDepositTxRequest in project bitsquare by bitsquare.
the class SendPublishDepositTxRequest method run.
@Override
protected void run() {
try {
runInterceptHook();
WalletService walletService = processModel.getWalletService();
AddressEntry offererMultiSigAddressEntry = walletService.getOrCreateAddressEntry(processModel.getOffer().getId(), AddressEntry.Context.MULTI_SIG);
AddressEntry offererPayoutAddressEntry = walletService.getOrCreateAddressEntry(processModel.getOffer().getId(), AddressEntry.Context.TRADE_PAYOUT);
PublishDepositTxRequest tradeMessage = new PublishDepositTxRequest(processModel.getId(), processModel.getPaymentAccountContractData(trade), processModel.getAccountId(), offererMultiSigAddressEntry.getPubKey(), trade.getContractAsJson(), trade.getOffererContractSignature(), offererPayoutAddressEntry.getAddressString(), processModel.getPreparedDepositTx(), processModel.getRawTransactionInputs());
processModel.getP2PService().sendEncryptedDirectMessage(trade.getTradingPeerNodeAddress(), processModel.tradingPeer.getPubKeyRing(), tradeMessage, new SendDirectMessageListener() {
@Override
public void onArrived() {
log.trace("Message arrived at peer.");
trade.setState(Trade.State.OFFERER_SENT_PUBLISH_DEPOSIT_TX_REQUEST);
complete();
}
@Override
public void onFault() {
appendToErrorMessage("PublishDepositTxRequest sending failed");
failed();
}
});
} catch (Throwable t) {
failed(t);
}
}
use of io.bitsquare.trade.protocol.trade.messages.PublishDepositTxRequest in project bitsquare by bitsquare.
the class ProcessPublishDepositTxRequest method run.
@Override
protected void run() {
try {
runInterceptHook();
log.debug("current trade state " + trade.getState());
PublishDepositTxRequest publishDepositTxRequest = (PublishDepositTxRequest) processModel.getTradeMessage();
checkTradeId(processModel.getId(), publishDepositTxRequest);
checkNotNull(publishDepositTxRequest);
PaymentAccountContractData paymentAccountContractData = checkNotNull(publishDepositTxRequest.offererPaymentAccountContractData);
final PaymentAccountFilter[] appliedPaymentAccountFilter = new PaymentAccountFilter[1];
if (processModel.isPeersPaymentAccountDataAreBanned(paymentAccountContractData, appliedPaymentAccountFilter)) {
failed("Other trader is banned by his trading account data.\n" + "paymentAccountContractData=" + paymentAccountContractData.getPaymentDetails() + "\n" + "banFilter=" + appliedPaymentAccountFilter[0].toString());
return;
}
processModel.tradingPeer.setPaymentAccountContractData(paymentAccountContractData);
processModel.tradingPeer.setAccountId(nonEmptyStringOf(publishDepositTxRequest.offererAccountId));
processModel.tradingPeer.setMultiSigPubKey(checkNotNull(publishDepositTxRequest.offererMultiSigPubKey));
processModel.tradingPeer.setContractAsJson(nonEmptyStringOf(publishDepositTxRequest.offererContractAsJson));
processModel.tradingPeer.setContractSignature(nonEmptyStringOf(publishDepositTxRequest.offererContractSignature));
processModel.tradingPeer.setPayoutAddressString(nonEmptyStringOf(publishDepositTxRequest.offererPayoutAddressString));
processModel.tradingPeer.setRawTransactionInputs(checkNotNull(publishDepositTxRequest.offererInputs));
processModel.setPreparedDepositTx(checkNotNull(publishDepositTxRequest.preparedDepositTx));
checkArgument(publishDepositTxRequest.offererInputs.size() > 0);
// update to the latest peer address of our peer if the message is correct
trade.setTradingPeerNodeAddress(processModel.getTempTradingPeerNodeAddress());
complete();
} catch (Throwable t) {
failed(t);
}
}
Aggregations