From 66dbb2e96449cefeddc3d5f95dc18dac529f9ad2 Mon Sep 17 00:00:00 2001 From: Alessandro Rezzi Date: Fri, 24 Feb 2023 00:05:57 +0100 Subject: [PATCH 1/5] Fixed current AutoCombineDust --- src/wallet/wallet.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 7be6cbd555eb..44dea3f2be5a 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -4094,7 +4094,8 @@ void CWallet::AutoCombineDust(CConnman* connman) int nChangePosInOut = -1; // 10% safety margin to avoid "Insufficient funds" errors - vecSend[0].nAmount = nTotalRewardsValue - (nTotalRewardsValue / 10); + long safetyThreshold = nTotalRewardsValue - (nTotalRewardsValue / 10); + vecSend[0].nAmount = safetyThreshold; { // For now, CreateTransaction requires cs_main lock. @@ -4107,7 +4108,7 @@ void CWallet::AutoCombineDust(CConnman* connman) } //we don't combine below the threshold unless the fees are 0 to avoid paying fees over fees over fees - if (!maxSize && nTotalRewardsValue < nAutoCombineThreshold && nFeeRet > 0) + if (!maxSize && safetyThreshold < nAutoCombineThreshold && nFeeRet > 0) continue; const CWallet::CommitResult& res = CommitTransaction(wtx, keyChange, connman); From 9ea65d55a5e9ba89ddcdca0f98f3c5a59b82edde Mon Sep 17 00:00:00 2001 From: Alessandro Rezzi Date: Sat, 4 Mar 2023 18:56:51 -0800 Subject: [PATCH 2/5] Fixed and improved setautocombinethreshold --- src/rpc/client.cpp | 1 + src/wallet/rpcwallet.cpp | 24 +++++++++++++++++++----- src/wallet/wallet.cpp | 14 +++++++------- src/wallet/wallet.h | 1 + src/wallet/walletdb.cpp | 21 ++++++++++++++++----- src/wallet/walletdb.h | 2 +- 6 files changed, 45 insertions(+), 18 deletions(-) diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 56b4dfa3fbbf..a6dc183c6513 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -149,6 +149,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { { "sendtoaddress", 4, "subtract_fee" }, { "setautocombinethreshold", 0, "enable" }, { "setautocombinethreshold", 1, "threshold" }, + { "setautocombinethreshold", 2, "frequency"}, { "setnetworkactive", 0, "active"}, { "setban", 2, "bantime" }, { "setban", 3, "absolute" }, diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 8076351850d2..fb97369d4adb 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4267,6 +4267,7 @@ UniValue getwalletinfo(const JSONRPCRequest& request) // Autocombine settings obj.pushKV("autocombine_enabled", pwallet->fCombineDust); obj.pushKV("autocombine_threshold", ValueFromAmount(pwallet->nAutoCombineThreshold)); + obj.pushKV("autocombine_frequency", pwallet->frequency); // Keypool information obj.pushKV("keypoololdest", pwallet->GetOldestKeyPoolTime()); @@ -4504,7 +4505,7 @@ UniValue setautocombinethreshold(const JSONRPCRequest& request) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) return NullUniValue; - if (request.fHelp || request.params.empty() || request.params.size() > 2) + if (request.fHelp || request.params.empty() || request.params.size() > 3) throw std::runtime_error( "setautocombinethreshold enable ( value )\n" "\nThis will set the auto-combine threshold value.\n" @@ -4514,21 +4515,24 @@ UniValue setautocombinethreshold(const JSONRPCRequest& request) "\nArguments:\n" "1. enable (boolean, required) Enable auto combine (true) or disable (false).\n" "2. threshold (numeric, optional. required if enable is true) Threshold amount. Must be greater than 1.\n" + "3. frequency (numeric, optional. default value is 30 if not provided). Check for UTXOs to autocombine each N blocks where N is the frequency.\n" "\nResult:\n" "{\n" " \"enabled\": true|false, (boolean) true if auto-combine is enabled, otherwise false\n" " \"threshold\": n.nnn, (numeric) auto-combine threshold in PIV\n" + " \"frequency\": n.nnn, (numeric) auto-combine frequency in blocks\n" " \"saved\": true|false (boolean) true if setting was saved to the database, otherwise false\n" "}\n" "\nExamples:\n" + - HelpExampleCli("setautocombinethreshold", "true 500.12") + HelpExampleRpc("setautocombinethreshold", "true, 500.12")); + HelpExampleCli("setautocombinethreshold", "true 500.12 40") + HelpExampleRpc("setautocombinethreshold", "true, 500.12, 40")); - RPCTypeCheck(request.params, {UniValue::VBOOL, UniValue::VNUM}); + RPCTypeCheck(request.params, {UniValue::VBOOL, UniValue::VNUM, UniValue::VNUM}); bool fEnable = request.params[0].get_bool(); CAmount nThreshold = 0; + int frequency = 30; if (fEnable) { if (request.params.size() < 2) { @@ -4537,6 +4541,12 @@ UniValue setautocombinethreshold(const JSONRPCRequest& request) nThreshold = AmountFromValue(request.params[1]); if (nThreshold < COIN) throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("The threshold value cannot be less than %s", FormatMoney(COIN))); + if (request.params.size() == 3) { + frequency = request.params[2].get_int(); + if (frequency <= 0) { + throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Frequency must be greater than 0")); + } + } } WalletBatch batch(pwallet->GetDBHandle()); @@ -4545,11 +4555,13 @@ UniValue setautocombinethreshold(const JSONRPCRequest& request) LOCK(pwallet->cs_wallet); pwallet->fCombineDust = fEnable; pwallet->nAutoCombineThreshold = nThreshold; + pwallet->frequency = frequency; UniValue result(UniValue::VOBJ); result.pushKV("enabled", fEnable); result.pushKV("threshold", ValueFromAmount(pwallet->nAutoCombineThreshold)); - if (batch.WriteAutoCombineSettings(fEnable, nThreshold)) { + result.pushKV("frequency", frequency); + if (batch.WriteAutoCombineSettings(fEnable, nThreshold, frequency)) { result.pushKV("saved", "true"); } else { result.pushKV("saved", "false"); @@ -4569,12 +4581,13 @@ UniValue getautocombinethreshold(const JSONRPCRequest& request) if (request.fHelp || !request.params.empty()) throw std::runtime_error( "getautocombinethreshold\n" - "\nReturns the current threshold for auto combining UTXOs, if any\n" + "\nReturns the current threshold and frequency for auto combining UTXOs, if any\n" "\nResult:\n" "{\n" " \"enabled\": true|false, (boolean) true if auto-combine is enabled, otherwise false\n" " \"threshold\": n.nnn (numeric) the auto-combine threshold amount in PIV\n" + " \"frequency\": n.nnn (numeric) the auto-combine frequency in blocks\n" "}\n" "\nExamples:\n" + @@ -4585,6 +4598,7 @@ UniValue getautocombinethreshold(const JSONRPCRequest& request) UniValue result(UniValue::VOBJ); result.pushKV("enabled", pwallet->fCombineDust); result.pushKV("threshold", ValueFromAmount(pwallet->nAutoCombineThreshold)); + result.pushKV("frequency", pwallet->frequency); return result; } diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 44dea3f2be5a..608061e861cf 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1340,7 +1340,7 @@ void CWallet::BlockConnected(const std::shared_ptr& pblock, const // If turned on Auto Combine will scan wallet for dust to combine // Outside of the cs_wallet lock because requires cs_main for now // due CreateTransaction/CommitTransaction dependency. - if (fCombineDust) { + if (fCombineDust && pindex->nHeight % frequency == 0) { AutoCombineDust(g_connman.get()); } } @@ -4054,8 +4054,8 @@ void CWallet::AutoCombineDust(CConnman* connman) vRewardCoins.push_back(out); nTotalRewardsValue += out.Value(); - // Combine to the threshold and not way above - if (nTotalRewardsValue > nAutoCombineThreshold) + // Combine to the threshold and not way above considering the safety margin. + if ((nTotalRewardsValue - (nTotalRewardsValue / 10)) > nAutoCombineThreshold) break; // Around 180 bytes per input. We use 190 to be certain @@ -4094,8 +4094,7 @@ void CWallet::AutoCombineDust(CConnman* connman) int nChangePosInOut = -1; // 10% safety margin to avoid "Insufficient funds" errors - long safetyThreshold = nTotalRewardsValue - (nTotalRewardsValue / 10); - vecSend[0].nAmount = safetyThreshold; + vecSend[0].nAmount = nTotalRewardsValue - (nTotalRewardsValue / 10); { // For now, CreateTransaction requires cs_main lock. @@ -4108,7 +4107,7 @@ void CWallet::AutoCombineDust(CConnman* connman) } //we don't combine below the threshold unless the fees are 0 to avoid paying fees over fees over fees - if (!maxSize && safetyThreshold < nAutoCombineThreshold && nFeeRet > 0) + if (!maxSize && vecSend[0].nAmount < nAutoCombineThreshold && nFeeRet > 0) continue; const CWallet::CommitResult& res = CommitTransaction(wtx, keyChange, connman); @@ -4117,7 +4116,7 @@ void CWallet::AutoCombineDust(CConnman* connman) continue; } - LogPrintf("AutoCombineDust sent transaction\n"); + LogPrintf("AutoCombineDust sent transaction. Fee=%d, Total value=%d, Sending=%d\n", nFeeRet, nTotalRewardsValue, vecSend[0].nAmount); delete coinControl; } @@ -4484,6 +4483,7 @@ void CWallet::SetNull() //Auto Combine Dust fCombineDust = false; nAutoCombineThreshold = 0; + frequency = 30; // Sapling. m_sspk_man->nWitnessCacheSize = 0; diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 94e27460a1ac..d6f8dd76d334 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -742,6 +742,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface //Auto Combine Inputs bool fCombineDust; CAmount nAutoCombineThreshold; + int frequency; /** Get database handle used by this wallet. Ideally this function would * not be necessary. diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 3d90081742cc..42e8f955e9fa 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -55,6 +55,7 @@ namespace DBKeys { // Wallet custom settings const std::string AUTOCOMBINE{"autocombinesettings"}; + const std::string AUTOCOMBINE_V2{"autocombinesettingsV2"}; const std::string STAKE_SPLIT_THRESHOLD{"stakeSplitThreshold"}; const std::string USE_CUSTOM_FEE{"fUseCustomFee"}; const std::string CUSTOM_FEE_VALUE{"nCustomFee"}; @@ -241,12 +242,14 @@ bool WalletBatch::WriteCustomFeeValue(const CAmount& nFee) return WriteIC(std::string(DBKeys::CUSTOM_FEE_VALUE), nFee); } -bool WalletBatch::WriteAutoCombineSettings(bool fEnable, CAmount nCombineThreshold) +bool WalletBatch::WriteAutoCombineSettings(bool fEnable, CAmount nCombineThreshold, int frequency) { - std::pair pSettings; - pSettings.first = fEnable; - pSettings.second = nCombineThreshold; - return WriteIC(std::string(DBKeys::AUTOCOMBINE), pSettings, true); + std::pair, int> pSettings; + pSettings.first.first = fEnable; + pSettings.first.second = nCombineThreshold; + pSettings.second = frequency; + EraseIC(std::string(DBKeys::AUTOCOMBINE)); + return WriteIC(std::string(DBKeys::AUTOCOMBINE_V2), pSettings, true); } bool WalletBatch::ReadPool(int64_t nPool, CKeyPool& keypool) @@ -535,9 +538,17 @@ bool ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, CW ssValue >> pSettings; pwallet->fCombineDust = pSettings.first; pwallet->nAutoCombineThreshold = pSettings.second; + // Value used for old autocombine + pwallet->frequency = 1; // originally saved as integer if (pwallet->nAutoCombineThreshold < COIN) pwallet->nAutoCombineThreshold *= COIN; + } else if (strType == DBKeys::AUTOCOMBINE_V2) { + std::pair, int> pSettings; + ssValue >> pSettings; + pwallet->fCombineDust = pSettings.first.first; + pwallet->nAutoCombineThreshold = pSettings.first.second; + pwallet->frequency = pSettings.second; } else if (strType == DBKeys::DESTDATA) { std::string strAddress, strKey, strValue; ssKey >> strAddress; diff --git a/src/wallet/walletdb.h b/src/wallet/walletdb.h index edee3449c85c..0f9f772ea105 100644 --- a/src/wallet/walletdb.h +++ b/src/wallet/walletdb.h @@ -165,7 +165,7 @@ class WalletBatch bool WriteStakeSplitThreshold(const CAmount& nStakeSplitThreshold); bool WriteUseCustomFee(bool fUse); bool WriteCustomFeeValue(const CAmount& nCustomFee); - bool WriteAutoCombineSettings(bool fEnable, CAmount nCombineThreshold); + bool WriteAutoCombineSettings(bool fEnable, CAmount nCombineThreshold, int frequency); bool ReadPool(int64_t nPool, CKeyPool& keypool); bool WritePool(int64_t nPool, const CKeyPool& keypool); From 1c300a2bc9b44e3fc82d1b613ffc6903eb212b7d Mon Sep 17 00:00:00 2001 From: Alessandro Rezzi Date: Sat, 4 Mar 2023 18:59:44 -0800 Subject: [PATCH 3/5] Remove deprecated autocombinerewards RPC command --- src/rpc/client.cpp | 2 -- src/wallet/rpcwallet.cpp | 49 ---------------------------------------- 2 files changed, 51 deletions(-) diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index a6dc183c6513..155a24f8a15f 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -29,8 +29,6 @@ static const CRPCConvertParam vRPCConvertParams[] = { { "addmultisigaddress", 0, "nrequired" }, { "addmultisigaddress", 1, "keys" }, { "addpeeraddress", 1, "port" }, - { "autocombinerewards", 0, "enable" }, - { "autocombinerewards", 1, "threshold" }, { "cleanbudget", 0, "try_sync" }, { "createmultisig", 0, "nrequired" }, { "createmultisig", 1, "keys" }, diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index fb97369d4adb..f861abce3319 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4450,54 +4450,6 @@ UniValue getstakesplitthreshold(const JSONRPCRequest& request) return ValueFromAmount(pwallet->GetStakeSplitThreshold()); } -UniValue autocombinerewards(const JSONRPCRequest& request) -{ - if (!IsDeprecatedRPCEnabled("autocombinerewards")) { - if (request.fHelp) { - throw std::runtime_error("autocombinerewards (Deprecated, will be removed in v6.0. To use this command, start pivxd with -deprecatedrpc=autocombinerewards)"); - } - throw JSONRPCError(RPC_METHOD_DEPRECATED, "autocombinerewards is deprecated and will be removed in v6.0. To use this command, start pivxd with -deprecatedrpc=autocombinerewards"); - } - - CWallet * const pwallet = GetWalletForJSONRPCRequest(request); - - if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) - return NullUniValue; - - bool fEnable = !request.params.empty() && request.params[0].get_bool(); - - if (request.fHelp || request.params.empty() || (fEnable && request.params.size() != 2) || request.params.size() > 2) - throw std::runtime_error( - "autocombinerewards enable ( threshold )\n" - "\nDEPRECATED!!! This command has been replaced with setautocombinethreshold and getautocombinethreshold and will be removed in a future version!!!\n" - "\nWallet will automatically monitor for any coins with value below the threshold amount, and combine them if they reside with the same PIVX address\n" - "When autocombinerewards runs it will create a transaction, and therefore will be subject to transaction fees.\n" - - "\nArguments:\n" - "1. enable (boolean, required) Enable auto combine (true) or disable (false)\n" - "2. threshold (numeric, optional, required if enable=True) Threshold amount (default: 0)\n" - - "\nExamples:\n" + - HelpExampleCli("autocombinerewards", "true 500") + HelpExampleRpc("autocombinerewards", "true 500")); - - WalletBatch batch(pwallet->GetDBHandle()); - CAmount nThreshold = 0; - - if (fEnable && request.params.size() > 1) { - nThreshold = AmountFromValue(request.params[1]); - if (nThreshold < COIN) - throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("The threshold value cannot be less than %s", FormatMoney(COIN))); - } - - pwallet->fCombineDust = fEnable; - pwallet->nAutoCombineThreshold = nThreshold; - - if (!batch.WriteAutoCombineSettings(fEnable, nThreshold)) - throw std::runtime_error("Changed settings in wallet but failed to save to database\n"); - - return NullUniValue; -} - UniValue setautocombinethreshold(const JSONRPCRequest& request) { CWallet * const pwallet = GetWalletForJSONRPCRequest(request); @@ -4738,7 +4690,6 @@ static const CRPCCommand commands[] = { // category name actor (function) okSafe argNames // --------------------- ------------------------ ----------------------- ------ -------- { "wallet", "getaddressinfo", &getaddressinfo, true, {"address"} }, - { "wallet", "autocombinerewards", &autocombinerewards, false, {"enable","threshold"} }, { "wallet", "setautocombinethreshold", &setautocombinethreshold, false, {"enable","threshold"} }, { "wallet", "getautocombinethreshold", &getautocombinethreshold, false, {} }, { "wallet", "abandontransaction", &abandontransaction, false, {"txid"} }, From e7437c9fb97f4a1bf1e15a9766873a0a1594eb21 Mon Sep 17 00:00:00 2001 From: Alessandro Rezzi Date: Sat, 4 Mar 2023 19:16:35 -0800 Subject: [PATCH 4/5] Update functional test DeprecatedRpcTest --- test/functional/rpc_deprecated.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/test/functional/rpc_deprecated.py b/test/functional/rpc_deprecated.py index b8acd991d47f..4ecb3bf075cf 100755 --- a/test/functional/rpc_deprecated.py +++ b/test/functional/rpc_deprecated.py @@ -5,14 +5,14 @@ """Test deprecation of RPC calls.""" from test_framework.test_framework import PivxTestFramework -from test_framework.util import assert_raises_rpc_error +# from test_framework.util import assert_raises_rpc_error class DeprecatedRpcTest(PivxTestFramework): def set_test_params(self): self.num_nodes = 2 self.setup_clean_chain = True - self.extra_args = [[], ["-deprecatedrpc=autocombinerewards"]] + # self.extra_args = [[], ["-deprecatedrpc=rpcname"]] add deprecated rpc here def run_test(self): # This test should be used to verify correct behaviour of deprecated @@ -21,13 +21,7 @@ def run_test(self): # self.log.info("Make sure that -deprecatedrpc=accounts allows it to take accounts") # assert_raises_rpc_error(-32, "listaccounts is deprecated", self.nodes[0].listaccounts) # self.nodes[1].listaccounts() - - self.log.info("Test autocombinerewards deprecation") - # The autocombinerewards RPC method has been deprecated - assert_raises_rpc_error(-32, "autocombinerewards is deprecated", self.nodes[0].autocombinerewards, True, 500) - self.nodes[1].autocombinerewards(True, 500) - - # self.log.info("No test cases to run") # remove this when adding any tests to this file + self.log.info("No test cases to run") # remove this when adding any tests to this file if __name__ == '__main__': From 63488be61d48c66fba7c8fb78fddbe3ae309fbc9 Mon Sep 17 00:00:00 2001 From: Alessandro Rezzi Date: Sat, 4 Mar 2023 19:04:27 -0800 Subject: [PATCH 5/5] Update functional test wallet_autocombine.py --- test/functional/wallet_autocombine.py | 36 +++++++++++++++++++-------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/test/functional/wallet_autocombine.py b/test/functional/wallet_autocombine.py index 251e4cc54400..c6c78982790f 100755 --- a/test/functional/wallet_autocombine.py +++ b/test/functional/wallet_autocombine.py @@ -25,6 +25,8 @@ def run_test(self): # Check the failure conditions for setautocombinethreshold assert_raises_rpc_error(-8, "Missing threshold value", self.nodes[0].setautocombinethreshold, True) assert_raises_rpc_error(-8, "The threshold value cannot be less than 1.00", self.nodes[0].setautocombinethreshold, True, 0.99) + assert_raises_rpc_error(-8, "Frequency must be greater than 0", self.nodes[0].setautocombinethreshold, True, 2, -1) + assert_raises_rpc_error(-8, "The threshold value cannot be less than 1.00", self.nodes[0].setautocombinethreshold, True, 0.99) self.log.info("Mining initial 100 blocks...") self.nodes[0].generate(100) @@ -37,22 +39,27 @@ def run_test(self): self.nodes[0].generate(2) walletinfo = self.nodes[0].getwalletinfo() - assert_equal(walletinfo['balance'], 500) + assert_equal(walletinfo['balance'], 250*2) assert_equal(walletinfo['txcount'], 102) - self.log.info("Set autocombine to 500 PIV") - setautocombine = self.nodes[0].setautocombinethreshold(True, 500) + self.log.info("Set autocombine to 500 PIV and frequency of 10") + setautocombine = self.nodes[0].setautocombinethreshold(True, 500, 10) assert_equal(setautocombine['enabled'], True) assert_equal(setautocombine['threshold'], 500) + assert_equal(setautocombine['frequency'], 10) getautocombine = self.nodes[0].getautocombinethreshold() assert_equal(getautocombine['enabled'], True) assert_equal(getautocombine['threshold'], 500) + assert_equal(getautocombine['frequency'], 10) walletinfo = self.nodes[0].getwalletinfo() assert_equal(walletinfo['autocombine_enabled'], True) assert_equal(walletinfo['autocombine_threshold'], 500) + assert_equal(walletinfo['autocombine_frequency'], 10) - self.log.info("Mine 1 more block to initiate an autocombine transaction") - self.nodes[0].generate(1) + self.log.info("Mine 8 more block to initiate an autocombine transaction") + + self.nodes[0].generate(8) # we need 8 more blocks to get a multiple of 10 + assert_equal(0, self.nodes[0].getblockcount() % 10) time.sleep(1) mempool = self.nodes[0].getrawmempool() @@ -60,16 +67,18 @@ def run_test(self): tx = mempool[0] nFee = self.nodes[0].getrawmempool(True)[mempool[0]]['fee'] walletinfo = self.nodes[0].getwalletinfo() - assert_equal(walletinfo['balance'], 750 - nFee) - assert_equal(walletinfo['txcount'], 104) + assert_equal(walletinfo['balance'], 250*10 - nFee) + assert_equal(walletinfo['txcount'], 111) # 110 coinbase txs + 1 to autocollect self.log.info("Mine 1 more block to confirm the autocombine transaction") block = self.nodes[0].generate(1) time.sleep(1) walletinfo = self.nodes[0].getwalletinfo() - assert_equal(walletinfo['balance'], 250 + 750 - nFee) - assert_equal(walletinfo['txcount'], 105) + assert_equal(walletinfo['balance'], 250*11 - nFee) + # 111 coinbase txs + 1 autocollect, good autocollect was not called again since nBlock % 10 = 1 + assert_equal(1, self.nodes[0].getblockcount() % 10) + assert_equal(walletinfo['txcount'], 112) txinfo = self.nodes[0].gettransaction(tx) assert_equal(txinfo['fee'], 0 - nFee) @@ -81,12 +90,17 @@ def run_test(self): setautocombine = self.nodes[0].setautocombinethreshold(False) assert_equal(setautocombine['enabled'], False) assert_equal(setautocombine['threshold'], 0) + assert_equal(setautocombine['frequency'], 30) # set back to default value + getautocombine = self.nodes[0].getautocombinethreshold() assert_equal(getautocombine['enabled'], False) assert_equal(getautocombine['threshold'], 0) + assert_equal(getautocombine['frequency'], 30) + walletinfo = self.nodes[0].getwalletinfo() assert_equal(walletinfo['autocombine_enabled'], False) assert_equal(walletinfo['autocombine_threshold'], 0) + assert_equal(walletinfo['autocombine_frequency'], 30) self.log.info("Mine 1 more block to make sure autocombine is disabled") self.nodes[0].generate(1) @@ -96,8 +110,8 @@ def run_test(self): assert_equal(len(mempool), 0) walletinfo = self.nodes[0].getwalletinfo() - assert_equal(walletinfo['balance'], 250 + 250 + 750 - nFee) - assert_equal(walletinfo['txcount'], 106) + assert_equal(walletinfo['balance'], 250*12 - nFee) + assert_equal(walletinfo['txcount'], 113) if __name__ == '__main__':