Skip to content
This repository was archived by the owner on May 13, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion joinmarket/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def __setattr__(self, name, value):
logFormatter = logging.Formatter(
('%(asctime)s [%(threadName)-12.12s] '
'[%(levelname)-5.5s] %(message)s'))
fileHandler = logging.FileHandler('logs/{}.log'.format(value))
dirname = os.path.split(os.path.abspath(__file__))
fileHandler = logging.FileHandler(os.path.join(dirname[0][:-11], 'logs/{}.log'.format(value)))
fileHandler.setFormatter(logFormatter)
log.addHandler(fileHandler)

Expand Down
3 changes: 2 additions & 1 deletion joinmarket/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,10 @@ def __init__(self,
self.index.append([0, 0])

def read_wallet_file_data(self, filename, pwd=None):
dirname = os.path.split(os.path.abspath(__file__))
self.path = None
self.index_cache = [[0, 0]] * self.max_mix_depth
path = os.path.join('wallets', filename)
path = os.path.join(dirname[0][:-11], 'wallets', filename)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using -11 and split here is fragile. Probably better to do something like:

dirname = os.path.dirname(os.path.abspath(__file__))
wallet_path = os.path.join(dirname, '..', 'wallets', filename)

Although I think moving wallet and log dir to configuration variables would probably be better still

if not os.path.isfile(path):
if get_network() == 'testnet':
log.debug('filename interpreted as seed, only available in '
Expand Down
6 changes: 4 additions & 2 deletions wallet-tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,14 +270,16 @@ def cus_print(s):
elif method == 'listwallets':
# Fetch list of wallets
possible_wallets = []
for (dirpath, dirnames, filenames) in os.walk('wallets'):
dirname = os.path.split(os.path.abspath(__file__))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar to above, use join instead of split:

dirname = os.path.dirname(os.path.abspath(__file__))
wallet_dir = os.path.join(dirname, 'wallets')

for (dirpath, dirnames, filenames) in os.walk(os.path.join(dirname[0], 'wallets')):
possible_wallets.extend(filenames)
# Breaking as we only want the top dir, not subdirs
break
# For each possible wallet file, read json to list
walletjsons = []
for possible_wallet in possible_wallets:
fd = open(os.path.join('wallets', possible_wallet), 'r')
dirname = os.path.split(os.path.abspath(__file__))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

fd = open(os.path.join(dirname[0], 'wallets', possible_wallet), 'r')
try:
walletfile = fd.read()
walletjson = json.loads(walletfile)
Expand Down