Skip to content

Add full support for BIP-370 (PSBTv2) #86

@notTanveer

Description

@notTanveer

Currently, embit provides only partial support for PSBT v2 as defined in BIP-370, with most input fields unimplemented and lacking test coverage.


Observations

1. No Explicit GlobalScope Class

  • embit currently does not define a dedicated GlobalScope class.
  • Global fields are handled directly in the PSBT class through attributes like:
    • self.unknown
    • self.xpubs
    • self.tx_version
    • self.locktime
    • and utility methods such as parse_unknowns().
  • This diverges from BIP-370, which specifies an explicit <globals> scope, distinct from inputs and outputs.

2. Partial PSBTv2 Field Support

  • InputScope and OutputScope have limited support for PSBTv2 fields (e.g., txid, vout, sequence, value, script_pubkey), conditionally handled when version == 2.
  • However, many new or optional v2 fields from BIP-370 are not implemented.
  • The current structure is more v0-centric, with v2 fields sprinkled in, rather than fully modular as per the spec.

3. Implementation Summary

Scope Dedicated Class BIP-370 v2 Fields Supported? Notes
GlobalScope Partially Managed inside the PSBT class
InputScope Partially Some v2 fields supported; others missing
OutputScope Partially Similar situation to InputScope

Proposed Plan

  • Refactor to introduce explicit GlobalScope support (optional but encouraged for modularity)
  • Implement full parsing and serialization for all defined BIP-370 fields
  • Add support for remaining v2-only fields across Input and Output scopes
  • Validate against BIP-370 test vectors
  • Add comprehensive unit tests to verify behavior

Happy to discuss the design direction and contribute the necessary changes! Let me know if there's already ongoing work I should align with.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions