mirror of
https://github.com/haveno-dex/haveno-ts.git
synced 2025-04-18 14:55:57 -04:00
wait for split output tx to unlock before taking offer
This commit is contained in:
parent
d739cc56e9
commit
da79f15a5a
@ -2276,8 +2276,12 @@ async function executeTrade(ctxP: Partial<TradeContext>): Promise<string> {
|
||||
// wait for split output tx to unlock
|
||||
if (ctx.isStopped) return ctx.offerId!;
|
||||
if (ctx.reserveExactAmount) {
|
||||
await mineToHeight(await monerod.getHeight() + 10); // TODO: wait for offer to be available (dandilion)
|
||||
await wait(TestConfig.daemonPollPeriodMs * 2);
|
||||
const splitOutputTxId = ctx.offer?.getSplitOutputTxHash();
|
||||
HavenoUtils.log(1, "Waiting for split output tx " + splitOutputTxId + " to unlock");
|
||||
if (splitOutputTxId) {
|
||||
await mineToUnlock(splitOutputTxId);
|
||||
await wait(TestConfig.trade.walletSyncPeriodMs + TestConfig.trade.maxTimePeerNoticeMs);
|
||||
}
|
||||
}
|
||||
|
||||
// take offer or get existing trade
|
||||
@ -3454,6 +3458,17 @@ async function mineToHeight(height: number) {
|
||||
if (miningStarted) await stopMining();
|
||||
}
|
||||
|
||||
async function mineToUnlock(txHash: string) {
|
||||
let tx = await monerod.getTx(txHash);
|
||||
if (tx && tx.getNumConfirmations() >= 10) return; // TODO: tx.getIsLocked()
|
||||
const miningStarted = await startMining();
|
||||
while (!tx || tx.getNumConfirmations() < 10) {
|
||||
await moneroTs.GenUtils.waitFor(TestConfig.trade.walletSyncPeriodMs);
|
||||
tx = await monerod.getTx(txHash);
|
||||
}
|
||||
if (miningStarted) await stopMining();
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for unlocked balance in wallet or Haveno daemon.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user