Skip to content

"WIP: Initial PSBT (BIP-174) data structures" #132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JAGADISHSUNILPEDNEKAR
Copy link
Contributor

WIP: Initial PSBT (BIP-174) data structures

This PR adds the initial data structures for BIP-174 PSBT implementation. I've focused on creating a minimal yet complete foundation that follows the specification while maintaining clean code practices.

What's included:

  • Basic PSBT class structure with core fields: Implemented the PSBT class with proper version number handling and container management that follows BIP-174 specifications
  • Input and Output container classes: Created dedicated classes that encapsulate the data structure requirements for PSBT inputs/outputs
  • PSBT type constants as defined in BIP-174: Added constants for all key types to ensure type-safety and readability throughout the implementation
  • Simple example demonstrating creation of a PSBT object: Added an example that shows how to construct a PSBT from an unsigned transaction
  • Basic tests to verify the implementation: Created focused tests that verify the core functionality

Design decisions:

  • I chose to implement PSBT with composition over inheritance to maintain clean separation between transaction elements and their PSBT metadata
  • The core PSBT class maintains references to inputs/outputs from the original transaction to ensure data consistency
  • Implemented careful property access patterns to prevent direct modification of critical fields
  • Fixed the output index access in the example script by using the stored value rather than trying to access a non-existent attribute on the TxInput object

Current limitations:

  • Serialization/deserialization not yet implemented (planned for next PR)
  • Not yet exposed in __init__.py to avoid breaking changes
  • Role-specific functionality (Creator, Updater, etc.) to come in future PRs

Running tests and examples:

The test can be run with: cd tests && python test_psbt.py
The example can be run with: cd examples && python psbt_create_basic.py

This is the first step toward full PSBT implementation. Next PRs will build on this foundation with serialization and role-specific functionality.

@JAGADISHSUNILPEDNEKAR
Copy link
Contributor Author

All the testcases are passing

Screenshot 2025-03-21 at 8 19 35 PM

@JAGADISHSUNILPEDNEKAR
Copy link
Contributor Author

Hi @karask as I have implemented the initial data structures for BIP-174 support including the core PSBT class, input/output containers and the key constants , also added the basic example and a test case to validate the functionality while laying down a clean modular serialisation and role based enhancements

In addressing the output index issue specifically, I decided to use the stored value rather than trying to access a non-existent attribute on the TxInput object, which provides a cleaner solution without requiring changes to the transaction classes.

Further I intend to implement from_bytes and to_bytes methods for PSBT serialization/deserialization as per BIP-174.

Can you please let me know what do you think about this?
Also let me know if you need any changes in the current implementation I would be happy to implement that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant