fn subs_hash_frag(ms: &str, pubdata: &PubData) -> String {
    let ms = ms.replace(
        "sha256(H)",
        &format!("sha256({})", &pubdata.sha256.to_hex()),
    );
    let ms = ms.replace(
        "hash256(H)",
        &format!("hash256({})", &pubdata.hash256.into_inner().to_hex()),
    );
    let ms = ms.replace(
        "ripemd160(H)",
        &format!("ripemd160({})", &pubdata.ripemd160.to_hex()),
    );
    let ms = ms.replace(
        "hash160(H)",
        &format!("hash160({})", &pubdata.hash160.to_hex()),
    );

    let mut rand_hash32 = [0u8; 32];
    rand::thread_rng().fill_bytes(&mut rand_hash32);

    let mut rand_hash20 = [0u8; 20];
    rand::thread_rng().fill_bytes(&mut rand_hash20);
    let ms = ms.replace("sha256(H!)", &format!("sha256({})", rand_hash32.to_hex()));
    let ms = ms.replace("hash256(H!)", &format!("hash256({})", rand_hash32.to_hex()));
    let ms = ms.replace(
        "ripemd160(H!)",
        &format!("ripemd160({})", rand_hash20.to_hex()),
    );
    let ms = ms.replace("hash160(H!)", &format!("hash160({})", rand_hash20.to_hex()));
    ms
}
// substitute hash fragments in the string as the per rules
substitute hash fragments in the string as the per rules
substitute hash fragments in the string as the per rules
fn subs_hash_frag(ms: &str, pubdata: &PubData) -> String {
    let ms = ms.replace(
        "sha256(H)",
        &format!("sha256({})", &pubdata.sha256.to_hex()),
    );
    let ms = ms.replace(
        "hash256(H)",
        &format!("hash256({})", &pubdata.hash256.into_inner().to_hex()),
    );
    let ms = ms.replace(
        "ripemd160(H)",
        &format!("ripemd160({})", &pubdata.ripemd160.to_hex()),
    );
    let ms = ms.replace(
        "hash160(H)",
        &format!("hash160({})", &pubdata.hash160.to_hex()),
    );
    let mut rand_hash32 = [0u8; 32];
    rand::thread_rng().fill_bytes(&mut rand_hash32);
    let mut rand_hash20 = [0u8; 20];
    rand::thread_rng().fill_bytes(&mut rand_hash20);
    let ms = ms.replace("sha256(H!)", &format!("sha256({})", rand_hash32.to_hex()));
    let ms = ms.replace("hash256(H!)", &format!("hash256({})", rand_hash32.to_hex()));
    let ms = ms.replace(
        "ripemd160(H!)",
        &format!("ripemd160({})", rand_hash20.to_hex()),
    );
    let ms = ms.replace("hash160(H!)", &format!("hash160({})", rand_hash20.to_hex()));
    ms
}
fn subs_hash_frag ( ms : & str , pubdata : & PubData ) -> String { let ms = ms . replace ( " " , & format ! ( " " pubdata sha256 to_hex ( ) ) , ) ; let ms = ms . replace ( " " , & format ! ( " " pubdata hash256 into_inner ( ) to_hex ( ) ) , ) ; let ms = ms . replace ( " " , & format ! ( " " pubdata ripemd160 to_hex ( ) ) , ) ; let ms = ms . replace ( " " , & format ! ( " " pubdata hash160 to_hex ( ) ) , ) ; let mut rand_hash32 = [ 0u8 ; 32 ] ; rand :: thread_rng ( ) . fill_bytes ( & mut rand_hash32 ) ; let mut rand_hash20 = [ 0u8 ; 20 ] ; rand :: thread_rng ( ) . fill_bytes ( & mut rand_hash20 ) ; let ms = ms . replace ( " " , & format ! ( " " rand_hash32 to_hex ( ) ) ) ; let ms = ms . replace ( " " , & format ! ( " " rand_hash32 to_hex ( ) ) ) ; let ms = ms . replace ( " " , & format ! ( " " rand_hash20 to_hex ( ) ) , ) ; let ms = ms . replace ( " " , & format ! ( " " rand_hash20 to_hex ( ) ) ) ; ms }
substitute hash fragments in the string as the per rules
substitute hash fragments in the string as the per rules
ms
&str
pubdata
&PubData
ms
&str
pubdata
&PubData