Last active
July 5, 2023 16:54
-
-
Save onur-ozkan/ab7038d6901a5f89dbda55d6416213d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env /usr/bin/python3 | |
import subprocess | |
import json | |
def check_unspent(coin, tool_bin, use_ac_name, script_pubkey): | |
command = [tool_bin] | |
if use_ac_name == True: | |
command.append('-ac_name=' + coin) | |
command.append('listunspent') | |
output = subprocess.check_output(command, universal_newlines=True) | |
unspent_list = json.loads(output) | |
filtered_list = [item for item in unspent_list if item['spendable'] == True | |
and item['amount'] < 0.1 | |
and item['scriptPubKey'] == script_pubkey] | |
result = len(filtered_list) | |
print(result) | |
return result | |
def execute_splitfunds(coin, amount, port): | |
sats = 10000 | |
high_utxo_coins = ["AYA", "EMC2", "MIL"] | |
if coin in high_utxo_coins: | |
sats = 100000 | |
url = f"http://127.0.0.1:{port}" | |
data = { | |
"coin": coin, | |
"agent": "iguana", | |
"method": "splitfunds", | |
"satoshis": str(sats), | |
"sendflag": 1, | |
"duplicates": str(amount) | |
} | |
command = [ | |
"/usr/bin/curl", | |
"--url", url, | |
"--data", json.dumps(data) | |
] | |
subprocess.run(command) | |
# Define the list of coins, amounts, ports, tool bins, and use_ac_name | |
coins = [ | |
{"coin": "KMD", "amount": 50, "port": 7776, | |
"tool_bin": "/usr/local/bin/komodo-cli", "use_ac_name": False, "scriptPubKey": "2102be4ac61cf534b0fb98568ec539ee9e34c5104088f94f21cee2945d37d88373daac"}, | |
{"coin": "LTC", "amount": 50, "port": 7776, | |
"tool_bin": "/usr/local/bin/litecoin-cli", "use_ac_name": False, "scriptPubKey": "2102be4ac61cf534b0fb98568ec539ee9e34c5104088f94f21cee2945d37d88373daac"}, | |
{"coin": "CCL", "amount": 50, "port": 7776, | |
"tool_bin": "/usr/local/bin/komodo-cli", "use_ac_name": True, "scriptPubKey": "2102be4ac61cf534b0fb98568ec539ee9e34c5104088f94f21cee2945d37d88373daac"}, | |
{"coin": "CLC", "amount": 50, "port": 7776, | |
"tool_bin": "/usr/local/bin/komodo-cli", "use_ac_name": True, "scriptPubKey": "2102be4ac61cf534b0fb98568ec539ee9e34c5104088f94f21cee2945d37d88373daac"}, | |
{"coin": "DOC", "amount": 50, "port": 7776, | |
"tool_bin": "/usr/local/bin/komodo-cli", "use_ac_name": True, "scriptPubKey": "2102be4ac61cf534b0fb98568ec539ee9e34c5104088f94f21cee2945d37d88373daac"}, | |
{"coin": "GLEEC", "amount": 50, "port": 7776, | |
"tool_bin": "/usr/local/bin/komodo-cli", "use_ac_name": True, "scriptPubKey": "2102be4ac61cf534b0fb98568ec539ee9e34c5104088f94f21cee2945d37d88373daac"}, | |
{"coin": "ILN", "amount": 50, "port": 7776, | |
"tool_bin": "/usr/local/bin/komodo-cli", "use_ac_name": True, "scriptPubKey": "2102be4ac61cf534b0fb98568ec539ee9e34c5104088f94f21cee2945d37d88373daac"}, | |
{"coin": "KOIN", "amount": 50, "port": 7776, | |
"tool_bin": "/usr/local/bin/komodo-cli", "use_ac_name": True, "scriptPubKey": "2102be4ac61cf534b0fb98568ec539ee9e34c5104088f94f21cee2945d37d88373daac"}, | |
{"coin": "MARTY", "amount": 50, "port": 7776, | |
"tool_bin": "/usr/local/bin/komodo-cli", "use_ac_name": True, "scriptPubKey": "2102be4ac61cf534b0fb98568ec539ee9e34c5104088f94f21cee2945d37d88373daac"}, | |
{"coin": "NINJA", "amount": 50, "port": 7776, | |
"tool_bin": "/usr/local/bin/komodo-cli", "use_ac_name": True, "scriptPubKey": "2102be4ac61cf534b0fb98568ec539ee9e34c5104088f94f21cee2945d37d88373daac"}, | |
{"coin": "PIRATE", "amount": 50, "port": 7776, | |
"tool_bin": "/usr/local/bin/komodo-cli", "use_ac_name": True, "scriptPubKey": "2102be4ac61cf534b0fb98568ec539ee9e34c5104088f94f21cee2945d37d88373daac"}, | |
{"coin": "SUPERNET", "amount": 50, "port": 7776, | |
"tool_bin": "/usr/local/bin/komodo-cli", "use_ac_name": True, "scriptPubKey": "2102be4ac61cf534b0fb98568ec539ee9e34c5104088f94f21cee2945d37d88373daac"}, | |
{"coin": "THC", "amount": 50, "port": 7776, | |
"tool_bin": "/usr/local/bin/komodo-cli", "use_ac_name": True, "scriptPubKey": "2102be4ac61cf534b0fb98568ec539ee9e34c5104088f94f21cee2945d37d88373daac"}, | |
{"coin": "KMD", "amount": 50, "port": 7779, | |
"tool_bin": "/usr/local/bin/komodo_3p-cli", "use_ac_name": False, "scriptPubKey": "2103259f6aa4d3c451a52b7327bff4af9f649be3477459997b52711b54f4c8fb6394ac"}, | |
{"coin": "AYA", "amount": 50, "port": 7779, | |
"tool_bin": "/usr/local/bin/aryacoin-cli", "use_ac_name": False, "scriptPubKey": "2103259f6aa4d3c451a52b7327bff4af9f649be3477459997b52711b54f4c8fb6394ac"}, | |
{"coin": "CHIPS", "amount": 50, "port": 7779, | |
"tool_bin": "/usr/local/bin/chips-cli", "use_ac_name": False, "scriptPubKey": "2103259f6aa4d3c451a52b7327bff4af9f649be3477459997b52711b54f4c8fb6394ac"}, | |
{"coin": "EMC2", "amount": 50, "port": 7779, | |
"tool_bin": "/usr/local/bin/einsteinium-cli", "use_ac_name": False, "scriptPubKey": "2103259f6aa4d3c451a52b7327bff4af9f649be3477459997b52711b54f4c8fb6394ac"}, | |
{"coin": "MCL", "amount": 50, "port": 7779, | |
"tool_bin": "/usr/local/bin/mcl-cli", "use_ac_name": False, "scriptPubKey": "2103259f6aa4d3c451a52b7327bff4af9f649be3477459997b52711b54f4c8fb6394ac"}, | |
{"coin": "MIL", "amount": 50, "port": 7779, | |
"tool_bin": "/usr/local/bin/mil-cli", "use_ac_name": False, "scriptPubKey": "2103259f6aa4d3c451a52b7327bff4af9f649be3477459997b52711b54f4c8fb6394ac"}, | |
{"coin": "TOKEL", "amount": 50, "port": 7779, | |
"tool_bin": "/usr/local/bin/tokel-cli", "use_ac_name": False, "scriptPubKey": "2103259f6aa4d3c451a52b7327bff4af9f649be3477459997b52711b54f4c8fb6394ac"}, | |
{"coin": "VRSC", "amount": 50, "port": 7779, | |
"tool_bin": "/usr/local/bin/verus-cli", "use_ac_name": False, "scriptPubKey": "2103259f6aa4d3c451a52b7327bff4af9f649be3477459997b52711b54f4c8fb6394ac"} | |
] | |
for coin in coins: | |
try: | |
unspent_count = check_unspent( | |
coin["coin"], coin["tool_bin"], coin["use_ac_name"], coin["scriptPubKey"]) | |
if unspent_count <= 20: | |
execute_splitfunds( | |
coin["coin"], coin["amount"], coin["port"]) | |
print(f"Split script executed for {coin['coin']}") | |
elif unspent_count is not None: | |
print( | |
f"Unspent coin count is more than 20 for {coin['coin']}. Skipping.") | |
except Exception as e: | |
print(f"An error occurred for {coin['coin']}: {e}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do not forget to update the
scriptPubKey
incoins
Notes for crontab usage:
t
fromdocker -it
)$HOME