bitcoin_balance_etl 0.1.2

A high-performance Bitcoin balance ETL tool for extracting wallet balances directly from Bitcoin Core's chainstate LevelDB, even on pruned nodes.
1
2
3
4
5
6
7
8
9
10
11
12
13
use bitcoin::{Address, Network, ScriptBuf};
use bitcoin::hashes::{sha256, Hash};

pub fn parse_address(script: &ScriptBuf, network: Network) -> String {

    match Address::from_script(script, network) {
        Ok(address) => address.to_string(),
        Err(_) => {
            let script_hash = sha256::Hash::hash(script.as_bytes());
            format!("script:{}", script_hash)
        }
    }
}