From e61fdab32ce23891d1ad91a9d6856ab5af54e208 Mon Sep 17 00:00:00 2001 From: Ian Slane Date: Sat, 20 Apr 2024 20:37:27 -0600 Subject: [PATCH] testing witness root calc --- mine-your-first-block/src/main.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/mine-your-first-block/src/main.rs b/mine-your-first-block/src/main.rs index ee299f9..294d7b7 100644 --- a/mine-your-first-block/src/main.rs +++ b/mine-your-first-block/src/main.rs @@ -156,21 +156,20 @@ fn create_coinbase_tx(total_tx_fee: u64, witness_root: String) -> Transaction { // value: 0, // }); // Made some edits to work directly with bytes so i didnt have to decode and encode - let op_return_prefix = vec![0x6a, 0x24, 0xaa, 0x21, 0xa9, 0xed]; - // let witness_root_bytes = hex::decode(witness_root).unwrap(); - let witness_root_bytes = hex::decode(witness_root).unwrap(); - let reversed_witness_root_bytes: Vec = witness_root_bytes.into_iter().rev().collect(); + //let op_return_prefix = vec![0x6a, 0x24, 0xaa, 0x21, 0xa9, 0xed]; + let mut witness_root_bytes = hex::decode(witness_root).unwrap(); + witness_root_bytes.reverse(); let witness_reserved_value_bytes = hex::decode(witness_reserved_value).unwrap(); let mut wtxid_commitment = Vec::new(); - wtxid_commitment.extend(reversed_witness_root_bytes); + wtxid_commitment.extend(witness_root_bytes); wtxid_commitment.extend(witness_reserved_value_bytes); let wtxid_commitment_hash = double_sha256(wtxid_commitment); - let mut scriptpubkey_for_wtxid = op_return_prefix; - scriptpubkey_for_wtxid.extend(wtxid_commitment_hash); - + // let mut scriptpubkey_for_wtxid = op_return_prefix; + // scriptpubkey_for_wtxid.extend(wtxid_commitment_hash); + let scriptpubkey_for_wtxid = format!("{}{}", "6a24aa21a9ed", hex::encode(wtxid_commitment_hash)); coinbase_tx.vout.push(Vout { scriptpubkey: hex::encode(scriptpubkey_for_wtxid), scriptpubkey_asm: "".to_string(),