spesmilo / spesmilo/electrum-protocol

Add `blockchain.block.stats` protocol method

Open
#14 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
No language data
Stars
18
Forks
8
PR merge metrics
No merged PRs in 30d

Description

This method is similar to blockchain.transaction.get(tx_hash, verbose=true), but instead of returning details of a transaction it returns statistics for a block, , essentially mirroring the result of the getblockstats call from the coin daemon. Block statistics are very useful for client side fee prediction, whether they are used internally by the wallet or presented to the user.


blockchain.block.stats

Returns statistics about a block, mirroring the result of the getblockstats call from the coin daemon.

Signature

blockchain.block.stats(height)
  • height: The block height.

Result

A dictionary which mirrors the result of the getblockstats call from the coin daemon.

Result Example

{
  "avgfee": 1041,
  "avgfeerate": 2,
  "avgtxsize": 690,
  "blockhash": "000000000000000000023c7d67a6bca33b6672cd2d930e4141a4d422516ed5a6",
  "feerate_percentiles": [
    1,
    1,
    1,
    2,
    4
  ],
  "height": 896381,
  "ins": 9441,
  "maxfee": 159149,
  "maxfeerate": 165,
  "maxtxsize": 151474,
  "medianfee": 304,
  "mediantime": 1747035113,
  "mediantxsize": 337,
  "minfee": 99,
  "minfeerate": 1,
  "mintxsize": 150,
  "outs": 6657,
  "subsidy": 312500000,
  "swtotal_size": 1559775,
  "swtotal_weight": 3391809,
  "swtxs": 2218,
  "time": 1747037716,
  "total_out": 2316008619061,
  "total_size": 1709776,
  "total_weight": 3991813,
  "totalfee": 2578737,
  "txs": 2477,
  "utxo_increase": -2784,
  "utxo_size_inc": -211085,
  "utxo_increase_actual": -3503,
  "utxo_size_inc_actual": -258483
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the existing blockchain.transaction.get(tx_hash, verbose=true) method with the requested blockchain.block.stats(height) signature. Check how the protocol represents methods and result dictionaries, then mirror the coin daemon's getblockstats result; it is done when the new method and the documented example expose the listed block statistics.

Written by the indexing model from the issue text.

Assessment

Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.