whisky-csl 1.0.23

Wrapper around the cardano-serialization-lib for easier transaction building, heavily inspired by cardano-cli APIs
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use cardano_serialization_lib::{self as csl};
use whisky_common::WError;

pub fn script_hash_to_stake_address(script_hash: &str, network_id: u8) -> Result<String, WError> {
    let script_hash = csl::ScriptHash::from_hex(script_hash).map_err(WError::from_err(
        "script_hash_to_stake_address - invalid script hash",
    ))?;
    let credential = csl::Credential::from_scripthash(&script_hash);
    let stake_address = csl::RewardAddress::new(network_id, &credential)
        .to_address()
        .to_bech32(None)
        .map_err(WError::from_err(
            "script_hash_to_stake_address - failed to convert to bech32",
        ))?;
    Ok(stake_address)
}