Skip to content
This repository was archived by the owner on May 13, 2022. It is now read-only.

Conversation

@Empty2k12
Copy link
Contributor

Until now you had to go go into the folder containing wallet-tool, yg or any other of the tools to use them. This commit solves this (at least for wallet-tool, log creation and everywhere the Wallet class is used).

You can now execute joinmarket from any filepath using a command like this
python ~/Desktop/JoinmarketDev/yield-generator-basic.py wallet.json

I am not sure if I have missed any code where the folder is being assumed.

To figure you the filepath a python function has been used. For all files in the /joinmarket/ subfolder the subfolder name is being stripped using [:-11]. Additionally the method to get the filepath returns a tuple and the actual filepath is accessed using the index.

I am not sure if this is best practice, since my knowledge in Python is still limited. Please suggest missing cases and code improvements!

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.05%) to 82.384% when pulling bdf7f67 on Empty2k12:develop into 72537e2 on JoinMarket-Org:develop.

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

# 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')

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants