Skip to content

Commit

Permalink
get payout tx id from seller or arbitrator
Browse files Browse the repository at this point in the history
  • Loading branch information
woodser committed Oct 1, 2024
1 parent e9f5277 commit 5f60336
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/HavenoClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2635,10 +2635,13 @@ async function executeTrade(ctxP: Partial<TradeContext>): Promise<string> {
// record balances on completion
if (ctx.isStopped) return ctx.offerId!;
if (!ctx.maker.balancesAfterPayout) {
ctx.payoutTxId = (await ctx.getBuyer().havenod!.getTrade(ctx.offerId!)).getPayoutTxId();
if (!ctx.payoutTxId) ctx.payoutTxId = (await ctx.arbitrator.havenod!.getTrade(ctx.offerId!)).getPayoutTxId(); // TODO: arbitrator will sign and publish payout tx id if buyer is offline; detect payout tx id on 0 conf
ctx.maker.balancesAfterPayout = await ctx.maker.havenod?.getBalances();
ctx.taker.balancesAfterPayout = await ctx.taker.havenod?.getBalances();

// record payout tx id
ctx.payoutTxId = (await ctx.getSeller().havenod!.getTrade(ctx.offerId!)).getPayoutTxId();
if (!ctx.payoutTxId) ctx.payoutTxId = (await ctx.arbitrator.havenod!.getTrade(ctx.offerId!)).getPayoutTxId(); // TODO: arbitrator will sign and publish payout tx id if buyer is offline; detect payout tx id on 0 conf
if (!ctx.payoutTxId) ctx.payoutTxId = (await ctx.getBuyer().havenod!.getTrade(ctx.offerId!)).getPayoutTxId(); // TODO: arbitrator does not have payout tx id until first confirmation because they defer publishing
}

// test balances after payout tx unless other trades can interfere
Expand Down

0 comments on commit 5f60336

Please sign in to comment.