bitcoin-core / bitcoincore.org

Bitcoin Core project website
https://bitcoincore.org/
MIT License
600 stars 471 forks source link

RPC doc generating script: always connect to regtest #751

Closed theStack closed 3 years ago

theStack commented 3 years ago

See Bitcoin Core PR https://github.com/bitcoin/bitcoin/pull/20987, in particular the discussion https://github.com/bitcoin/bitcoin/pull/20987#discussion_r562762266.

The recommended network for generating RPC docs is regtest, as stated in the script's file header comments: // (2) install bitcoin core, set it up to use regtest

To achieve this, the user previosly needed to manually put regtest=1 into ~/.bitcoin/bitcoin.conf -- the script didn't specify a concrete network, so without config file setting, mainnet was used. With the change in this commit, we will always connect to regtest by passing the -regtest option to the bitcoin-cli invokation.

With this change, harding's well-described way to use the script involving file editing via mighty vi(m) will be reduced to just running the following commands:

$ bitcoind -regtest -daemon
$ go run generate.go
$ bitcoin-cli -regtest stop

Note that I'm far from a golang expert and just tried to wrap my head around variadic functions and slices. Prepending the arguments slice with the chainoption (-regtest) seemed the easiest solution to me, but curious to hear how a more "gothonic" (does that word exist?) approach would look like.

theStack commented 3 years ago

Thanks for reviewing! Force-pushed with your suggestion of updating the error message.

laanwj commented 3 years ago

Going to test.

Tested ACK a25cd3be1876db50d0bdf5026acc6a04c0834cf1

sudo install git golang wget
wget https://bitcoincore.org/bin/bitcoin-core-0.21.0/bitcoin-0.21.0-x86_64-linux-gnu.tar.gz
tar -zxf bitcoin-0.21.0-x86_64-linux-gnu.tar.gz
export PATH="$PWD/bitcoin-0.21.0/bin:$PATH"
bitcoind  -regtest -daemon
git clone -b doc-gen_always_connect_to_regtest https://github.com/theStack/bitcoincore.org.git
cd bitcoincore.org/contrib/doc-gen
go run generate.go

Regenerates exactly the same documentation as is currently in the repository.