Support offerer offline at payout tx with mailbox

This commit is contained in:
Manfred Karrer 2015-03-21 12:10:40 +01:00
parent 12bea799f3
commit 02c9035af5
18 changed files with 51 additions and 27 deletions

View file

@ -583,11 +583,11 @@ public class TradeManager {
mailboxMessages.put(tradeId, mailboxMessage); mailboxMessages.put(tradeId, mailboxMessage);
log.trace("mailboxMessage with tradeID " + tradeId); log.trace("mailboxMessage with tradeID " + tradeId);
if (takerAsSellerProtocolMap.containsKey(tradeId)) { if (takerAsSellerProtocolMap.containsKey(tradeId)) {
takerAsSellerProtocolMap.get(tradeId).setMailboxMessage(encrypted); takerAsSellerProtocolMap.get(tradeId).setMailboxMessage(mailboxMessage);
log.trace("sellerAsTakerProtocolMap exist with tradeID " + tradeId); log.trace("sellerAsTakerProtocolMap exist with tradeID " + tradeId);
} }
if (offererAsBuyerProtocolMap.containsKey(tradeId)) { if (offererAsBuyerProtocolMap.containsKey(tradeId)) {
offererAsBuyerProtocolMap.get(tradeId).setMailboxMessage(encrypted); offererAsBuyerProtocolMap.get(tradeId).setMailboxMessage(mailboxMessage);
log.trace("buyerAcceptsOfferProtocolMap exist with tradeID " + tradeId); log.trace("buyerAcceptsOfferProtocolMap exist with tradeID " + tradeId);
} }
} }

View file

@ -26,12 +26,12 @@ public class RequestDepositTxInputsMessage extends TradeMessage implements Seria
public final Coin tradeAmount; public final Coin tradeAmount;
public final String takeOfferFeeTxId; 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.tradeId = tradeId;
this.takeOfferFeeTxId = takeOfferFeeTxId; this.takeOfferFeeTxId = takeOfferFeeTxId;
this.tradeAmount = tradeAmount; this.tradeAmount = tradeAmount;
this.takerPubKey = takerPubKey; this.takerTradeWalletPubKey = takerTradeWalletPubKey;
} }
} }

View file

@ -23,6 +23,8 @@ import org.bitcoinj.core.TransactionOutput;
import java.io.Serializable; import java.io.Serializable;
import java.security.PublicKey;
import java.util.List; import java.util.List;
public class RequestTakerDepositPaymentMessage extends TradeMessage implements Serializable { 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> offererConnectedOutputsForAllInputs;
public final List<TransactionOutput> offererOutputs; 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 FiatAccount offererFiatAccount;
public final String offererAccountId; public final String offererAccountId;
public RequestTakerDepositPaymentMessage(String tradeId, public RequestTakerDepositPaymentMessage(String tradeId,
List<TransactionOutput> offererConnectedOutputsForAllInputs, List<TransactionOutput> offererConnectedOutputsForAllInputs,
List<TransactionOutput> offererOutputs, List<TransactionOutput> offererOutputs,
byte[] offererPubKey, byte[] offererTradeWalletPubKey,
PublicKey offererP2PSigPublicKey,
PublicKey offererP2PEncryptPublicKey,
FiatAccount offererFiatAccount, FiatAccount offererFiatAccount,
String offererAccountId) { String offererAccountId) {
this.offererP2PSigPublicKey = offererP2PSigPublicKey;
this.offererP2PEncryptPublicKey = offererP2PEncryptPublicKey;
this.tradeId = tradeId; this.tradeId = tradeId;
this.offererConnectedOutputsForAllInputs = offererConnectedOutputsForAllInputs; this.offererConnectedOutputsForAllInputs = offererConnectedOutputsForAllInputs;
this.offererOutputs = offererOutputs; this.offererOutputs = offererOutputs;
this.offererPubKey = offererPubKey; this.offererTradeWalletPubKey = offererTradeWalletPubKey;
this.offererFiatAccount = offererFiatAccount; this.offererFiatAccount = offererFiatAccount;
this.offererAccountId = offererAccountId; this.offererAccountId = offererAccountId;
} }

View file

@ -38,10 +38,11 @@ public class Offerer implements Serializable {
transient public FiatAccount fiatAccount; transient public FiatAccount fiatAccount;
transient public String accountId; transient public String accountId;
transient public PublicKey p2pSigPubKey; transient public PublicKey p2pSigPubKey;
transient public PublicKey p2pEncryptPubKey;
transient public byte[] registrationPubKey; transient public byte[] registrationPubKey;
transient public DeterministicKey registrationKeyPair; transient public DeterministicKey registrationKeyPair;
transient public AddressEntry addressEntry; transient public AddressEntry addressEntry;
transient public byte[] pubKey; transient public byte[] tradeWalletPubKey;
// written by tasks // written by tasks
public byte[] payoutTxSignature; public byte[] payoutTxSignature;

View file

@ -82,7 +82,8 @@ public class OffererAsBuyerModel extends SharedTradeModel implements Serializabl
offerer.fiatAccount = user.getBankAccount(offer.getBankAccountId()); offerer.fiatAccount = user.getBankAccount(offer.getBankAccountId());
offerer.accountId = user.getAccountId(); offerer.accountId = user.getAccountId();
offerer.p2pSigPubKey = user.getP2PSigPubKey(); offerer.p2pSigPubKey = user.getP2PSigPubKey();
offerer.pubKey = offerer.addressEntry.getPubKey(); offerer.p2pEncryptPubKey = user.getP2PEncryptPubKey();
offerer.tradeWalletPubKey = offerer.addressEntry.getPubKey();
log.debug("BuyerAsOffererModel addressEntry " + offerer.addressEntry); log.debug("BuyerAsOffererModel addressEntry " + offerer.addressEntry);
} }

View file

@ -45,5 +45,5 @@ public class Taker implements Serializable {
public Transaction preparedDepositTx; public Transaction preparedDepositTx;
public List<TransactionOutput> connectedOutputsForAllInputs; public List<TransactionOutput> connectedOutputsForAllInputs;
public String payoutAddressString; public String payoutAddressString;
public byte[] pubKey; public byte[] tradeWalletPubKey;
} }

View file

@ -48,8 +48,8 @@ public class CreateAndSignPayoutTx extends Task<OffererAsBuyerModel> {
takerPayoutAmount, takerPayoutAmount,
model.offerer.addressEntry, model.offerer.addressEntry,
model.taker.payoutAddressString, model.taker.payoutAddressString,
model.offerer.pubKey, model.offerer.tradeWalletPubKey,
model.taker.pubKey, model.taker.tradeWalletPubKey,
model.arbitratorPubKey); model.arbitratorPubKey);
model.offerer.payoutTxSignature = offererPayoutTxSignature; model.offerer.payoutTxSignature = offererPayoutTxSignature;

View file

@ -45,7 +45,7 @@ public class ProcessRequestDepositTxInputsMessage extends Task<OffererAsBuyerMod
trade.setTradeAmount(positiveCoinOf(nonZeroCoinOf(requestDepositTxInputsMessage.tradeAmount))); trade.setTradeAmount(positiveCoinOf(nonZeroCoinOf(requestDepositTxInputsMessage.tradeAmount)));
model.setTakeOfferFeeTxId(nonEmptyStringOf(requestDepositTxInputsMessage.takeOfferFeeTxId)); model.setTakeOfferFeeTxId(nonEmptyStringOf(requestDepositTxInputsMessage.takeOfferFeeTxId));
model.taker.pubKey = checkNotNull(requestDepositTxInputsMessage.takerPubKey); model.taker.tradeWalletPubKey = checkNotNull(requestDepositTxInputsMessage.takerTradeWalletPubKey);
complete(); complete();
} catch (Throwable t) { } catch (Throwable t) {

View file

@ -39,7 +39,9 @@ public class RequestTakerDepositPayment extends Task<OffererAsBuyerModel> {
model.id, model.id,
model.offerer.connectedOutputsForAllInputs, model.offerer.connectedOutputsForAllInputs,
model.offerer.outputs, model.offerer.outputs,
model.offerer.pubKey, model.offerer.tradeWalletPubKey,
model.offerer.p2pSigPubKey,
model.offerer.p2pEncryptPubKey,
model.offerer.fiatAccount, model.offerer.fiatAccount,
model.offerer.accountId); model.offerer.accountId);

View file

@ -50,8 +50,8 @@ public class SignAndPublishDepositTx extends Task<OffererAsBuyerModel> {
model.taker.connectedOutputsForAllInputs, model.taker.connectedOutputsForAllInputs,
model.offerer.outputs, model.offerer.outputs,
offererInputAmount, offererInputAmount,
model.offerer.pubKey, model.offerer.tradeWalletPubKey,
model.taker.pubKey, model.taker.tradeWalletPubKey,
model.arbitratorPubKey, model.arbitratorPubKey,
new FutureCallback<Transaction>() { new FutureCallback<Transaction>() {
@Override @Override

View file

@ -25,6 +25,8 @@ import org.bitcoinj.core.TransactionOutput;
import java.io.Serializable; import java.io.Serializable;
import java.security.PublicKey;
import java.util.List; import java.util.List;
public class Offerer implements Serializable { public class Offerer implements Serializable {
@ -35,7 +37,7 @@ public class Offerer implements Serializable {
public Peer peer; public Peer peer;
// written by tasks // written by tasks
public byte[] pubKey; public byte[] tradeWalletPubKey;
public Coin payoutAmount; public Coin payoutAmount;
public String payoutAddressString; public String payoutAddressString;
public List<TransactionOutput> connectedOutputsForAllInputs; public List<TransactionOutput> connectedOutputsForAllInputs;
@ -43,5 +45,7 @@ public class Offerer implements Serializable {
public byte[] signature; public byte[] signature;
public FiatAccount fiatAccount; public FiatAccount fiatAccount;
public String accountId; public String accountId;
public PublicKey p2pSigPublicKey;
public PublicKey p2pEncryptPubKey;
} }

View file

@ -43,7 +43,7 @@ public class Taker implements Serializable {
transient public byte[] registrationPubKey; // TODO not read yet, missing impl. transient public byte[] registrationPubKey; // TODO not read yet, missing impl.
transient public DeterministicKey registrationKeyPair; transient public DeterministicKey registrationKeyPair;
transient public AddressEntry addressEntry; transient public AddressEntry addressEntry;
transient public byte[] pubKey; transient public byte[] tradeWalletPubKey;
// written by tasks // written by tasks
public List<TransactionOutput> connectedOutputsForAllInputs; public List<TransactionOutput> connectedOutputsForAllInputs;

View file

@ -91,7 +91,7 @@ public class TakerAsSellerModel extends SharedTradeModel implements Serializable
taker.accountId = user.getAccountId(); taker.accountId = user.getAccountId();
taker.p2pSigPubKey = user.getP2PSigPubKey(); taker.p2pSigPubKey = user.getP2PSigPubKey();
taker.p2pEncryptPublicKey = user.getP2PEncryptPubKey(); taker.p2pEncryptPublicKey = user.getP2PEncryptPubKey();
taker.pubKey = taker.addressEntry.getPubKey(); taker.tradeWalletPubKey = taker.addressEntry.getPubKey();
} }
// Get called form taskRunner after each completed task // Get called form taskRunner after each completed task

View file

@ -44,7 +44,9 @@ public class ProcessRequestTakerDepositPaymentMessage extends Task<TakerAsSeller
model.offerer.connectedOutputsForAllInputs = checkNotNull(message.offererConnectedOutputsForAllInputs); model.offerer.connectedOutputsForAllInputs = checkNotNull(message.offererConnectedOutputsForAllInputs);
checkArgument(message.offererConnectedOutputsForAllInputs.size() > 0); checkArgument(message.offererConnectedOutputsForAllInputs.size() > 0);
model.offerer.outputs = checkNotNull(message.offererOutputs); 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.fiatAccount = checkNotNull(message.offererFiatAccount);
model.offerer.accountId = nonEmptyStringOf(message.offererAccountId); model.offerer.accountId = nonEmptyStringOf(message.offererAccountId);

View file

@ -36,7 +36,11 @@ public class SendPayoutTxToOfferer extends Task<TakerAsSellerModel> {
@Override @Override
protected void doRun() { protected void doRun() {
PayoutTxPublishedMessage tradeMessage = new PayoutTxPublishedMessage(model.id, model.getPayoutTx()); 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 @Override
public void handleResult() { public void handleResult() {
log.trace("PayoutTxPublishedMessage successfully arrived at peer"); log.trace("PayoutTxPublishedMessage successfully arrived at peer");

View file

@ -44,7 +44,7 @@ public class SendRequestDepositTxInputsMessage extends Task<TakerAsSellerModel>
model.id, model.id,
model.getTakeOfferFeeTx().getHashAsString(), model.getTakeOfferFeeTx().getHashAsString(),
model.trade.getTradeAmount(), model.trade.getTradeAmount(),
model.taker.pubKey model.taker.tradeWalletPubKey
); );
model.messageService.sendMessage(model.offerer.peer, msg, new SendMessageListener() { model.messageService.sendMessage(model.offerer.peer, msg, new SendMessageListener() {

View file

@ -48,8 +48,8 @@ public class SignAndPublishPayoutTx extends Task<TakerAsSellerModel> {
model.taker.payoutAmount, model.taker.payoutAmount,
model.offerer.payoutAddressString, model.offerer.payoutAddressString,
model.taker.addressEntry, model.taker.addressEntry,
model.offerer.pubKey, model.offerer.tradeWalletPubKey,
model.taker.pubKey, model.taker.tradeWalletPubKey,
model.arbitratorPubKey, model.arbitratorPubKey,
new FutureCallback<Transaction>() { new FutureCallback<Transaction>() {
@Override @Override

View file

@ -48,8 +48,8 @@ public class TakerCreatesAndSignsDepositTx extends Task<TakerAsSellerModel> {
model.offerer.connectedOutputsForAllInputs, model.offerer.connectedOutputsForAllInputs,
model.offerer.outputs, model.offerer.outputs,
model.taker.addressEntry, model.taker.addressEntry,
model.offerer.pubKey, model.offerer.tradeWalletPubKey,
model.taker.pubKey, model.taker.tradeWalletPubKey,
model.arbitratorPubKey); model.arbitratorPubKey);