Issue Description
The current ListTxns API uses the special range $\mathbf{startHeight=0}$ and $\mathbf{endHeight=-1}$ to implicitly retrieve all transactions, including unmined (mempool) transactions.
This is problematic because:
-
Performance: Including the constantly changing mempool is an unnecessary performance hit when a user only needs a specific historical block range.
-
Clarity: The behavior relies on "magic number" range values (the non-descriptive $\mathbf{0}$ and $\mathbf{-1}$ combination) rather than explicit control. Explicit control means using a clear, well-named input (like a dedicated flag) to directly command the desired behavior, making the code's intent immediately obvious.
Proposed Improvement
Refactor the underlying transaction listing method to introduce an explicit boolean flag, such as $\mathbf{include\_unmined}$.
- This allows users to explicitly opt-in to mempool transactions, ensuring that standard historical queries are optimized for speed by avoiding unnecessary mempool lookups.
- It replaces the confusing special range with a clear, explicit control mechanism.
Motivation and Context
Follow-up on @yyforyongyu's comment #1091 (comment)