global: address -> addr rename

This commit is contained in:
nym21
2026-03-17 11:01:21 +01:00
parent 5609e6c010
commit f62943199c
141 changed files with 3788 additions and 3754 deletions
@@ -6,20 +6,20 @@ use axum::{
routing::get,
};
use brk_types::{
AddressParam, AddressStats, AddressTxidsParam, AddressValidation, Transaction, Txid, Utxo,
ValidateAddressParam,
AddrParam, AddrStats, AddrTxidsParam, AddrValidation, Transaction, Txid, Utxo,
ValidateAddrParam,
};
use crate::{CacheStrategy, extended::TransformResponseExtended};
use super::AppState;
pub trait AddressRoutes {
fn add_addresses_routes(self) -> Self;
pub trait AddrRoutes {
fn add_addr_routes(self) -> Self;
}
impl AddressRoutes for ApiRouter<AppState> {
fn add_addresses_routes(self) -> Self {
impl AddrRoutes for ApiRouter<AppState> {
fn add_addr_routes(self) -> Self {
self
.route("/api/address", get(Redirect::temporary("/api/addresses")))
.route("/api/addresses", get(Redirect::temporary("/api#tag/addresses")))
@@ -28,16 +28,16 @@ impl AddressRoutes for ApiRouter<AppState> {
get_with(async |
uri: Uri,
headers: HeaderMap,
Path(path): Path<AddressParam>,
Path(path): Path<AddrParam>,
State(state): State<AppState>
| {
state.cached_json(&headers, CacheStrategy::Height, &uri, move |q| q.address(path.address)).await
state.cached_json(&headers, CacheStrategy::Height, &uri, move |q| q.addr(path.addr)).await
}, |op| op
.id("get_address")
.addresses_tag()
.addrs_tag()
.summary("Address information")
.description("Retrieve address information including balance and transaction counts. Supports all standard Bitcoin address types (P2PKH, P2SH, P2WPKH, P2WSH, P2TR).\n\n*[Mempool.space docs](https://mempool.space/docs/api/rest#get-address)*")
.ok_response::<AddressStats>()
.ok_response::<AddrStats>()
.not_modified()
.bad_request()
.not_found()
@@ -49,14 +49,14 @@ impl AddressRoutes for ApiRouter<AppState> {
get_with(async |
uri: Uri,
headers: HeaderMap,
Path(path): Path<AddressParam>,
Query(params): Query<AddressTxidsParam>,
Path(path): Path<AddrParam>,
Query(params): Query<AddrTxidsParam>,
State(state): State<AppState>
| {
state.cached_json(&headers, CacheStrategy::Height, &uri, move |q| q.address_txs(path.address, params.after_txid, 25)).await
state.cached_json(&headers, CacheStrategy::Height, &uri, move |q| q.addr_txs(path.addr, params.after_txid, 25)).await
}, |op| op
.id("get_address_txs")
.addresses_tag()
.addrs_tag()
.summary("Address transactions")
.description("Get transaction history for an address, sorted with newest first. Returns up to 50 mempool transactions plus the first 25 confirmed transactions. Use ?after_txid=<txid> for pagination.\n\n*[Mempool.space docs](https://mempool.space/docs/api/rest#get-address-transactions)*")
.ok_response::<Vec<Transaction>>()
@@ -71,14 +71,14 @@ impl AddressRoutes for ApiRouter<AppState> {
get_with(async |
uri: Uri,
headers: HeaderMap,
Path(path): Path<AddressParam>,
Query(params): Query<AddressTxidsParam>,
Path(path): Path<AddrParam>,
Query(params): Query<AddrTxidsParam>,
State(state): State<AppState>
| {
state.cached_json(&headers, CacheStrategy::Height, &uri, move |q| q.address_txs(path.address, params.after_txid, 25)).await
state.cached_json(&headers, CacheStrategy::Height, &uri, move |q| q.addr_txs(path.addr, params.after_txid, 25)).await
}, |op| op
.id("get_address_confirmed_txs")
.addresses_tag()
.addrs_tag()
.summary("Address confirmed transactions")
.description("Get confirmed transactions for an address, 25 per page. Use ?after_txid=<txid> for pagination.\n\n*[Mempool.space docs](https://mempool.space/docs/api/rest#get-address-transactions-chain)*")
.ok_response::<Vec<Transaction>>()
@@ -93,14 +93,14 @@ impl AddressRoutes for ApiRouter<AppState> {
get_with(async |
uri: Uri,
headers: HeaderMap,
Path(path): Path<AddressParam>,
Path(path): Path<AddrParam>,
State(state): State<AppState>
| {
let hash = state.sync(|q| q.address_mempool_hash(&path.address));
state.cached_json(&headers, CacheStrategy::MempoolHash(hash), &uri, move |q| q.address_mempool_txids(path.address)).await
let hash = state.sync(|q| q.addr_mempool_hash(&path.addr));
state.cached_json(&headers, CacheStrategy::MempoolHash(hash), &uri, move |q| q.addr_mempool_txids(path.addr)).await
}, |op| op
.id("get_address_mempool_txs")
.addresses_tag()
.addrs_tag()
.summary("Address mempool transactions")
.description("Get unconfirmed transaction IDs for an address from the mempool (up to 50).\n\n*[Mempool.space docs](https://mempool.space/docs/api/rest#get-address-transactions-mempool)*")
.ok_response::<Vec<Txid>>()
@@ -114,13 +114,13 @@ impl AddressRoutes for ApiRouter<AppState> {
get_with(async |
uri: Uri,
headers: HeaderMap,
Path(path): Path<AddressParam>,
Path(path): Path<AddrParam>,
State(state): State<AppState>
| {
state.cached_json(&headers, CacheStrategy::Height, &uri, move |q| q.address_utxos(path.address)).await
state.cached_json(&headers, CacheStrategy::Height, &uri, move |q| q.addr_utxos(path.addr)).await
}, |op| op
.id("get_address_utxos")
.addresses_tag()
.addrs_tag()
.summary("Address UTXOs")
.description("Get unspent transaction outputs (UTXOs) for an address. Returns txid, vout, value, and confirmation status for each UTXO.\n\n*[Mempool.space docs](https://mempool.space/docs/api/rest#get-address-utxo)*")
.ok_response::<Vec<Utxo>>()
@@ -135,16 +135,16 @@ impl AddressRoutes for ApiRouter<AppState> {
get_with(async |
uri: Uri,
headers: HeaderMap,
Path(path): Path<ValidateAddressParam>,
Path(path): Path<ValidateAddrParam>,
State(state): State<AppState>
| {
state.cached_json(&headers, CacheStrategy::Static, &uri, move |_q| Ok(AddressValidation::from_address(&path.address))).await
state.cached_json(&headers, CacheStrategy::Static, &uri, move |_q| Ok(AddrValidation::from_addr(&path.addr))).await
}, |op| op
.id("validate_address")
.addresses_tag()
.addrs_tag()
.summary("Validate address")
.description("Validate a Bitcoin address and get information about its type and scriptPubKey.\n\n*[Mempool.space docs](https://mempool.space/docs/api/rest#get-address-validate)*")
.ok_response::<AddressValidation>()
.ok_response::<AddrValidation>()
.not_modified()
),
)
+3 -3
View File
@@ -14,7 +14,7 @@ use axum::{
use crate::{
Error,
api::{
addresses::AddressRoutes, blocks::BlockRoutes, mempool::MempoolRoutes,
addrs::AddrRoutes, blocks::BlockRoutes, mempool::MempoolRoutes,
metrics_legacy::ApiMetricsLegacyRoutes, mining::MiningRoutes,
series::ApiSeriesRoutes, server::ServerRoutes, transactions::TxRoutes,
},
@@ -23,7 +23,7 @@ use crate::{
use super::AppState;
mod addresses;
mod addrs;
mod blocks;
mod mempool;
mod metrics_legacy;
@@ -46,7 +46,7 @@ impl ApiRoutes for ApiRouter<AppState> {
.add_metrics_legacy_routes()
.add_block_routes()
.add_tx_routes()
.add_addresses_routes()
.add_addr_routes()
.add_mempool_routes()
.add_mining_routes()
.route("/api/server", get(Redirect::temporary("/api#tag/server")))
+5 -5
View File
@@ -23,7 +23,7 @@ struct ErrorDetail {
/// Error category: "invalid_request", "forbidden", "not_found", "unavailable", or "internal"
#[schemars(with = "String")]
r#type: &'static str,
/// Machine-readable error code (e.g. "invalid_address", "series_not_found")
/// Machine-readable error code (e.g. "invalid_addr", "series_not_found")
#[schemars(with = "String")]
code: &'static str,
/// Human-readable description
@@ -47,14 +47,14 @@ fn error_status(e: &BrkError) -> StatusCode {
match e {
BrkError::InvalidTxid
| BrkError::InvalidNetwork
| BrkError::InvalidAddress
| BrkError::InvalidAddr
| BrkError::UnsupportedType(_)
| BrkError::Parse(_)
| BrkError::NoSeries
| BrkError::SeriesUnsupportedIndex { .. }
| BrkError::WeightExceeded { .. } => StatusCode::BAD_REQUEST,
BrkError::UnknownAddress
BrkError::UnknownAddr
| BrkError::UnknownTxid
| BrkError::NotFound(_)
| BrkError::NoData
@@ -70,7 +70,7 @@ fn error_status(e: &BrkError) -> StatusCode {
fn error_code(e: &BrkError) -> &'static str {
match e {
BrkError::InvalidAddress => "invalid_address",
BrkError::InvalidAddr => "invalid_addr",
BrkError::InvalidTxid => "invalid_txid",
BrkError::InvalidNetwork => "invalid_network",
BrkError::UnsupportedType(_) => "unsupported_type",
@@ -78,7 +78,7 @@ fn error_code(e: &BrkError) -> &'static str {
BrkError::NoSeries => "no_series",
BrkError::SeriesUnsupportedIndex { .. } => "series_unsupported_index",
BrkError::WeightExceeded { .. } => "weight_exceeded",
BrkError::UnknownAddress => "unknown_address",
BrkError::UnknownAddr => "unknown_addr",
BrkError::UnknownTxid => "unknown_txid",
BrkError::NotFound(_) => "not_found",
BrkError::OutOfRange(_) => "out_of_range",
@@ -6,7 +6,7 @@ use schemars::JsonSchema;
use crate::error::ErrorBody;
pub trait TransformResponseExtended<'t> {
fn addresses_tag(self) -> Self;
fn addrs_tag(self) -> Self;
fn blocks_tag(self) -> Self;
fn mempool_tag(self) -> Self;
fn metrics_tag(self) -> Self;
@@ -40,7 +40,7 @@ pub trait TransformResponseExtended<'t> {
}
impl<'t> TransformResponseExtended<'t> for TransformOperation<'t> {
fn addresses_tag(self) -> Self {
fn addrs_tag(self) -> Self {
self.tag("Addresses")
}