use mini_bitcoin_script::hash;
use mini_bitcoin_script::script::validate_p2pkh;
use mini_bitcoin_script::tokenizer::parse_script;
fn main() {
let fake_sig = [0x30u8; 71];
let fake_pubkey = [0x02u8; 33];
let pubkey_hash = hash::hash160(&fake_pubkey);
let mut script_sig = Vec::new();
script_sig.push(fake_sig.len() as u8); script_sig.extend_from_slice(&fake_sig);
script_sig.push(fake_pubkey.len() as u8);
script_sig.extend_from_slice(&fake_pubkey);
let mut script_pubkey = Vec::new();
script_pubkey.push(0x76); script_pubkey.push(0xa9); script_pubkey.push(0x14); script_pubkey.extend_from_slice(&pubkey_hash);
script_pubkey.push(0x88); script_pubkey.push(0xac);
let tokens = parse_script(&script_pubkey).expect("valid scriptPubKey");
println!("scriptPubKey tokens:");
print!(" ");
for token in &tokens {
print!(" {token}");
}
println!();
println!();
let result = validate_p2pkh(&script_sig, &script_pubkey).expect("execution succeeded");
println!("P2PKH validation result: {result}");
}