3个版本
0.1.2 | 2022年10月3日 |
---|---|
0.1.1 | 2022年9月28日 |
0.1.0 | 2022年9月28日 |
#334 在 #请求
每月 21 次下载
用于 bitcoin-blockchain-query
10KB
133 行
Electrs查询
从Electrs服务器请求信息
这个库提供了一些有用的函数,用于查询有关Electrs服务器的常见信息。
⚠️ 这是一个实验性项目。请自行承担风险。⚠️
安装
将包添加到Cargo.toml文件
[dependencies]
electrs-query = "0.1.2"
用法
use electrs_query::{get_balance_for_address, get_relay_fee, get_utxos_for_address, Client};
// setup
let address = "127.0.0.1:50001";
let client = Client::new(address);
// get realy fee
let relay_fee = get_relay_fee(&client);
println!("relay fee result: {}", relay_fee);
let p2pkh_address = "mv7RvNNQ7HpQf2diQai5hgpeuzkFoAQP9G".to_string();
// get balance for p2pkh address
let address_balance = get_balance_for_address(&p2pkh_address, &client);
println!("balance: {:#?}", address_balance);
// get utxo for p2pkh address
let address_utxos = get_utxos_for_address(&p2pkh_address, &client);
println!("utxos: {:#?}", address_utxos);
// get historical transactions for p2pkh address
let historical_transactions = get_historical_transactions_for_address(&p2pkh_address, &client);
println!("historical transactions: {:#?}", historical_transactions);
let p2sh_address = "2MzBNKyJjx44BDJfwEevVzS3Q9Z5kSEYUZB".to_string();
// get balance for p2sh address
let address_balance = get_balance_for_address(&p2sh_address, &client);
println!("balance: {:#?}", address_balance);
// get utxos for p2sh address
let address_utxos = get_utxos_for_address(&p2pkh_address, &client);
println!("utxos: {:#?}", address_utxos);
// get historical transactions for p2sh address
let historical_transactions = get_historical_transactions_for_address(&p2sh_address, &client);
println!("historical transactions: {:#?}", historical_transactions);
let p2wpkh_address = "tb1qphdqqxupe6dzkz3z58twy5l4s0v24mle5gkp99".to_string();
// get balance for p2wpkh address
let address_balance = get_balance_for_address(&p2wpkh_address, &client);
println!("balance: {:#?}", address_balance);
// get utxos for p2wpkh address
let address_utxos = get_utxos_for_address(&p2pkh_address, &client);
println!("utxos: {:#?}", address_utxos);
// get historical transactions for p2wpkh address
let historical_transactions = get_historical_transactions_for_address(&p2wpkh_address, &client);
println!("historical transactions: {:#?}", historical_transactions);
API
在文档中查找所有可用函数的列表
相关
- electrs-request - electrs RPC命令的类型安全包装器
- bitcoin-node-query - 查询比特币节点信息
- bitcoind-request - bitcoind RPC命令的类型安全包装器
- bitcoin-terminal-dashboard - 终端中的比特币仪表板
许可证
MIT © Joe Gesualdo
依赖关系
~9.5MB
~137K SLoC