mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
Fix SelectCoinsMinConf to allow instant respends (#3061)
* Modify tests to check for instant respends This should fail atm... * Fix SelectCoinsMinConf to allow instant respends Now tests should pass again.
This commit is contained in:
parent
2e7ec23693
commit
c74f2cd8b2
@ -78,6 +78,9 @@ class InstantSendTest(DashTestFramework):
|
||||
assert (res['hash'] != wrong_block)
|
||||
# wait for long time only for first node
|
||||
timeout = 1
|
||||
# send coins back to the controller node without waiting for confirmations
|
||||
receiver.sendtoaddress(self.nodes[0].getnewaddress(), 0.9, "", "", True)
|
||||
assert_equal(receiver.getwalletinfo()["balance"], 0)
|
||||
# mine more blocks
|
||||
# TODO: mine these blocks on an isolated node
|
||||
set_mocktime(get_mocktime() + 1)
|
||||
@ -116,6 +119,9 @@ class InstantSendTest(DashTestFramework):
|
||||
for node in self.nodes:
|
||||
self.wait_for_instantlock(is_id, node)
|
||||
assert_raises_jsonrpc(-5, "No such mempool or blockchain transaction", isolated.getrawtransaction, dblspnd_txid)
|
||||
# send coins back to the controller node without waiting for confirmations
|
||||
receiver.sendtoaddress(self.nodes[0].getnewaddress(), 0.9, "", "", True)
|
||||
assert_equal(receiver.getwalletinfo()["balance"], 0)
|
||||
|
||||
if __name__ == '__main__':
|
||||
InstantSendTest().main()
|
||||
|
@ -2677,6 +2677,8 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, const int nConfMin
|
||||
std::sort(vCoins.begin(), vCoins.end(), less_then_denom);
|
||||
}
|
||||
|
||||
int nMaxChainLength = std::min(gArgs.GetArg("-limitancestorcount", DEFAULT_ANCESTOR_LIMIT), gArgs.GetArg("-limitdescendantcount", DEFAULT_DESCENDANT_LIMIT));
|
||||
|
||||
// try to find nondenom first to prevent unneeded spending of mixed coins
|
||||
for (unsigned int tryDenom = tryDenomStart; tryDenom < 2; tryDenom++)
|
||||
{
|
||||
@ -2690,11 +2692,13 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, const int nConfMin
|
||||
|
||||
const CWalletTx *pcoin = output.tx;
|
||||
|
||||
bool fLockedByIS = pcoin->IsLockedByInstantSend();
|
||||
|
||||
// if (fDebug) LogPrint("selectcoins", "value %s confirms %d\n", FormatMoney(pcoin->vout[output.i].nValue), output.nDepth);
|
||||
if (output.nDepth < (pcoin->IsFromMe(ISMINE_ALL) ? nConfMine : nConfTheirs))
|
||||
if (output.nDepth < (pcoin->IsFromMe(ISMINE_ALL) ? nConfMine : nConfTheirs) && !fLockedByIS)
|
||||
continue;
|
||||
|
||||
if (!mempool.TransactionWithinChainLimit(pcoin->GetHash(), nMaxAncestors))
|
||||
if (!mempool.TransactionWithinChainLimit(pcoin->GetHash(), fLockedByIS ? nMaxChainLength : nMaxAncestors))
|
||||
continue;
|
||||
|
||||
int i = output.i;
|
||||
|
Loading…
Reference in New Issue
Block a user