use of bisq.core.trade.messages.PayoutTxPublishedMessage in project bisq-core by bisq-network.
the class BuyerAsMakerProtocol method doApplyMailboxMessage.
// /////////////////////////////////////////////////////////////////////////////////////////
// Mailbox
// /////////////////////////////////////////////////////////////////////////////////////////
@Override
public void doApplyMailboxMessage(NetworkEnvelope networkEnvelop, Trade trade) {
this.trade = trade;
if (networkEnvelop instanceof MailboxMessage) {
MailboxMessage mailboxMessage = (MailboxMessage) networkEnvelop;
NodeAddress peerNodeAddress = mailboxMessage.getSenderNodeAddress();
if (networkEnvelop instanceof DepositTxPublishedMessage)
handle((DepositTxPublishedMessage) networkEnvelop, peerNodeAddress);
else if (networkEnvelop instanceof PayoutTxPublishedMessage)
handle((PayoutTxPublishedMessage) networkEnvelop, peerNodeAddress);
else
log.error("We received an unhandled MailboxMessage" + networkEnvelop.toString());
}
}
use of bisq.core.trade.messages.PayoutTxPublishedMessage in project bisq-core by bisq-network.
the class SellerSendPayoutTxPublishedMessage method run.
@Override
protected void run() {
try {
runInterceptHook();
if (trade.getPayoutTx() != null) {
final String id = processModel.getOfferId();
final PayoutTxPublishedMessage message = new PayoutTxPublishedMessage(id, trade.getPayoutTx().bitcoinSerialize(), processModel.getMyNodeAddress(), UUID.randomUUID().toString());
trade.setState(Trade.State.SELLER_SENT_PAYOUT_TX_PUBLISHED_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.SELLER_SAW_ARRIVED_PAYOUT_TX_PUBLISHED_MSG);
complete();
}
@Override
public void onStoredInMailbox() {
log.info("Message stored in mailbox. tradeId={}", id);
trade.setState(Trade.State.SELLER_STORED_IN_MAILBOX_PAYOUT_TX_PUBLISHED_MSG);
complete();
}
@Override
public void onFault(String errorMessage) {
log.error("sendEncryptedMailboxMessage failed. message=" + message);
trade.setState(Trade.State.SELLER_SEND_FAILED_PAYOUT_TX_PUBLISHED_MSG);
appendToErrorMessage("Sending message failed: message=" + message + "\nerrorMessage=" + errorMessage);
failed(errorMessage);
}
});
} else {
log.error("trade.getPayoutTx() = " + trade.getPayoutTx());
failed("PayoutTx is null");
}
} catch (Throwable t) {
failed(t);
}
}
use of bisq.core.trade.messages.PayoutTxPublishedMessage in project bisq-core by bisq-network.
the class BuyerProcessPayoutTxPublishedMessage method run.
@Override
protected void run() {
try {
runInterceptHook();
log.debug("current trade state " + trade.getState());
PayoutTxPublishedMessage message = (PayoutTxPublishedMessage) processModel.getTradeMessage();
Validator.checkTradeId(processModel.getOfferId(), message);
checkNotNull(message);
checkArgument(message.getPayoutTx() != null);
// update to the latest peer address of our peer if the message is correct
trade.setTradingPeerNodeAddress(processModel.getTempTradingPeerNodeAddress());
if (trade.getPayoutTx() == null) {
Transaction walletTx = processModel.getTradeWalletService().addTxToWallet(message.getPayoutTx());
trade.setPayoutTx(walletTx);
BtcWalletService.printTx("payoutTx received from peer", walletTx);
trade.setState(Trade.State.BUYER_RECEIVED_PAYOUT_TX_PUBLISHED_MSG);
processModel.getBtcWalletService().swapTradeEntryToAvailableEntry(trade.getId(), AddressEntry.Context.MULTI_SIG);
} else {
log.info("We got the payout tx already set from BuyerSetupPayoutTxListener and do nothing here. trade ID={}", trade.getId());
}
processModel.removeMailboxMessageAfterProcessing(trade);
complete();
} catch (Throwable t) {
failed(t);
}
}
use of bisq.core.trade.messages.PayoutTxPublishedMessage in project bisq-core by bisq-network.
the class BuyerAsTakerProtocol method doApplyMailboxMessage.
// /////////////////////////////////////////////////////////////////////////////////////////
// Mailbox
// /////////////////////////////////////////////////////////////////////////////////////////
@Override
public void doApplyMailboxMessage(NetworkEnvelope networkEnvelop, Trade trade) {
this.trade = trade;
final NodeAddress senderNodeAddress = ((MailboxMessage) networkEnvelop).getSenderNodeAddress();
if (networkEnvelop instanceof PublishDepositTxRequest)
handle((PublishDepositTxRequest) networkEnvelop, senderNodeAddress);
else if (networkEnvelop instanceof PayoutTxPublishedMessage) {
handle((PayoutTxPublishedMessage) networkEnvelop, senderNodeAddress);
} else
log.error("We received an unhandled MailboxMessage" + networkEnvelop.toString());
}
Aggregations