mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-01-03 09:29:44 +00:00
onTakeOffer() invokes result handler after trade completely initialized
This commit is contained in:
parent
f8fa838a9b
commit
b72db7f20d
6 changed files with 18 additions and 9 deletions
|
@ -111,7 +111,7 @@ public class XmrWalletService {
|
||||||
.setPath(path)
|
.setPath(path)
|
||||||
.setPassword("abctesting123"));
|
.setPassword("abctesting123"));
|
||||||
multisigWallets.put(tradeId, multisigWallet);
|
multisigWallets.put(tradeId, multisigWallet);
|
||||||
multisigWallet.startSyncing(5000l); // TODO (woodser): apps stall if too many multisig wallets and too short sync period
|
multisigWallet.startSyncing(5000l); // TODO (woodser): use sync period from config. apps stall if too many multisig wallets and too short sync period
|
||||||
return multisigWallet;
|
return multisigWallet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -699,8 +699,7 @@ public abstract class Trade implements Tradable, Model {
|
||||||
// The deserialized tx has not actual confidence data, so we need to get the fresh one from the wallet.
|
// The deserialized tx has not actual confidence data, so we need to get the fresh one from the wallet.
|
||||||
void updateDepositTxFromWallet() {
|
void updateDepositTxFromWallet() {
|
||||||
if (getMakerDepositTx() != null && getTakerDepositTx() != null) {
|
if (getMakerDepositTx() != null && getTakerDepositTx() != null) {
|
||||||
System.out.println(processModel.getProvider().getXmrWalletService());
|
MoneroWallet multisigWallet = processModel.getProvider().getXmrWalletService().getMultisigWallet(getId());
|
||||||
MoneroWallet multisigWallet = processModel.getProvider().getXmrWalletService().getMultisigWallet(getId());
|
|
||||||
applyDepositTxs(multisigWallet.getTx(getMakerDepositTx().getHash()), multisigWallet.getTx(getTakerDepositTx().getHash()));
|
applyDepositTxs(multisigWallet.getTx(getMakerDepositTx().getHash()), multisigWallet.getTx(getTakerDepositTx().getHash()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -737,8 +737,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
|
||||||
|
|
||||||
initTradeAndProtocol(trade, tradeProtocol);
|
initTradeAndProtocol(trade, tradeProtocol);
|
||||||
|
|
||||||
((TakerProtocol) tradeProtocol).onTakeOffer();
|
((TakerProtocol) tradeProtocol).onTakeOffer(tradeResultHandler);
|
||||||
tradeResultHandler.handleResult(trade);
|
|
||||||
requestPersistence();
|
requestPersistence();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -21,6 +21,7 @@ package bisq.core.trade.protocol;
|
||||||
import bisq.core.offer.Offer;
|
import bisq.core.offer.Offer;
|
||||||
import bisq.core.trade.BuyerAsTakerTrade;
|
import bisq.core.trade.BuyerAsTakerTrade;
|
||||||
import bisq.core.trade.Trade;
|
import bisq.core.trade.Trade;
|
||||||
|
import bisq.core.trade.handlers.TradeResultHandler;
|
||||||
import bisq.core.trade.messages.DelayedPayoutTxSignatureRequest;
|
import bisq.core.trade.messages.DelayedPayoutTxSignatureRequest;
|
||||||
import bisq.core.trade.messages.DepositResponse;
|
import bisq.core.trade.messages.DepositResponse;
|
||||||
import bisq.core.trade.messages.DepositTxAndDelayedPayoutTxMessage;
|
import bisq.core.trade.messages.DepositTxAndDelayedPayoutTxMessage;
|
||||||
|
@ -66,6 +67,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
// TODO (woodser): remove unused request handling
|
// TODO (woodser): remove unused request handling
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class BuyerAsTakerProtocol extends BuyerProtocol implements TakerProtocol {
|
public class BuyerAsTakerProtocol extends BuyerProtocol implements TakerProtocol {
|
||||||
|
|
||||||
|
private TradeResultHandler tradeResultHandler;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Constructor
|
// Constructor
|
||||||
|
@ -87,8 +90,9 @@ public class BuyerAsTakerProtocol extends BuyerProtocol implements TakerProtocol
|
||||||
|
|
||||||
// TODO (woodser): this implementation is duplicated with SellerAsTakerProtocol
|
// TODO (woodser): this implementation is duplicated with SellerAsTakerProtocol
|
||||||
@Override
|
@Override
|
||||||
public void onTakeOffer() {
|
public void onTakeOffer(TradeResultHandler tradeResultHandler) {
|
||||||
System.out.println("onTakeOffer()");
|
System.out.println("onTakeOffer()");
|
||||||
|
this.tradeResultHandler = tradeResultHandler;
|
||||||
|
|
||||||
expect(phase(Trade.Phase.INIT)
|
expect(phase(Trade.Phase.INIT)
|
||||||
.with(TakerEvent.TAKE_OFFER)
|
.with(TakerEvent.TAKE_OFFER)
|
||||||
|
@ -297,6 +301,7 @@ public class BuyerAsTakerProtocol extends BuyerProtocol implements TakerProtocol
|
||||||
() -> {
|
() -> {
|
||||||
stopTimeout();
|
stopTimeout();
|
||||||
handleTaskRunnerSuccess(sender, request);
|
handleTaskRunnerSuccess(sender, request);
|
||||||
|
tradeResultHandler.handleResult(trade); // trade is initialized
|
||||||
},
|
},
|
||||||
errorMessage -> {
|
errorMessage -> {
|
||||||
errorMessageHandler.handleErrorMessage(errorMessage);
|
errorMessageHandler.handleErrorMessage(errorMessage);
|
||||||
|
|
|
@ -21,6 +21,7 @@ package bisq.core.trade.protocol;
|
||||||
import bisq.core.offer.Offer;
|
import bisq.core.offer.Offer;
|
||||||
import bisq.core.trade.SellerAsTakerTrade;
|
import bisq.core.trade.SellerAsTakerTrade;
|
||||||
import bisq.core.trade.Trade;
|
import bisq.core.trade.Trade;
|
||||||
|
import bisq.core.trade.handlers.TradeResultHandler;
|
||||||
import bisq.core.trade.messages.CounterCurrencyTransferStartedMessage;
|
import bisq.core.trade.messages.CounterCurrencyTransferStartedMessage;
|
||||||
import bisq.core.trade.messages.DepositResponse;
|
import bisq.core.trade.messages.DepositResponse;
|
||||||
import bisq.core.trade.messages.InitMultisigRequest;
|
import bisq.core.trade.messages.InitMultisigRequest;
|
||||||
|
@ -61,6 +62,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
// TODO (woodser): remove unused request handling
|
// TODO (woodser): remove unused request handling
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class SellerAsTakerProtocol extends SellerProtocol implements TakerProtocol {
|
public class SellerAsTakerProtocol extends SellerProtocol implements TakerProtocol {
|
||||||
|
|
||||||
|
private TradeResultHandler tradeResultHandler;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Constructor
|
// Constructor
|
||||||
|
@ -78,8 +81,9 @@ public class SellerAsTakerProtocol extends SellerProtocol implements TakerProtoc
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTakeOffer() {
|
public void onTakeOffer(TradeResultHandler tradeResultHandler) {
|
||||||
System.out.println("onTakeOffer()");
|
System.out.println("onTakeOffer()");
|
||||||
|
this.tradeResultHandler = tradeResultHandler;
|
||||||
|
|
||||||
expect(phase(Trade.Phase.INIT)
|
expect(phase(Trade.Phase.INIT)
|
||||||
.with(TakerEvent.TAKE_OFFER)
|
.with(TakerEvent.TAKE_OFFER)
|
||||||
|
@ -262,7 +266,7 @@ public class SellerAsTakerProtocol extends SellerProtocol implements TakerProtoc
|
||||||
System.out.println("SellerAsTakerProtocol.handlePaymentAccountPayloadRequest()");
|
System.out.println("SellerAsTakerProtocol.handlePaymentAccountPayloadRequest()");
|
||||||
Validator.checkTradeId(processModel.getOfferId(), request);
|
Validator.checkTradeId(processModel.getOfferId(), request);
|
||||||
processModel.setTradeMessage(request);
|
processModel.setTradeMessage(request);
|
||||||
expect(anyPhase(Trade.Phase.INIT, Trade.Phase.DEPOSIT_PUBLISHED)
|
expect(anyPhase(Trade.Phase.INIT, Trade.Phase.DEPOSIT_PUBLISHED) // TODO: only deposit_published should be expected
|
||||||
.with(request)
|
.with(request)
|
||||||
.from(sender)) // TODO (woodser): ensure this asserts sender == response.getSenderNodeAddress()
|
.from(sender)) // TODO (woodser): ensure this asserts sender == response.getSenderNodeAddress()
|
||||||
.setup(tasks(
|
.setup(tasks(
|
||||||
|
@ -272,6 +276,7 @@ public class SellerAsTakerProtocol extends SellerProtocol implements TakerProtoc
|
||||||
() -> {
|
() -> {
|
||||||
stopTimeout();
|
stopTimeout();
|
||||||
handleTaskRunnerSuccess(sender, request);
|
handleTaskRunnerSuccess(sender, request);
|
||||||
|
tradeResultHandler.handleResult(trade); // trade is initialized
|
||||||
},
|
},
|
||||||
errorMessage -> {
|
errorMessage -> {
|
||||||
errorMessageHandler.handleErrorMessage(errorMessage);
|
errorMessageHandler.handleErrorMessage(errorMessage);
|
||||||
|
|
|
@ -17,9 +17,10 @@
|
||||||
|
|
||||||
package bisq.core.trade.protocol;
|
package bisq.core.trade.protocol;
|
||||||
|
|
||||||
|
import bisq.core.trade.handlers.TradeResultHandler;
|
||||||
|
|
||||||
public interface TakerProtocol extends TraderProtocol {
|
public interface TakerProtocol extends TraderProtocol {
|
||||||
void onTakeOffer();
|
void onTakeOffer(TradeResultHandler tradeResultHandler);
|
||||||
|
|
||||||
enum TakerEvent implements FluentProtocol.Event {
|
enum TakerEvent implements FluentProtocol.Event {
|
||||||
TAKE_OFFER
|
TAKE_OFFER
|
||||||
|
|
Loading…
Reference in a new issue