diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 6a150e2c32d9..ed615e2c5a65 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3721,12 +3721,13 @@ UniValue getwalletinfo(const JSONRPCRequest& request) " \"immature_balance\": xxxxxx, (numeric) the total immature balance of the wallet in PIV\n" " \"txcount\": xxxxxxx, (numeric) the total number of transactions in the wallet\n" " \"keypoololdest\": xxxxxx, (numeric) the timestamp (seconds since GMT epoch) of the oldest pre-generated key in the key pool\n" - " \"keypoolsize\": xxxx, (numeric) how many new keys are pre-generated (only counts external keys)\n" - " \"keypoolsize_hd_internal\": xxxx, (numeric) how many new keys are pre-generated for internal use (used for change outputs, only appears if the wallet is using this feature, otherwise external keys are used)\n" - " \"keypoolsize_hd_staking\": xxxx, (numeric) how many new keys are pre-generated for staking use (used for staking contracts, only appears if the wallet is using this feature)\n" + " \"keypoolsize\": xxxx, (numeric) how many new keys are pre-generated (only counts external keys)\n" + " \"keypoolsize_hd_internal\": xxxx, (numeric) how many new keys are pre-generated for internal use (used for change outputs, only appears if the wallet is using this feature, otherwise external keys are used)\n" + " \"keypoolsize_hd_staking\": xxxx, (numeric) how many new keys are pre-generated for staking use (used for staking contracts, only appears if the wallet is using this feature)\n" " \"unlocked_until\": ttt, (numeric) the timestamp in seconds since epoch (midnight Jan 1 1970 GMT) that the wallet is unlocked for transfers, or 0 if the wallet is locked\n" " \"paytxfee\": x.xxxx (numeric) the transaction fee configuration, set in PIV/kB\n" - " \"hdseedid\": \"\" (string, optional) the Hash160 of the HD seed (only present when HD is enabled)\n" + " \"hdseedid\": \"\" (string, optional) the Hash160 of the HD seed (only present when HD is enabled)\n" + " \"last_processed_block\": xxxxx, (numeric) the last block processed block height\n" "}\n" "\nExamples:\n" + @@ -3768,6 +3769,7 @@ UniValue getwalletinfo(const JSONRPCRequest& request) if (pwalletMain->IsCrypted()) obj.pushKV("unlocked_until", nWalletUnlockTime); obj.pushKV("paytxfee", ValueFromAmount(payTxFee.GetFeePerK())); + obj.pushKV("last_processed_block", pwalletMain->GetLastBlockHeight()); return obj; } diff --git a/test/functional/mining_pos_coldStaking.py b/test/functional/mining_pos_coldStaking.py index 07a6b2e0e2b3..f5c5eb289acb 100755 --- a/test/functional/mining_pos_coldStaking.py +++ b/test/functional/mining_pos_coldStaking.py @@ -421,6 +421,7 @@ def run_test(self): def checkBalances(self): w_info = self.nodes[0].getwalletinfo() + assert_equal(self.nodes[0].getblockcount(), w_info['last_processed_block']) self.log.info("OWNER - Delegated %f / Cold %f [%f / %f]" % ( float(w_info["delegated_balance"]), w_info["cold_staking_balance"], float(w_info["immature_delegated_balance"]), w_info["immature_cold_staking_balance"])) @@ -428,6 +429,7 @@ def checkBalances(self): assert_equal(float(w_info["immature_delegated_balance"]), self.expected_immature_balance) assert_equal(float(w_info["cold_staking_balance"]), 0) w_info = self.nodes[1].getwalletinfo() + assert_equal(self.nodes[1].getblockcount(), w_info['last_processed_block']) self.log.info("STAKER - Delegated %f / Cold %f [%f / %f]" % ( float(w_info["delegated_balance"]), w_info["cold_staking_balance"], float(w_info["immature_delegated_balance"]), w_info["immature_cold_staking_balance"])) diff --git a/test/functional/mining_pos_reorg.py b/test/functional/mining_pos_reorg.py index d59ee8d8006d..35cb84350405 100755 --- a/test/functional/mining_pos_reorg.py +++ b/test/functional/mining_pos_reorg.py @@ -47,6 +47,7 @@ def disconnect_all(self): def get_tot_balance(self, nodeid): wi = self.nodes[nodeid].getwalletinfo() + assert_equal(self.nodes[nodeid].getblockcount(), wi['last_processed_block']) return wi['balance'] + wi['immature_balance'] def check_money_supply(self, expected_piv): diff --git a/test/functional/sapling_wallet_anchorfork.py b/test/functional/sapling_wallet_anchorfork.py index 92a4666885f3..40943257ab6e 100755 --- a/test/functional/sapling_wallet_anchorfork.py +++ b/test/functional/sapling_wallet_anchorfork.py @@ -24,6 +24,7 @@ def run_test (self): self.sync_all() walletinfo = self.nodes[0].getwalletinfo() + assert_equal(self.nodes[0].getblockcount(), walletinfo['last_processed_block']) assert_equal(walletinfo['immature_balance'], 1000) assert_equal(walletinfo['balance'], 0) diff --git a/test/functional/wallet_basic.py b/test/functional/wallet_basic.py index 2b8f7af43767..e0c8634a855e 100755 --- a/test/functional/wallet_basic.py +++ b/test/functional/wallet_basic.py @@ -32,6 +32,9 @@ def setup_network(self): def get_vsize(self, txn): return self.nodes[0].decoderawtransaction(txn)['size'] + def check_wallet_processed_blocks(self, nodeid, walletinfo): + assert_equal(self.nodes[nodeid].getblockcount(), walletinfo['last_processed_block']) + def run_test(self): # Check that there's no UTXO on none of the nodes assert_equal(len(self.nodes[0].listunspent()), 0) @@ -43,6 +46,7 @@ def run_test(self): self.nodes[0].generate(1) walletinfo = self.nodes[0].getwalletinfo() + self.check_wallet_processed_blocks(0, walletinfo) assert_equal(walletinfo['immature_balance'], 250) assert_equal(walletinfo['balance'], 0) @@ -54,13 +58,17 @@ def run_test(self): assert_equal(self.nodes[1].getbalance(), 250) assert_equal(self.nodes[2].getbalance(), 0) + walletinfo = self.nodes[0].getwalletinfo() + self.check_wallet_processed_blocks(0, walletinfo) + self.check_wallet_processed_blocks(1, self.nodes[1].getwalletinfo()) + self.check_wallet_processed_blocks(2, self.nodes[2].getwalletinfo()) + # Check that only first and second nodes have UTXOs utxos = self.nodes[0].listunspent() assert_equal(len(utxos), 1) assert_equal(len(self.nodes[1].listunspent()), 1) assert_equal(len(self.nodes[2].listunspent()), 0) - walletinfo = self.nodes[0].getwalletinfo() assert_equal(walletinfo['immature_balance'], 0) # Exercise locking of unspent outputs @@ -185,6 +193,7 @@ def run_test(self): assert_equal(balance_nodes, [self.nodes[i].getbalance() for i in range(3)]) # Exercise listsinceblock with the last two blocks + self.check_wallet_processed_blocks(0, self.nodes[0].getwalletinfo()) coinbase_tx_1 = self.nodes[0].listsinceblock(blocks[0]) assert_equal(coinbase_tx_1["lastblock"], blocks[1]) assert_equal(len(coinbase_tx_1["transactions"]), 1)