mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-04-20 23:56:30 -04:00
Support offerer offline at payout tx with mailbox
This commit is contained in:
parent
12bea799f3
commit
02c9035af5
@ -583,11 +583,11 @@ public class TradeManager {
|
||||
mailboxMessages.put(tradeId, mailboxMessage);
|
||||
log.trace("mailboxMessage with tradeID " + tradeId);
|
||||
if (takerAsSellerProtocolMap.containsKey(tradeId)) {
|
||||
takerAsSellerProtocolMap.get(tradeId).setMailboxMessage(encrypted);
|
||||
takerAsSellerProtocolMap.get(tradeId).setMailboxMessage(mailboxMessage);
|
||||
log.trace("sellerAsTakerProtocolMap exist with tradeID " + tradeId);
|
||||
}
|
||||
if (offererAsBuyerProtocolMap.containsKey(tradeId)) {
|
||||
offererAsBuyerProtocolMap.get(tradeId).setMailboxMessage(encrypted);
|
||||
offererAsBuyerProtocolMap.get(tradeId).setMailboxMessage(mailboxMessage);
|
||||
log.trace("buyerAcceptsOfferProtocolMap exist with tradeID " + tradeId);
|
||||
}
|
||||
}
|
||||
|
@ -26,12 +26,12 @@ public class RequestDepositTxInputsMessage extends TradeMessage implements Seria
|
||||
|
||||
public final Coin tradeAmount;
|
||||
public final String takeOfferFeeTxId;
|
||||
public final byte[] takerPubKey;
|
||||
public final byte[] takerTradeWalletPubKey;
|
||||
|
||||
public RequestDepositTxInputsMessage(String tradeId, String takeOfferFeeTxId, Coin tradeAmount, byte[] takerPubKey) {
|
||||
public RequestDepositTxInputsMessage(String tradeId, String takeOfferFeeTxId, Coin tradeAmount, byte[] takerTradeWalletPubKey) {
|
||||
this.tradeId = tradeId;
|
||||
this.takeOfferFeeTxId = takeOfferFeeTxId;
|
||||
this.tradeAmount = tradeAmount;
|
||||
this.takerPubKey = takerPubKey;
|
||||
this.takerTradeWalletPubKey = takerTradeWalletPubKey;
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ import org.bitcoinj.core.TransactionOutput;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.security.PublicKey;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RequestTakerDepositPaymentMessage extends TradeMessage implements Serializable {
|
||||
@ -30,20 +32,28 @@ public class RequestTakerDepositPaymentMessage extends TradeMessage implements S
|
||||
|
||||
public final List<TransactionOutput> offererConnectedOutputsForAllInputs;
|
||||
public final List<TransactionOutput> offererOutputs;
|
||||
public final byte[] offererPubKey;
|
||||
public final byte[] offererTradeWalletPubKey;
|
||||
public final PublicKey offererP2PSigPublicKey;
|
||||
public final PublicKey offererP2PEncryptPublicKey;
|
||||
|
||||
|
||||
public final FiatAccount offererFiatAccount;
|
||||
public final String offererAccountId;
|
||||
|
||||
public RequestTakerDepositPaymentMessage(String tradeId,
|
||||
List<TransactionOutput> offererConnectedOutputsForAllInputs,
|
||||
List<TransactionOutput> offererOutputs,
|
||||
byte[] offererPubKey,
|
||||
byte[] offererTradeWalletPubKey,
|
||||
PublicKey offererP2PSigPublicKey,
|
||||
PublicKey offererP2PEncryptPublicKey,
|
||||
FiatAccount offererFiatAccount,
|
||||
String offererAccountId) {
|
||||
this.offererP2PSigPublicKey = offererP2PSigPublicKey;
|
||||
this.offererP2PEncryptPublicKey = offererP2PEncryptPublicKey;
|
||||
this.tradeId = tradeId;
|
||||
this.offererConnectedOutputsForAllInputs = offererConnectedOutputsForAllInputs;
|
||||
this.offererOutputs = offererOutputs;
|
||||
this.offererPubKey = offererPubKey;
|
||||
this.offererTradeWalletPubKey = offererTradeWalletPubKey;
|
||||
this.offererFiatAccount = offererFiatAccount;
|
||||
this.offererAccountId = offererAccountId;
|
||||
}
|
||||
|
@ -38,10 +38,11 @@ public class Offerer implements Serializable {
|
||||
transient public FiatAccount fiatAccount;
|
||||
transient public String accountId;
|
||||
transient public PublicKey p2pSigPubKey;
|
||||
transient public PublicKey p2pEncryptPubKey;
|
||||
transient public byte[] registrationPubKey;
|
||||
transient public DeterministicKey registrationKeyPair;
|
||||
transient public AddressEntry addressEntry;
|
||||
transient public byte[] pubKey;
|
||||
transient public byte[] tradeWalletPubKey;
|
||||
|
||||
// written by tasks
|
||||
public byte[] payoutTxSignature;
|
||||
|
@ -82,7 +82,8 @@ public class OffererAsBuyerModel extends SharedTradeModel implements Serializabl
|
||||
offerer.fiatAccount = user.getBankAccount(offer.getBankAccountId());
|
||||
offerer.accountId = user.getAccountId();
|
||||
offerer.p2pSigPubKey = user.getP2PSigPubKey();
|
||||
offerer.pubKey = offerer.addressEntry.getPubKey();
|
||||
offerer.p2pEncryptPubKey = user.getP2PEncryptPubKey();
|
||||
offerer.tradeWalletPubKey = offerer.addressEntry.getPubKey();
|
||||
log.debug("BuyerAsOffererModel addressEntry " + offerer.addressEntry);
|
||||
}
|
||||
|
||||
|
@ -45,5 +45,5 @@ public class Taker implements Serializable {
|
||||
public Transaction preparedDepositTx;
|
||||
public List<TransactionOutput> connectedOutputsForAllInputs;
|
||||
public String payoutAddressString;
|
||||
public byte[] pubKey;
|
||||
public byte[] tradeWalletPubKey;
|
||||
}
|
||||
|
@ -48,8 +48,8 @@ public class CreateAndSignPayoutTx extends Task<OffererAsBuyerModel> {
|
||||
takerPayoutAmount,
|
||||
model.offerer.addressEntry,
|
||||
model.taker.payoutAddressString,
|
||||
model.offerer.pubKey,
|
||||
model.taker.pubKey,
|
||||
model.offerer.tradeWalletPubKey,
|
||||
model.taker.tradeWalletPubKey,
|
||||
model.arbitratorPubKey);
|
||||
|
||||
model.offerer.payoutTxSignature = offererPayoutTxSignature;
|
||||
|
@ -45,7 +45,7 @@ public class ProcessRequestDepositTxInputsMessage extends Task<OffererAsBuyerMod
|
||||
|
||||
trade.setTradeAmount(positiveCoinOf(nonZeroCoinOf(requestDepositTxInputsMessage.tradeAmount)));
|
||||
model.setTakeOfferFeeTxId(nonEmptyStringOf(requestDepositTxInputsMessage.takeOfferFeeTxId));
|
||||
model.taker.pubKey = checkNotNull(requestDepositTxInputsMessage.takerPubKey);
|
||||
model.taker.tradeWalletPubKey = checkNotNull(requestDepositTxInputsMessage.takerTradeWalletPubKey);
|
||||
|
||||
complete();
|
||||
} catch (Throwable t) {
|
||||
|
@ -39,7 +39,9 @@ public class RequestTakerDepositPayment extends Task<OffererAsBuyerModel> {
|
||||
model.id,
|
||||
model.offerer.connectedOutputsForAllInputs,
|
||||
model.offerer.outputs,
|
||||
model.offerer.pubKey,
|
||||
model.offerer.tradeWalletPubKey,
|
||||
model.offerer.p2pSigPubKey,
|
||||
model.offerer.p2pEncryptPubKey,
|
||||
model.offerer.fiatAccount,
|
||||
model.offerer.accountId);
|
||||
|
||||
|
@ -50,8 +50,8 @@ public class SignAndPublishDepositTx extends Task<OffererAsBuyerModel> {
|
||||
model.taker.connectedOutputsForAllInputs,
|
||||
model.offerer.outputs,
|
||||
offererInputAmount,
|
||||
model.offerer.pubKey,
|
||||
model.taker.pubKey,
|
||||
model.offerer.tradeWalletPubKey,
|
||||
model.taker.tradeWalletPubKey,
|
||||
model.arbitratorPubKey,
|
||||
new FutureCallback<Transaction>() {
|
||||
@Override
|
||||
|
@ -25,6 +25,8 @@ import org.bitcoinj.core.TransactionOutput;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.security.PublicKey;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Offerer implements Serializable {
|
||||
@ -35,7 +37,7 @@ public class Offerer implements Serializable {
|
||||
public Peer peer;
|
||||
|
||||
// written by tasks
|
||||
public byte[] pubKey;
|
||||
public byte[] tradeWalletPubKey;
|
||||
public Coin payoutAmount;
|
||||
public String payoutAddressString;
|
||||
public List<TransactionOutput> connectedOutputsForAllInputs;
|
||||
@ -43,5 +45,7 @@ public class Offerer implements Serializable {
|
||||
public byte[] signature;
|
||||
public FiatAccount fiatAccount;
|
||||
public String accountId;
|
||||
public PublicKey p2pSigPublicKey;
|
||||
public PublicKey p2pEncryptPubKey;
|
||||
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public class Taker implements Serializable {
|
||||
transient public byte[] registrationPubKey; // TODO not read yet, missing impl.
|
||||
transient public DeterministicKey registrationKeyPair;
|
||||
transient public AddressEntry addressEntry;
|
||||
transient public byte[] pubKey;
|
||||
transient public byte[] tradeWalletPubKey;
|
||||
|
||||
// written by tasks
|
||||
public List<TransactionOutput> connectedOutputsForAllInputs;
|
||||
|
@ -91,7 +91,7 @@ public class TakerAsSellerModel extends SharedTradeModel implements Serializable
|
||||
taker.accountId = user.getAccountId();
|
||||
taker.p2pSigPubKey = user.getP2PSigPubKey();
|
||||
taker.p2pEncryptPublicKey = user.getP2PEncryptPubKey();
|
||||
taker.pubKey = taker.addressEntry.getPubKey();
|
||||
taker.tradeWalletPubKey = taker.addressEntry.getPubKey();
|
||||
}
|
||||
|
||||
// Get called form taskRunner after each completed task
|
||||
|
@ -44,7 +44,9 @@ public class ProcessRequestTakerDepositPaymentMessage extends Task<TakerAsSeller
|
||||
model.offerer.connectedOutputsForAllInputs = checkNotNull(message.offererConnectedOutputsForAllInputs);
|
||||
checkArgument(message.offererConnectedOutputsForAllInputs.size() > 0);
|
||||
model.offerer.outputs = checkNotNull(message.offererOutputs);
|
||||
model.offerer.pubKey = checkNotNull(message.offererPubKey);
|
||||
model.offerer.tradeWalletPubKey = checkNotNull(message.offererTradeWalletPubKey);
|
||||
model.offerer.p2pSigPublicKey = checkNotNull(message.offererP2PSigPublicKey);
|
||||
model.offerer.p2pEncryptPubKey = checkNotNull(message.offererP2PEncryptPublicKey);
|
||||
model.offerer.fiatAccount = checkNotNull(message.offererFiatAccount);
|
||||
model.offerer.accountId = nonEmptyStringOf(message.offererAccountId);
|
||||
|
||||
|
@ -36,7 +36,11 @@ public class SendPayoutTxToOfferer extends Task<TakerAsSellerModel> {
|
||||
@Override
|
||||
protected void doRun() {
|
||||
PayoutTxPublishedMessage tradeMessage = new PayoutTxPublishedMessage(model.id, model.getPayoutTx());
|
||||
model.messageService.sendMessage(model.offerer.peer, tradeMessage, new SendMessageListener() {
|
||||
model.messageService.sendMessage(model.offerer.peer,
|
||||
tradeMessage,
|
||||
model.offerer.p2pSigPublicKey,
|
||||
model.offerer.p2pEncryptPubKey,
|
||||
new SendMessageListener() {
|
||||
@Override
|
||||
public void handleResult() {
|
||||
log.trace("PayoutTxPublishedMessage successfully arrived at peer");
|
||||
|
@ -44,7 +44,7 @@ public class SendRequestDepositTxInputsMessage extends Task<TakerAsSellerModel>
|
||||
model.id,
|
||||
model.getTakeOfferFeeTx().getHashAsString(),
|
||||
model.trade.getTradeAmount(),
|
||||
model.taker.pubKey
|
||||
model.taker.tradeWalletPubKey
|
||||
);
|
||||
|
||||
model.messageService.sendMessage(model.offerer.peer, msg, new SendMessageListener() {
|
||||
|
@ -48,8 +48,8 @@ public class SignAndPublishPayoutTx extends Task<TakerAsSellerModel> {
|
||||
model.taker.payoutAmount,
|
||||
model.offerer.payoutAddressString,
|
||||
model.taker.addressEntry,
|
||||
model.offerer.pubKey,
|
||||
model.taker.pubKey,
|
||||
model.offerer.tradeWalletPubKey,
|
||||
model.taker.tradeWalletPubKey,
|
||||
model.arbitratorPubKey,
|
||||
new FutureCallback<Transaction>() {
|
||||
@Override
|
||||
|
@ -48,8 +48,8 @@ public class TakerCreatesAndSignsDepositTx extends Task<TakerAsSellerModel> {
|
||||
model.offerer.connectedOutputsForAllInputs,
|
||||
model.offerer.outputs,
|
||||
model.taker.addressEntry,
|
||||
model.offerer.pubKey,
|
||||
model.taker.pubKey,
|
||||
model.offerer.tradeWalletPubKey,
|
||||
model.taker.tradeWalletPubKey,
|
||||
model.arbitratorPubKey);
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user