use of io.bitsquare.p2p.messaging.SendMailboxMessageListener in project bitsquare by bitsquare.
the class SendPayDepositRequest method run.
@Override
protected void run() {
try {
runInterceptHook();
checkNotNull(trade.getTradeAmount(), "TradeAmount must not be null");
checkNotNull(trade.getTakeOfferFeeTxId(), "TakeOfferFeeTxId must not be null");
WalletService walletService = processModel.getWalletService();
AddressEntry takerMultiSigPubKeyAddressEntry = walletService.getOrCreateAddressEntry(processModel.getOffer().getId(), AddressEntry.Context.MULTI_SIG);
AddressEntry takerPayoutAddressEntry = walletService.getOrCreateAddressEntry(processModel.getOffer().getId(), AddressEntry.Context.TRADE_PAYOUT);
byte[] takerMultiSigPubKey = takerMultiSigPubKeyAddressEntry.getPubKey();
String takerPayoutAddressString = takerPayoutAddressEntry.getAddressString();
PayDepositRequest payDepositRequest = new PayDepositRequest(processModel.getMyNodeAddress(), processModel.getId(), trade.getTradeAmount().value, trade.getTradePrice().value, processModel.getRawTransactionInputs(), processModel.getChangeOutputValue(), processModel.getChangeOutputAddress(), takerMultiSigPubKey, takerPayoutAddressString, processModel.getPubKeyRing(), processModel.getPaymentAccountContractData(trade), processModel.getAccountId(), trade.getTakeOfferFeeTxId(), new ArrayList<>(processModel.getUser().getAcceptedArbitratorAddresses()), trade.getArbitratorNodeAddress());
processModel.getP2PService().sendEncryptedMailboxMessage(trade.getTradingPeerNodeAddress(), processModel.tradingPeer.getPubKeyRing(), payDepositRequest, new SendMailboxMessageListener() {
@Override
public void onArrived() {
log.trace("Message arrived at peer.");
complete();
}
@Override
public void onStoredInMailbox() {
log.trace("Message stored in mailbox.");
complete();
}
@Override
public void onFault(String errorMessage) {
appendToErrorMessage("PayDepositRequest sending failed");
failed();
}
});
} catch (Throwable t) {
failed(t);
}
}
Aggregations