-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathautomate.py
More file actions
162 lines (148 loc) · 4.94 KB
/
Copy pathautomate.py
File metadata and controls
162 lines (148 loc) · 4.94 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
import os, random
import asyncio, subprocess
height = "2875721" #@param {type:"string"}
seed = "water lopped sayings hookup slug befit outbreak hence gourmet gambit eggs reruns assorted huge coffee unknown pause evicted zero obvious zesty army jellyfish jockey jellyfish" #@param {type:"string"}
# adjust your cli path
path = "./"
# add .exe if on windows
cmd = path + "monero-wallet-cli"
print(cmd) #debug path
waln = f"mir{random.randint(1, 999999)}" #random wallet name
async def run():
# we are using cake wallet node
pro = await asyncio.create_subprocess_exec(cmd, '--daemon-address', 'xmr-node.cakewallet.com:18081', '--restore-from-seed', '--electrum-seed', seed, '--restore-height', height, '--generate-new-wallet', waln, '--password', '', stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
while 1:
await asyncio.sleep(0.1)
print("if")
o = await pro.stdout.readline()
print("ii")
if "Logging to" in str(o):
break
elif len(str(o)) == 0:
print(o)
break
else:
print(o)
continue
print("out")
pro.stdin.write(b'\n') # press enter (skip seed offset)
await pro.stdin.drain()
print(await pro.stdout.readline())
print(await pro.stdout.readline())
print(await pro.stdout.readline())
while 1: # detect block sync
await asyncio.sleep(0.1)
print("is")
o = await asyncio.wait_for(pro.stdout.readline(), timeout=1.0)
print("ii")
if "Starting refresh..." in str(o):
break
elif len(str(o)) == 0:
print(o)
break
else:
print(o)
pro.stdin.write(b'\n')
await pro.stdin.drain()
continue
while 1: ## wait for refreshing to finish!
await asyncio.sleep(0.1)
print("it")
try:
o = await asyncio.wait_for(pro.stdout.readline(), timeout=1.0)
print("3i")
if len(o) == 0: raise("err")
print(o)
if "Starting refresh..." in str(o): continue
if "\\rRefresh done," in str(o): break
except: # press enter untill refresh is done
await asyncio.sleep(1)
print("tryingENTER")
pro.stdin.write(b'\n')
await pro.stdin.drain()
print("tryingENTERSUC")
print("REFRESHISDONE")
pro.stdin.write(b'exit\n')
await pro.stdin.drain()
print(await pro.stdout.readline())
print(await pro.stdout.readline())
print(await pro.stdout.readline())
while 1:
await asyncio.sleep(0.1)
print("i")
o = await pro.stdout.readline()
print("ii")
if "[wallet" in str(o) or "Background refresh" in str(o):
print(o)
break
elif len(str(o)) == 0:
print(o)
break
else:
print(o)
continue
print("DONEEE!")
try:
pro.stdin.write(b'exit\n')
await pro.stdin.drain()
print(await pro.stdout.readline())
except: pass
await pro.wait() # Wait for the process to complete
if pro.returncode:
print(f"Process exited with return code {pro.returncode}")
# Wallet is created now we run whatever commands
# replace your cmd in the next line
pro2 = await asyncio.create_subprocess_exec(cmd, '--daemon-address', 'xmr-node.cakewallet.com:18081', '--wallet', waln, '--password', '', "--command", "sweep_all", "433CbZXrdTBQzESkZReqQp1TKmj7MfUBXbc8FkG1jpVTBFxY9MCk1RXPWSG6CnCbqW7eiMTEGFgbHXj3rx3PxZadPgFD3DX", stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
while 1:
await asyncio.sleep(0.1)
print("if")
o = await pro2.stdout.readline()
print("ii")
if "operating this daemon" in str(o):
print(o)
break
elif len(str(o)) == 0:
print(o)
break
else:
print(o)
continue
print("out")
pro2.stdin.write(b'\n') #enter empty password
await pro2.stdin.drain()
while 1:
await asyncio.sleep(0.1)
print("iff")
o = await pro2.stdout.readline()
print("ii")
if "Spending from" in str(o):
print(o)
break
elif len(str(o)) == 0:
print(o)
break
else:
print(o)
continue
print("out2")
pro2.stdin.write(b'Y\n') #yes
await pro2.stdin.drain()
while 1:
await asyncio.sleep(0.1)
print("ifff")
o = await pro2.stdout.readline()
print("ii")
if "Is this okay?" in str(o):
print(o)
break
elif len(str(o)) == 0:
print(o)
break
else:
print(o)
continue
print(await pro2.stdout.readline())
print(await pro2.stdout.readline())
print(await pro2.stdout.readline())
#await asyncio.gather(run()) #run in colab
asyncio.run(run())