Skip to content

Conversation

@theStack
Copy link
Contributor

Legacy addresses are less and less common these days and not recommended to use, so it seems senseful to also reflect that in the example addresses and update to the most recent address / output type (bech32m / P2TR). Also, as I couldn't see any value in computing these at runtime, they are pre-generated. This was done with the following Python script, executed in ./test/functional (it's also included in the commit body, though without the she-bang):

#!/usr/bin/env python3
from test_framework.segwit_addr import CHARSET, decode_segwit_address, encode_segwit_address
from test_framework.messages import sha256

output_key = sha256(b'bitcoin dummy taproot output key')
for network, hrp in [('mainnet', 'bc'), ('signet', 'tb'), ('testnet', 'tb'), ('regtest', 'bcrt')]:
    dummy_address = encode_segwit_address(hrp, 1, output_key)
    while decode_segwit_address(hrp, dummy_address) != (None, None):
        last_char = CHARSET[(CHARSET.index(dummy_address[-1]) + 1) % 32]
        dummy_address = dummy_address[:-1] + last_char
    print(f'{network:7} example address: {dummy_address}')

Note that the last bech32 character is modified in order to make the checksum fail.

master (mainnet):

image

PR (mainnet):

image

@DrahtBot
Copy link
Contributor

DrahtBot commented Mar 22, 2024

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK maflcko, pablomartin4btc
Concept ACK MarnixCroes, kristapsk

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

@theStack theStack force-pushed the example-addr_update_to_p2tr branch from c6fa0ab to 960b2d4 Compare March 22, 2024 17:08
Copy link
Contributor

@MarnixCroes MarnixCroes left a comment

Choose a reason for hiding this comment

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

cACK

Using the default address type (bech32) for this makes the most sense I think, instead of the latest, no?

@theStack
Copy link
Contributor Author

@MarnixCroes

Using the default address type (bech32) for this makes the most sense I think, instead of the latest, no?

P2TR addresses look similar enough to P2WPKH ones (with the only difference that they are longer and start with "bc1p..." rather than "bc1q..."), so I thought it's fine if use the most recent one already. No hard feelings though, I'm happy to change this if requested, it doesn't take too much effort to adapt the Python script used.

The dummy addresses have been computed with the following Python script
(executed under ./test/functional):

--------------------------------------------------------------------------------------------------------
from test_framework.segwit_addr import CHARSET, decode_segwit_address, encode_segwit_address
from test_framework.messages import sha256

output_key = sha256(b'bitcoin dummy taproot output key')
for network, hrp in [('mainnet', 'bc'), ('signet', 'tb'), ('testnet', 'tb'), ('regtest', 'bcrt')]:
    dummy_address = encode_segwit_address(hrp, 1, output_key)
    while decode_segwit_address(hrp, dummy_address) != (None, None):
        last_char = CHARSET[(CHARSET.index(dummy_address[-1]) + 1) % 32]
        dummy_address = dummy_address[:-1] + last_char
    print(f'{network:7} example address: {dummy_address}')
--------------------------------------------------------------------------------------------------------

Co-authored-by: MarcoFalke <*~=`'#}+{/-|&$^[email protected]>
@theStack theStack force-pushed the example-addr_update_to_p2tr branch from 960b2d4 to c6d1b8d Compare March 28, 2024 10:23
@maflcko
Copy link
Contributor

maflcko commented Mar 28, 2024

lgtm ACK c6d1b8d

@DrahtBot DrahtBot requested a review from MarnixCroes March 28, 2024 10:33
Copy link
Contributor

@pablomartin4btc pablomartin4btc left a comment

Choose a reason for hiding this comment

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

tACK c6d1b8d

Tested running bitcoin-qt on signet.

image

Also tested the script provided in the description.
/test/functional$ ./gen_add_type.py
mainnet example address: bc1p35yvjel7srp783ztf8v6jdra7dhfzk5jaun8xz2qp6ws7z80n4tq2jku9f
signet  example address: tb1p35yvjel7srp783ztf8v6jdra7dhfzk5jaun8xz2qp6ws7z80n4tqa6qnlg
testnet example address: tb1p35yvjel7srp783ztf8v6jdra7dhfzk5jaun8xz2qp6ws7z80n4tqa6qnlg
regtest example address: bcrt1p35yvjel7srp783ztf8v6jdra7dhfzk5jaun8xz2qp6ws7z80n4tqsr2427

@kristapsk
Copy link
Contributor

Concept ACK

@maflcko
Copy link
Contributor

maflcko commented Apr 18, 2024

rfm or is anything left to be done here?

@hebasto hebasto merged commit c05c214 into bitcoin-core:master Apr 18, 2024
@theStack theStack deleted the example-addr_update_to_p2tr branch April 18, 2024 09:09
@bitcoin-core bitcoin-core locked and limited conversation to collaborators Apr 18, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants