|
| 1 | +# Contributing to Programming Bitcoin |
| 2 | + |
| 3 | +Thank you for your interest in contributing to this project! This is an educational implementation of Bitcoin cryptography in Rust. |
| 4 | + |
| 5 | +## Getting Started |
| 6 | + |
| 7 | +1. Fork the repository |
| 8 | +2. Clone your fork: `git clone https://github.com/YOUR_USERNAME/programming_bitcoin.git` |
| 9 | +3. Create a branch: `git checkout -b feature/your-feature-name` |
| 10 | +4. Make your changes |
| 11 | +5. Run tests: `cargo test` |
| 12 | +6. Format code: `cargo fmt` |
| 13 | +7. Run clippy: `cargo clippy` |
| 14 | +8. Commit your changes: `git commit -am 'Add some feature'` |
| 15 | +9. Push to the branch: `git push origin feature/your-feature-name` |
| 16 | +10. Create a Pull Request |
| 17 | + |
| 18 | +## Development Setup |
| 19 | + |
| 20 | +### Prerequisites |
| 21 | +- Rust 1.70+ (install via [rustup](https://rustup.rs/)) |
| 22 | +- Git |
| 23 | + |
| 24 | +### Building |
| 25 | +```bash |
| 26 | +cargo build |
| 27 | +``` |
| 28 | + |
| 29 | +### Running Tests |
| 30 | +```bash |
| 31 | +# Run all tests |
| 32 | +cargo test |
| 33 | + |
| 34 | +# Run specific chapter tests |
| 35 | +cargo test --test ch01_finite_fields_tests |
| 36 | +cargo test --test ch02_elliptic_curves_tests |
| 37 | +cargo test --test ch03_bitcoin_crypto_tests |
| 38 | +cargo test --test ch04_serialization_tests |
| 39 | + |
| 40 | +# Run a specific test |
| 41 | +cargo test test_field_element_creation |
| 42 | + |
| 43 | +# Run with output |
| 44 | +cargo test -- --nocapture |
| 45 | +``` |
| 46 | + |
| 47 | +### Code Quality |
| 48 | + |
| 49 | +Before submitting a PR, ensure: |
| 50 | + |
| 51 | +1. **All tests pass:** |
| 52 | + ```bash |
| 53 | + cargo test |
| 54 | + ``` |
| 55 | + |
| 56 | +2. **Code is formatted:** |
| 57 | + ```bash |
| 58 | + cargo fmt |
| 59 | + ``` |
| 60 | + |
| 61 | +3. **No clippy warnings:** |
| 62 | + ```bash |
| 63 | + cargo clippy -- -D warnings |
| 64 | + ``` |
| 65 | + |
| 66 | +4. **Documentation builds:** |
| 67 | + ```bash |
| 68 | + cargo doc --no-deps |
| 69 | + ``` |
| 70 | + |
| 71 | +## Project Structure |
| 72 | + |
| 73 | +``` |
| 74 | +src/ |
| 75 | +├── ch01_finite_fields/ # Finite field arithmetic |
| 76 | +├── ch02_elliptic_curves/ # Basic elliptic curve operations |
| 77 | +├── ch03_ecc/ # Bitcoin's secp256k1 curve |
| 78 | +└── ch04_serialization/ # Bitcoin serialization formats |
| 79 | +
|
| 80 | +tests/ |
| 81 | +├── ch01_finite_fields_tests.rs |
| 82 | +├── ch02_elliptic_curves_tests.rs |
| 83 | +├── ch03_bitcoin_crypto_tests.rs |
| 84 | +└── ch04_serialization_tests.rs |
| 85 | +``` |
| 86 | + |
| 87 | +## Coding Guidelines |
| 88 | + |
| 89 | +### Style |
| 90 | +- Follow Rust standard style (enforced by `rustfmt`) |
| 91 | +- Use meaningful variable names |
| 92 | +- Add comments for complex algorithms |
| 93 | +- Keep functions focused and small |
| 94 | + |
| 95 | +### Testing |
| 96 | +- Write tests for new functionality |
| 97 | +- Maintain or improve code coverage |
| 98 | +- Test edge cases and error conditions |
| 99 | +- Use descriptive test names: `test_<what>_<scenario>` |
| 100 | + |
| 101 | +### Documentation |
| 102 | +- Add doc comments for public APIs |
| 103 | +- Include examples in doc comments when helpful |
| 104 | +- Update README.md if adding new features |
| 105 | + |
| 106 | +### Commits |
| 107 | +- Write clear, descriptive commit messages |
| 108 | +- Use present tense ("Add feature" not "Added feature") |
| 109 | +- Reference issues when applicable (#123) |
| 110 | + |
| 111 | +## Types of Contributions |
| 112 | + |
| 113 | +### Bug Reports |
| 114 | +- Use GitHub Issues |
| 115 | +- Include steps to reproduce |
| 116 | +- Provide expected vs actual behavior |
| 117 | +- Include Rust version and OS |
| 118 | + |
| 119 | +### Feature Requests |
| 120 | +- Use GitHub Issues |
| 121 | +- Explain the use case |
| 122 | +- Describe the proposed solution |
| 123 | +- Consider alternatives |
| 124 | + |
| 125 | +### Code Contributions |
| 126 | +- Follow the development setup above |
| 127 | +- Ensure all checks pass |
| 128 | +- Update tests and documentation |
| 129 | +- Keep PRs focused on a single concern |
| 130 | + |
| 131 | +### Documentation |
| 132 | +- Fix typos and improve clarity |
| 133 | +- Add examples |
| 134 | +- Improve README or inline docs |
| 135 | + |
| 136 | +## Pull Request Process |
| 137 | + |
| 138 | +1. **Update tests** - Add or update tests for your changes |
| 139 | +2. **Update documentation** - Update README.md, doc comments, etc. |
| 140 | +3. **Run checks locally** - Ensure tests, fmt, and clippy pass |
| 141 | +4. **Create PR** - Provide a clear description of changes |
| 142 | +5. **Address feedback** - Respond to review comments |
| 143 | +6. **Wait for CI** - All GitHub Actions must pass |
| 144 | + |
| 145 | +## Code Review |
| 146 | + |
| 147 | +All submissions require review. We use GitHub pull requests for this purpose. |
| 148 | + |
| 149 | +Reviewers will check: |
| 150 | +- Code quality and style |
| 151 | +- Test coverage |
| 152 | +- Documentation |
| 153 | +- Performance implications |
| 154 | +- Security considerations |
| 155 | + |
| 156 | +## Questions? |
| 157 | + |
| 158 | +Feel free to: |
| 159 | +- Open an issue for questions |
| 160 | +- Start a discussion |
| 161 | +- Reach out to maintainers |
| 162 | + |
| 163 | +## License |
| 164 | + |
| 165 | +By contributing, you agree that your contributions will be licensed under the same license as the project (see LICENSE file). |
| 166 | + |
| 167 | +## Learning Resources |
| 168 | + |
| 169 | +This project follows the book "Programming Bitcoin" by Jimmy Song: |
| 170 | +- [Programming Bitcoin](https://programmingbitcoin.com/) |
| 171 | +- [Bitcoin Wiki](https://en.bitcoin.it/) |
| 172 | +- [secp256k1 specification](https://www.secg.org/sec2-v2.pdf) |
| 173 | + |
| 174 | +## Code of Conduct |
| 175 | + |
| 176 | +Be respectful, inclusive, and constructive. This is a learning project - questions and mistakes are welcome! |
0 commit comments