server: moved params from brk_types

This commit is contained in:
nym21
2026-04-02 23:49:01 +02:00
parent 744dce932c
commit 4840e564f4
34 changed files with 315 additions and 197 deletions

View File

@@ -3,7 +3,7 @@ use std::cmp::Ordering;
use brk_error::{Error, Result}; use brk_error::{Error, Result};
use brk_types::{ use brk_types::{
CpfpEntry, CpfpInfo, FeeRate, MempoolBlock, MempoolInfo, MempoolRecentTx, RecommendedFees, CpfpEntry, CpfpInfo, FeeRate, MempoolBlock, MempoolInfo, MempoolRecentTx, RecommendedFees,
Txid, TxidParam, TxidPrefix, Weight, Txid, TxidPrefix, Weight,
}; };
use crate::Query; use crate::Query;
@@ -51,10 +51,10 @@ impl Query {
Ok(mempool.get_txs().recent().to_vec()) Ok(mempool.get_txs().recent().to_vec())
} }
pub fn cpfp(&self, TxidParam { txid }: TxidParam) -> Result<CpfpInfo> { pub fn cpfp(&self, txid: &Txid) -> Result<CpfpInfo> {
let mempool = self.mempool().ok_or(Error::MempoolNotAvailable)?; let mempool = self.mempool().ok_or(Error::MempoolNotAvailable)?;
let entries = mempool.get_entries(); let entries = mempool.get_entries();
let prefix = TxidPrefix::from(&txid); let prefix = TxidPrefix::from(txid);
let entry = entries let entry = entries
.get(&prefix) .get(&prefix)

View File

@@ -2,23 +2,23 @@ use bitcoin::hex::DisplayHex;
use brk_error::{Error, Result}; use brk_error::{Error, Result};
use brk_types::{ use brk_types::{
BlockHash, Height, MerkleProof, Timestamp, TxInIndex, TxIndex, TxOutspend, TxStatus, BlockHash, Height, MerkleProof, Timestamp, TxInIndex, TxIndex, TxOutspend, TxStatus,
Transaction, Txid, TxidParam, TxidPrefix, Vin, Vout, Transaction, Txid, TxidPrefix, Vin, Vout,
}; };
use vecdb::{ReadableVec, VecIndex}; use vecdb::{ReadableVec, VecIndex};
use crate::Query; use crate::Query;
impl Query { impl Query {
pub fn transaction(&self, TxidParam { txid }: TxidParam) -> Result<Transaction> { pub fn transaction(&self, txid: &Txid) -> Result<Transaction> {
// First check mempool for unconfirmed transactions // First check mempool for unconfirmed transactions
if let Some(mempool) = self.mempool() if let Some(mempool) = self.mempool()
&& let Some(tx_with_hex) = mempool.get_txs().get(&txid) && let Some(tx_with_hex) = mempool.get_txs().get(txid)
{ {
return Ok(tx_with_hex.tx().clone()); return Ok(tx_with_hex.tx().clone());
} }
// Look up confirmed transaction by txid prefix // Look up confirmed transaction by txid prefix
let prefix = TxidPrefix::from(&txid); let prefix = TxidPrefix::from(txid);
let indexer = self.indexer(); let indexer = self.indexer();
let Ok(Some(tx_index)) = indexer let Ok(Some(tx_index)) = indexer
.stores .stores
@@ -32,16 +32,16 @@ impl Query {
self.transaction_by_index(tx_index) self.transaction_by_index(tx_index)
} }
pub fn transaction_status(&self, TxidParam { txid }: TxidParam) -> Result<TxStatus> { pub fn transaction_status(&self, txid: &Txid) -> Result<TxStatus> {
// First check mempool for unconfirmed transactions // First check mempool for unconfirmed transactions
if let Some(mempool) = self.mempool() if let Some(mempool) = self.mempool()
&& mempool.get_txs().contains_key(&txid) && mempool.get_txs().contains_key(txid)
{ {
return Ok(TxStatus::UNCONFIRMED); return Ok(TxStatus::UNCONFIRMED);
} }
// Look up confirmed transaction by txid prefix // Look up confirmed transaction by txid prefix
let prefix = TxidPrefix::from(&txid); let prefix = TxidPrefix::from(txid);
let indexer = self.indexer(); let indexer = self.indexer();
let Ok(Some(tx_index)) = indexer let Ok(Some(tx_index)) = indexer
.stores .stores
@@ -70,8 +70,8 @@ impl Query {
}) })
} }
pub fn transaction_raw(&self, TxidParam { txid }: TxidParam) -> Result<Vec<u8>> { pub fn transaction_raw(&self, txid: &Txid) -> Result<Vec<u8>> {
let prefix = TxidPrefix::from(&txid); let prefix = TxidPrefix::from(txid);
let indexer = self.indexer(); let indexer = self.indexer();
let Ok(Some(tx_index)) = indexer let Ok(Some(tx_index)) = indexer
.stores .stores
@@ -84,16 +84,16 @@ impl Query {
self.transaction_raw_by_index(tx_index) self.transaction_raw_by_index(tx_index)
} }
pub fn transaction_hex(&self, TxidParam { txid }: TxidParam) -> Result<String> { pub fn transaction_hex(&self, txid: &Txid) -> Result<String> {
// First check mempool for unconfirmed transactions // First check mempool for unconfirmed transactions
if let Some(mempool) = self.mempool() if let Some(mempool) = self.mempool()
&& let Some(tx_with_hex) = mempool.get_txs().get(&txid) && let Some(tx_with_hex) = mempool.get_txs().get(txid)
{ {
return Ok(tx_with_hex.hex().to_string()); return Ok(tx_with_hex.hex().to_string());
} }
// Look up confirmed transaction by txid prefix // Look up confirmed transaction by txid prefix
let prefix = TxidPrefix::from(&txid); let prefix = TxidPrefix::from(txid);
let indexer = self.indexer(); let indexer = self.indexer();
let Ok(Some(tx_index)) = indexer let Ok(Some(tx_index)) = indexer
.stores .stores
@@ -107,24 +107,24 @@ impl Query {
self.transaction_hex_by_index(tx_index) self.transaction_hex_by_index(tx_index)
} }
pub fn outspend(&self, txid: TxidParam, vout: Vout) -> Result<TxOutspend> { pub fn outspend(&self, txid: &Txid, vout: Vout) -> Result<TxOutspend> {
let all = self.outspends(txid)?; let all = self.outspends(txid)?;
all.into_iter() all.into_iter()
.nth(usize::from(vout)) .nth(usize::from(vout))
.ok_or(Error::OutOfRange("Output index out of range".into())) .ok_or(Error::OutOfRange("Output index out of range".into()))
} }
pub fn outspends(&self, TxidParam { txid }: TxidParam) -> Result<Vec<TxOutspend>> { pub fn outspends(&self, txid: &Txid) -> Result<Vec<TxOutspend>> {
// Mempool outputs are unspent in on-chain terms // Mempool outputs are unspent in on-chain terms
if let Some(mempool) = self.mempool() if let Some(mempool) = self.mempool()
&& let Some(tx_with_hex) = mempool.get_txs().get(&txid) && let Some(tx_with_hex) = mempool.get_txs().get(txid)
{ {
let output_count = tx_with_hex.tx().output.len(); let output_count = tx_with_hex.tx().output.len();
return Ok(vec![TxOutspend::UNSPENT; output_count]); return Ok(vec![TxOutspend::UNSPENT; output_count]);
} }
// Look up confirmed transaction // Look up confirmed transaction
let prefix = TxidPrefix::from(&txid); let prefix = TxidPrefix::from(txid);
let indexer = self.indexer(); let indexer = self.indexer();
let Ok(Some(tx_index)) = indexer let Ok(Some(tx_index)) = indexer
.stores .stores
@@ -248,12 +248,12 @@ impl Query {
self.client().send_raw_transaction(hex) self.client().send_raw_transaction(hex)
} }
pub fn merkleblock_proof(&self, txid_param: TxidParam) -> Result<String> { pub fn merkleblock_proof(&self, txid: &Txid) -> Result<String> {
let (_, height) = self.resolve_tx(&txid_param.txid)?; let (_, height) = self.resolve_tx(txid)?;
let header = self.read_block_header(height)?; let header = self.read_block_header(height)?;
let txids = self.block_txids_by_height(height)?; let txids = self.block_txids_by_height(height)?;
let target: bitcoin::Txid = (&txid_param.txid).into(); let target: bitcoin::Txid = txid.into();
let btxids: Vec<bitcoin::Txid> = txids.iter().map(bitcoin::Txid::from).collect(); let btxids: Vec<bitcoin::Txid> = txids.iter().map(bitcoin::Txid::from).collect();
let mb = bitcoin::MerkleBlock::from_header_txids_with_predicate(&header, &btxids, |t| { let mb = bitcoin::MerkleBlock::from_header_txids_with_predicate(&header, &btxids, |t| {
*t == target *t == target
@@ -261,8 +261,8 @@ impl Query {
Ok(bitcoin::consensus::encode::serialize_hex(&mb)) Ok(bitcoin::consensus::encode::serialize_hex(&mb))
} }
pub fn merkle_proof(&self, txid_param: TxidParam) -> Result<MerkleProof> { pub fn merkle_proof(&self, txid: &Txid) -> Result<MerkleProof> {
let (tx_index, height) = self.resolve_tx(&txid_param.txid)?; let (tx_index, height) = self.resolve_tx(txid)?;
let first_tx = self let first_tx = self
.indexer() .indexer()
.vecs .vecs

View File

@@ -5,12 +5,13 @@ use axum::{
response::Redirect, response::Redirect,
routing::get, routing::get,
}; };
use brk_types::{ use brk_types::{AddrStats, AddrValidation, Transaction, Txid, Utxo, Version};
AddrParam, AddrStats, AddrTxidsParam, AddrValidation, Transaction, Txid, Utxo,
ValidateAddrParam, Version,
};
use crate::{AppState, CacheStrategy, extended::TransformResponseExtended}; use crate::{
AppState, CacheStrategy,
extended::TransformResponseExtended,
params::{AddrParam, AddrTxidsParam, ValidateAddrParam},
};
pub trait AddrRoutes { pub trait AddrRoutes {
fn add_addr_routes(self) -> Self; fn add_addr_routes(self) -> Self;

View File

@@ -4,12 +4,13 @@ use axum::{
http::{HeaderMap, Uri}, http::{HeaderMap, Uri},
}; };
use brk_query::BLOCK_TXS_PAGE_SIZE; use brk_query::BLOCK_TXS_PAGE_SIZE;
use brk_types::{ use brk_types::{BlockInfo, BlockInfoV1, BlockStatus, BlockTimestamp, Transaction, TxIndex, Txid, Version};
BlockHashParam, BlockHashStartIndex, BlockHashTxIndex, BlockInfo, BlockInfoV1, BlockStatus,
BlockTimestamp, HeightParam, TimestampParam, Transaction, TxIndex, Txid, Version,
};
use crate::{AppState, CacheStrategy, extended::TransformResponseExtended}; use crate::{
AppState, CacheStrategy,
extended::TransformResponseExtended,
params::{BlockHashParam, BlockHashStartIndex, BlockHashTxIndex, HeightParam, TimestampParam},
};
pub trait BlockRoutes { pub trait BlockRoutes {
fn add_block_routes(self) -> Self; fn add_block_routes(self) -> Self;

View File

@@ -3,9 +3,13 @@ use axum::{
extract::{Query, State}, extract::{Query, State},
http::{HeaderMap, Uri}, http::{HeaderMap, Uri},
}; };
use brk_types::{DifficultyAdjustment, HistoricalPrice, OptionalTimestampParam, Prices, Timestamp}; use brk_types::{DifficultyAdjustment, HistoricalPrice, Prices, Timestamp};
use crate::{AppState, CacheStrategy, extended::TransformResponseExtended}; use crate::{
AppState, CacheStrategy,
extended::TransformResponseExtended,
params::OptionalTimestampParam,
};
pub trait GeneralRoutes { pub trait GeneralRoutes {
fn add_general_routes(self) -> Self; fn add_general_routes(self) -> Self;

View File

@@ -6,12 +6,16 @@ use axum::{
routing::get, routing::get,
}; };
use brk_types::{ use brk_types::{
BlockCountParam, BlockFeesEntry, BlockInfoV1, BlockRewardsEntry, BlockSizesWeights, BlockFeesEntry, BlockInfoV1, BlockRewardsEntry, BlockSizesWeights,
DifficultyAdjustmentEntry, HashrateSummary, PoolDetail, PoolHashrateEntry, PoolInfo, DifficultyAdjustmentEntry, HashrateSummary, PoolDetail, PoolHashrateEntry, PoolInfo,
PoolSlugAndHeightParam, PoolSlugParam, PoolsSummary, RewardStats, TimePeriodParam, PoolsSummary, RewardStats,
}; };
use crate::{AppState, CacheStrategy, Error, extended::TransformResponseExtended}; use crate::{
AppState, CacheStrategy, Error,
extended::TransformResponseExtended,
params::{BlockCountParam, PoolSlugAndHeightParam, PoolSlugParam, TimePeriodParam},
};
pub trait MiningRoutes { pub trait MiningRoutes {
fn add_mining_routes(self) -> Self; fn add_mining_routes(self) -> Self;

View File

@@ -6,12 +6,13 @@ use axum::{
extract::{Path, State}, extract::{Path, State},
http::{HeaderMap, Uri}, http::{HeaderMap, Uri},
}; };
use brk_types::{ use brk_types::{CpfpInfo, MerkleProof, Transaction, TxOutspend, TxStatus, Txid, Version};
CpfpInfo, MerkleProof, Transaction, TxOutspend, TxStatus, Txid, TxidParam, TxidVout,
TxidsParam, Version,
};
use crate::{AppState, CacheStrategy, extended::TransformResponseExtended}; use crate::{
AppState, CacheStrategy,
extended::TransformResponseExtended,
params::{TxidParam, TxidVout, TxidsParam},
};
pub trait TxRoutes { pub trait TxRoutes {
fn add_tx_routes(self) -> Self; fn add_tx_routes(self) -> Self;
@@ -24,7 +25,7 @@ impl TxRoutes for ApiRouter<AppState> {
"/api/v1/cpfp/{txid}", "/api/v1/cpfp/{txid}",
get_with( get_with(
async |uri: Uri, headers: HeaderMap, Path(param): Path<TxidParam>, State(state): State<AppState>| { async |uri: Uri, headers: HeaderMap, Path(param): Path<TxidParam>, State(state): State<AppState>| {
state.cached_json(&headers, state.tx_cache(Version::ONE, &param.txid), &uri, move |q| q.cpfp(param)).await state.cached_json(&headers, state.tx_cache(Version::ONE, &param.txid), &uri, move |q| q.cpfp(&param.txid)).await
}, },
|op| op |op| op
.id("get_cpfp") .id("get_cpfp")
@@ -45,7 +46,7 @@ impl TxRoutes for ApiRouter<AppState> {
Path(param): Path<TxidParam>, Path(param): Path<TxidParam>,
State(state): State<AppState> State(state): State<AppState>
| { | {
state.cached_json(&headers, state.tx_cache(Version::ONE, &param.txid), &uri, move |q| q.transaction(param)).await state.cached_json(&headers, state.tx_cache(Version::ONE, &param.txid), &uri, move |q| q.transaction(&param.txid)).await
}, },
|op| op |op| op
.id("get_tx") .id("get_tx")
@@ -67,10 +68,10 @@ impl TxRoutes for ApiRouter<AppState> {
async | async |
uri: Uri, uri: Uri,
headers: HeaderMap, headers: HeaderMap,
Path(txid): Path<TxidParam>, Path(param): Path<TxidParam>,
State(state): State<AppState> State(state): State<AppState>
| { | {
state.cached_text(&headers, state.tx_cache(Version::ONE, &txid.txid), &uri, move |q| q.transaction_hex(txid)).await state.cached_text(&headers, state.tx_cache(Version::ONE, &param.txid), &uri, move |q| q.transaction_hex(&param.txid)).await
}, },
|op| op |op| op
.id("get_tx_hex") .id("get_tx_hex")
@@ -89,8 +90,8 @@ impl TxRoutes for ApiRouter<AppState> {
.api_route( .api_route(
"/api/tx/{txid}/merkleblock-proof", "/api/tx/{txid}/merkleblock-proof",
get_with( get_with(
async |uri: Uri, headers: HeaderMap, Path(txid): Path<TxidParam>, State(state): State<AppState>| { async |uri: Uri, headers: HeaderMap, Path(param): Path<TxidParam>, State(state): State<AppState>| {
state.cached_text(&headers, state.tx_cache(Version::ONE, &txid.txid), &uri, move |q| q.merkleblock_proof(txid)).await state.cached_text(&headers, state.tx_cache(Version::ONE, &param.txid), &uri, move |q| q.merkleblock_proof(&param.txid)).await
}, },
|op| op |op| op
.id("get_tx_merkleblock_proof") .id("get_tx_merkleblock_proof")
@@ -107,8 +108,8 @@ impl TxRoutes for ApiRouter<AppState> {
.api_route( .api_route(
"/api/tx/{txid}/merkle-proof", "/api/tx/{txid}/merkle-proof",
get_with( get_with(
async |uri: Uri, headers: HeaderMap, Path(txid): Path<TxidParam>, State(state): State<AppState>| { async |uri: Uri, headers: HeaderMap, Path(param): Path<TxidParam>, State(state): State<AppState>| {
state.cached_json(&headers, state.tx_cache(Version::ONE, &txid.txid), &uri, move |q| q.merkle_proof(txid)).await state.cached_json(&headers, state.tx_cache(Version::ONE, &param.txid), &uri, move |q| q.merkle_proof(&param.txid)).await
}, },
|op| op |op| op
.id("get_tx_merkle_proof") .id("get_tx_merkle_proof")
@@ -131,8 +132,7 @@ impl TxRoutes for ApiRouter<AppState> {
Path(path): Path<TxidVout>, Path(path): Path<TxidVout>,
State(state): State<AppState> State(state): State<AppState>
| { | {
let txid = TxidParam { txid: path.txid }; state.cached_json(&headers, CacheStrategy::Tip, &uri, move |q| q.outspend(&path.txid, path.vout)).await
state.cached_json(&headers, CacheStrategy::Tip, &uri, move |q| q.outspend(txid, path.vout)).await
}, },
|op| op |op| op
.id("get_tx_outspend") .id("get_tx_outspend")
@@ -154,10 +154,10 @@ impl TxRoutes for ApiRouter<AppState> {
async | async |
uri: Uri, uri: Uri,
headers: HeaderMap, headers: HeaderMap,
Path(txid): Path<TxidParam>, Path(param): Path<TxidParam>,
State(state): State<AppState> State(state): State<AppState>
| { | {
state.cached_json(&headers, CacheStrategy::Tip, &uri, move |q| q.outspends(txid)).await state.cached_json(&headers, CacheStrategy::Tip, &uri, move |q| q.outspends(&param.txid)).await
}, },
|op| op |op| op
.id("get_tx_outspends") .id("get_tx_outspends")
@@ -176,8 +176,8 @@ impl TxRoutes for ApiRouter<AppState> {
.api_route( .api_route(
"/api/tx/{txid}/raw", "/api/tx/{txid}/raw",
get_with( get_with(
async |uri: Uri, headers: HeaderMap, Path(txid): Path<TxidParam>, State(state): State<AppState>| { async |uri: Uri, headers: HeaderMap, Path(param): Path<TxidParam>, State(state): State<AppState>| {
state.cached_bytes(&headers, state.tx_cache(Version::ONE, &txid.txid), &uri, move |q| q.transaction_raw(txid)).await state.cached_bytes(&headers, state.tx_cache(Version::ONE, &param.txid), &uri, move |q| q.transaction_raw(&param.txid)).await
}, },
|op| op |op| op
.id("get_tx_raw") .id("get_tx_raw")
@@ -200,7 +200,7 @@ impl TxRoutes for ApiRouter<AppState> {
Path(param): Path<TxidParam>, Path(param): Path<TxidParam>,
State(state): State<AppState> State(state): State<AppState>
| { | {
state.cached_json(&headers, state.tx_cache(Version::ONE, &param.txid), &uri, move |q| q.transaction_status(param)).await state.cached_json(&headers, state.tx_cache(Version::ONE, &param.txid), &uri, move |q| q.transaction_status(&param.txid)).await
}, },
|op| op |op| op
.id("get_tx_status") .id("get_tx_status")

View File

@@ -9,10 +9,12 @@ use axum::{
}; };
use brk_traversable::TreeNode; use brk_traversable::TreeNode;
use brk_types::{ use brk_types::{
CostBasisCohortParam, CostBasisFormatted, CostBasisParams, CostBasisQuery, DataRangeFormat, CostBasisFormatted, DataRangeFormat, Date, DetailedSeriesCount, Index, IndexInfo,
Date, DetailedSeriesCount, Index, IndexInfo, PaginatedSeries, Pagination, SearchQuery, PaginatedSeries, Pagination, SearchQuery, SeriesData, SeriesInfo, SeriesList, SeriesName,
SeriesData, SeriesInfo, SeriesList, SeriesName, SeriesSelection, SeriesSelectionLegacy, SeriesSelection, SeriesSelectionLegacy,
}; };
use crate::params::{CostBasisCohortParam, CostBasisParams, CostBasisQuery};
use schemars::JsonSchema; use schemars::JsonSchema;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};

View File

@@ -9,12 +9,15 @@ use axum::{
}; };
use brk_traversable::TreeNode; use brk_traversable::TreeNode;
use brk_types::{ use brk_types::{
CostBasisCohortParam, CostBasisFormatted, CostBasisParams, CostBasisQuery, DataRangeFormat, CostBasisFormatted, DataRangeFormat, Date, IndexInfo, PaginatedSeries, Pagination, SearchQuery,
Date, IndexInfo, PaginatedSeries, Pagination, SearchQuery, SeriesCount, SeriesData, SeriesInfo, SeriesCount, SeriesData, SeriesInfo, SeriesNameWithIndex, SeriesSelection,
SeriesNameWithIndex, SeriesParam, SeriesSelection,
}; };
use crate::{CacheStrategy, extended::TransformResponseExtended}; use crate::{
CacheStrategy,
extended::TransformResponseExtended,
params::{CostBasisCohortParam, CostBasisParams, CostBasisQuery, SeriesParam},
};
use super::AppState; use super::AppState;

View File

@@ -36,6 +36,7 @@ mod api;
pub mod cache; pub mod cache;
mod error; mod error;
mod extended; mod extended;
pub mod params;
mod state; mod state;
pub use api::ApiRoutes; pub use api::ApiRoutes;

View File

@@ -1,7 +1,7 @@
use schemars::JsonSchema; use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use crate::Addr; use brk_types::Addr;
#[derive(Deserialize, JsonSchema)] #[derive(Deserialize, JsonSchema)]
pub struct AddrParam { pub struct AddrParam {

View File

@@ -1,7 +1,7 @@
use schemars::JsonSchema; use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use crate::Txid; use brk_types::Txid;
#[derive(Debug, Default, Deserialize, JsonSchema)] #[derive(Debug, Default, Deserialize, JsonSchema)]
pub struct AddrTxidsParam { pub struct AddrTxidsParam {

View File

@@ -1,7 +1,7 @@
use schemars::JsonSchema; use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use crate::BlockHash; use brk_types::BlockHash;
#[derive(Deserialize, JsonSchema)] #[derive(Deserialize, JsonSchema)]
pub struct BlockHashParam { pub struct BlockHashParam {

View File

@@ -1,7 +1,7 @@
use schemars::JsonSchema; use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use crate::{BlockHash, TxIndex}; use brk_types::{BlockHash, TxIndex};
#[derive(Deserialize, JsonSchema)] #[derive(Deserialize, JsonSchema)]
pub struct BlockHashStartIndex { pub struct BlockHashStartIndex {

View File

@@ -1,7 +1,7 @@
use schemars::JsonSchema; use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use crate::{BlockHash, TxIndex}; use brk_types::{BlockHash, TxIndex};
#[derive(Deserialize, JsonSchema)] #[derive(Deserialize, JsonSchema)]
pub struct BlockHashTxIndex { pub struct BlockHashTxIndex {

View File

@@ -1,33 +1,7 @@
use std::{fmt, ops::Deref};
use schemars::JsonSchema; use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use crate::{CostBasisBucket, CostBasisValue, Date}; use brk_types::{Cohort, CostBasisBucket, CostBasisValue, Date};
/// Cohort identifier for cost basis distribution.
#[derive(Deserialize, JsonSchema)]
#[schemars(example = &"all", example = &"sth", example = &"lth")]
pub struct Cohort(String);
impl fmt::Display for Cohort {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(&self.0)
}
}
impl<T: Into<String>> From<T> for Cohort {
fn from(s: T) -> Self {
Self(s.into())
}
}
impl Deref for Cohort {
type Target = str;
fn deref(&self) -> &Self::Target {
&self.0
}
}
/// Path parameters for cost basis distribution endpoint. /// Path parameters for cost basis distribution endpoint.
#[derive(Deserialize, JsonSchema)] #[derive(Deserialize, JsonSchema)]

View File

@@ -1,7 +1,7 @@
use schemars::JsonSchema; use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use crate::Height; use brk_types::Height;
#[derive(Deserialize, JsonSchema)] #[derive(Deserialize, JsonSchema)]
pub struct HeightParam { pub struct HeightParam {

View File

@@ -1,7 +1,7 @@
use schemars::JsonSchema; use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use crate::Limit; use brk_types::Limit;
#[derive(Deserialize, JsonSchema)] #[derive(Deserialize, JsonSchema)]
pub struct LimitParam { pub struct LimitParam {

View File

@@ -0,0 +1,35 @@
mod addr_param;
mod addr_txids_param;
mod block_count_param;
mod blockhash_param;
mod blockhash_start_index;
mod blockhash_tx_index;
mod cost_basis_params;
mod height_param;
mod limit_param;
mod pool_slug_param;
mod series_param;
mod time_period_param;
mod timestamp_param;
mod txid_param;
mod txid_vout;
mod txids_param;
mod validate_addr_param;
pub use addr_param::*;
pub use addr_txids_param::*;
pub use block_count_param::*;
pub use blockhash_param::*;
pub use blockhash_start_index::*;
pub use blockhash_tx_index::*;
pub use cost_basis_params::*;
pub use height_param::*;
pub use limit_param::*;
pub use pool_slug_param::*;
pub use series_param::*;
pub use time_period_param::*;
pub use timestamp_param::*;
pub use txid_param::*;
pub use txid_vout::*;
pub use txids_param::*;
pub use validate_addr_param::*;

View File

@@ -1,7 +1,7 @@
use schemars::JsonSchema; use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use super::{Height, PoolSlug}; use brk_types::{Height, PoolSlug};
#[derive(Deserialize, JsonSchema)] #[derive(Deserialize, JsonSchema)]
pub struct PoolSlugParam { pub struct PoolSlugParam {

View File

@@ -1,7 +1,7 @@
use schemars::JsonSchema; use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use crate::SeriesName; use brk_types::SeriesName;
#[derive(Deserialize, JsonSchema)] #[derive(Deserialize, JsonSchema)]
pub struct SeriesParam { pub struct SeriesParam {

View File

@@ -1,7 +1,7 @@
use schemars::JsonSchema; use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use super::TimePeriod; use brk_types::TimePeriod;
#[derive(Deserialize, JsonSchema)] #[derive(Deserialize, JsonSchema)]
pub struct TimePeriodParam { pub struct TimePeriodParam {

View File

@@ -1,7 +1,7 @@
use schemars::JsonSchema; use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use crate::Timestamp; use brk_types::Timestamp;
#[derive(Deserialize, JsonSchema)] #[derive(Deserialize, JsonSchema)]
pub struct TimestampParam { pub struct TimestampParam {

View File

@@ -1,7 +1,7 @@
use schemars::JsonSchema; use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use crate::Txid; use brk_types::Txid;
#[derive(Deserialize, JsonSchema)] #[derive(Deserialize, JsonSchema)]
pub struct TxidParam { pub struct TxidParam {

View File

@@ -1,7 +1,7 @@
use schemars::JsonSchema; use schemars::JsonSchema;
use serde::Deserialize; use serde::Deserialize;
use crate::{Txid, Vout}; use brk_types::{Txid, Vout};
/// Transaction output reference (txid + output index) /// Transaction output reference (txid + output index)
#[derive(Deserialize, JsonSchema)] #[derive(Deserialize, JsonSchema)]

View File

@@ -2,7 +2,7 @@ use std::str::FromStr;
use schemars::JsonSchema; use schemars::JsonSchema;
use crate::Txid; use brk_types::Txid;
/// Query parameter for transaction-times endpoint. /// Query parameter for transaction-times endpoint.
#[derive(JsonSchema)] #[derive(JsonSchema)]

View File

@@ -0,0 +1,28 @@
use std::{fmt, ops::Deref};
use schemars::JsonSchema;
use serde::Deserialize;
/// Cohort identifier for cost basis distribution.
#[derive(Deserialize, JsonSchema)]
#[schemars(example = &"all", example = &"sth", example = &"lth")]
pub struct Cohort(String);
impl fmt::Display for Cohort {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(&self.0)
}
}
impl<T: Into<String>> From<T> for Cohort {
fn from(s: T) -> Self {
Self(s.into())
}
}
impl Deref for Cohort {
type Target = str;
fn deref(&self) -> &Self::Target {
&self.0
}
}

View File

@@ -10,9 +10,7 @@ mod addr_index_any;
mod addr_index_outpoint; mod addr_index_outpoint;
mod addr_index_tx_index; mod addr_index_tx_index;
mod addr_mempool_stats; mod addr_mempool_stats;
mod addr_param;
mod addr_stats; mod addr_stats;
mod addr_txids_param;
mod addr_validation; mod addr_validation;
mod age; mod age;
mod basis_points_16; mod basis_points_16;
@@ -23,7 +21,6 @@ mod bitcoin;
mod blk_metadata; mod blk_metadata;
mod blk_position; mod blk_position;
mod block; mod block;
mod block_count_param;
mod block_extras; mod block_extras;
mod block_fee_rates_entry; mod block_fee_rates_entry;
mod block_fees_entry; mod block_fees_entry;
@@ -38,21 +35,18 @@ mod block_status;
mod block_timestamp; mod block_timestamp;
mod block_weight_entry; mod block_weight_entry;
mod blockhash; mod blockhash;
mod blockhash_param;
mod blockhash_prefix; mod blockhash_prefix;
mod blockhash_start_index;
mod blockhash_tx_index;
mod bytes; mod bytes;
mod cents; mod cents;
mod cents_compact; mod cents_compact;
mod cents_sats; mod cents_sats;
mod cents_signed; mod cents_signed;
mod cents_squared_sats; mod cents_squared_sats;
mod cohort;
mod coinbase_tag; mod coinbase_tag;
mod cpfp; mod cpfp;
mod cost_basis_bucket; mod cost_basis_bucket;
mod cost_basis_distribution; mod cost_basis_distribution;
mod cost_basis_params;
mod cost_basis_value; mod cost_basis_value;
mod data_range; mod data_range;
mod data_range_format; mod data_range_format;
@@ -83,7 +77,6 @@ mod hashrate_summary;
mod health; mod health;
mod height; mod height;
mod historical_price; mod historical_price;
mod height_param;
mod hex; mod hex;
mod hour1; mod hour1;
mod hour12; mod hour12;
@@ -92,7 +85,6 @@ mod index;
mod index_info; mod index_info;
mod indexes; mod indexes;
mod limit; mod limit;
mod limit_param;
mod mempool_block; mod mempool_block;
mod mempool_entry_info; mod mempool_entry_info;
mod mempool_info; mod mempool_info;
@@ -135,7 +127,6 @@ mod pool_detail;
mod pool_info; mod pool_info;
mod pool_hashrate_entry; mod pool_hashrate_entry;
mod pool_slug; mod pool_slug;
mod pool_slug_param;
mod pool_stats; mod pool_stats;
mod pools; mod pools;
mod pools_summary; mod pools_summary;
@@ -157,7 +148,6 @@ mod series_name;
mod series_name_with_index; mod series_name_with_index;
mod series_output; mod series_output;
mod series_paginated; mod series_paginated;
mod series_param;
mod series_selection; mod series_selection;
mod series_selection_legacy; mod series_selection_legacy;
mod stored_bool; mod stored_bool;
@@ -175,9 +165,7 @@ mod supply_state;
mod sync_status; mod sync_status;
mod term; mod term;
mod time_period; mod time_period;
mod time_period_param;
mod timestamp; mod timestamp;
mod timestamp_param;
mod tree_node; mod tree_node;
mod tx; mod tx;
mod tx_index; mod tx_index;
@@ -185,10 +173,7 @@ mod tx_status;
mod tx_version; mod tx_version;
mod tx_with_hex; mod tx_with_hex;
mod txid; mod txid;
mod txid_param;
mod txid_prefix; mod txid_prefix;
mod txids_param;
mod txid_vout;
mod txin; mod txin;
mod txin_index; mod txin_index;
mod txout; mod txout;
@@ -198,7 +183,6 @@ mod type_index;
mod unit; mod unit;
mod unknown_output_index; mod unknown_output_index;
mod utxo; mod utxo;
mod validate_addr_param;
mod vin; mod vin;
mod vout; mod vout;
mod vsize; mod vsize;
@@ -216,9 +200,7 @@ pub use addr_index_any::*;
pub use addr_index_outpoint::*; pub use addr_index_outpoint::*;
pub use addr_index_tx_index::*; pub use addr_index_tx_index::*;
pub use addr_mempool_stats::*; pub use addr_mempool_stats::*;
pub use addr_param::*;
pub use addr_stats::*; pub use addr_stats::*;
pub use addr_txids_param::*;
pub use addr_validation::*; pub use addr_validation::*;
pub use age::*; pub use age::*;
pub use basis_points_16::*; pub use basis_points_16::*;
@@ -229,7 +211,6 @@ pub use bitcoin::*;
pub use blk_metadata::*; pub use blk_metadata::*;
pub use blk_position::*; pub use blk_position::*;
pub use block::*; pub use block::*;
pub use block_count_param::*;
pub use block_extras::*; pub use block_extras::*;
pub use block_fee_rates_entry::*; pub use block_fee_rates_entry::*;
pub use block_fees_entry::*; pub use block_fees_entry::*;
@@ -244,21 +225,18 @@ pub use block_status::*;
pub use block_timestamp::*; pub use block_timestamp::*;
pub use block_weight_entry::*; pub use block_weight_entry::*;
pub use blockhash::*; pub use blockhash::*;
pub use blockhash_param::*;
pub use blockhash_prefix::*; pub use blockhash_prefix::*;
pub use blockhash_start_index::*;
pub use blockhash_tx_index::*;
pub use bytes::*; pub use bytes::*;
pub use cents::*; pub use cents::*;
pub use cents_compact::*; pub use cents_compact::*;
pub use cents_sats::*; pub use cents_sats::*;
pub use cents_signed::*; pub use cents_signed::*;
pub use cents_squared_sats::*; pub use cents_squared_sats::*;
pub use cohort::*;
pub use coinbase_tag::*; pub use coinbase_tag::*;
pub use cpfp::*; pub use cpfp::*;
pub use cost_basis_bucket::*; pub use cost_basis_bucket::*;
pub use cost_basis_distribution::*; pub use cost_basis_distribution::*;
pub use cost_basis_params::*;
pub use cost_basis_value::*; pub use cost_basis_value::*;
pub use data_range::*; pub use data_range::*;
pub use data_range_format::*; pub use data_range_format::*;
@@ -289,7 +267,6 @@ pub use hashrate_summary::*;
pub use health::*; pub use health::*;
pub use height::*; pub use height::*;
pub use historical_price::*; pub use historical_price::*;
pub use height_param::*;
pub use hex::*; pub use hex::*;
pub use hour1::*; pub use hour1::*;
pub use hour4::*; pub use hour4::*;
@@ -298,7 +275,6 @@ pub use index::*;
pub use index_info::*; pub use index_info::*;
pub use indexes::*; pub use indexes::*;
pub use limit::*; pub use limit::*;
pub use limit_param::*;
pub use mempool_block::*; pub use mempool_block::*;
pub use mempool_entry_info::*; pub use mempool_entry_info::*;
pub use mempool_info::*; pub use mempool_info::*;
@@ -341,7 +317,6 @@ pub use pool_detail::*;
pub use pool_info::*; pub use pool_info::*;
pub use pool_hashrate_entry::*; pub use pool_hashrate_entry::*;
pub use pool_slug::*; pub use pool_slug::*;
pub use pool_slug_param::*;
pub use pool_stats::*; pub use pool_stats::*;
pub use pools::*; pub use pools::*;
pub use pools_summary::*; pub use pools_summary::*;
@@ -363,7 +338,6 @@ pub use series_name::*;
pub use series_name_with_index::*; pub use series_name_with_index::*;
pub use series_output::*; pub use series_output::*;
pub use series_paginated::*; pub use series_paginated::*;
pub use series_param::*;
pub use series_selection::*; pub use series_selection::*;
pub use series_selection_legacy::*; pub use series_selection_legacy::*;
pub use stored_bool::*; pub use stored_bool::*;
@@ -381,9 +355,7 @@ pub use supply_state::*;
pub use sync_status::*; pub use sync_status::*;
pub use term::*; pub use term::*;
pub use time_period::*; pub use time_period::*;
pub use time_period_param::*;
pub use timestamp::*; pub use timestamp::*;
pub use timestamp_param::*;
pub use tree_node::*; pub use tree_node::*;
pub use tx::*; pub use tx::*;
pub use tx_index::*; pub use tx_index::*;
@@ -391,10 +363,7 @@ pub use tx_status::*;
pub use tx_version::*; pub use tx_version::*;
pub use tx_with_hex::*; pub use tx_with_hex::*;
pub use txid::*; pub use txid::*;
pub use txid_param::*;
pub use txid_prefix::*; pub use txid_prefix::*;
pub use txids_param::*;
pub use txid_vout::*;
pub use txin::*; pub use txin::*;
pub use txin_index::*; pub use txin_index::*;
pub use txout::*; pub use txout::*;
@@ -404,7 +373,6 @@ pub use type_index::*;
pub use unit::*; pub use unit::*;
pub use unknown_output_index::*; pub use unknown_output_index::*;
pub use utxo::*; pub use utxo::*;
pub use validate_addr_param::*;
pub use vin::*; pub use vin::*;
pub use vout::*; pub use vout::*;
pub use vsize::*; pub use vsize::*;

View File

@@ -144,10 +144,10 @@
* A single block fees data point. * A single block fees data point.
* *
* @typedef {Object} BlockFeesEntry * @typedef {Object} BlockFeesEntry
* @property {Height} avgHeight * @property {Height} avgHeight - Average block height in this window
* @property {Timestamp} timestamp * @property {Timestamp} timestamp - Unix timestamp at the window midpoint
* @property {Sats} avgFees * @property {Sats} avgFees - Average fees per block in this window (sats)
* @property {Dollars} uSD - BTC/USD price at that height * @property {Dollars} uSD - BTC/USD price at this height
*/ */
/** /**
* Block hash * Block hash
@@ -203,7 +203,6 @@
* @property {number} nonce - Nonce * @property {number} nonce - Nonce
* @property {number} bits - Compact target (bits) * @property {number} bits - Compact target (bits)
* @property {number} difficulty - Block difficulty * @property {number} difficulty - Block difficulty
* @property {boolean=} stale - Whether this block is stale (orphaned)
* @property {BlockExtras} extras - Extended block data * @property {BlockExtras} extras - Extended block data
*/ */
/** /**
@@ -219,25 +218,25 @@
* A single block rewards data point. * A single block rewards data point.
* *
* @typedef {Object} BlockRewardsEntry * @typedef {Object} BlockRewardsEntry
* @property {Height} avgHeight * @property {Height} avgHeight - Average block height in this window
* @property {Timestamp} timestamp * @property {Timestamp} timestamp - Unix timestamp at the window midpoint
* @property {Sats} avgRewards * @property {Sats} avgRewards - Average coinbase reward per block (subsidy + fees, sats)
* @property {Dollars} uSD - BTC/USD price at that height * @property {Dollars} uSD - BTC/USD price at this height
*/ */
/** /**
* A single block size data point. * A single block size data point.
* *
* @typedef {Object} BlockSizeEntry * @typedef {Object} BlockSizeEntry
* @property {Height} avgHeight * @property {Height} avgHeight - Average block height in this window
* @property {Timestamp} timestamp * @property {Timestamp} timestamp - Unix timestamp at the window midpoint
* @property {number} avgSize * @property {number} avgSize - Rolling 24h median block size (bytes)
*/ */
/** /**
* Combined block sizes and weights response. * Combined block sizes and weights response.
* *
* @typedef {Object} BlockSizesWeights * @typedef {Object} BlockSizesWeights
* @property {BlockSizeEntry[]} sizes * @property {BlockSizeEntry[]} sizes - Block size data points
* @property {BlockWeightEntry[]} weights * @property {BlockWeightEntry[]} weights - Block weight data points
*/ */
/** /**
* Block status indicating whether block is in the best chain * Block status indicating whether block is in the best chain
@@ -259,9 +258,9 @@
* A single block weight data point. * A single block weight data point.
* *
* @typedef {Object} BlockWeightEntry * @typedef {Object} BlockWeightEntry
* @property {Height} avgHeight * @property {Height} avgHeight - Average block height in this window
* @property {Timestamp} timestamp * @property {Timestamp} timestamp - Unix timestamp at the window midpoint
* @property {Weight} avgWeight * @property {Weight} avgWeight - Rolling 24h median block weight (weight units)
*/ */
/** /**
* Unsigned cents (u64) - for values that should never be negative. * Unsigned cents (u64) - for values that should never be negative.
@@ -409,10 +408,10 @@
* Serializes as array: [timestamp, height, difficulty, change_percent] * Serializes as array: [timestamp, height, difficulty, change_percent]
* *
* @typedef {Object} DifficultyAdjustmentEntry * @typedef {Object} DifficultyAdjustmentEntry
* @property {Timestamp} timestamp * @property {Timestamp} timestamp - Unix timestamp of the adjustment
* @property {Height} height * @property {Height} height - Block height of the adjustment
* @property {number} difficulty * @property {number} difficulty - Difficulty value
* @property {number} changePercent * @property {number} changePercent - Adjustment ratio (new/previous, e.g. 1.068 = +6.8%)
*/ */
/** /**
* A single difficulty data point in the hashrate summary. * A single difficulty data point in the hashrate summary.
@@ -509,10 +508,10 @@
* Server health status * Server health status
* *
* @typedef {Object} Health * @typedef {Object} Health
* @property {string} status * @property {string} status - Health status ("healthy")
* @property {string} service * @property {string} service - Service name
* @property {string} version * @property {string} version - Server version
* @property {string} timestamp * @property {string} timestamp - Current server time (ISO 8601)
* @property {string} startedAt - Server start time (ISO 8601) * @property {string} startedAt - Server start time (ISO 8601)
* @property {number} uptimeSeconds - Uptime in seconds * @property {number} uptimeSeconds - Uptime in seconds
* @property {Height} indexedHeight - Height of the last indexed block * @property {Height} indexedHeight - Height of the last indexed block
@@ -540,15 +539,15 @@
* Historical price response * Historical price response
* *
* @typedef {Object} HistoricalPrice * @typedef {Object} HistoricalPrice
* @property {HistoricalPriceEntry[]} prices * @property {HistoricalPriceEntry[]} prices - Price data points
* @property {ExchangeRates} exchangeRates * @property {ExchangeRates} exchangeRates - Exchange rates (currently empty)
*/ */
/** /**
* A single price data point * A single price data point
* *
* @typedef {Object} HistoricalPriceEntry * @typedef {Object} HistoricalPriceEntry
* @property {number} time * @property {number} time - Unix timestamp
* @property {Dollars} uSD * @property {Dollars} uSD - BTC/USD price
*/ */
/** @typedef {number} Hour1 */ /** @typedef {number} Hour1 */
/** @typedef {number} Hour12 */ /** @typedef {number} Hour12 */
@@ -610,21 +609,21 @@
* @property {{ [key: string]: VSize }} feeHistogram - Fee histogram: `[[fee_rate, vsize], ...]` sorted by descending fee rate * @property {{ [key: string]: VSize }} feeHistogram - Fee histogram: `[[fee_rate, vsize], ...]` sorted by descending fee rate
*/ */
/** /**
* Simplified mempool transaction for the recent transactions endpoint * Simplified mempool transaction for the `/api/mempool/recent` endpoint.
* *
* @typedef {Object} MempoolRecentTx * @typedef {Object} MempoolRecentTx
* @property {Txid} txid * @property {Txid} txid - Transaction ID
* @property {Sats} fee * @property {Sats} fee - Transaction fee (sats)
* @property {VSize} vsize * @property {VSize} vsize - Virtual size (vbytes)
* @property {Sats} value * @property {Sats} value - Total output value (sats)
*/ */
/** /**
* Merkle inclusion proof for a transaction * Merkle inclusion proof for a transaction
* *
* @typedef {Object} MerkleProof * @typedef {Object} MerkleProof
* @property {Height} blockHeight * @property {Height} blockHeight - Block height containing the transaction
* @property {string[]} merkle * @property {string[]} merkle - Merkle proof path (hex-encoded hashes)
* @property {number} pos * @property {number} pos - Transaction position in the block
*/ */
/** @typedef {number} Minute10 */ /** @typedef {number} Minute10 */
/** @typedef {number} Minute30 */ /** @typedef {number} Minute30 */
@@ -802,8 +801,8 @@
* Current price response matching mempool.space /api/v1/prices format * Current price response matching mempool.space /api/v1/prices format
* *
* @typedef {Object} Prices * @typedef {Object} Prices
* @property {Timestamp} time * @property {Timestamp} time - Unix timestamp
* @property {Dollars} uSD * @property {Dollars} uSD - BTC/USD price
*/ */
/** /**
* A range boundary: integer index, date, or timestamp. * A range boundary: integer index, date, or timestamp.
@@ -831,9 +830,9 @@
* @typedef {Object} RewardStats * @typedef {Object} RewardStats
* @property {Height} startBlock - First block in the range * @property {Height} startBlock - First block in the range
* @property {Height} endBlock - Last block in the range * @property {Height} endBlock - Last block in the range
* @property {Sats} totalReward * @property {Sats} totalReward - Total coinbase rewards (subsidy + fees) in sats
* @property {Sats} totalFee * @property {Sats} totalFee - Total transaction fees in sats
* @property {number} totalTx * @property {number} totalTx - Total number of transactions
*/ */
/** /**
* Satoshis * Satoshis
@@ -1000,17 +999,17 @@
* Transaction information compatible with mempool.space API format * Transaction information compatible with mempool.space API format
* *
* @typedef {Object} Transaction * @typedef {Object} Transaction
* @property {(TxIndex|null)=} index * @property {(TxIndex|null)=} index - Internal transaction index (brk-specific, not in mempool.space)
* @property {Txid} txid * @property {Txid} txid - Transaction ID
* @property {TxVersion} version * @property {TxVersion} version - Transaction version
* @property {RawLockTime} locktime * @property {RawLockTime} locktime - Transaction lock time
* @property {TxIn[]} vin - Transaction inputs * @property {TxIn[]} vin - Transaction inputs
* @property {TxOut[]} vout - Transaction outputs * @property {TxOut[]} vout - Transaction outputs
* @property {number} size - Transaction size in bytes * @property {number} size - Transaction size in bytes
* @property {Weight} weight - Transaction weight * @property {Weight} weight - Transaction weight
* @property {number} sigops - Number of signature operations * @property {number} sigops - Number of signature operations
* @property {Sats} fee - Transaction fee in satoshis * @property {Sats} fee - Transaction fee in satoshis
* @property {TxStatus} status * @property {TxStatus} status - Confirmation status (confirmed, block height/hash/time)
*/ */
/** /**
* Hierarchical tree node for organizing series into categories * Hierarchical tree node for organizing series into categories
@@ -1096,10 +1095,10 @@
* Unspent transaction output * Unspent transaction output
* *
* @typedef {Object} Utxo * @typedef {Object} Utxo
* @property {Txid} txid * @property {Txid} txid - Transaction ID of the UTXO
* @property {Vout} vout * @property {Vout} vout - Output index
* @property {TxStatus} status * @property {TxStatus} status - Confirmation status
* @property {Sats} value * @property {Sats} value - Output value in satoshis
*/ */
/** /**
* Virtual size in vbytes (weight / 4, rounded up) * Virtual size in vbytes (weight / 4, rounded up)

View File

@@ -387,7 +387,10 @@ class BlockFeesEntry(TypedDict):
A single block fees data point. A single block fees data point.
Attributes: Attributes:
USD: BTC/USD price at that height avgHeight: Average block height in this window
timestamp: Unix timestamp at the window midpoint
avgFees: Average fees per block in this window (sats)
USD: BTC/USD price at this height
""" """
avgHeight: Height avgHeight: Height
timestamp: Timestamp timestamp: Timestamp
@@ -466,7 +469,6 @@ class BlockInfoV1(TypedDict):
nonce: Nonce nonce: Nonce
bits: Compact target (bits) bits: Compact target (bits)
difficulty: Block difficulty difficulty: Block difficulty
stale: Whether this block is stale (orphaned)
extras: Extended block data extras: Extended block data
""" """
id: BlockHash id: BlockHash
@@ -482,7 +484,6 @@ class BlockInfoV1(TypedDict):
nonce: int nonce: int
bits: int bits: int
difficulty: float difficulty: float
stale: bool
extras: BlockExtras extras: BlockExtras
class BlockRewardsEntry(TypedDict): class BlockRewardsEntry(TypedDict):
@@ -490,7 +491,10 @@ class BlockRewardsEntry(TypedDict):
A single block rewards data point. A single block rewards data point.
Attributes: Attributes:
USD: BTC/USD price at that height avgHeight: Average block height in this window
timestamp: Unix timestamp at the window midpoint
avgRewards: Average coinbase reward per block (subsidy + fees, sats)
USD: BTC/USD price at this height
""" """
avgHeight: Height avgHeight: Height
timestamp: Timestamp timestamp: Timestamp
@@ -500,6 +504,11 @@ class BlockRewardsEntry(TypedDict):
class BlockSizeEntry(TypedDict): class BlockSizeEntry(TypedDict):
""" """
A single block size data point. A single block size data point.
Attributes:
avgHeight: Average block height in this window
timestamp: Unix timestamp at the window midpoint
avgSize: Rolling 24h median block size (bytes)
""" """
avgHeight: Height avgHeight: Height
timestamp: Timestamp timestamp: Timestamp
@@ -508,6 +517,11 @@ class BlockSizeEntry(TypedDict):
class BlockWeightEntry(TypedDict): class BlockWeightEntry(TypedDict):
""" """
A single block weight data point. A single block weight data point.
Attributes:
avgHeight: Average block height in this window
timestamp: Unix timestamp at the window midpoint
avgWeight: Rolling 24h median block weight (weight units)
""" """
avgHeight: Height avgHeight: Height
timestamp: Timestamp timestamp: Timestamp
@@ -516,6 +530,10 @@ class BlockWeightEntry(TypedDict):
class BlockSizesWeights(TypedDict): class BlockSizesWeights(TypedDict):
""" """
Combined block sizes and weights response. Combined block sizes and weights response.
Attributes:
sizes: Block size data points
weights: Block weight data points
""" """
sizes: List[BlockSizeEntry] sizes: List[BlockSizeEntry]
weights: List[BlockWeightEntry] weights: List[BlockWeightEntry]
@@ -684,6 +702,12 @@ class DifficultyAdjustmentEntry(TypedDict):
""" """
A single difficulty adjustment entry. A single difficulty adjustment entry.
Serializes as array: [timestamp, height, difficulty, change_percent] Serializes as array: [timestamp, height, difficulty, change_percent]
Attributes:
timestamp: Unix timestamp of the adjustment
height: Block height of the adjustment
difficulty: Difficulty value
change_percent: Adjustment ratio (new/previous, e.g. 1.068 = +6.8%)
""" """
timestamp: Timestamp timestamp: Timestamp
height: Height height: Height
@@ -803,6 +827,10 @@ class Health(TypedDict):
Server health status Server health status
Attributes: Attributes:
status: Health status ("healthy")
service: Service name
version: Server version
timestamp: Current server time (ISO 8601)
started_at: Server start time (ISO 8601) started_at: Server start time (ISO 8601)
uptime_seconds: Uptime in seconds uptime_seconds: Uptime in seconds
indexed_height: Height of the last indexed block indexed_height: Height of the last indexed block
@@ -831,6 +859,10 @@ class HeightParam(TypedDict):
class HistoricalPriceEntry(TypedDict): class HistoricalPriceEntry(TypedDict):
""" """
A single price data point A single price data point
Attributes:
time: Unix timestamp
USD: BTC/USD price
""" """
time: int time: int
USD: Dollars USD: Dollars
@@ -838,6 +870,10 @@ class HistoricalPriceEntry(TypedDict):
class HistoricalPrice(TypedDict): class HistoricalPrice(TypedDict):
""" """
Historical price response Historical price response
Attributes:
prices: Price data points
exchangeRates: Exchange rates (currently empty)
""" """
prices: List[HistoricalPriceEntry] prices: List[HistoricalPriceEntry]
exchangeRates: ExchangeRates exchangeRates: ExchangeRates
@@ -902,7 +938,13 @@ class MempoolInfo(TypedDict):
class MempoolRecentTx(TypedDict): class MempoolRecentTx(TypedDict):
""" """
Simplified mempool transaction for the recent transactions endpoint Simplified mempool transaction for the `/api/mempool/recent` endpoint.
Attributes:
txid: Transaction ID
fee: Transaction fee (sats)
vsize: Virtual size (vbytes)
value: Total output value (sats)
""" """
txid: Txid txid: Txid
fee: Sats fee: Sats
@@ -912,6 +954,11 @@ class MempoolRecentTx(TypedDict):
class MerkleProof(TypedDict): class MerkleProof(TypedDict):
""" """
Merkle inclusion proof for a transaction Merkle inclusion proof for a transaction
Attributes:
block_height: Block height containing the transaction
merkle: Merkle proof path (hex-encoded hashes)
pos: Transaction position in the block
""" """
block_height: Height block_height: Height
merkle: List[str] merkle: List[str]
@@ -1121,6 +1168,10 @@ class PoolsSummary(TypedDict):
class Prices(TypedDict): class Prices(TypedDict):
""" """
Current price response matching mempool.space /api/v1/prices format Current price response matching mempool.space /api/v1/prices format
Attributes:
time: Unix timestamp
USD: BTC/USD price
""" """
time: Timestamp time: Timestamp
USD: Dollars USD: Dollars
@@ -1149,6 +1200,9 @@ class RewardStats(TypedDict):
Attributes: Attributes:
startBlock: First block in the range startBlock: First block in the range
endBlock: Last block in the range endBlock: Last block in the range
totalReward: Total coinbase rewards (subsidy + fees) in sats
totalFee: Total transaction fees in sats
totalTx: Total number of transactions
""" """
startBlock: Height startBlock: Height
endBlock: Height endBlock: Height
@@ -1318,12 +1372,17 @@ class Transaction(TypedDict):
Transaction information compatible with mempool.space API format Transaction information compatible with mempool.space API format
Attributes: Attributes:
index: Internal transaction index (brk-specific, not in mempool.space)
txid: Transaction ID
version: Transaction version
locktime: Transaction lock time
vin: Transaction inputs vin: Transaction inputs
vout: Transaction outputs vout: Transaction outputs
size: Transaction size in bytes size: Transaction size in bytes
weight: Transaction weight weight: Transaction weight
sigops: Number of signature operations sigops: Number of signature operations
fee: Transaction fee in satoshis fee: Transaction fee in satoshis
status: Confirmation status (confirmed, block height/hash/time)
""" """
index: Union[TxIndex, None] index: Union[TxIndex, None]
txid: Txid txid: Txid
@@ -1369,6 +1428,12 @@ class TxidVout(TypedDict):
class Utxo(TypedDict): class Utxo(TypedDict):
""" """
Unspent transaction output Unspent transaction output
Attributes:
txid: Transaction ID of the UTXO
vout: Output index
status: Confirmation status
value: Output value in satoshis
""" """
txid: Txid txid: Txid
vout: Vout vout: Vout

View File

@@ -10,6 +10,7 @@
padding: 2rem; padding: 2rem;
.cube { .cube {
cursor: pointer;
width: var(--cube); width: var(--cube);
height: var(--cube); height: var(--cube);
overflow: hidden; overflow: hidden;
@@ -17,6 +18,37 @@
line-height: var(--line-height-sm); line-height: var(--line-height-sm);
--face-color: var(--border-color); --face-color: var(--border-color);
color: var(--color); color: var(--color);
transition:
color,
background-color,
border-color,
outline-color,
text-decoration-color,
fill,
stroke,
opacity,
box-shadow,
transform,
translate,
scale,
rotate,
filter,
-webkit-backdrop-filter,
backdrop-filter,
display,
content-visibility,
overlay,
pointer-events;
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
transition-duration: 50ms;
user-select: none;
&:hover {
--face-color: var(--inv-border-color);
color: var(--background-color);
}
&:active {
--face-color: var(--orange);
}
.face { .face {
transform-origin: 0 0; transform-origin: 0 0;

View File

@@ -31,6 +31,7 @@
--color: light-dark(var(--black), var(--white)); --color: light-dark(var(--black), var(--white));
--off-color: var(--gray); --off-color: var(--gray);
--border-color: light-dark(var(--light-gray), var(--dark-gray)); --border-color: light-dark(var(--light-gray), var(--dark-gray));
--inv-border-color: light-dark(var(--dark-gray), var(--light-gray));
--off-border-color: light-dark(var(--dark-white), var(--light-black)); --off-border-color: light-dark(var(--dark-white), var(--light-black));
--font-size-xs: 0.75rem; --font-size-xs: 0.75rem;