Start the node.
(self, extra_args=None, *, cwd=None, stdout=None, stderr=None, env=None, **kwargs)
| 244 | return getattr(self._rpc, name) |
| 245 | |
| 246 | def start(self, extra_args=None, *, cwd=None, stdout=None, stderr=None, env=None, **kwargs): |
| 247 | """Start the node.""" |
| 248 | if extra_args is None: |
| 249 | extra_args = self.extra_args |
| 250 | |
| 251 | # If listening and no -bind is given, then bitcoind would bind P2P ports on |
| 252 | # 0.0.0.0:P and 127.0.0.1:P+1 (for incoming Tor connections), where P is |
| 253 | # a unique port chosen by the test framework and configured as port=P in |
| 254 | # bitcoin.conf. To avoid collisions, change it to 127.0.0.1:tor_port(). |
| 255 | will_listen = all(e != "-nolisten" and e != "-listen=0" for e in extra_args) |
| 256 | has_explicit_bind = self.has_explicit_bind or any(e.startswith("-bind=") for e in extra_args) |
| 257 | if will_listen and not has_explicit_bind: |
| 258 | extra_args.append(f"-bind=0.0.0.0:{p2p_port(self.index)}") |
| 259 | extra_args.append(f"-bind=127.0.0.1:{tor_port(self.index)}=onion") |
| 260 | |
| 261 | self.use_v2transport = "-v2transport=1" in extra_args or (self.default_to_v2 and "-v2transport=0" not in extra_args) |
| 262 | |
| 263 | # Add a new stdout and stderr file each time bitcoind is started |
| 264 | if stderr is None: |
| 265 | stderr = tempfile.NamedTemporaryFile(dir=self.stderr_dir, delete=False) |
| 266 | if stdout is None: |
| 267 | stdout = tempfile.NamedTemporaryFile(dir=self.stdout_dir, delete=False) |
| 268 | self.stderr = stderr |
| 269 | self.stdout = stdout |
| 270 | |
| 271 | if cwd is None: |
| 272 | cwd = self.cwd |
| 273 | |
| 274 | # Delete any existing cookie file -- if such a file exists (eg due to |
| 275 | # unclean shutdown), it will get overwritten anyway by bitcoind, and |
| 276 | # potentially interfere with our attempt to authenticate |
| 277 | delete_cookie_file(self.datadir_path, self.chain) |
| 278 | |
| 279 | # add environment variable LIBC_FATAL_STDERR_=1 so that libc errors are written to stderr and not the terminal |
| 280 | subp_env = dict(os.environ, LIBC_FATAL_STDERR_="1") |
| 281 | if env is not None: |
| 282 | subp_env.update(env) |
| 283 | |
| 284 | self.process = subprocess.Popen(self.args + extra_args, env=subp_env, stdout=stdout, stderr=stderr, cwd=cwd, **kwargs) |
| 285 | |
| 286 | self.running = True |
| 287 | self.log.debug("bitcoind started, waiting for RPC to come up") |
| 288 | |
| 289 | def create_new_rpc_connection(self, *, mode="AUTO", client_timeout=None): |
| 290 | """Create an additional RPC connection, likely to be used in a new thread.""" |
no test coverage detected