@@ -106,8 +106,7 @@ def prompt_password(prompt, confirm=True):
106106 return password
107107
108108
109- def init_cmdline (config_options , server ):
110- config = SimpleConfig (config_options )
109+ def init_cmdline (config_options , wallet_path , server ):
111110 cmdname = config .get ('cmd' )
112111 cmd = known_commands [cmdname ]
113112
@@ -122,7 +121,7 @@ def init_cmdline(config_options, server):
122121 cmd .requires_network = True
123122
124123 # instantiate wallet for command-line
125- storage = WalletStorage (config . get_wallet_path () )
124+ storage = WalletStorage (wallet_path )
126125
127126 if cmd .requires_wallet and not storage .file_exists ():
128127 print_msg ("Error: Wallet file not found." )
@@ -324,9 +323,8 @@ if __name__ == '__main__':
324323 if not uri .startswith ('bitcoin:' ):
325324 print_stderr ('unknown command:' , uri )
326325 sys .exit (1 )
327- config_options ['url' ] = uri
328326
329- # todo: defer this to gui
327+ # singleton
330328 config = SimpleConfig (config_options )
331329
332330 if config .get ('testnet' ):
@@ -392,9 +390,10 @@ if __name__ == '__main__':
392390 else :
393391 # command line
394392 cmd = known_commands [cmdname ]
393+ wallet_path = config .get_wallet_path ()
395394 if not config .get ('offline' ):
396- init_cmdline (config_options , True )
397- timeout = config_options .get ('timeout' , 60 )
395+ init_cmdline (config_options , wallet_path , True )
396+ timeout = config .get ('timeout' , 60 )
398397 if timeout : timeout = int (timeout )
399398 try :
400399 result = daemon .request (config , 'run_cmdline' , (config_options ,), timeout )
@@ -410,7 +409,7 @@ if __name__ == '__main__':
410409 if cmd .requires_network :
411410 print_msg ("This command cannot be run offline" )
412411 sys_exit (1 )
413- init_cmdline (config_options , False )
412+ init_cmdline (config_options , wallet_path , False )
414413 plugins = init_plugins (config , 'cmdline' )
415414 coro = run_offline_command (config , config_options , plugins )
416415 fut = asyncio .run_coroutine_threadsafe (coro , loop )
0 commit comments