Skip to content

TODO : Implement Unified Address Object for Multi-Type Address Support #149

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

Unified Address Object Implementation

This PR introduces a new UnifiedAddress class that provides a unified way to handle all Bitcoin address types (P2PKH, P2SH, P2WPKH, P2WSH, P2TR) and enables conversion between compatible address types.

Changes:

  • Created a new address.py module with the UnifiedAddress class
  • Added support for detecting address types automatically
  • Implemented conversion logic between compatible address formats
  • Added functionality to create addresses from various sources (strings, hashes, scripts, witness programs)
  • Added comprehensive tests for all address functionality

Key Features:

  • Simplified API for handling different address types uniformly
  • Easy conversion between address formats (e.g., P2PKH → P2WPKH)
  • Support for nested SegWit addresses (P2SH-P2WPKH, P2SH-P2WSH)
  • Complete type-hinting for better development experience
  • Comprehensive validation of address formats and conversions

Example Usage:

# Create from existing addresses
unified = UnifiedAddress(p2pkh_address)

# Convert between address types
p2wpkh = unified.to_address_type(P2WPKH_ADDRESS_V0)

# Create from address string with auto-detection
address = UnifiedAddress.from_address("tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx")

All the tests pass
Screenshot 2025-03-30 at 12 59 05 AM

@JAGADISHSUNILPEDNEKAR
Copy link
Contributor Author

HI @karask
Just checking on this PR

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