Skip to content

Commit d48c1e8

Browse files
committed
Add window final block height to getchaintxstats
The getchaintxstats RPC now returns the additional key of window_final_block_height
1 parent 442a9c6 commit d48c1e8

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

doc/release-notes-16695.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Updated RPCs
2+
------------
3+
4+
- The `getchaintxstats` RPC now returns the additional key of
5+
`window_final_block_height`.

src/rpc/blockchain.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,6 +1639,7 @@ static UniValue getchaintxstats(const JSONRPCRequest& request)
16391639
" \"time\": xxxxx, (numeric) The timestamp for the final block in the window in UNIX format.\n"
16401640
" \"txcount\": xxxxx, (numeric) The total number of transactions in the chain up to that point.\n"
16411641
" \"window_final_block_hash\": \"...\", (string) The hash of the final block in the window.\n"
1642+
" \"window_final_block_height\": xxxxx, (numeric) The height of the final block in the window.\n"
16421643
" \"window_block_count\": xxxxx, (numeric) Size of the window in number of blocks.\n"
16431644
" \"window_tx_count\": xxxxx, (numeric) The number of transactions in the window. Only returned if \"window_block_count\" is > 0.\n"
16441645
" \"window_interval\": xxxxx, (numeric) The elapsed time in the window in seconds. Only returned if \"window_block_count\" is > 0.\n"
@@ -1689,6 +1690,7 @@ static UniValue getchaintxstats(const JSONRPCRequest& request)
16891690
ret.pushKV("time", (int64_t)pindex->nTime);
16901691
ret.pushKV("txcount", (int64_t)pindex->nChainTx);
16911692
ret.pushKV("window_final_block_hash", pindex->GetBlockHash().GetHex());
1693+
ret.pushKV("window_final_block_height", pindex->nHeight);
16921694
ret.pushKV("window_block_count", blockcount);
16931695
if (blockcount > 0) {
16941696
ret.pushKV("window_tx_count", nTxDiff);

test/functional/rpc_blockchain.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ def _test_getchaintxstats(self):
186186
assert_equal(chaintxstats['time'], b200['time'])
187187
assert_equal(chaintxstats['txcount'], 201)
188188
assert_equal(chaintxstats['window_final_block_hash'], b200_hash)
189+
assert_equal(chaintxstats['window_final_block_height'], 200)
189190
assert_equal(chaintxstats['window_block_count'], 199)
190191
assert_equal(chaintxstats['window_tx_count'], 199)
191192
assert_equal(chaintxstats['window_interval'], time_diff)
@@ -195,6 +196,7 @@ def _test_getchaintxstats(self):
195196
assert_equal(chaintxstats['time'], b1['time'])
196197
assert_equal(chaintxstats['txcount'], 2)
197198
assert_equal(chaintxstats['window_final_block_hash'], b1_hash)
199+
assert_equal(chaintxstats['window_final_block_height'], 1)
198200
assert_equal(chaintxstats['window_block_count'], 0)
199201
assert 'window_tx_count' not in chaintxstats
200202
assert 'window_interval' not in chaintxstats

0 commit comments

Comments
 (0)