Skip to content

BIP21: clarify that example addresses are intentionally invalid #1861

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

Merged
merged 1 commit into from
Jun 4, 2025

Conversation

ethicnology
Copy link
Contributor

@ethicnology ethicnology commented May 29, 2025

Clarify to readers that the addresses used in the examples are intentionally invalid to prevent accidental transactions.

@jonatack jonatack added Pending acceptance This BIP modification requires sign-off by the champion of the BIP being modified Bug fix labels May 29, 2025
@jonatack
Copy link
Member

cc BIP author @TheBlueMatt for feedback

@ethicnology ethicnology changed the title fix: Invalid address in BIP21 example BIP21: correct invalid address in BIP21 example May 29, 2025
@ethicnology ethicnology changed the title BIP21: correct invalid address in BIP21 example BIP21: correct invalid address in examples May 29, 2025
@murchandamus
Copy link
Contributor

This may have been on purpose, given that it is examples and not test vectors, because in the past people have sent money to addresses published in BIPs or Bitcoin books which were no longer held by anyone or for which it was then unclear where the funds should be sent.

@kristapsk
Copy link

I think it's ok here to have invalid addresses on purpose, but maybe that should be mentioned in text that these example addresses aren't real, I also have spent some extra time in past with tests because of this.

@jonatack
Copy link
Member

jonatack commented Jun 1, 2025

@murchandamus @kristapsk good points; this has come up occasionally in Bitcoin Core as well, where the developer notes state:

- Use *invalid* bech32 addresses (e.g. in the constant array `EXAMPLE_ADDRESS`) for
  `RPCExamples` help documentation.

  - *Rationale*: Prevent accidental transactions by users and encourage the use
    of bech32 addresses by default.

@ethicnology
Copy link
Contributor Author

ethicnology commented Jun 1, 2025

I can replace legacy addresses to encourage the use of bech32.

Why should we prevent accidental transactions rather than providing valid examples ?

EDIT: Using valid regtest/testnet/signet addresses could solve both issues

@jonatack
Copy link
Member

jonatack commented Jun 1, 2025

I'd suggest updating this as @kristapsk suggested.

@ethicnology
Copy link
Contributor Author

Amended with bc1q09vm5lfy0j5reeulh4x5752q25uqqvz34hufdl from EXAMPLE_ADDRESS

@ethicnology
Copy link
Contributor Author

rename commit from fix: bip21 example invalid address to refactor: replace BIP21 legacy addresses to bech32

Copy link
Contributor

@murchandamus murchandamus left a comment

Choose a reason for hiding this comment

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

BIP 21 is Final and was specified with use of base58 addresses as it predates segwit. While some people have more recently also applied the described scheme to native segwit addresses, these examples do not conform to the specification of this proposal. I don’t think changing the examples to bech32 addresses makes sense in this context.

Recently, BIP 321 was proposed as a replacement for BIP 21. Perhaps what you were looking for is part of BIP 321?

@ethicnology
Copy link
Contributor Author

@murchandamus

Initially, I came to report that the addresses in the examples were invalid, and that this could lead some developers, like myself or kristapsk, to waste time debugging and questioning our integration, when in fact the issue came from the example itself being invalid

Following the creation of this issue, it appears that the invalid addresses weren’t random but intentionally used to prevent accidental transactions.

I suggested replacing the invalid addresses with ones from test networks like testnet, signet, or regtest, in order to keep the example valid while still avoiding accidental transactions. However, it doesn't seems to be convincing, so I've amended my commit with an invalid bech32 address from EXAMPLE_ADDRESSES as recommended in the bitcoin core developers notes.

If the BIP is final and we shouldn't change anything then we can close my PR

@murchandamus
Copy link
Contributor

Hey @ethicnology, I touched base with @TheBlueMatt. The addresses were indeed invalid on purpose. So, I would also suggest what @kristapsk proposed: to add a line that informs readers that the addresses are invalid on purpose. If you would like to take a stab at that, please edit this branch, otherwise, please feel free to close it and probably @jonatack, myself, or someone else will open a PR to amend BIP 21 to add the warning.

@ethicnology ethicnology changed the title BIP21: correct invalid address in examples BIP21: invalid address in examples Jun 4, 2025
@ethicnology
Copy link
Contributor Author

@murchandamus done in fad325e

Copy link
Contributor

@murchandamus murchandamus left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@jonatack jonatack changed the title BIP21: invalid address in examples BIP21: clarify that example addresses are intentionally invalid Jun 4, 2025
Copy link
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

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

ACK fad325e

Updated the PR title and description.

@jonatack jonatack removed the Pending acceptance This BIP modification requires sign-off by the champion of the BIP being modified label Jun 4, 2025
@jonatack jonatack merged commit 820a044 into bitcoin:master Jun 4, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants