Skip to content
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

support native segwit regtest addresses (#148) #162

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

Conversation

chadchapnick
Copy link

@chadchapnick chadchapnick commented Aug 28, 2024

Add support for Native Segwit addresses on regtest networks

Resolves Issue #148

To verify this human readable part for bech32 regtest addresses, the following references may be helpful:

buidl/script.py Outdated
if len(s) == 42:
# p2wpkh
return P2WPKHScriptPubKey(decode_bech32(s)[2])
elif len(s) == 62:
elif len(s) == 62 or len(s) == 64:
Copy link

@Shadouts Shadouts Sep 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fuzzy. I think a root-level branch specific for regtest would be better because a bc1q with length 64 should throw.

...
elif s[:4] in ("bc1q", "tb1q"):
        if len(s) == 42:
            # p2wpkh
            return P2WPKHScriptPubKey(decode_bech32(s)[2])
        elif len(s) == 62:
            # p2wsh
            return P2WSHScriptPubKey(decode_bech32(s)[2])
elif s[:6] == "bcrt1q":
        if len(s) == 44:
            # p2wpkh
            return P2WPKHScriptPubKey(decode_bech32(s)[2])
        elif len(s) == 64:
            # p2wsh
            return P2WSHScriptPubKey(decode_bech32(s)[2])
...

@chadchapnick chadchapnick force-pushed the fix/148-regtest-native-segwit-support branch from 98d8fa8 to 70107fa Compare October 1, 2024 04:37
@chadchapnick chadchapnick force-pushed the fix/148-regtest-native-segwit-support branch from 70107fa to 92a2549 Compare October 29, 2024 15:13
@chadchapnick chadchapnick force-pushed the fix/148-regtest-native-segwit-support branch from 92a2549 to eb30d28 Compare October 29, 2024 17:41
@jimmysong
Copy link
Collaborator

Are there plans to add regtest as a separate network parameter? There are a lot of functions that use network as a parameter and if we're to support regtest, they all need to be updated. For example bech32.py has a function encode_bech32_checksum. That would need to return the address of the type that is in this function.

@chadchapnick chadchapnick force-pushed the fix/148-regtest-native-segwit-support branch 2 times, most recently from f1b34e0 to eb30d28 Compare November 5, 2024 18:35
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.

3 participants