mirror of
https://github.com/haveno-dex/haveno-ts.git
synced 2024-12-24 23:09:26 -05:00
observe deposit txs before recording context after offer taken
This commit is contained in:
parent
6bd9f29063
commit
2f581d87b2
6
dist/HavenoClient.js
vendored
6
dist/HavenoClient.js
vendored
@ -1037,8 +1037,10 @@ class HavenoClient {
|
||||
.setPaymentAccountId(paymentAccountId);
|
||||
if (amount)
|
||||
request.setAmount(amount.toString());
|
||||
HavenoUtils_1.default.log(0, "Taking offer with taker amount: " + amount);
|
||||
return (await this._tradesClient.takeOffer(request, { password: this._password })).getTrade();
|
||||
const resp = await this._tradesClient.takeOffer(request, { password: this._password });
|
||||
if (resp.getTrade())
|
||||
return resp.getTrade();
|
||||
throw new HavenoError_1.default(resp.getFailureReason()?.getDescription(), resp.getFailureReason()?.getAvailabilityResult());
|
||||
}
|
||||
catch (e) {
|
||||
throw new HavenoError_1.default(e.message, e.code);
|
||||
|
2
dist/HavenoClient.js.map
vendored
2
dist/HavenoClient.js.map
vendored
File diff suppressed because one or more lines are too long
@ -2715,16 +2715,11 @@ async function takeOffer(ctxP: Partial<TradeContext>): Promise<TradeInfo> {
|
||||
|
||||
// record context after offer taken, once
|
||||
if (ctx.getBuyer().balancesAfterTake === undefined) {
|
||||
ctx.tradeAmount = BigInt(trade.getAmount()); // re-assign trade amount which could be adjusted
|
||||
ctx.arbitrator.trade = await ctx.arbitrator.havenod!.getTrade(ctx.offerId!);
|
||||
ctx.maker.trade = await ctx.maker.havenod!.getTrade(ctx.offerId!);
|
||||
ctx.taker.trade = await ctx.taker.havenod!.getTrade(ctx.offerId!);
|
||||
ctx.maker.balancesAfterTake = await ctx.maker.havenod!.getBalances();
|
||||
ctx.taker.balancesAfterTake = await ctx.taker.havenod!.getBalances();
|
||||
ctx.maker.depositTx = await monerod.getTx(ctx.arbitrator.trade!.getMakerDepositTxId());
|
||||
ctx.taker.depositTx = await monerod.getTx(ctx.arbitrator.trade!.getTakerDepositTxId());
|
||||
|
||||
// wait to observe deposit txs
|
||||
ctx.arbitrator.trade = await ctx.arbitrator.havenod!.getTrade(ctx.offerId!);
|
||||
ctx.maker.depositTx = await monerod.getTx(ctx.arbitrator.trade!.getMakerDepositTxId());
|
||||
ctx.taker.depositTx = await monerod.getTx(ctx.arbitrator.trade!.getTakerDepositTxId());
|
||||
if (!ctx.maker.depositTx || !ctx.taker.depositTx) {
|
||||
if (!ctx.maker.depositTx) HavenoUtils.log(0, "Maker deposit tx not found with id " + ctx.arbitrator.trade!.getMakerDepositTxId() + ", waiting...");
|
||||
if (!ctx.taker.depositTx) HavenoUtils.log(0, "Taker deposit tx not found with id " + ctx.arbitrator.trade!.getTakerDepositTxId() + ", waiting...");
|
||||
@ -2734,6 +2729,13 @@ async function takeOffer(ctxP: Partial<TradeContext>): Promise<TradeInfo> {
|
||||
if (!ctx.maker.depositTx) throw new Error("Maker deposit tx not found with id " + ctx.arbitrator.trade!.getMakerDepositTxId());
|
||||
if (!ctx.taker.depositTx) throw new Error("Taker deposit tx not found with id " + ctx.arbitrator.trade!.getTakerDepositTxId());
|
||||
}
|
||||
|
||||
// record context
|
||||
ctx.tradeAmount = BigInt(trade.getAmount()); // re-assign trade amount which could be adjusted
|
||||
ctx.maker.trade = await ctx.maker.havenod!.getTrade(ctx.offerId!);
|
||||
ctx.taker.trade = await ctx.taker.havenod!.getTrade(ctx.offerId!);
|
||||
ctx.maker.balancesAfterTake = await ctx.maker.havenod!.getBalances();
|
||||
ctx.taker.balancesAfterTake = await ctx.taker.havenod!.getBalances();
|
||||
ctx.maker.depositTxFee = BigInt(ctx.maker.depositTx!.getFee());
|
||||
ctx.taker.depositTxFee = BigInt(ctx.taker.depositTx!.getFee());
|
||||
ctx.maker.tradeFee = BigInt(trade.getOffer()!.getMakerFee());
|
||||
|
Loading…
Reference in New Issue
Block a user