rpc: Avoid getchaintxstats invalid results
Summary:
The getchaintxstats RPC reply during AU background download may return non-zero, but invalid, values for window_tx_count and txrate.
For example, txcount may be zero for a to-be-downloaded block, but may be non-zero for an ancestor block which is already downloaded. Thus, the values returned may be negative (and cause intermediate integer sanitizer violations).
Also, txcount may be accurate for the snapshot base block, or a descendant of it. However it may be zero for an ancestor block that still needs to be downloaded. Thus, the values returned may be positive, but wrong.
Fix all issues by skipping the returned value if either txcount is unset (equal to zero).
Also, skip txcount in the returned value, if it is unset (equal to zero).
This is a backport of core#29720
Test Plan: ninja all check-all
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Subscribers: Fabien
Differential Revision: https://reviews.bitcoinabc.org/D18053