boha
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRust library for crypto bounties, puzzles and challenges data. Eight collections across six blockchains (Bitcoin, Ethereum, Litecoin, Monero, Decred, Arweave). All data embedded at compile time as references.
&'static这是一款用于加密货币赏金、谜题与挑战数据的Rust库。涵盖6条区块链(Bitcoin、Ethereum、Litecoin、Monero、Decred、Arweave)上的8个数据集合。所有数据在编译时以引用的形式嵌入。
&'staticInstall
安装
toml
[dependencies]
boha = "0.16"toml
[dependencies]
boha = "0.16"With async balance fetching (requires tokio runtime)
启用异步余额查询(需要tokio运行时)
boha = { version = "0.16", features = ["balance"] }
tokio = { version = "1", features = ["full"] }
undefinedboha = { version = "0.16", features = ["balance"] }
tokio = { version = "1", features = ["full"] }
undefinedPuzzle ID Format
谜题ID格式
IDs follow pattern. Two exceptions have no slash.
collection/identifier| Collection | ID example | Notes |
|---|---|---|
| b1000 | | Number 1-256, accepts u32/usize/&str |
| arweave | | Name string |
| ballet | | Serial number |
| bitaps | | Single puzzle, no slash |
| bitimage | | Name string |
| gsmg | | Single puzzle, no slash |
| hash_collision | | sha1, sha256, ripemd160, hash160, hash256, op_abs |
| zden | | snake_case level names |
ID遵循格式。有两个例外情况不包含斜杠。
collection/identifier| 集合名称 | ID示例 | 说明 |
|---|---|---|
| b1000 | | 编号1-256,支持u32/usize/&str类型 |
| arweave | | 名称字符串 |
| ballet | | 序列号 |
| bitaps | | 单个谜题,无斜杠 |
| bitimage | | 名称字符串 |
| gsmg | | 单个谜题,无斜杠 |
| hash_collision | | 支持sha1, sha256, ripemd160, hash160, hash256, op_abs |
| zden | | 蛇形命名法的关卡名称 |
API
API
rust
use boha::{b1000, hash_collision, zden, Status, Chain};
// Fetch by collection-specific getter
let p = b1000::get(66).unwrap();
println!("{} - {}", p.address.value, p.status);
// Fetch by universal ID
let p = boha::get("hash_collision/sha256").unwrap();
// Iterate and filter
let targets: Vec<_> = b1000::all()
.filter(|p| p.status == Status::Unsolved)
.filter(|p| p.pubkey.is_some())
.collect();
// Key range (b1000 only) - puzzle N has key in [2^(N-1), 2^N-1]
let range = b1000::get(90).unwrap().key_range().unwrap();
// Big key range for bits > 128
let (lo, hi) = b1000::get(200).unwrap().key_range_big().unwrap();
// Stats
let s = boha::stats();
println!("Total: {}, Unsolved: {}", s.total, s.unsolved);
// Explorer URLs
let url = p.chain.tx_explorer_url("txid_here");
let addr_url = p.explorer_url();rust
use boha::{b1000, hash_collision, zden, Status, Chain};
// 通过集合专属获取函数获取谜题
let p = b1000::get(66).unwrap();
println!("{} - {}", p.address.value, p.status);
// 通过通用ID获取谜题
let p = boha::get("hash_collision/sha256").unwrap();
// 遍历并过滤谜题
let targets: Vec<_> = b1000::all()
.filter(|p| p.status == Status::Unsolved)
.filter(|p| p.pubkey.is_some())
.collect();
// 密钥范围(仅适用于b1000)- 谜题N的密钥范围为[2^(N-1), 2^N-1]
let range = b1000::get(90).unwrap().key_range().unwrap();
// 适用于位数>128的大密钥范围
let (lo, hi) = b1000::get(200).unwrap().key_range_big().unwrap();
// 统计信息
let s = boha::stats();
println!("Total: {}, Unsolved: {}", s.total, s.unsolved);
// 区块链浏览器URL
let url = p.chain.tx_explorer_url("txid_here");
let addr_url = p.explorer_url();Balance fetching (feature: balance
)
balance余额查询(特性:balance
)
balancerust
use boha::balance;
#[tokio::main]
async fn main() {
let bal = balance::fetch("1A1zP1...", boha::Chain::Bitcoin).await.unwrap();
println!("{} sats confirmed, {:.8} BTC total", bal.confirmed, bal.total_btc());
}Supports Bitcoin (mempool.space), Litecoin (litecoinspace.org) and Ethereum (Etherscan).
rust
use boha::balance;
#[tokio::main]
async fn main() {
let bal = balance::fetch("1A1zP1...", boha::Chain::Bitcoin).await.unwrap();
println!("{} sats confirmed, {:.8} BTC total", bal.confirmed, bal.total_btc());
}支持Bitcoin(mempool.space)、Litecoin(litecoinspace.org)和Ethereum(Etherscan)。
Key Data Types
核心数据类型
See types.md for full struct definitions.
Core types: , , , , (Solved/Unsolved/Claimed/Swept), , , .
PuzzleAddressKeyChainStatusAuthorSolverTransactionA puzzle has: address, chain, status, optional prize, optional pubkey, optional private key (if solved), transactions history, solver info, and assets (images/hints for visual puzzles).
完整的结构体定义请查看types.md。
核心类型包括:、、、、(已解决/未解决/已领取/已划转)、、、。
PuzzleAddressKeyChainStatusAuthorSolverTransaction每个谜题包含:地址、区块链、状态、可选赏金、可选公钥、可选私钥(若已解决)、交易历史、解题者信息,以及资源(视觉谜题的图片/提示)。
Collections Overview
集合概览
See collections.md for detailed collection data.
详细的集合数据请查看collections.md。
Limitations
限制说明
- All data is - no heap allocation, no runtime loading.
&'static - works for bits <= 128. Use
key_range()for larger.key_range_big() - Balance fetching is async and requires the feature flag.
balance - Puzzle data lives in - don't hardcode in Rust source.
data/*.jsonc
- 所有数据均为类型——无堆内存分配,无运行时加载。
&'static - 仅适用于位数≤128的情况。位数更大时请使用
key_range()。key_range_big() - 余额查询为异步操作,需要启用特性标志。
balance - 谜题数据存储在中——请勿在Rust源码中硬编码。
data/*.jsonc