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