mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-12-23 03:59:36 +00:00
arbitrator does not share payment account key until after first confirmation (#457)
use payout address from contract instead of PaymentSentMessage
This commit is contained in:
parent
1a6d635e3b
commit
c153afff67
8 changed files with 17 additions and 29 deletions
|
@ -32,7 +32,6 @@ import javax.annotation.Nullable;
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Value
|
@Value
|
||||||
public final class PaymentSentMessage extends TradeMailboxMessage {
|
public final class PaymentSentMessage extends TradeMailboxMessage {
|
||||||
private final String buyerPayoutAddress;
|
|
||||||
private final NodeAddress senderNodeAddress;
|
private final NodeAddress senderNodeAddress;
|
||||||
@Nullable
|
@Nullable
|
||||||
private final String counterCurrencyTxId;
|
private final String counterCurrencyTxId;
|
||||||
|
@ -49,7 +48,6 @@ public final class PaymentSentMessage extends TradeMailboxMessage {
|
||||||
private String counterCurrencyExtraData;
|
private String counterCurrencyExtraData;
|
||||||
|
|
||||||
public PaymentSentMessage(String tradeId,
|
public PaymentSentMessage(String tradeId,
|
||||||
String buyerPayoutAddress,
|
|
||||||
NodeAddress senderNodeAddress,
|
NodeAddress senderNodeAddress,
|
||||||
@Nullable String counterCurrencyTxId,
|
@Nullable String counterCurrencyTxId,
|
||||||
@Nullable String counterCurrencyExtraData,
|
@Nullable String counterCurrencyExtraData,
|
||||||
|
@ -58,7 +56,6 @@ public final class PaymentSentMessage extends TradeMailboxMessage {
|
||||||
String updatedMultisigHex,
|
String updatedMultisigHex,
|
||||||
@Nullable byte[] paymentAccountKey) {
|
@Nullable byte[] paymentAccountKey) {
|
||||||
this(tradeId,
|
this(tradeId,
|
||||||
buyerPayoutAddress,
|
|
||||||
senderNodeAddress,
|
senderNodeAddress,
|
||||||
counterCurrencyTxId,
|
counterCurrencyTxId,
|
||||||
counterCurrencyExtraData,
|
counterCurrencyExtraData,
|
||||||
|
@ -75,7 +72,6 @@ public final class PaymentSentMessage extends TradeMailboxMessage {
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
private PaymentSentMessage(String tradeId,
|
private PaymentSentMessage(String tradeId,
|
||||||
String buyerPayoutAddress,
|
|
||||||
NodeAddress senderNodeAddress,
|
NodeAddress senderNodeAddress,
|
||||||
@Nullable String counterCurrencyTxId,
|
@Nullable String counterCurrencyTxId,
|
||||||
@Nullable String counterCurrencyExtraData,
|
@Nullable String counterCurrencyExtraData,
|
||||||
|
@ -85,7 +81,6 @@ public final class PaymentSentMessage extends TradeMailboxMessage {
|
||||||
@Nullable String updatedMultisigHex,
|
@Nullable String updatedMultisigHex,
|
||||||
@Nullable byte[] paymentAccountKey) {
|
@Nullable byte[] paymentAccountKey) {
|
||||||
super(messageVersion, tradeId, uid);
|
super(messageVersion, tradeId, uid);
|
||||||
this.buyerPayoutAddress = buyerPayoutAddress;
|
|
||||||
this.senderNodeAddress = senderNodeAddress;
|
this.senderNodeAddress = senderNodeAddress;
|
||||||
this.counterCurrencyTxId = counterCurrencyTxId;
|
this.counterCurrencyTxId = counterCurrencyTxId;
|
||||||
this.counterCurrencyExtraData = counterCurrencyExtraData;
|
this.counterCurrencyExtraData = counterCurrencyExtraData;
|
||||||
|
@ -98,7 +93,6 @@ public final class PaymentSentMessage extends TradeMailboxMessage {
|
||||||
public protobuf.NetworkEnvelope toProtoNetworkEnvelope() {
|
public protobuf.NetworkEnvelope toProtoNetworkEnvelope() {
|
||||||
final protobuf.PaymentSentMessage.Builder builder = protobuf.PaymentSentMessage.newBuilder();
|
final protobuf.PaymentSentMessage.Builder builder = protobuf.PaymentSentMessage.newBuilder();
|
||||||
builder.setTradeId(tradeId)
|
builder.setTradeId(tradeId)
|
||||||
.setBuyerPayoutAddress(buyerPayoutAddress)
|
|
||||||
.setSenderNodeAddress(senderNodeAddress.toProtoMessage())
|
.setSenderNodeAddress(senderNodeAddress.toProtoMessage())
|
||||||
.setUid(uid);
|
.setUid(uid);
|
||||||
|
|
||||||
|
@ -114,7 +108,6 @@ public final class PaymentSentMessage extends TradeMailboxMessage {
|
||||||
public static PaymentSentMessage fromProto(protobuf.PaymentSentMessage proto,
|
public static PaymentSentMessage fromProto(protobuf.PaymentSentMessage proto,
|
||||||
String messageVersion) {
|
String messageVersion) {
|
||||||
return new PaymentSentMessage(proto.getTradeId(),
|
return new PaymentSentMessage(proto.getTradeId(),
|
||||||
proto.getBuyerPayoutAddress(),
|
|
||||||
NodeAddress.fromProto(proto.getSenderNodeAddress()),
|
NodeAddress.fromProto(proto.getSenderNodeAddress()),
|
||||||
ProtoUtil.stringOrNullFromProto(proto.getCounterCurrencyTxId()),
|
ProtoUtil.stringOrNullFromProto(proto.getCounterCurrencyTxId()),
|
||||||
ProtoUtil.stringOrNullFromProto(proto.getCounterCurrencyExtraData()),
|
ProtoUtil.stringOrNullFromProto(proto.getCounterCurrencyExtraData()),
|
||||||
|
@ -130,7 +123,6 @@ public final class PaymentSentMessage extends TradeMailboxMessage {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "PaymentSentMessage{" +
|
return "PaymentSentMessage{" +
|
||||||
"\n buyerPayoutAddress='" + buyerPayoutAddress + '\'' +
|
|
||||||
",\n senderNodeAddress=" + senderNodeAddress +
|
",\n senderNodeAddress=" + senderNodeAddress +
|
||||||
",\n counterCurrencyTxId=" + counterCurrencyTxId +
|
",\n counterCurrencyTxId=" + counterCurrencyTxId +
|
||||||
",\n counterCurrencyExtraData=" + counterCurrencyExtraData +
|
",\n counterCurrencyExtraData=" + counterCurrencyExtraData +
|
||||||
|
|
|
@ -154,7 +154,7 @@ public class ArbitratorProtocol extends DisputeProtocol {
|
||||||
latchTrade();
|
latchTrade();
|
||||||
Validator.checkTradeId(processModel.getOfferId(), request);
|
Validator.checkTradeId(processModel.getOfferId(), request);
|
||||||
processModel.setTradeMessage(request);
|
processModel.setTradeMessage(request);
|
||||||
expect(phase(Trade.Phase.DEPOSITS_PUBLISHED)
|
expect(anyPhase(Trade.Phase.DEPOSITS_PUBLISHED, Trade.Phase.DEPOSITS_CONFIRMED, Trade.Phase.DEPOSITS_UNLOCKED)
|
||||||
.with(request)
|
.with(request)
|
||||||
.from(peer))
|
.from(peer))
|
||||||
.setup(tasks(
|
.setup(tasks(
|
||||||
|
|
|
@ -41,6 +41,12 @@ public class ArbitratorProcessPaymentAccountKeyRequest extends TradeTask {
|
||||||
try {
|
try {
|
||||||
runInterceptHook();
|
runInterceptHook();
|
||||||
|
|
||||||
|
// ensure deposit txs confirmed
|
||||||
|
trade.listenForDepositTxs();
|
||||||
|
if (trade.getPhase().ordinal() < Trade.Phase.DEPOSITS_CONFIRMED.ordinal()) {
|
||||||
|
throw new RuntimeException("Arbitrator refusing payment account key request for trade " + trade.getId() + " because the deposit txs have not confirmed");
|
||||||
|
}
|
||||||
|
|
||||||
// create response for buyer with key to decrypt seller's payment account payload
|
// create response for buyer with key to decrypt seller's payment account payload
|
||||||
PaymentAccountKeyResponse response = new PaymentAccountKeyResponse(
|
PaymentAccountKeyResponse response = new PaymentAccountKeyResponse(
|
||||||
trade.getId(),
|
trade.getId(),
|
||||||
|
|
|
@ -17,8 +17,6 @@
|
||||||
|
|
||||||
package bisq.core.trade.protocol.tasks;
|
package bisq.core.trade.protocol.tasks;
|
||||||
|
|
||||||
import bisq.core.btc.model.XmrAddressEntry;
|
|
||||||
import bisq.core.btc.wallet.XmrWalletService;
|
|
||||||
import bisq.core.network.MessageState;
|
import bisq.core.network.MessageState;
|
||||||
import bisq.core.trade.Trade;
|
import bisq.core.trade.Trade;
|
||||||
import bisq.core.trade.messages.PaymentSentMessage;
|
import bisq.core.trade.messages.PaymentSentMessage;
|
||||||
|
@ -53,11 +51,6 @@ public class BuyerSendPaymentSentMessage extends SendMailboxMessageTask {
|
||||||
protected TradeMailboxMessage getTradeMailboxMessage(String tradeId) {
|
protected TradeMailboxMessage getTradeMailboxMessage(String tradeId) {
|
||||||
if (message == null) {
|
if (message == null) {
|
||||||
|
|
||||||
// gather relevant info
|
|
||||||
XmrWalletService walletService = processModel.getProvider().getXmrWalletService();
|
|
||||||
final String id = processModel.getOfferId();
|
|
||||||
XmrAddressEntry payoutAddressEntry = walletService.getOrCreateAddressEntry(id, XmrAddressEntry.Context.TRADE_PAYOUT);
|
|
||||||
|
|
||||||
// We do not use a real unique ID here as we want to be able to re-send the exact same message in case the
|
// We do not use a real unique ID here as we want to be able to re-send the exact same message in case the
|
||||||
// peer does not respond with an ACK msg in a certain time interval. To avoid that we get dangling mailbox
|
// peer does not respond with an ACK msg in a certain time interval. To avoid that we get dangling mailbox
|
||||||
// messages where only the one which gets processed by the peer would be removed we use the same uid. All
|
// messages where only the one which gets processed by the peer would be removed we use the same uid. All
|
||||||
|
@ -65,7 +58,6 @@ public class BuyerSendPaymentSentMessage extends SendMailboxMessageTask {
|
||||||
String deterministicId = tradeId + processModel.getMyNodeAddress().getFullAddress();
|
String deterministicId = tradeId + processModel.getMyNodeAddress().getFullAddress();
|
||||||
message = new PaymentSentMessage(
|
message = new PaymentSentMessage(
|
||||||
tradeId,
|
tradeId,
|
||||||
payoutAddressEntry.getAddressString(),
|
|
||||||
processModel.getMyNodeAddress(),
|
processModel.getMyNodeAddress(),
|
||||||
trade.getCounterCurrencyTxId(),
|
trade.getCounterCurrencyTxId(),
|
||||||
trade.getCounterCurrencyExtraData(),
|
trade.getCounterCurrencyExtraData(),
|
||||||
|
|
|
@ -68,7 +68,6 @@ public class ProcessSignContractRequest extends TradeTask {
|
||||||
trader.setPayoutAddressString(request.getPayoutAddress());
|
trader.setPayoutAddressString(request.getPayoutAddress());
|
||||||
|
|
||||||
// sign contract only when both deposit txs hashes known
|
// sign contract only when both deposit txs hashes known
|
||||||
// TODO (woodser): synchronize contract creation; both requests received at the same time
|
|
||||||
// TODO (woodser): remove makerDepositTxId and takerDepositTxId from Trade
|
// TODO (woodser): remove makerDepositTxId and takerDepositTxId from Trade
|
||||||
if (processModel.getMaker().getDepositTxHash() == null || processModel.getTaker().getDepositTxHash() == null) {
|
if (processModel.getMaker().getDepositTxHash() == null || processModel.getTaker().getDepositTxHash() == null) {
|
||||||
complete();
|
complete();
|
||||||
|
|
|
@ -99,7 +99,7 @@ public class ProcessSignContractResponse extends TradeTask {
|
||||||
@Override
|
@Override
|
||||||
public void onArrived() {
|
public void onArrived() {
|
||||||
log.info("{} arrived: arbitrator={}; offerId={}; uid={}", request.getClass().getSimpleName(), trade.getArbitratorNodeAddress(), trade.getId(), request.getUid());
|
log.info("{} arrived: arbitrator={}; offerId={}; uid={}", request.getClass().getSimpleName(), trade.getArbitratorNodeAddress(), trade.getId(), request.getUid());
|
||||||
trade.setState(Trade.State.SAW_ARRIVED_PUBLISH_DEPOSIT_TX_REQUEST);
|
trade.setStateIfValidTransitionTo(Trade.State.SAW_ARRIVED_PUBLISH_DEPOSIT_TX_REQUEST);
|
||||||
processModel.getTradeManager().requestPersistence();
|
processModel.getTradeManager().requestPersistence();
|
||||||
complete();
|
complete();
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,11 +42,11 @@ public class SellerProcessPaymentSentMessage extends TradeTask {
|
||||||
Validator.checkTradeId(processModel.getOfferId(), message);
|
Validator.checkTradeId(processModel.getOfferId(), message);
|
||||||
checkNotNull(message);
|
checkNotNull(message);
|
||||||
|
|
||||||
trade.getBuyer().setPayoutAddressString(Validator.nonEmptyStringOf(message.getBuyerPayoutAddress())); // TODO (woodser): verify against contract
|
// store buyer info
|
||||||
trade.getBuyer().setPayoutTxHex(message.getPayoutTxHex());
|
trade.getBuyer().setPayoutTxHex(message.getPayoutTxHex());
|
||||||
trade.getBuyer().setUpdatedMultisigHex(message.getUpdatedMultisigHex());
|
trade.getBuyer().setUpdatedMultisigHex(message.getUpdatedMultisigHex());
|
||||||
|
|
||||||
// decrypt peer's payment account payload
|
// decrypt buyer's payment account payload
|
||||||
trade.decryptPeersPaymentAccountPayload(message.getPaymentAccountKey());
|
trade.decryptPeersPaymentAccountPayload(message.getPaymentAccountKey());
|
||||||
|
|
||||||
// sync and update multisig wallet
|
// sync and update multisig wallet
|
||||||
|
|
|
@ -440,14 +440,13 @@ message FinalizePayoutTxRequest {
|
||||||
|
|
||||||
message PaymentSentMessage {
|
message PaymentSentMessage {
|
||||||
string trade_id = 1;
|
string trade_id = 1;
|
||||||
string buyer_payout_address = 2;
|
NodeAddress sender_node_address = 2;
|
||||||
NodeAddress sender_node_address = 3;
|
string counter_currency_tx_id = 3;
|
||||||
string counter_currency_tx_id = 4;
|
string uid = 4;
|
||||||
string uid = 5;
|
string counter_currency_extra_data = 5;
|
||||||
string counter_currency_extra_data = 6;
|
string payout_tx_hex = 6;
|
||||||
string payout_tx_hex = 7;
|
string updated_multisig_hex = 7;
|
||||||
string updated_multisig_hex = 8;
|
bytes payment_account_key = 8;
|
||||||
bytes payment_account_key = 9;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message PaymentReceivedMessage {
|
message PaymentReceivedMessage {
|
||||||
|
|
Loading…
Reference in a new issue