stampchain-io / btc_stamps

Bitcoin Stamps Indexer
https://stampchain.io
GNU Affero General Public License v3.0
13 stars 4 forks source link

Potential Taproot Address Decoding Issues for Debug #98

Closed reinamora137 closed 8 months ago

reinamora137 commented 10 months ago

telegram-cloud-photo-size-1-5161318820613303380-y

reinamora137 commented 10 months ago

blocks.py debug:

        try:
            source = CBitcoinAddress.from_taproot_scriptPubKey(prev_vout_script_pubkey)
reinamora137 commented 10 months ago

Transaction: 8f842c7fcb165902a3ef8e7e2b888ede6277c15e3a5c1e9fb92ccbfd0bc303f6

reinamora137 commented 9 months ago

this should have been resolved with the addition of this function:

def decode_address(script_pubkey):
    try:
        # Attempt standard address decoding
        address = CBitcoinAddress.from_scriptPubKey(script_pubkey)
        return str(address)
    except Exception as e:
        # Handle other types of addresses
        if len(script_pubkey) == 34 and script_pubkey[0] == 0x51:  # Taproot check
            # Extract the witness program for Taproot
            witness_program = script_pubkey[2:]
            # Decode as Bech32m address
            return pubkeyhash_to_addr(witness_program, prefix='bc', encoding='bech32', witver=1)
        else:
            raise ValueError("Unsupported scriptPubKey format")
reinamora137 commented 9 months ago

final testing in progress to confirm.

reinamora137 commented 8 months ago

this was resolved in the new function to decode addresses