-
Notifications
You must be signed in to change notification settings - Fork 3
/
IMAGE_INSCRIBOOR_V1
84 lines (69 loc) · 3.09 KB
/
IMAGE_INSCRIBOOR_V1
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
import subprocess
import time
import json
import re
import os
def run_node_commands(start, end, directory, file_extension):
for i in range(start, end + 1):
# Construct the file name
file_number = str(i)
image_path = os.path.join(directory, f"{file_number}.{file_extension}")
# Check if file exists
if not os.path.isfile(image_path):
print(f"File not found: {image_path}")
continue
# Extract base file name without serial number
base_file_name = os.path.basename(image_path).split('.')[0]
# Construct and run the first command
mint_command = f"node . mint DU4Tz7fp9TLyhRfncJJ94K45XizP9vycUE {image_path}"
result_mint = subprocess.run(mint_command, shell=True, capture_output=True, text=True)
print("Output from mint command:")
print(result_mint.stdout)
# Check if there is an error in the first command
if result_mint.stderr:
print("Error in mint command:")
print(result_mint.stderr)
# Check for specific error message in the first command's output
if "'64: too-long-mempool-chain'" in result_mint.stdout:
print("Detected specific error message, proceeding to wallet sync...")
# Wait for 180 seconds after mint command
time.sleep(180)
# Loop for the second command
while True:
wallet_sync_command = "node . wallet sync"
result_sync = subprocess.run(wallet_sync_command, shell=True, capture_output=True, text=True)
print("Output from wallet sync command:")
print(result_sync.stdout)
if result_sync.stderr:
print("Error in wallet sync command:")
print(result_sync.stderr)
# Check for success message
if "inscription txid:" in result_sync.stdout:
print("Successful inscription, extracting txid and updating JSON file.")
txid = re.search("inscription txid: (\w+)", result_sync.stdout).group(1)
update_json_file(base_file_name, image_path, txid)
break
# Check for the specific error and retry
elif "'64: too-long-mempool-chain'" in result_sync.stdout:
print("Detected specific error message, retrying in 180 seconds...")
time.sleep(180)
else:
print("Unknown response, stopping the retry loop.")
break
def update_json_file(base_file_name, image_path, txid):
json_file_name = f"{base_file_name}.json"
data = {}
if os.path.isfile(json_file_name):
with open(json_file_name, 'r') as file:
data = json.load(file)
data[os.path.basename(image_path)] = txid
with open(json_file_name, 'w') as file:
json.dump(data, file, indent=4)
# replace with FILEPATH to collection.
directory = 'C:\\Users\\YourMom\\Desktop\\NodeRunners\\Hi-res'
# replace with file extension
file_extension = 'png'
# enter range of files to inscribe.
start = 8
end = 33
run_node_commands(start, end, directory, file_extension)