-
Notifications
You must be signed in to change notification settings - Fork 0
/
createWallet.py
49 lines (39 loc) · 1.79 KB
/
createWallet.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Copyright (c) 2020 Vishnu J. Seesahai
# Use of this source code is governed by an MIT
# license that can be found in the LICENSE file.
import subprocess, os, sys, json
import time
#from resource import resource_path
def resource_path(relative_path):
#dir = QDir.currentPath()
if hasattr(sys, '_MEIPASS'):
return os.path.join(sys._MEIPASS, relative_path)
return os.path.join(os.path.abspath('.'), relative_path)
def seed_execute(uname, pwd, pp, old_pass_line, seed_entry):
try:
cmd_result, err = subprocess.Popen(resource_path("bin/wallet -u "+uname+" -P "+pwd+" --create"), shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate(("{\"passphrase\":\""+pp+"\",\"seed\":\""+ seed_entry +"\",\"seedpassphrase\":\""+old_pass_line+"\"}").encode('utf-8'))
err = err.decode('utf-8')
print('cmd_result', cmd_result)
if err and not "pktwallet.conf does not exist" in err:
print('Error:', err)
cmd_result = {}
else:
cmd_result = json.loads(cmd_result.decode('utf-8'))
return cmd_result
except:
print("Could not create wallet")
return {}
def execute(uname, pwd, pp):
try:
cmd_result, err = subprocess.Popen(resource_path("bin/wallet -u "+uname+" -P "+pwd+" --create"), shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate(("{\"passphrase\":\""+pp+"\"}").encode('utf-8'))
err = err.decode('utf-8')
print(cmd_result, err)
if err and not cmd_result:
print('Error:', err)
cmd_result = {}
else:
cmd_result = json.loads(cmd_result.decode('utf-8'))
return cmd_result
except:
print("Could not create wallet")
return {}