Skip to content

Commit

Permalink
Expose internal node to localhost only (#2455)
Browse files Browse the repository at this point in the history
* Remove unused import

* Comparison to None, True should be 'if cond is None:'

* Expose internal node to localhost only
  • Loading branch information
roshii authored Jun 4, 2024
1 parent e0eccac commit db3df46
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,14 @@ def construct_node_cmd(
btcd_cmd += " -validatepegin=0 "
btcd_cmd += " -txindex=1 "
btcd_cmd += " -initialfreecoins=2100000000000000 "
btcd_cmd += " -port={} -rpcport={} -rpcbind=0.0.0.0".format(
rpcconn.rpcport + 1, rpcconn.rpcport
)
btcd_cmd += " -port={} -rpcport={}".format(rpcconn.rpcport + 1, rpcconn.rpcport)
btcd_cmd += " -rpcuser={} -rpcpassword={} ".format(
rpcconn.rpcuser, rpcconn.rpcpassword
)
btcd_cmd += " -rpcallowip=0.0.0.0/0 -rpcallowip=172.17.0.0/16 "
if not run_docker:
if not log_stdout:
btcd_cmd += " -noprinttoconsole"
if datadir == None:
if datadir is None:
datadir = tempfile.mkdtemp(prefix="bitcoind_datadir")
btcd_cmd += ' -datadir="{}" '.format(datadir)
print(f"extra_args={extra_args})")
Expand Down
19 changes: 8 additions & 11 deletions src/cryptoadvance/specter/process_controller/node_controller.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
""" Stuff to control a bitcoind-instance.
"""

import atexit
import json
import logging
import os
import platform
import re
import shutil
import signal
import subprocess
Expand Down Expand Up @@ -48,7 +48,7 @@ def __init__(

@property
def ipaddress(self):
if self._ipaddress == None:
if self._ipaddress is None:
raise Exception("ipadress is none")
else:
return self._ipaddress
Expand All @@ -73,7 +73,7 @@ def get_rpc(self):
return rpc

def render_url(self, password_mask=False):
if password_mask == True:
if password_mask is True:
password = "xxxxxx"
else:
password = self.rpcpassword
Expand Down Expand Up @@ -226,7 +226,7 @@ def stop_node(self):

def mine(self, address=None, block_count=1):
"""Does mining to the attached address with as many as block_count blocks"""
if address == None:
if address is None:
if self.node_impl == "bitcoin":
address = "mruae2834buqxk77oaVpephnA5ZAxNNJ1r"
else:
Expand Down Expand Up @@ -358,17 +358,14 @@ def construct_node_cmd(
if network != "mainnet" and network != "main":
btcd_cmd += " -{} ".format(network)
btcd_cmd += " -fallbackfee=0.0002 "
btcd_cmd += " -port={} -rpcport={} -rpcbind=0.0.0.0 -rpcbind=0.0.0.0".format(
rpcconn.rpcport - 1, rpcconn.rpcport
)
btcd_cmd += " -port={} -rpcport={}".format(rpcconn.rpcport - 1, rpcconn.rpcport)
btcd_cmd += " -rpcuser={} -rpcpassword={} ".format(
rpcconn.rpcuser, rpcconn.rpcpassword
)
btcd_cmd += " -rpcallowip=0.0.0.0/0 -rpcallowip=172.17.0.0/16 "
if not run_docker:
if not log_stdout:
btcd_cmd += " -noprinttoconsole"
if datadir == None:
if datadir is None:
datadir = tempfile.mkdtemp(prefix="bitcoind_datadir")
btcd_cmd += ' -datadir="{}" '.format(datadir)
if extra_args:
Expand Down Expand Up @@ -412,7 +409,7 @@ def _start_node(
log_stdout=False,
extra_args=[],
):
if datadir == None:
if datadir is None:
datadir = tempfile.mkdtemp(
prefix=f"specter_{self.node_impl}_regtest_plain_datadir_"
)
Expand Down Expand Up @@ -484,7 +481,7 @@ def cleanup_node(self, cleanup_hard=None, datadir=None):
if not hasattr(self, "datadir"):
self.datadir = None

if cleanup_hard == None:
if cleanup_hard is None:
cleanup_hard = self.cleanup_hard
if not hasattr(self, "node_proc"):
logger.info("node process was not running")
Expand Down

0 comments on commit db3df46

Please sign in to comment.