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)
|
||||
.setPassword("abctesting123"));
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -699,7 +699,6 @@ 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.
|
||||
void updateDepositTxFromWallet() {
|
||||
if (getMakerDepositTx() != null && getTakerDepositTx() != null) {
|
||||
System.out.println(processModel.getProvider().getXmrWalletService());
|
||||
MoneroWallet multisigWallet = processModel.getProvider().getXmrWalletService().getMultisigWallet(getId());
|
||||
applyDepositTxs(multisigWallet.getTx(getMakerDepositTx().getHash()), multisigWallet.getTx(getTakerDepositTx().getHash()));
|
||||
}
|
||||
|
|
|
@ -737,8 +737,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
|
|||
|
||||
initTradeAndProtocol(trade, tradeProtocol);
|
||||
|
||||
((TakerProtocol) tradeProtocol).onTakeOffer();
|
||||
tradeResultHandler.handleResult(trade);
|
||||
((TakerProtocol) tradeProtocol).onTakeOffer(tradeResultHandler);
|
||||
requestPersistence();
|
||||
}
|
||||
},
|
||||
|
|
|
@ -21,6 +21,7 @@ package bisq.core.trade.protocol;
|
|||
import bisq.core.offer.Offer;
|
||||
import bisq.core.trade.BuyerAsTakerTrade;
|
||||
import bisq.core.trade.Trade;
|
||||
import bisq.core.trade.handlers.TradeResultHandler;
|
||||
import bisq.core.trade.messages.DelayedPayoutTxSignatureRequest;
|
||||
import bisq.core.trade.messages.DepositResponse;
|
||||
import bisq.core.trade.messages.DepositTxAndDelayedPayoutTxMessage;
|
||||
|
@ -67,6 +68,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
@Slf4j
|
||||
public class BuyerAsTakerProtocol extends BuyerProtocol implements TakerProtocol {
|
||||
|
||||
private TradeResultHandler tradeResultHandler;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -87,8 +90,9 @@ public class BuyerAsTakerProtocol extends BuyerProtocol implements TakerProtocol
|
|||
|
||||
// TODO (woodser): this implementation is duplicated with SellerAsTakerProtocol
|
||||
@Override
|
||||
public void onTakeOffer() {
|
||||
public void onTakeOffer(TradeResultHandler tradeResultHandler) {
|
||||
System.out.println("onTakeOffer()");
|
||||
this.tradeResultHandler = tradeResultHandler;
|
||||
|
||||
expect(phase(Trade.Phase.INIT)
|
||||
.with(TakerEvent.TAKE_OFFER)
|
||||
|
@ -297,6 +301,7 @@ public class BuyerAsTakerProtocol extends BuyerProtocol implements TakerProtocol
|
|||
() -> {
|
||||
stopTimeout();
|
||||
handleTaskRunnerSuccess(sender, request);
|
||||
tradeResultHandler.handleResult(trade); // trade is initialized
|
||||
},
|
||||
errorMessage -> {
|
||||
errorMessageHandler.handleErrorMessage(errorMessage);
|
||||
|
|
|
@ -21,6 +21,7 @@ package bisq.core.trade.protocol;
|
|||
import bisq.core.offer.Offer;
|
||||
import bisq.core.trade.SellerAsTakerTrade;
|
||||
import bisq.core.trade.Trade;
|
||||
import bisq.core.trade.handlers.TradeResultHandler;
|
||||
import bisq.core.trade.messages.CounterCurrencyTransferStartedMessage;
|
||||
import bisq.core.trade.messages.DepositResponse;
|
||||
import bisq.core.trade.messages.InitMultisigRequest;
|
||||
|
@ -62,6 +63,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
@Slf4j
|
||||
public class SellerAsTakerProtocol extends SellerProtocol implements TakerProtocol {
|
||||
|
||||
private TradeResultHandler tradeResultHandler;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -78,8 +81,9 @@ public class SellerAsTakerProtocol extends SellerProtocol implements TakerProtoc
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void onTakeOffer() {
|
||||
public void onTakeOffer(TradeResultHandler tradeResultHandler) {
|
||||
System.out.println("onTakeOffer()");
|
||||
this.tradeResultHandler = tradeResultHandler;
|
||||
|
||||
expect(phase(Trade.Phase.INIT)
|
||||
.with(TakerEvent.TAKE_OFFER)
|
||||
|
@ -262,7 +266,7 @@ public class SellerAsTakerProtocol extends SellerProtocol implements TakerProtoc
|
|||
System.out.println("SellerAsTakerProtocol.handlePaymentAccountPayloadRequest()");
|
||||
Validator.checkTradeId(processModel.getOfferId(), 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)
|
||||
.from(sender)) // TODO (woodser): ensure this asserts sender == response.getSenderNodeAddress()
|
||||
.setup(tasks(
|
||||
|
@ -272,6 +276,7 @@ public class SellerAsTakerProtocol extends SellerProtocol implements TakerProtoc
|
|||
() -> {
|
||||
stopTimeout();
|
||||
handleTaskRunnerSuccess(sender, request);
|
||||
tradeResultHandler.handleResult(trade); // trade is initialized
|
||||
},
|
||||
errorMessage -> {
|
||||
errorMessageHandler.handleErrorMessage(errorMessage);
|
||||
|
|
|
@ -17,9 +17,10 @@
|
|||
|
||||
package bisq.core.trade.protocol;
|
||||
|
||||
import bisq.core.trade.handlers.TradeResultHandler;
|
||||
|
||||
public interface TakerProtocol extends TraderProtocol {
|
||||
void onTakeOffer();
|
||||
void onTakeOffer(TradeResultHandler tradeResultHandler);
|
||||
|
||||
enum TakerEvent implements FluentProtocol.Event {
|
||||
TAKE_OFFER
|
||||
|
|
Loading…
Reference in a new issue