Skip to content

Commit d209bcb

Browse files
committed
Merge #751: RPC doc generating script: always connect to regtest
a25cd3b RPC doc generating script: always connect to regtest (Sebastian Falbesoner) Pull request description: See Bitcoin Core PR bitcoin/bitcoin#20987, in particular the discussion bitcoin/bitcoin#20987 (comment). 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)](bitcoin/bitcoin#20987 (comment)) 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. ACKs for top commit: laanwj: Tested ACK a25cd3b Tree-SHA512: 566aeb6c13e35baef88b0aefe6445fbe90c1d4df1e8310a0a5e910dd947745f00e206705940ed3701bd6c763a425d23ffbbf0ea331dbde3dfe61d75b22ebee3c
2 parents 8c3b777 + a25cd3b commit d209bcb

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

contrib/doc-gen/generate.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
)
2121

2222
const BITCOIN_COMMAND = "bitcoin-cli"
23+
const BITCOIN_CHAINOPTION = "-regtest"
2324

2425
type Command struct {
2526
Name string
@@ -158,9 +159,10 @@ func open(path string) io.Writer {
158159
}
159160

160161
func run(args ...string) string {
162+
args = append([]string{BITCOIN_CHAINOPTION}, args...)
161163
out, err := exec.Command(BITCOIN_COMMAND, args...).CombinedOutput()
162164
if err != nil {
163-
log.Fatalf("Cannot run bitcoin-cli: %s, is bitcoind running?", err.Error())
165+
log.Fatalf("Cannot run bitcoin-cli: %s, is bitcoind (regtest) running?", err.Error())
164166
}
165167

166168
return string(out)

0 commit comments

Comments
 (0)