Electrs Request
Send RPC commands to an Electrs server.
⚠️ This is experimental. Please use at your own risk.⚠️
This library provides typesafe functions over raw RPC Electrs commands to easily and safely retrieve information from a the server node.
As this library only provides typesafety over raw RPC commands, functions will be mapped 1:1 to RPC commands. See ElectrumX for a list of all commands and what they return.
If you're looking for a higher level api for querying information from electrum (i.e. balance for address, etc) , take a look at electrs-query, which provides higher-level functions to query an electrs server.
Install
Add package to Cargo.toml file
electrs-request = "0.1.3"
Usage:
let electrs_server_address = "127.0.0.1:50001";
let client = new;
// get the relay fee
let response = new.call.unwrap;
println!;
let p2pkh_address = "mv7RvNNQ7HpQf2diQai5hgpeuzkFoAQP9G".to_string;
// And address must be converted to a public key hash, then hashed using sha256 and then converted to little endian before requesting information from electrs.
let p2pkh_pk_hash = get_public_key_hash_from_address;
let p2pkh_script = format!;
let p2pkh_script_sha256 = sha256_hex;
let p2pkh_script_sha256_le = convert_big_endian_hex_to_little_endian;
// get the balance for a p2pkh address
let balance_response = new
.call
.unwrap;
println!;
// get utxos for address
let unspent_response = new
.call
.unwrap;
println!;
Commands
List of all electrs commands can be found on exectrumx docs
Related
- electrs-query - Query Electrs server for information
- bitcoind-request - Easily send rpc commands to Bitcoin core
- bitcoin-node-query - Query Bitcoin Node for information
- bitcoin-terminal-dashboard - Bitcoin Dashboard in the terminal
License
MIT © Joe Gesualdo