How to ensure there is no version mismatch? #17236

issue nopara73 opened this issue on October 24, 2019
  1. nopara73 commented at 2:33 AM on October 24, 2019: none

    Motivation

    We would like to ship bitcoind with our software, however it's problematic if the user has already Bitcoin Core in her machine, because of the disk requirements.

    In order to avoid API/database/etc incompatibilities and various potential disastrous scenarios we would like to prevent the user to use Bitcoin Core with our software if the version of her own Core and our shipped Core differs.

    Question

    How do similar software resolve this issue?

    Idea 1

    Should I play a setup procedure with the user like this:

    1. Do you want to use Bitcoin Core with Wasabi? Yes -> 2. / No -> END
    2. Do you have already Bitcoin Core installed? Yes -> 3. / No -> GOOD
    3. What version of Bitcoin Core do you have? ... -> Same -> 4. / Different -> BAD
    4. Try to detect data folder automatically. Success -> GOOD / Fail -> 5.
    5. What's your current Bitcoin Core's data folder? ... -> GOOD
    
    - What if we update Bitcoin Core? Replay step 3.
    - What if the user updates Bitcoin Core? It's a problem, there's no way we can detect it.
    

    Idea 2

    What I can do is to try to detect Bitcoin Core's default data folder and also get some input from the user if she's using a custom data folder, but is there a way to acquire the version from the data folder somehow?

    Idea 3

    I could call bitcoind --version. In this case the user should tell us the location of bitcoind. In that case, is it possible to recognize programmatically her custom data folder if she's using one?

    Reiterating The Question

    What are the common strategies of doing this? Is it possible to detect if Bitcoin Core is installed and what data folder is used?

  2. nopara73 added the label Feature on Oct 24, 2019
  3. MarcoFalke commented at 2:42 AM on October 24, 2019: member

    All you need is the rpc auth (not the whole datadir), then you can get the version as described in https://github.com/bitcoin/bitcoin/blob/master/doc/JSON-RPC-interface.md#versioning

  4. MarcoFalke added the label Questions and Help on Oct 24, 2019
  5. MarcoFalke removed the label Feature on Oct 24, 2019
  6. emilengler commented at 11:58 AM on October 24, 2019: contributor

    But for the RPC auth you need the datadir right? At least you need te specify it every time when you use the non default one with bitcoin-cil.

  7. laanwj commented at 5:51 PM on October 24, 2019: member

    If it is running and you know the datadir, and assuming they use cookie auth, you can use RPC to query the version. Other cases (not currently running, datadir unknown, custom user/password auth) are more difficult.

    The version from RPC is useful for sanity-checking the version when your application launches (and is already installed and attuned to a bitcoin core installation), to detect whether the user has upgraded behind your back.

    but is there a way to acquire the version from the data folder somehow?

    A datadir at rest doesn't have a version. Although there have been some incompatible changes with regard to data files, such as block index upgrades, usually they tend to be compatible through a range of versions.

    I think it's more useful to look for installed version(s) of bitcoin core, and check their version, not to reason from the datadir.

    In that case, is it possible to recognize programmatically her custom data folder if she's using one?

    Not in general, there are many ways to pass a custom data directory.

    It's possible to mimic bitcoin d/-qt's own logic to find the default data directory. This is platform specific. E.g., for UNIX, default to ~/.bitcoin, look for a bitcoin.conf there, there might be a datadir=... there that points somewhere else.

    But it's not possible this way to find out if someone happens to specify a non-standard datadir through -datadir=... or -conf=... (with a custom datadir) on the command line from a script or init task.

    As there is no 'perfect' way to detect this I think it'd be best to look at some of the hints and based on those, ask the user at install time, whether they provide an existing install of bitcoin core (specifying the data directory if it's not the default one, let them check the auto-detected values) or want to install a new one.

  8. emilengler commented at 6:42 PM on October 24, 2019: contributor

    But it's not possible this way to find out if someone happens to specify a non-standard datadir through -datadir=... or -conf=... (with a custom datadir) on the command line from a script or init task.

    A quirky way on UNIX systems would be to parse ps aux | grep bitcoind. Then you could get the -conf and -datadir parameter if you have sufficient permissions

  9. MarcoFalke commented at 7:08 PM on October 24, 2019: member

    It is possible to have multiple datadirs in different locations, so I'd advise against using an assumed datadir without asking the user

  10. laanwj commented at 8:10 PM on October 24, 2019: member

    to make things worse, if you go around looking for datadirs, here might be datadirs for altcoins that are difficult to distinguish from bitcoin's

  11. nopara73 commented at 11:11 PM on October 24, 2019: none

    Thank you for the replies! In summary: there's no best practice, but numerous approaches and ideas with different tradeoffs, which if someone finds this thread should be able to evaluate. While I believe we did not fully exhausted the topic, we explored it to a reasonable degree and maybe it's better to not waste more time of this repo's devs with this, so closing.

  12. nopara73 closed this on Oct 24, 2019

  13. DrahtBot locked this on Dec 16, 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-26 06:14 UTC

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