pub fn parse_insane_ms<Ctx: ScriptContext>(
    ms: &str,
    pubdata: &PubData,
) -> Miniscript<DescriptorPublicKey, Ctx> {
    let ms = subs_hash_frag(ms, pubdata);
    let ms =
        Miniscript::<String, Ctx>::from_str_insane(&ms).expect("only parsing valid minsicripts");
    let mut i = 0;
    let mut j = pubdata.pks.len();
    let ms = ms.translate_pk_infallible(
        &mut |pk_str: &String| {
            let avail = !pk_str.ends_with("!");
            if avail {
                i = i + 1;
                if pk_str.starts_with("K") {
                    DescriptorPublicKey::Single(SinglePub {
                        origin: None,
                        key: SinglePubKey::FullKey(pubdata.pks[i]),
                    })
                } else if pk_str.starts_with("X") {
                    DescriptorPublicKey::Single(SinglePub {
                        origin: None,
                        key: SinglePubKey::XOnly(pubdata.x_only_pks[i]),
                    })
                } else {
                    // Parse any other keys as known to allow compatibility with existing tests
                    DescriptorPublicKey::Single(SinglePub {
                        origin: None,
                        key: SinglePubKey::FullKey(pubdata.pks[i]),
                    })
                }
            } else {
                DescriptorPublicKey::Single(SinglePub {
                    origin: None,
                    key: SinglePubKey::FullKey(random_pk(59)),
                })
            }
        },
        &mut |pk_str: &String| {
            let avail = !pk_str.ends_with("!");
            if avail {
                j = j - 1;
                if pk_str.starts_with("K") {
                    DescriptorPublicKey::Single(SinglePub {
                        origin: None,
                        key: SinglePubKey::FullKey(pubdata.pks[j]),
                    })
                } else if pk_str.starts_with("X") {
                    DescriptorPublicKey::Single(SinglePub {
                        origin: None,
                        key: SinglePubKey::XOnly(pubdata.x_only_pks[j]),
                    })
                } else {
                    // Parse any other keys as known to allow compatibility with existing tests
                    DescriptorPublicKey::Single(SinglePub {
                        origin: None,
                        key: SinglePubKey::FullKey(pubdata.pks[j]),
                    })
                }
            } else {
                DescriptorPublicKey::Single(SinglePub {
                    origin: None,
                    key: SinglePubKey::FullKey(random_pk(59)),
                })
            }
        },
    );
    ms
}
/// Parse an insane miniscript into a miniscript with the format described above at file header
Parse an insane miniscript into a miniscript with the format described above at file header
Parse an insane miniscript into a miniscript with the format described above at file header
pub fn parse_insane_ms<Ctx: ScriptContext>(
    ms: &str,
    pubdata: &PubData,
) -> Miniscript<DescriptorPublicKey, Ctx> {
    let ms = subs_hash_frag(ms, pubdata);
    let ms =
        Miniscript::<String, Ctx>::from_str_insane(&ms).expect("only parsing valid minsicripts");
    let mut i = 0;
    let mut j = pubdata.pks.len();
    let ms = ms.translate_pk_infallible(
        &mut |pk_str: &String| {
            let avail = !pk_str.ends_with("!");
            if avail {
                i = i + 1;
                if pk_str.starts_with("K") {
                    DescriptorPublicKey::Single(SinglePub {
                        origin: None,
                        key: SinglePubKey::FullKey(pubdata.pks[i]),
                    })
                } else if pk_str.starts_with("X") {
                    DescriptorPublicKey::Single(SinglePub {
                        origin: None,
                        key: SinglePubKey::XOnly(pubdata.x_only_pks[i]),
                    })
                } else {
                    // Parse any other keys as known to allow compatibility with existing tests
                    DescriptorPublicKey::Single(SinglePub {
                        origin: None,
                        key: SinglePubKey::FullKey(pubdata.pks[i]),
                    })
                }
            } else {
                DescriptorPublicKey::Single(SinglePub {
                    origin: None,
                    key: SinglePubKey::FullKey(random_pk(59)),
                })
            }
        },
        &mut |pk_str: &String| {
            let avail = !pk_str.ends_with("!");
            if avail {
                j = j - 1;
                if pk_str.starts_with("K") {
                    DescriptorPublicKey::Single(SinglePub {
                        origin: None,
                        key: SinglePubKey::FullKey(pubdata.pks[j]),
                    })
                } else if pk_str.starts_with("X") {
                    DescriptorPublicKey::Single(SinglePub {
                        origin: None,
                        key: SinglePubKey::XOnly(pubdata.x_only_pks[j]),
                    })
                } else {
                    // Parse any other keys as known to allow compatibility with existing tests
                    DescriptorPublicKey::Single(SinglePub {
                        origin: None,
                        key: SinglePubKey::FullKey(pubdata.pks[j]),
                    })
                }
            } else {
                DescriptorPublicKey::Single(SinglePub {
                    origin: None,
                    key: SinglePubKey::FullKey(random_pk(59)),
                })
            }
        },
    );
    ms
}
pub fn parse_insane_ms < Ctx : ScriptContext > ( ms : & str , pubdata : & PubData , ) -> Miniscript < DescriptorPublicKey , Ctx > { let ms = subs_hash_frag ( ms , pubdata ) ; let ms = Miniscript :: < String , Ctx > :: from_str_insane ( & ms ) . expect ( " " ) ; let mut i = 0 ; let mut j = pubdata . pks . len ( ) ; let ms = ms . translate_pk_infallible ( & mut | pk_str : & String | { let avail = ! pk_str . ends_with ( " " ) ; if avail { i = i + 1 ; if pk_str . starts_with ( " " ) { DescriptorPublicKey :: Single ( SinglePub { origin : None , key : SinglePubKey :: FullKey ( pubdata . pks [ i ] ) , } ) } else if pk_str . starts_with ( " " ) { DescriptorPublicKey :: Single ( SinglePub { origin : None , key : SinglePubKey :: XOnly ( pubdata . x_only_pks [ i ] ) , } ) } else { // Parse any other keys as known to allow compatibility with existing tests DescriptorPublicKey :: Single ( SinglePub { origin : None , key : SinglePubKey :: FullKey ( pubdata . pks [ i ] ) , } ) } } else { DescriptorPublicKey :: Single ( SinglePub { origin : None , key : SinglePubKey :: FullKey ( random_pk ( 59 ) ) , } ) } } , & mut | pk_str : & String | { let avail = ! pk_str . ends_with ( " " ) ; if avail { j = j - 1 ; if pk_str . starts_with ( " " ) { DescriptorPublicKey :: Single ( SinglePub { origin : None , key : SinglePubKey :: FullKey ( pubdata . pks [ j ] ) , } ) } else if pk_str . starts_with ( " " ) { DescriptorPublicKey :: Single ( SinglePub { origin : None , key : SinglePubKey :: XOnly ( pubdata . x_only_pks [ j ] ) , } ) } else { // Parse any other keys as known to allow compatibility with existing tests DescriptorPublicKey :: Single ( SinglePub { origin : None , key : SinglePubKey :: FullKey ( pubdata . pks [ j ] ) , } ) } } else { DescriptorPublicKey :: Single ( SinglePub { origin : None , key : SinglePubKey :: FullKey ( random_pk ( 59 ) ) , } ) } } , ) ; ms }
Parse an insane miniscript into a miniscript with the format described above at file header
Parse an insane miniscript into a miniscript with the format described above at file header
ms
&str
pubdata
&PubData
ms
&str
pubdata
&PubData