Skip to content

Commit db3df46

Browse files
authored
Expose internal node to localhost only (#2455)
* Remove unused import * Comparison to None, True should be 'if cond is None:' * Expose internal node to localhost only
1 parent e0eccac commit db3df46

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

src/cryptoadvance/specter/process_controller/elementsd_controller.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,14 @@ def construct_node_cmd(
7070
btcd_cmd += " -validatepegin=0 "
7171
btcd_cmd += " -txindex=1 "
7272
btcd_cmd += " -initialfreecoins=2100000000000000 "
73-
btcd_cmd += " -port={} -rpcport={} -rpcbind=0.0.0.0".format(
74-
rpcconn.rpcport + 1, rpcconn.rpcport
75-
)
73+
btcd_cmd += " -port={} -rpcport={}".format(rpcconn.rpcport + 1, rpcconn.rpcport)
7674
btcd_cmd += " -rpcuser={} -rpcpassword={} ".format(
7775
rpcconn.rpcuser, rpcconn.rpcpassword
7876
)
79-
btcd_cmd += " -rpcallowip=0.0.0.0/0 -rpcallowip=172.17.0.0/16 "
8077
if not run_docker:
8178
if not log_stdout:
8279
btcd_cmd += " -noprinttoconsole"
83-
if datadir == None:
80+
if datadir is None:
8481
datadir = tempfile.mkdtemp(prefix="bitcoind_datadir")
8582
btcd_cmd += ' -datadir="{}" '.format(datadir)
8683
print(f"extra_args={extra_args})")

src/cryptoadvance/specter/process_controller/node_controller.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
""" Stuff to control a bitcoind-instance.
22
"""
3+
34
import atexit
45
import json
56
import logging
67
import os
78
import platform
8-
import re
99
import shutil
1010
import signal
1111
import subprocess
@@ -48,7 +48,7 @@ def __init__(
4848

4949
@property
5050
def ipaddress(self):
51-
if self._ipaddress == None:
51+
if self._ipaddress is None:
5252
raise Exception("ipadress is none")
5353
else:
5454
return self._ipaddress
@@ -73,7 +73,7 @@ def get_rpc(self):
7373
return rpc
7474

7575
def render_url(self, password_mask=False):
76-
if password_mask == True:
76+
if password_mask is True:
7777
password = "xxxxxx"
7878
else:
7979
password = self.rpcpassword
@@ -226,7 +226,7 @@ def stop_node(self):
226226

227227
def mine(self, address=None, block_count=1):
228228
"""Does mining to the attached address with as many as block_count blocks"""
229-
if address == None:
229+
if address is None:
230230
if self.node_impl == "bitcoin":
231231
address = "mruae2834buqxk77oaVpephnA5ZAxNNJ1r"
232232
else:
@@ -358,17 +358,14 @@ def construct_node_cmd(
358358
if network != "mainnet" and network != "main":
359359
btcd_cmd += " -{} ".format(network)
360360
btcd_cmd += " -fallbackfee=0.0002 "
361-
btcd_cmd += " -port={} -rpcport={} -rpcbind=0.0.0.0 -rpcbind=0.0.0.0".format(
362-
rpcconn.rpcport - 1, rpcconn.rpcport
363-
)
361+
btcd_cmd += " -port={} -rpcport={}".format(rpcconn.rpcport - 1, rpcconn.rpcport)
364362
btcd_cmd += " -rpcuser={} -rpcpassword={} ".format(
365363
rpcconn.rpcuser, rpcconn.rpcpassword
366364
)
367-
btcd_cmd += " -rpcallowip=0.0.0.0/0 -rpcallowip=172.17.0.0/16 "
368365
if not run_docker:
369366
if not log_stdout:
370367
btcd_cmd += " -noprinttoconsole"
371-
if datadir == None:
368+
if datadir is None:
372369
datadir = tempfile.mkdtemp(prefix="bitcoind_datadir")
373370
btcd_cmd += ' -datadir="{}" '.format(datadir)
374371
if extra_args:
@@ -412,7 +409,7 @@ def _start_node(
412409
log_stdout=False,
413410
extra_args=[],
414411
):
415-
if datadir == None:
412+
if datadir is None:
416413
datadir = tempfile.mkdtemp(
417414
prefix=f"specter_{self.node_impl}_regtest_plain_datadir_"
418415
)
@@ -484,7 +481,7 @@ def cleanup_node(self, cleanup_hard=None, datadir=None):
484481
if not hasattr(self, "datadir"):
485482
self.datadir = None
486483

487-
if cleanup_hard == None:
484+
if cleanup_hard is None:
488485
cleanup_hard = self.cleanup_hard
489486
if not hasattr(self, "node_proc"):
490487
logger.info("node process was not running")

0 commit comments

Comments
 (0)