Windows client launch inconsistency #5663

issue ajp8164 opened this issue on January 14, 2015
  1. ajp8164 commented at 11:23 PM on January 14, 2015: none

    When launching Bitcoin Core from a BIP21 (or comparable) URL the app opens up connected to live net (without -testnet parameter) when it sees the address starting with 'n'. The app does, however, open up connected to testnet if the address starts with 'm' (with -testnet parameter). This behavior is inconsistent and should be corrected to be consistent across all valid testnet (and live net) addresses.

  2. laanwj added the label GUI on Jan 15, 2015
  3. laanwj added the label Priority Low on Jan 15, 2015
  4. Diapolo commented at 12:29 PM on January 16, 2015: none

    I don't understand the problem, you click a link containing mainnet address and it opens mainnet, you click a link containing a testnet address and it opens testnet, whats wrong here?

  5. laanwj commented at 12:32 PM on January 16, 2015: member

    @Diapolo He implies that there is a difference in handling testnet addresses starting with 'm' and starting with 'n' in the URIs. It's curious as AFAIK there is no code that looks at the first letter to determine what kind of address it is.

  6. chanalex88 commented at 8:08 PM on February 5, 2015: none

    So how does the client app (bitcoin-qt.exe) know to open up testnet when the addresses start with 'm' meaning they are testnet addresses?

    The issue is that strangely the logic works for addresses starting with 'm' but not those starting with 'n'.

  7. laanwj commented at 10:02 AM on February 6, 2015: member

    This is where the logic is where the client's network is selected based on the address passed in, thus would be a good starting point: https://github.com/bitcoin/bitcoin/blob/master/src/qt/paymentserver.cpp#L207

    So on line 216 it first checks if the address is valid for mainnet, if so, it selects mainnet. Then it checks if the address is valid for testnet, if so, it selects testnet. If neither it justs falls through, as an 'invalid address' error will be shown later after client start-up finished.

    There is no 'address starts with X' heuristic anywhere, just full address decodes+checks, so that's why I'm spooked as to why this may happen.

  8. Diapolo commented at 10:09 AM on February 6, 2015: none

    I still think the initial issue description is unclear... he writes The app does ... open up connected to testnet if the address starts with 'm' (with -testnet parameter). Is that a running instance with -testnet supplied or what does that mean?

  9. chanalex88 commented at 12:03 AM on February 12, 2015: none

    I think he meant to say that the app does open up connected to testnet fresh (and not a running instance) correctly if the address starts with 'm', as if it runs with -testnet parameter. However, if the address starts with 'n', then the app opens up connected to the live net, which is incorrect.

    I was able to repro it on my machine before that whenever the address starts with 'n' like n379DyezL6xbcrR71V1iWfxjicT4t16RmQ, the app opens up connecting to the live net, even though I expect it to connect to testnet.

    I checked the code. I understand that it does not check for the 'm' or 'n' character directly, but could the CBitcoinAddress::IsValid() function have some bug that incorrectly treats an address starting with 'n' as a live net address?

  10. jonasschnelli commented at 2:02 PM on November 30, 2015: contributor

    Tested again with current master (Windows / OSX). Both platforms handles address/network mapping correct. bitcoin:n379DyezL6xbcrR71V1iWfxjicT4t16RmQ did successfully open bitcoin-qt with testnet on both platforms. Closing.

    <img width="849" alt="bildschirmfoto 2015-11-30 um 15 00 57" src="https://cloud.githubusercontent.com/assets/178464/11473555/560fa6ca-9773-11e5-8f06-9d1301311349.png">

  11. jonasschnelli closed this on Nov 30, 2015

  12. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-21 18:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me