sidan_csl_rs/core/utils/
staking.rs

1
2
3
4
5
6
7
8
9
10
11
12
use cardano_serialization_lib::JsError;

use crate::*;

pub fn script_hash_to_stake_address(script_hash: &str, network_id: u8) -> Result<String, JsError> {
    let script_hash = csl::ScriptHash::from_hex(script_hash)?;
    let credential = csl::Credential::from_scripthash(&script_hash);
    let stake_address = csl::RewardAddress::new(network_id, &credential)
        .to_address()
        .to_bech32(None)?;
    Ok(stake_address)
}