From f8bb12a4421cd5114d4fdd4d7cba133f316ca118 Mon Sep 17 00:00:00 2001 From: Adam Gibson Date: Thu, 16 Sep 2021 14:44:54 +0100 Subject: [PATCH] fix wallet list load for current datadir --- scripts/jmwalletd.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/scripts/jmwalletd.py b/scripts/jmwalletd.py index 289a1be9d..8683e0540 100644 --- a/scripts/jmwalletd.py +++ b/scripts/jmwalletd.py @@ -26,7 +26,6 @@ SNICKERReceiverService, SNICKERReceiver, create_wallet, \ StorageError, StoragePasswordError, get_max_cj_fee_values from jmbase.support import get_log, set_logging_level, jmprint,EXIT_ARGERROR, EXIT_FAILURE,DUST_THRESHOLD -import glob import jwt @@ -473,17 +472,14 @@ def unlockwallet(self, request, walletname): #This route should return list of current wallets created. @app.route('/wallet/all', methods=['GET']) def listwallets(self, request): - #this is according to the assumption that wallets are there in /.joinmarket by default, also currently path for linux system only. - #first user taken for path - user_path = glob.glob('/home/*/')[0] - - wallet_dir = f"{user_path}.joinmarket/wallets/*.jmdat" - wallets = (glob.glob(wallet_dir)) - - offset = len(user_path)+len('.joinmarket/wallets/') - #to get only names - short_wallets = [wallet[offset:] for wallet in wallets] - return response(request,wallets=short_wallets) + wallet_dir = os.path.join(jm_single().datadir, 'wallets') + # TODO: we allow any file name; .jmdat is only + # a convention; but this means we should validate these + # wallet files before returning them (though JM itself + # never puts any other kind of file in this directory, + # the user conceivably might). + wallets = os.listdir(wallet_dir) + return response(request, wallets=wallets) #route to get external address for deposit @app.route('/address/new/',methods=['GET'])