Skip to content

Instantly share code, notes, and snippets.

@choffstein
Last active November 26, 2024 01:57
Show Gist options
  • Save choffstein/33e3ddd1b2317e9ab742d752a3cf6d92 to your computer and use it in GitHub Desktop.
Save choffstein/33e3ddd1b2317e9ab742d752a3cf6d92 to your computer and use it in GitHub Desktop.
import json
import glob
import tqdm
import requests
import json
import yaml
import subprocess
import os
if __name__ == "__main__":
### FIGURE OUT WHICH VOUCHERS WORK
key_to_file = {}
ceremony_vouchers = json.load(open("../ceremony_vouchers.json"))
voucher_files = glob.glob("../vouchers/*.txt")
peer_priv_keys = []
for voucher_file in tqdm.tqdm(voucher_files):
with open(voucher_file, "r") as f:
peer_priv_key = f.read()
voucher_hex = '0x' + peer_priv_key[-114:]
if voucher_hex in ceremony_vouchers:
peer_priv_keys.append(peer_priv_key)
key_to_file[peer_priv_key] = voucher_file
with open('.config/config.yml', 'r') as stream:
config_yaml = yaml.safe_load(stream)
### SET UP OUR MASTER WALLET
MASTER_PRIV_KEY = peer_priv_keys[0]
print(MASTER_PRIV_KEY)
config_yaml['p2p']['peerPrivKey'] = MASTER_PRIV_KEY
with open('.config/config.yml', 'w') as stream:
yaml.dump(config_yaml, stream)
with open('.config/config.yml.MASTER', 'w') as stream:
yaml.dump(config_yaml, stream)
qclient_output = subprocess.check_output(['../client/qclient-2.0.2.3-darwin-arm64', 'token', 'balance'])
MASTER_WALLET = qclient_output.decode('utf-8')[-68:-2]
for peer_priv_key in tqdm.tqdm(peer_priv_keys[1:]):
config_yaml['p2p']['peerPrivKey'] = peer_priv_key
with open('.config/config.yml', 'w') as stream:
yaml.dump(config_yaml, stream)
try:
qclient_output = subprocess.check_output(['../client/qclient-2.0.2.3-darwin-arm64', 'token', 'balance'])
except:
import ipdb; ipdb.set_trace()
wallet_address = qclient_output.decode('utf-8')[-68:-2]
r = requests.post("https://bridge-layer.quilibrium.com/coins", json={'address':wallet_address})
request_value = r.json()
if len(request_value['coins']) == 0:
print('Skipping ' + peer_priv_key)
continue
coin_address = request_value['coins'][0]['address']
qclient_output = subprocess.check_output(['../client/qclient-2.0.2.3-darwin-arm64', 'token', 'transfer', MASTER_WALLET, coin_address])
### MERGE ALL THE COINS INTO ONE
config_yaml['p2p']['peerPrivKey'] = MASTER_PRIV_KEY
with open('.config/config.yml', 'w') as stream:
yaml.dump(config_yaml, stream)
r = requests.post("https://bridge-layer.quilibrium.com/coins", json={'address':MASTER_WALLET})
coin_addresses = ' '.join([coin['address'] for coin in r.json()['coins']])
os.system(f"../client/qclient-2.0.2.3-darwin-arm64 token merge " + coin_addresses)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment