Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
slanesuke committed Apr 17, 2024
1 parent 8da6a5c commit 8e33c79
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions mine-your-first-block/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -953,12 +953,13 @@ fn main() {
// Generate coinbase tx
let coinbase_tx = create_coinbase_tx(total_fees);
let serialized_cb_tx = serialize_tx(&coinbase_tx);
println!("Coinbase TX: {}", serialized_cb_tx);
let cd_tx_bytes = hex::decode(serialized_cb_tx.clone()).unwrap();

// coinbase txid
let coinbase_txid = double_sha256(cd_tx_bytes);
// Reverse the bytes
let mut coinbase_txid_le = coinbase_txid;
let mut coinbase_txid_le = coinbase_txid.to_vec();
coinbase_txid_le.reverse();
let coinbase_txid = hex::encode(coinbase_txid_le);

Expand Down Expand Up @@ -989,10 +990,10 @@ fn main() {
append_to_file("../output.txt", &serialized_cb_tx).unwrap();

// to test block weight
let half_txid = sorted_txids.len() /2;
//let half_txid = sorted_txids.len() /2;

// Add the txids to the block
for txid in &sorted_txids[0..half_txid] {
for txid in &sorted_txids {
append_to_file("../output.txt", txid).unwrap();
}
println!("Success, the block met the target difficulty!");
Expand Down

0 comments on commit 8e33c79

Please sign in to comment.