karask / python-bitcoin-utils

Library to interact with the Bitcoin network. Ideal for low-level learning and experimenting.
MIT License
262 stars 99 forks source link

TODO: Organize Constants into Sections for Enhanced Readability and Maintainability #70

Closed guptamukund22 closed 2 months ago

guptamukund22 commented 2 months ago

While going through the codebase , I saw a TODO mentioning to organize constants.The current implementation of constants within the python-bitcoin-utils library is functional but lacks a structured organization. This makes it harder for new contributors to navigate the codebase and for existing contributors to maintain and update constant values efficiently. To address this issue, I propose reorganizing all constants into clearly defined sections based on their functionality and relevance to different parts of the Bitcoin protocol.

Proposed Changes: Address Types: Group all constants defining Bitcoin address types (P2PKH, P2SH, SegWit versions) in one section to centralize address-related data.

Transaction Signature Types: Organize all transaction signature-related constants (SIGHASH types) into a dedicated section for better visibility and maintenance.

Timelock and Replace-by-Fee (RBF) Constants: Create a section for constants that handle transaction timing features like timelocks and the RBF protocol, enhancing the structure for transaction policy implementations.

Transaction Versions and Scripts: Assemble constants related to transaction versions and specific script settings in a distinct section to aid in transaction formatting and validation processes.

Monetary Constants: Consolidate all monetary-related constants, such as SATOSHIS_PER_BITCOIN, into one section to streamline financial calculations and updates.

karask commented 2 months ago

See the PR comment.