Build a simplified Bitcoin transaction model while practising structs, enums,
traits, ownership, borrowing, collections, and Result-based error handling.
The crate is intentionally incomplete. Search for TODO and implement each part;
do not change the public type names or function signatures.
- Read ASSIGNMENT.md.
- Complete Parts 3–5 in
transaction.rsanderror.rs. - Remove
#[ignore]from the relevant test and run it. - Complete the traits and borrowing functions in Parts 6–7.
- Build the payment example in
main.rs. - Complete UTXO selection and its tests.
- Add the remaining required tests yourself.
cargo test
cargo test -- --ignored
cargo run
cargo fmt --check
cargo clippy --all-targets --all-features -- -D warningscargo test checks the starter project. Ignored tests intentionally exercise
unfinished code; enable them progressively rather than leaving them ignored in the
submission.
Answer in your own words. Add the ownership compiler error from Part 7 as a fenced text block, then explain what caused it.
- What is a Bitcoin transaction input?
- What is a Bitcoin transaction output?
- What is a UTXO?
- What does an outpoint identify?
- How is a transaction fee calculated?
- Why use integers rather than floating-point numbers for bitcoin amounts?
- Why does
total_input_value()borrowself? - Why does
add_input()take&mut self? - What happens when an input is moved into a transaction?
- Why is
Resultpreferable topanic!for validation failures? - How do enums help model regular and coinbase inputs?
- How does the
BitcoinValuetrait reduce duplication?
Describe any choices you made, including your UTXO-selection trade-offs and (if attempted) the optional transaction-state extension.
Paste the output of cargo run here once Part 8 is complete.