-
Notifications
You must be signed in to change notification settings - Fork 1
/
Monero_Business_Wallet.py
616 lines (479 loc) · 24.7 KB
/
Monero_Business_Wallet.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
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
import os
import csv
import time
import json
import gzip
import psutil
import base64
import qrcode
import random
import requests
import threading
import subprocess
from lxml import html
import monero_usd_price
import PySimpleGUI as sg
from datetime import datetime, timezone
import platform
import clipboard
import swap_functions as swap
import wallet_functions as wallet
import gui_functions as gui
import config as cfg
# OPEN STUFF FUNCTIONS #################################################################################################
def start_local_rpc_server_thread():
if platform.system() == 'Windows':
cmd = f'monero-wallet-rpc --wallet-file {cfg.wallet_name} --password "" --rpc-bind-port {cfg.rpc_bind_port} --disable-rpc-login --confirm-external-bind --daemon-host {host} --daemon-port {port}'
else:
cmd = f'{os.getcwd()}/monero-wallet-rpc --wallet-file {cfg.wallet_name} --password "" --rpc-bind-port {cfg.rpc_bind_port} --disable-rpc-login --confirm-external-bind --daemon-host {host} --daemon-port {port}'
if start_block_height:
command = f'{cfg.monero_wallet_cli_path} --wallet-file {os.path.join(cfg.wallet_file_path, cfg.wallet_name)} --password "" --restore-height {start_block_height} --command exit'
proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
blocks_synced = False
while not blocks_synced:
output = proc.stdout.readline().decode("utf-8").strip()
print(f'SYNCING BLOCKS:{output}')
if "Opened wallet:" in output:
blocks_synced = True
break
if proc.poll() is not None:
break
process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
while True:
output = process.stdout.readline().decode("utf-8").strip()
print(f'RPC STARTING:{output}')
if "Starting wallet RPC server" in output:
cfg.rpc_is_ready = True
break
if process.poll() is not None:
break
# CLOSE STUFF FUNCTIONS ################################################################################################
def kill_everything():
print('\n\n Please close this terminal window and relaunch the Monero Business Wallet')
cfg.stop_flag.set() # Stop threads gracefully
# Kill the program
current_process = psutil.Process(os.getpid()) # Get the current process ID
current_process.terminate() # Terminate the current process and its subprocesses
def kill_monero_wallet_rpc():
# Check which platform we are on and get the process list accordingly
if platform.system() == 'Windows':
process = subprocess.Popen("tasklist", stdout=subprocess.PIPE)
rpc_path = 'monero-wallet-rpc.exe'
else:
process = subprocess.Popen("ps", stdout=subprocess.PIPE)
rpc_path = 'monero-wallet-r'
out, err = process.communicate()
for line in out.splitlines():
if rpc_path.encode() in line:
if platform.system() == 'Windows': # Check if we are on Windows and get the PID accordingly
pid = int(line.split()[1].decode("utf-8"))
else:
pid = int(line.split()[0].decode("utf-8"))
os.kill(pid, 9)
print(f"Successfully killed monero-wallet-rpc with PID {pid}")
cfg.rpc_is_ready = False
break
else:
print("monero-wallet-rpc process not found")
# OTHER RANDOM FUNCTIONS ###############################################################################################
def random_partial_amount(xmr_balance):
random_value = float(random.randint(100, 1000))
partial_amount = xmr_balance / random_value
print(f'Sending random amount {str(partial_amount)} XRM')
return partial_amount
def convert_or_forward(xmr_wallet_balance_to_forward):
if cfg.random_delay: # If Using Random Delay
random_delay = random.randint(1, (60 * 60 * 24 * cfg.delay_days)) # Sleep for 1 second to 1 month.
time.sleep(random_delay)
print(f'Waiting {(((random_delay/60)/60)/24)} Days Before Transfer')
if cfg.convert: # If Converting
if cfg.random_amounts: # If Using Random Amount
xmr_wallet_balance_to_forward = random_partial_amount(xmr_balance=xmr_wallet_balance_to_forward)
swap_info = swap.with_sideshift(shift_to_coin=cfg.convert_coin, to_wallet=cfg.convert_wallet, on_network=cfg.convert_network, amount_to_convert=xmr_wallet_balance_to_forward)
if swap_info:
print(swap_info)
write_swap_to_csv(swap_info=swap_info) # Maybe also add a thing to include the IP we used.
# Optionally add a "check for success" but not sure if there is really much of a point.
else:
print('There was a problem, so we did not swap anything.')
elif cfg.forward: # If Forwarding
if cfg.random_amounts: # If Using Random Amount
xmr_wallet_balance_to_forward = random_partial_amount(xmr_balance=xmr_wallet_balance_to_forward)
# Transfer what we have
wallet.send_monero(destination_address=cfg.cold_wallet, amount=xmr_wallet_balance_to_forward)
def get_random_monero_node():
response = requests.get('https://monero.fail/')
tree = html.fromstring(response.content)
urls = tree.xpath('//span[@class="nodeURL"]/text()')
random.shuffle(urls) # mix them up so we get a random one instead of top to bottom.
for url in urls:
if '://' in url:
url = url.split('://')[1]
if ':' in url: # make sure that it has the port
print(url)
if wallet.check_if_node_works(url):
print(f'WORKS: {url}')
return url
def make_payment_id(): # ADD TO MoneroSub pip package at some point
payment_id = ''.join([random.choice('0123456789abcdef') for _ in range(16)])
return payment_id
def check_if_amount_is_proper_format(amount):
if type(amount) == int:
return True
elif type(amount) == float:
if round(amount, 12) == amount:
return True
else:
return False
else:
return False
# WRITE FILE FUNCTIONS #################################################################################################
def write_swap_to_csv(swap_info, filename=cfg.swap_file):
# Check if file exists
file_exists = os.path.isfile(filename)
# If file doesn't exist, write headers first
if not file_exists:
with open(filename, 'w', newline='', encoding='utf-8') as file:
writer = csv.writer(file)
# Add 'timestamp' to the beginning of the headers
headers = ['timestamp'] + list(swap_info.keys())
writer.writerow(headers)
# Write (or append) the data
with open(filename, 'a', newline='', encoding='utf-8') as file:
writer = csv.writer(file)
# Get current timestamp in RFC3339 format
current_timestamp = datetime.now(timezone.utc).isoformat()
# Add timestamp to the beginning of the data
data = [current_timestamp] + list(swap_info.values())
writer.writerow(data)
def write_settings_to_file(settings):
with open('settings.txt', 'w') as f:
json.dump(settings, f)
print('Wrote settings.')
def write_transactions_to_csv(transactions, filename=cfg.received_transactions_file):
# List to store existing transactions
existing_txids = []
# Column names as variables (so they can be changed in one place)
transaction_id_name = 'Transaction ID'
usd_amount_name = 'USD Amount'
xmr_amount_name = 'XMR Amount'
atomic_units_amount_name = 'Atomic Units Amount'
timestamp_name = 'Timestamp'
wallet_address_name = 'Wallet Address'
# Columns to exclude
exclude_columns = ["amounts", "double_spend_seen", "fee", "locked", "subaddr_index", "subaddr_indices", "suggested_confirmations_threshold", "unlock_time"]
# Columns to rename
rename_columns = {
"amount": atomic_units_amount_name,
"confirmations": "Confirmations When Recorded",
"height": "Block Height",
"timestamp": timestamp_name,
"type": "Payment Direction",
"payment_id": "Payment ID",
"note": "Note",
"txid": transaction_id_name,
"address": wallet_address_name,
}
# Order of columns
desired_order = [timestamp_name, usd_amount_name, xmr_amount_name, atomic_units_amount_name, "Payment ID", "Note", "Transaction ID", "Confirmations When Recorded", wallet_address_name]
# If the file exists, read it to get the existing txids
if os.path.exists(filename):
with open(filename, mode='r', newline='', encoding='utf-8') as file:
reader = csv.DictReader(file)
for row in reader:
existing_txids.append(row[transaction_id_name])
# Filter transactions based on whether their transaction ID is already recorded
new_transactions = [tx for tx in transactions if tx["txid"] not in existing_txids]
# Remove unwanted columns and rename columns as necessary
for tx in new_transactions:
for col in exclude_columns:
if col in tx:
del tx[col]
for old_name, new_name in rename_columns.items():
if old_name in tx:
tx[new_name] = tx.pop(old_name)
# Do Currency Conversions
tx[xmr_amount_name] = monero_usd_price.calculate_monero_from_atomic_units(atomic_units=tx[atomic_units_amount_name])
tx[usd_amount_name] = monero_usd_price.calculate_usd_from_atomic_units(atomic_units=tx[atomic_units_amount_name], print_price_to_console=False, monero_price=cfg.current_monero_price,)
# Convert from a POSIX timestamp to a human-readable format
tx[timestamp_name] = datetime.fromtimestamp(tx[timestamp_name]).strftime('%Y-%m-%d %H:%M:%S')
# Sort new_transactions based on timestamp
new_transactions.sort(key=lambda x: datetime.strptime(x[timestamp_name], '%Y-%m-%d %H:%M:%S'))
# Write the new transactions to the CSV
with open(filename, mode='a', newline='', encoding='utf-8') as file:
writer = csv.DictWriter(file, fieldnames=desired_order)
# If the CSV was empty, write the headers
if file.tell() == 0:
writer.writeheader()
for tx in new_transactions:
# Use the desired order to write rows
ordered_tx = {col: tx[col] for col in desired_order}
writer.writerow(ordered_tx)
print(f'Wrote to {filename}')
# LOOPING THREADS ######################################################################################################
def check_for_new_transactions():
while not cfg.stop_flag.is_set():
try:
cfg.current_monero_price = monero_usd_price.median_price(print_price_to_console=False)
print(f'Got current Monero price: {str(cfg.current_monero_price)}')
# Get All Transactions
transactions = wallet.get_all_transactions()
# Filter to incoming/outgoing
incoming_filtered_tx = wallet.filter_transactions(transfers=transactions, direction='in')
outgoing_filtered_tx = wallet.filter_transactions(transfers=transactions, direction='out')
# Write new ones to csv
write_transactions_to_csv(transactions=incoming_filtered_tx, filename=cfg.received_transactions_file)
write_transactions_to_csv(transactions=outgoing_filtered_tx, filename=cfg.sent_transactions_file)
print('Wrote new transactions to csv files.')
# Wait 2 minutes (Monero has a 2-minute block time).
time.sleep(120)
except Exception as e:
print(f'Exception in thread "check_for_new_transactions: {e}"')
def autoforward_monero():
while not cfg.stop_flag.is_set():
try:
# See if our balance is over usd_amount_to_leave_in_wallet_for_tx_fees
xmr_wallet_balance_to_forward = wallet.get_wallet_balance_in_xmr_minus_amount(amount_in_usd=cfg.usd_amount_to_leave_in_wallet_for_tx_fees)
if xmr_wallet_balance_to_forward > 0:
# DO "wait until over $X"
#print(f'THIS IS WHAT WAIT FOR BALANCE IS: {str(cfg.wait_for_balance)}')
if cfg.wait_for_balance:
# Make sure we have over $X
if wallet.get_wallet_balance_in_xmr_minus_amount(amount_in_usd=(cfg.wait_for_min_usd + cfg.usd_amount_to_leave_in_wallet_for_tx_fees)): # Evaluates to False if we don't have enough
# Are we converting, or forwarding?
convert_or_forward(xmr_wallet_balance_to_forward=xmr_wallet_balance_to_forward)
else:
print('Balance not yet above forwarding limit.')
# DO NOT "wait until over $100"
else:
# Are we converting, or forwarding?
convert_or_forward(xmr_wallet_balance_to_forward=xmr_wallet_balance_to_forward)
# Not enough to bother transferring
else:
print('No balance worth forwarding.')
# Wait 2 minutes (Monero has a 2-minute block time).
time.sleep(120)
except Exception as e:
print(f'Exception in thread "check_for_new_transactions: {e}"')
# GUI FUNCTIONS (NOT LAYOUT) ########################################################################################################
def refresh_gui():
global window
window.close()
window = gui.create_main_window() # recreate the window to refresh the GUI
gui.bind_checkboxes(window=window)
def make_transparent():
# Make the main window transparent
window.TKroot.attributes('-alpha', 0.00)
def make_visible():
# Make the main window transparent
window.TKroot.attributes('-alpha', 1.00)
def update_gui_balance():
while not cfg.stop_flag.is_set():
try:
# Get the wallet balance info
cfg.wallet_balance_xmr, cfg.wallet_balance_usd, cfg.xmr_unlocked_balance = wallet.get_wallet_balance()
#print(cfg.wallet_balance_usd)
# Update the GUI with the new balance info
if not cfg.wallet_balance_usd == '---.--':
window['wallet_balance_in_usd'].update(f' Balance: ${cfg.wallet_balance_usd} USD')
window['wallet_balance_in_xmr'].update(f' XMR: {cfg.wallet_balance_xmr:.12f}')
# Wait before updating again
time.sleep(5)
except Exception as e:
print(f'Exception in thread "update_gui_balance: {e}"')
# SET THEME ############################################################################################################
# Start with template
sg.theme('DarkGrey2')
# Modify the colors you want to change
sg.theme_background_color(cfg.ui_overall_background) # MAIN BACKGROUND COLOR
sg.theme_button_color((cfg.ui_button_a_font, cfg.ui_button_a)) # whiteish, blackish
sg.theme_text_color(cfg.monero_orange) # HEADING TEXT AND DIVIDERS
sg.theme_text_element_background_color(cfg.ui_title_bar) # Text Heading Boxes
sg.theme_element_background_color(cfg.ui_title_bar) # subscriptions & transactions box color
sg.theme_element_text_color(cfg.ui_sub_font) # My Subscriptions Text Color
sg.theme_input_background_color(cfg.ui_title_bar)
sg.theme_input_text_color(cfg.monero_orange)
sg.theme_border_width(0)
sg.theme_slider_border_width(0)
# START PROGRAM ########################################################################################################
# BEGIN "Add Daemon/Node" SECTION
if os.path.exists(cfg.node_filename):
with open(cfg.node_filename, 'r') as f:
node = f.readline().strip() # read first line into 'node'
else:
# welcome popup
sg.popup(cfg.welcome_popup_text, icon=cfg.icon, no_titlebar=True, background_color=cfg.ui_overall_background, grab_anywhere=True)
# Define the window's layout
layout = gui.make_node_window_layout()
# Create the window
window = sg.Window('Node Input', layout, keep_on_top=True, no_titlebar=True, grab_anywhere=True)
# Event loop
while True:
event, values = window.read()
if event == 'add_node':
node = values['custom_node']
if '://' in node:
node = node.split('://')[1]
print(node)
if wallet.check_if_node_works(node):
window['custom_node'].update(value="Success!")
# Save the node to the file
with open(cfg.node_filename, 'w') as f:
f.write(node + '\n')
break
else:
window['custom_node'].update(value="Node did not respond. Try Another.")
elif event == 'add_random_node':
print('Adding a random node. Please wait. \nThe software will seem to be frozen until a node is found.')
node = get_random_monero_node()
# Save the node to the file
with open(cfg.node_filename, 'w') as f:
f.write(node + '\n')
break
if event == sg.WIN_CLOSED:
break
window.close()
host = node.split(':')[0]
port = node.split(':')[1]
daemon_rpc_url = f"http://{host}:{port}/json_rpc"
# END "Add Daemon/Node" SECTION
# BEGIN "Convert/Forward" SECTION
# Note: cold_storage takes priority over convert. If both are specified, it should forward to cold storage only.
if os.path.exists(cfg.cold_wallet_filename):
with open(cfg.cold_wallet_filename, 'r') as f:
cfg.cold_wallet = f.readline().strip()
if wallet.check_if_monero_wallet_address_is_valid_format(cfg.cold_wallet):
cfg.forward = True
elif os.path.exists(cfg.convert_wallet_filename):
with open(cfg.convert_wallet_filename, 'r') as f:
data = f.read().strip()
data = json.loads(data)
cfg.convert_wallet = data['wallet']
cfg.convert_coin = data['coin']
cfg.convert_network = data['network']
if cfg.convert_wallet and cfg.convert_coin and cfg.convert_network:
cfg.convert = True
print(cfg.convert_wallet, cfg.convert_coin, cfg.convert_network)
# If we haven't configured either, have the user configure one
if not cfg.forward and not cfg.convert:
gui.prompt_for_convert_forward_selection()
# If both are configured, make sure "Forward" takes priority.
if cfg.forward and cfg.convert:
cfg.convert = False
# END "Convert/Forward" SECTION
# START PREREQUISITES ##################################################################################################
start_block_height = wallet.check_if_wallet_exists(daemon_rpc_url=daemon_rpc_url) # auto-create one if it doesn't exist
# Start Local RPC Server
kill_monero_wallet_rpc() # May be running from a previous launch
threading.Thread(target=start_local_rpc_server_thread).start()
# Make "Please Wait" Popup
window = sg.Window("Waiting", layout=gui.make_please_wait_popup(), finalize=True, keep_on_top=True, no_titlebar=True, grab_anywhere=True)
# Wait until the RPC server starts
while not cfg.rpc_is_ready:
# Check for window events
event, values = window.read(timeout=100) # Read with a timeout so the window is updated
print('\n\nRPC Server has started')
cfg.wallet_address = wallet.get_wallet_address() # Now that the RPC Server is running, get the wallet address
try: # Now that the RPC Server is running, get the wallet balance
cfg.wallet_balance_xmr, cfg.wallet_balance_usd, cfg.xmr_unlocked_balance = wallet.get_wallet_balance()
except:
pass
# GET SETTINGS #########################################################################################################
# Check if settings.txt exists and read it
if os.path.exists('settings.txt'):
print('FOUND THE SETTINGS FILE')
with open(file='settings.txt', mode='r', encoding='utf-8') as f:
settings = json.load(f)
print(settings)
print(type(settings))
# Update our config file with these settings
cfg.random_amounts = settings["random_amounts"]
cfg.random_delay = settings["random_delay"]
cfg.delay_days = settings["delay_days"]
cfg.wait_for_balance = settings["wait_for_balance"]
print(cfg.wait_for_balance)
else:
print('NO SETTING FILE!')
settings = {
"random_amounts": cfg.random_amounts,
"random_delay": cfg.random_delay,
"wait_for_balance": cfg.wait_for_balance,
"delay_days": cfg.delay_days
}
# CREATE THE MAIN WINDOW ###############################################################################################
window.close() # Close "Please Wait" Popup
window = gui.create_main_window()
gui.bind_checkboxes(window=window)
# START THREADS ########################################################################################################
# Continually update displayed GUI balance every 5 seconds
threading.Thread(target=update_gui_balance).start()
# Continually update the payments received/sent csv files every 2 min (every block)
threading.Thread(target=check_for_new_transactions).start()
# Continually auto-forward Monero if conditions are met every 2 min (every block)
threading.Thread(target=autoforward_monero).start()
# MAIN EVENT LOOP ######################################################################################################
while True:
event, values = window.read()
print(f"Event: {event}, Values: {values}")
# CLOSE BUTTON PRESSED
if event == sg.WIN_CLOSED:
break
# COPY ADDRESS BUTTON PRESSED
elif event == 'copy_address':
clipboard.copy(cfg.wallet_address)
print(f'COPIED: {cfg.wallet_address}')
# RANDOM AMOUNTS CHECKBOX
elif event == 'random_amounts':
cfg.random_amounts = window['random_amounts'].get()
print(f'Changed to: {cfg.random_amounts}')
settings["random_amounts"] = cfg.random_amounts
write_settings_to_file(settings=settings)
# RANDOM DELAY CHECKBOX
elif event == 'random_delay':
cfg.random_delay = window['random_delay'].get()
print(f'Changed to: {cfg.random_delay}')
settings["random_delay"] = cfg.random_delay
write_settings_to_file(settings=settings)
# DELAY DAYS NUMBER
elif event == 'delay_days':
cfg.delay_days = window['delay_days'].get()
print(f'Changed to: {cfg.delay_days}')
settings["delay_days"] = cfg.delay_days
write_settings_to_file(settings=settings)
# WAIT FOR BALANCE CHECKBOX
elif event == 'wait_for_balance':
cfg.wait_for_balance = window['wait_for_balance'].get()
print(f'Changed to: {cfg.wait_for_balance}')
settings["wait_for_balance"] = cfg.wait_for_balance
write_settings_to_file(settings=settings)
# MIN USD NUMBER
elif event == 'wait_for_min_usd':
cfg.wait_for_min_usd = window['wait_for_min_usd'].get()
print(f'Changed to: {cfg.wait_for_min_usd}')
settings["wait_for_min_usd"] = cfg.wait_for_min_usd
write_settings_to_file(settings=settings)
# SEND BUTTON PRESSED
elif event == 'send':
try:
withdraw_to_wallet = values['withdraw_to_wallet']
if values['withdraw_amount'] == '':
withdraw_amount = None
else:
withdraw_amount = float(values['withdraw_amount'])
print(withdraw_to_wallet)
print(withdraw_amount)
if withdraw_amount == None:
choice = sg.popup(f"Are you sure you want to send all your XMR to this address?\n", text_color=cfg.ui_sub_font, title='', custom_text=(" Yes, I am sure! ", " No, CANCEL! "), no_titlebar=True, background_color=cfg.ui_title_bar, modal=True, grab_anywhere=True, icon=cfg.icon)
if "No, CANCEL!" in choice:
print("Cancelled wallet sweep!")
pass
elif "Yes, I am sure!" in choice:
wallet.send_monero(destination_address=withdraw_to_wallet, amount=cfg.xmr_unlocked_balance)
print("The wallet has been swept!")
else:
wallet.send_monero(destination_address=withdraw_to_wallet, amount=withdraw_amount)
except Exception as e:
print(e)
print('failed to send')
window['withdraw_to_wallet'].update('Error: Enter a valid wallet address and XMR amount.')
window.close()