Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add recent utxos rest API endpoint #97

Draft
wants to merge 1 commit into
base: mempool
Choose a base branch
from

Conversation

mononaut
Copy link
Contributor

Draft PR to add a new /address/:address/utxo/recent REST API endpoint, which returns the most recent utxos_limit confirmed utxos for the given address, plus all unconfirmed utxos, sorted in descending order of confirmation status & block height.

Motivation

Unlike the existing /address/:address/utxo endpoint, this new API retrieves UTXOs by scanning address history in reverse chronological order, which means it can return early with useful data once it hits one of the resource limits, rather than throwing errors on addresses with excessive activity.

This makes it more suitable for e.g. utxo charts and visualizations.

Implementation

The PR also adds a new config parameter utxos_history_limit, which defines the maximum number of transaction history entries to process while looking up utxos. If an address's utxos are buried beneath more than this number of history entries, the API may return early with fewer than utxos_limit confirmed utxos.

Results are cached under a new cache_db key prefix b'R'.

Todo

  • test reorg/stale block behavior

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant