mirror of
https://github.com/haveno-dex/haveno-ts.git
synced 2025-01-25 22:15:58 -05:00
fix unintended mining when funding outputs
This commit is contained in:
parent
1f5ee145ad
commit
7c630b82cd
@ -1940,7 +1940,7 @@ async function waitForUnlockedTxs(...txHashes: string[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if the wallet has an unlocked amount.
|
* Indicates if the given wallets have unspent outputs.
|
||||||
*
|
*
|
||||||
* @param {MoneroWallet[]} wallets - wallets to check
|
* @param {MoneroWallet[]} wallets - wallets to check
|
||||||
* @param {BigInt} amt - amount to check
|
* @param {BigInt} amt - amount to check
|
||||||
@ -1976,6 +1976,7 @@ async function fundOutputs(wallets: any[], amt: bigint, numOutputs?: number, wai
|
|||||||
destinations.push(new MoneroDestination((await wallet.createSubaddress()).getAddress(), monerojs.BigInteger(amt.toString())));
|
destinations.push(new MoneroDestination((await wallet.createSubaddress()).getAddress(), monerojs.BigInteger(amt.toString())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!destinations.length) return;
|
||||||
|
|
||||||
// fund destinations
|
// fund destinations
|
||||||
let txConfig = new MoneroTxConfig().setAccountIndex(0).setRelay(true);
|
let txConfig = new MoneroTxConfig().setAccountIndex(0).setRelay(true);
|
||||||
@ -1992,9 +1993,13 @@ async function fundOutputs(wallets: any[], amt: bigint, numOutputs?: number, wai
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// wait for wallets to see transfers
|
||||||
|
await wait(TestConfig.walletSyncPeriodMs);
|
||||||
|
|
||||||
// mine until outputs unlock
|
// mine until outputs unlock
|
||||||
|
if (!waitForUnlock) return;
|
||||||
let miningStarted = false;
|
let miningStarted = false;
|
||||||
while (!await hasUnspentOutputs(wallets, amt, numOutputs, waitForUnlock ? false : undefined)) {
|
while (!await hasUnspentOutputs(wallets, amt, numOutputs, false)) {
|
||||||
if (!miningStarted) {
|
if (!miningStarted) {
|
||||||
await startMining();
|
await startMining();
|
||||||
miningStarted = true;
|
miningStarted = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user