![tlysakov@gmail.com](/assets/img/avatar_default.png)
13 changed files with 2797 additions and 0 deletions
@ -0,0 +1,21 @@ |
|||
MIT License |
|||
|
|||
Copyright (c) 2019 Anton Lysakov |
|||
|
|||
Permission is hereby granted, free of charge, to any person obtaining a copy |
|||
of this software and associated documentation files (the "Software"), to deal |
|||
in the Software without restriction, including without limitation the rights |
|||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|||
copies of the Software, and to permit persons to whom the Software is |
|||
furnished to do so, subject to the following conditions: |
|||
|
|||
The above copyright notice and this permission notice shall be included in all |
|||
copies or substantial portions of the Software. |
|||
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|||
SOFTWARE. |
@ -0,0 +1,58 @@ |
|||
# Komodo Cryptoconditons Terminal User Interfaces (aka TUIs) |
|||
|
|||
These tools creating for demonstration and partial automation of Komodo cryptoconditions modules testing. (RogueCC game, AssetsCC, OraclesCC, GatewaysCC, MarmaraCC, ...) |
|||
|
|||
|
|||
Developer installation (on Ubuntu 18.04) : |
|||
|
|||
Python3 required for execution: |
|||
|
|||
* `sudo apt-get install python3.6 python3-pip libgnutls28-dev` |
|||
|
|||
pip packages needed: |
|||
|
|||
* `pip3 install setuptools wheel slick-bitcoinrpc` |
|||
* or `pip3 install -r requirements.txt` |
|||
|
|||
Starting: |
|||
|
|||
# TUI for RogueCC |
|||
|
|||
If you're looking for player 3 in 1 (daemon + game + TUI) multiOS bundle - please check `releases` of this repo. |
|||
|
|||
`python3 rogue_tui.py` |
|||
|
|||
![alt text](https://i.imgur.com/gkcxMGt.png) |
|||
|
|||
# TUI for OraclesCC |
|||
|
|||
Have files uploader/downloader functionality - also there is a AWS branch for AWS certificates uploading demonstration |
|||
|
|||
`python3 oracles_cc_tui.py` |
|||
|
|||
![alt text](https://i.imgur.com/tfHwRqc.png) |
|||
|
|||
# TUI for GatewaysCC |
|||
|
|||
![alt text](https://i.imgur.com/c8DPfpp.png) |
|||
|
|||
`python3 gateways_creation_tui.py` |
|||
|
|||
`python3 gateways_usage_tui.py` |
|||
|
|||
At the moment raw version of manual gateway how-to guide can be found here: https://docs.komodoplatform.com/cc/contracts/gateways/scenarios/tutorial.html I advice to read it before you start use this tool to understand the flow. |
|||
|
|||
# TUI for MarmaraCC |
|||
|
|||
`python3 marmara_tui.py` |
|||
|
|||
![alt text](https://i.imgur.com/uonMWHl.png) |
|||
|
|||
# TUI for AssetsCC (not much finished) |
|||
|
|||
`python3 assets_cc_tui.py` |
|||
|
|||
Before execution be sure than daemon for needed AC up. |
|||
|
|||
|
|||
|
@ -0,0 +1,39 @@ |
|||
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM |
|||
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWWWWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM |
|||
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWX0xlc:ldOKNWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM |
|||
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMWX0xo:,........';lxOXNMMMMMMMMMMMMMMMMMMMMMMMMMMMMM |
|||
MMMMMMMMMMMMMMMMMMMMMMMMWNKkoc,..................':ox0XWMMMMMMMMMMMMMMMMMMMMMMMM |
|||
MMMMMMMMMMMMMMMMMMMWNKkdc;............................,:ok0NWMMMMMMMMMMMMMMMMMMM |
|||
MMMMMMMMMMMMMMWNKOdl;'.....................................,cdkKNWMMMMMMMMMMMMMM |
|||
MMMMMMMMMMMMMW0c'..............................................';kNMMMMMMMMMMMMM |
|||
MMMMMMMMMMMMMK:......................';:c:'......................,kWMMMMMMMMMMMM |
|||
MMMMMMMMMMMMXl...................;cdkKNWWNXOdl;'..................;OWMMMMMMMMMMM |
|||
MMMMMMMMMMMNo...............,cok0XWMMMMMMMMMMWNKkdc;'..............:KMMMMMMMMMMM |
|||
MMMMMMMMMMWx'...........;ox0XWMMMMMMMMMMMMMMMMMMMMWNKko:............lXMMMMMMMMMM |
|||
MMMMMMMMMWk,...........lXWMMMMMMMMMMMMWWWWMMMMMMMMMMMMMNx'...........oNMMMMMMMMM |
|||
MMMMMMMMW0;...........cKMMMMMMMMMWNXOdl::cdkKNWMMMMMMMMMNo...........'xWMMMMMMMM |
|||
MMMMMMMMKc...........;0WMMMMMWN0xl:,........';ldOXWMMMMMMXl...........,OWMMMMMMM |
|||
MMMMMMMXl...........,kWMMMMMMKl..................;OWMMMMMMK:...........;0MMMMMMM |
|||
MMMMMMNd...........'xNMMMMMMXl....................:0WMMMMMWO;...........cKMMMMMM |
|||
MMMMMNx'...........oNMMMMMMNd......................cKMMMMMMWk'...........lXMMMMM |
|||
MMMMWO,...........lXMMMMMMWx'.......................oXMMMMMMNd'...........dNMMMM |
|||
MMMMXc...........,OWMMMMMMK:........................,kWMMMMMMKc...........;0MMMM |
|||
MMMMWx'...........oXMMMMMMNd........................cKMMMMMMWk,...........lXMMMM |
|||
MMMMMNd...........'dNMMMMMMXl......................:0MMMMMMWO;...........cKMMMMM |
|||
MMMMMMXl...........,kWMMMMMMKc....................,OWMMMMMM0:...........;0MMMMMM |
|||
MMMMMMMKc...........;OWMMMMMW0:..................,kWMMMMMMXc...........,OWMMMMMM |
|||
MMMMMMMM0;...........:KMMMMMMWKko:,..........';lx0WMMMMMMNo...........'xWMMMMMMM |
|||
MMMMMMMMWk,...........lXMMMMMMMMWWXOxl:,,;cdOKNWMMMMMMMMNx'...........dNMMMMMMMM |
|||
MMMMMMMMMWx'...........dNMMMMMMMMMMMMWNXXNWMMMMMMMMMMMMWk,...........lXMMMMMMMMM |
|||
MMMMMMMMMMNo............cx0XWMMMMMMMMMMMMMMMMMMMMMMWN0kl,...........cKMMMMMMMMMM |
|||
MMMMMMMMMMMXl..............,:ok0XWMMMMMMMMMMMMWNKkdc;..............;0WMMMMMMMMMM |
|||
MMMMMMMMMMMMK:..................,cokKNWMMWNKOdl;'.................,kWMMMMMMMMMMM |
|||
MMMMMMMMMMMMWO;......................;cool;'.....................'xNMMMMMMMMMMMM |
|||
MMMMMMMMMMMMMWk;................................................'dNMMMMMMMMMMMMM |
|||
MMMMMMMMMMMMMMWXOxl;'.......................................,cdkKWMMMMMMMMMMMMMM |
|||
MMMMMMMMMMMMMMMMMMWNKOdc;..............................,cok0NWMMMMMMMMMMMMMMMMMM |
|||
MMMMMMMMMMMMMMMMMMMMMMMWNKkoc,....................,:ox0XWMMMMMMMMMMMMMMMMMMMMMMM |
|||
MMMMMMMMMMMMMMMMMMMMMMMMMMMMWX0ko:,..........':lx0XWMMMMMMMMMMMMMMMMMMMMMMMMMMMM |
|||
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWX0xl:,,;ldOKNWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM |
|||
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWNNXNWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM |
|||
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM |
@ -0,0 +1,129 @@ |
|||
import http |
|||
from slickrpc import Proxy |
|||
|
|||
|
|||
# RPC connection |
|||
def rpc_connect(rpc_user, rpc_password, port): |
|||
try: |
|||
rpc_connection = Proxy("http://%s:%s@127.0.0.1:%d"%(rpc_user, rpc_password, port)) |
|||
except Exception: |
|||
raise Exception("Connection error! Probably no daemon on selected port.") |
|||
return rpc_connection |
|||
|
|||
|
|||
# Non CC calls |
|||
def getinfo(rpc_connection): |
|||
try: |
|||
getinfo = rpc_connection.getinfo() |
|||
except Exception: |
|||
raise Exception("Connection error!") |
|||
return getinfo |
|||
|
|||
|
|||
def sendrawtransaction(rpc_connection, hex): |
|||
tx_id = rpc_connection.sendrawtransaction(hex) |
|||
return tx_id |
|||
|
|||
|
|||
def gettransaction(rpc_connection, tx_id): |
|||
transaction_info = rpc_connection.gettransaction(tx_id) |
|||
return transaction_info |
|||
|
|||
|
|||
def getrawtransaction(rpc_connection, tx_id): |
|||
rawtransaction = rpc_connection.getrawtransaction(tx_id) |
|||
return rawtransaction |
|||
|
|||
|
|||
def getbalance(rpc_connection): |
|||
balance = rpc_connection.getbalance() |
|||
return balance |
|||
|
|||
# Token CC calls |
|||
def token_create(rpc_connection, name, supply, description): |
|||
token_hex = rpc_connection.tokencreate(name, supply, description) |
|||
return token_hex |
|||
|
|||
|
|||
def token_info(rpc_connection, token_id): |
|||
token_info = rpc_connection.tokeninfo(token_id) |
|||
return token_info |
|||
|
|||
|
|||
#TODO: have to add option with pubkey input |
|||
def token_balance(rpc_connection, token_id): |
|||
token_balance = rpc_connection.tokenbalance(token_id) |
|||
return token_balance |
|||
|
|||
def token_list(rpc_connection): |
|||
token_list = rpc_connection.tokenlist() |
|||
return token_list |
|||
|
|||
|
|||
def token_convert(rpc_connection, evalcode, token_id, pubkey, supply): |
|||
token_convert_hex = rpc_connection.tokenconvert(evalcode, token_id, pubkey, supply) |
|||
return token_convert_hex |
|||
|
|||
def get_rawmempool(rpc_connection): |
|||
mempool = rpc_connection.getrawmempool() |
|||
return mempool |
|||
|
|||
# Oracle CC calls |
|||
def oracles_create(rpc_connection, name, description, data_type): |
|||
oracles_hex = rpc_connection.oraclescreate(name, description, data_type) |
|||
return oracles_hex |
|||
|
|||
|
|||
def oracles_register(rpc_connection, oracle_id, data_fee): |
|||
oracles_register_hex = rpc_connection.oraclesregister(oracle_id, data_fee) |
|||
return oracles_register_hex |
|||
|
|||
|
|||
def oracles_subscribe(rpc_connection, oracle_id, publisher_id, data_fee): |
|||
oracles_subscribe_hex = rpc_connection.oraclessubscribe(oracle_id, publisher_id, data_fee) |
|||
return oracles_subscribe_hex |
|||
|
|||
|
|||
def oracles_info(rpc_connection, oracle_id): |
|||
oracles_info = rpc_connection.oraclesinfo(oracle_id) |
|||
return oracles_info |
|||
|
|||
|
|||
def oracles_data(rpc_connection, oracle_id, hex_string): |
|||
oracles_data = rpc_connection.oraclesdata(oracle_id, hex_string) |
|||
return oracles_data |
|||
|
|||
|
|||
def oracles_list(rpc_connection): |
|||
oracles_list = rpc_connection.oracleslist() |
|||
return oracles_list |
|||
|
|||
|
|||
def oracles_samples(rpc_connection, oracletxid, batonutxo, num): |
|||
oracles_sample = rpc_connection.oraclessamples(oracletxid, batonutxo, num) |
|||
return oracles_sample |
|||
|
|||
|
|||
# Gateways CC calls |
|||
# Arguments changing dynamically depends of M N, so supposed to wrap it this way |
|||
# token_id, oracle_id, coin_name, token_supply, M, N + pubkeys for each N |
|||
def gateways_bind(rpc_connection, *args): |
|||
gateways_bind_hex = rpc_connection.gatewaysbind(*args) |
|||
return gateways_bind_hex |
|||
|
|||
|
|||
def gateways_deposit(rpc_connection, gateway_id, height, coin_name,\ |
|||
coin_txid, claim_vout, deposit_hex, proof, dest_pub, amount): |
|||
gateways_deposit_hex = rpc_connection.gatewaysdeposit(gateway_id, height, coin_name,\ |
|||
coin_txid, claim_vout, deposit_hex, proof, dest_pub, amount) |
|||
return gateways_deposit_hex |
|||
|
|||
|
|||
def gateways_claim(rpc_connection, gateway_id, coin_name, deposit_txid, dest_pub, amount): |
|||
gateways_claim_hex = rpc_connection.gatewaysclaim(gateway_id, coin_name, deposit_txid, dest_pub, amount) |
|||
return gateways_claim_hex |
|||
|
|||
|
|||
def gateways_withdraw(rpc_connection, gateway_id, coin_name, withdraw_pub, amount): |
|||
gateways_withdraw_hex = rpc_connection.gatewayswithdraw(gateway_id, coin_name, withdraw_pub, amount) |
|||
return gateways_withdraw_hex |
File diff suppressed because it is too large
@ -0,0 +1,8 @@ |
|||
configobj==5.0.6 |
|||
pip==9.0.1 |
|||
pycurl==7.43.0.2 |
|||
setuptools==39.0.1 |
|||
six==1.12.0 |
|||
slick-bitcoinrpc==0.1.4 |
|||
ujson==1.35 |
|||
wheel==0.32.3 |
@ -0,0 +1,67 @@ |
|||
#!/usr/bin/env python3 |
|||
|
|||
from lib import rpclib, tuilib |
|||
import os |
|||
import time |
|||
|
|||
|
|||
header = "\ |
|||
___ _ _____ \n\ |
|||
/ _ \ | | / __ \\\n\ |
|||
/ /_\ \ ___ ___ ___ | |_ ___ | / \/\n\ |
|||
| _ |/ __|/ __| / _ \| __|/ __|| | \n\ |
|||
| | | |\__ \\\__ \| __/| |_ \__ \| \__/\\\n\ |
|||
\_| |_/|___/|___/ \___| \__||___/ \____/\n" |
|||
|
|||
|
|||
menuItems = [ |
|||
{"Check current connection": tuilib.getinfo_tui}, |
|||
{"Check mempool": tuilib.print_mempool}, |
|||
{"Print tokens list": tuilib.print_tokens_list}, |
|||
{"Check my tokens balances" : tuilib.print_tokens_balances}, |
|||
# transfer tokens (pre-print tokens balances) |
|||
{"Create token": tuilib.token_create_tui}, |
|||
# trading zone - pre-print token orders - possible to open order or fill existing one |
|||
{"Exit": exit} |
|||
] |
|||
|
|||
|
|||
def main(): |
|||
while True: |
|||
os.system('clear') |
|||
print(tuilib.colorize(header, 'pink')) |
|||
print(tuilib.colorize('CLI version 0.2 by Anton Lysakov\n', 'green')) |
|||
for item in menuItems: |
|||
print(tuilib.colorize("[" + str(menuItems.index(item)) + "] ", 'blue') + list(item.keys())[0]) |
|||
choice = input(">> ") |
|||
try: |
|||
if int(choice) < 0: |
|||
raise ValueError |
|||
# Call the matching function |
|||
if list(menuItems[int(choice)].keys())[0] == "Exit": |
|||
list(menuItems[int(choice)].values())[0]() |
|||
else: |
|||
list(menuItems[int(choice)].values())[0](rpc_connection) |
|||
except (ValueError, IndexError): |
|||
pass |
|||
|
|||
|
|||
if __name__ == "__main__": |
|||
while True: |
|||
try: |
|||
print(tuilib.colorize("Welcome to the GatewaysCC TUI!\n" |
|||
"Please provide asset chain RPC connection details for initialization", "blue")) |
|||
rpc_connection = tuilib.rpc_connection_tui() |
|||
rpclib.getinfo(rpc_connection) |
|||
except Exception: |
|||
print(tuilib.colorize("Cant connect to RPC! Please re-check credentials.", "pink")) |
|||
else: |
|||
print(tuilib.colorize("Succesfully connected!\n", "green")) |
|||
with (open("lib/logo.txt", "r")) as logo: |
|||
for line in logo: |
|||
print(line, end='') |
|||
time.sleep(0.04) |
|||
print("\n") |
|||
break |
|||
main() |
|||
|
@ -0,0 +1,67 @@ |
|||
#!/usr/bin/env python3 |
|||
|
|||
from lib import rpclib, tuilib |
|||
import os |
|||
import time |
|||
|
|||
header = "\ |
|||
_____ _ _____ _____ \n\ |
|||
| __ \ | | / __ \/ __ \\\n\ |
|||
| | \/ __ _| |_ _____ ____ _ _ _ ___| / \/| / \/\n\ |
|||
| | __ / _` | __/ _ \ \ /\ / / _` | | | / __| | | | \n\ |
|||
| |_\ \ (_| | || __/\ V V / (_| | |_| \__ \ \__/\| \__/\\\n\ |
|||
\____/\__,_|\__\___| \_/\_/ \__,_|\__, |___/\____/ \____/\n\ |
|||
__/ | \n\ |
|||
|___/ \n" |
|||
|
|||
|
|||
menuItems = [ |
|||
{"Check current connection": tuilib.getinfo_tui}, |
|||
{"Check mempool": tuilib.print_mempool}, |
|||
{"Create token": tuilib.token_create_tui}, |
|||
{"Create oracle": tuilib.oracle_create_tui}, |
|||
{"Register as publisher for oracle": tuilib.oracle_register_tui}, |
|||
{"Subscribe on oracle (+UTXO generator)": tuilib.oracle_subscription_utxogen}, |
|||
{"Bind Gateway": tuilib.gateways_bind_tui}, |
|||
{"Exit": exit} |
|||
] |
|||
|
|||
|
|||
def main(): |
|||
while True: |
|||
os.system('clear') |
|||
print(tuilib.colorize(header, 'pink')) |
|||
print(tuilib.colorize('CLI version 0.2\n', 'green')) |
|||
for item in menuItems: |
|||
print(tuilib.colorize("[" + str(menuItems.index(item)) + "] ", 'blue') + list(item.keys())[0]) |
|||
choice = input(">> ") |
|||
try: |
|||
if int(choice) < 0: |
|||
raise ValueError |
|||
# Call the matching function |
|||
if list(menuItems[int(choice)].keys())[0] == "Exit": |
|||
list(menuItems[int(choice)].values())[0]() |
|||
else: |
|||
list(menuItems[int(choice)].values())[0](rpc_connection) |
|||
except (ValueError, IndexError): |
|||
pass |
|||
|
|||
|
|||
if __name__ == "__main__": |
|||
while True: |
|||
try: |
|||
print(tuilib.colorize("Welcome to the GatewaysCC TUI!\n" |
|||
"Please provide asset chain RPC connection details for initialization", "blue")) |
|||
rpc_connection = tuilib.rpc_connection_tui() |
|||
rpclib.getinfo(rpc_connection) |
|||
except Exception: |
|||
print(tuilib.colorize("Cant connect to RPC! Please re-check credentials.", "pink")) |
|||
else: |
|||
print(tuilib.colorize("Succesfully connected!\n", "green")) |
|||
with (open("lib/logo.txt", "r")) as logo: |
|||
for line in logo: |
|||
print(line, end='') |
|||
time.sleep(0.04) |
|||
print("\n") |
|||
break |
|||
main() |
@ -0,0 +1,96 @@ |
|||
#!/usr/bin/env python3 |
|||
|
|||
from lib import rpclib, tuilib |
|||
import os, time |
|||
|
|||
header = "\ |
|||
_____ _ _____ _____ \n\ |
|||
| __ \ | | / __ \/ __ \\\n\ |
|||
| | \/ __ _| |_ _____ ____ _ _ _ ___| / \/| / \/\n\ |
|||
| | __ / _` | __/ _ \ \ /\ / / _` | | | / __| | | | \n\ |
|||
| |_\ \ (_| | || __/\ V V / (_| | |_| \__ \ \__/\| \__/\\\n\ |
|||
\____/\__,_|\__\___| \_/\_/ \__,_|\__, |___/\____/ \____/\n\ |
|||
__/ | \n\ |
|||
|___/ \n" |
|||
|
|||
menuItems = [ |
|||
{"Check connection to assetchain": tuilib.getinfo_tui}, |
|||
{"Check assetchain mempool": tuilib.print_mempool}, |
|||
{"Check connection to KMD": tuilib.getinfo_tui}, |
|||
{"Connect to KMD daemon": tuilib.rpc_kmd_connection_tui}, |
|||
{"Send KMD gateway deposit transaction": tuilib.gateways_send_kmd}, |
|||
{"Execute gateways deposit": tuilib.gateways_deposit_tui}, |
|||
{"Execute gateways claim": tuilib.gateways_claim_tui}, |
|||
{"Execute gateways withdrawal": tuilib.gateways_withdrawal_tui}, |
|||
{"Exit": exit} |
|||
] |
|||
|
|||
def main(): |
|||
while True: |
|||
os.system('clear') |
|||
print(tuilib.colorize(header, 'pink')) |
|||
print(tuilib.colorize('CLI version 0.2\n', 'green')) |
|||
for item in menuItems: |
|||
print(tuilib.colorize("[" + str(menuItems.index(item)) + "] ", 'blue') + list(item.keys())[0]) |
|||
choice = input(">> ") |
|||
try: |
|||
if int(choice) < 0: |
|||
raise ValueError |
|||
# Call the matching function |
|||
if list(menuItems[int(choice)].keys())[0] == "Exit": |
|||
list(menuItems[int(choice)].values())[0]() |
|||
# We have to call KMD specific functions with connection to KMD daemon |
|||
elif list(menuItems[int(choice)].keys())[0] == "Connect to KMD daemon": |
|||
rpc_connection_kmd = list(menuItems[int(choice)].values())[0]() |
|||
elif list(menuItems[int(choice)].keys())[0] == "Check connection to KMD": |
|||
while True: |
|||
try: |
|||
list(menuItems[int(choice)].values())[0](rpc_connection_kmd) |
|||
break |
|||
except Exception as e: |
|||
print("Please connect to KMD daemon first!") |
|||
input("Press [Enter] to continue...") |
|||
break |
|||
elif list(menuItems[int(choice)].keys())[0] == "Send KMD gateway deposit transaction": |
|||
while True: |
|||
try: |
|||
list(menuItems[int(choice)].values())[0](rpc_connection_kmd) |
|||
break |
|||
except Exception as e: |
|||
print(e) |
|||
print("Please connect to KMD daemon first!") |
|||
input("Press [Enter] to continue...") |
|||
break |
|||
elif list(menuItems[int(choice)].keys())[0] == "Execute gateways deposit": |
|||
while True: |
|||
try: |
|||
list(menuItems[int(choice)].values())[0](rpc_connection, rpc_connection_kmd) |
|||
break |
|||
except Exception as e: |
|||
print(e) |
|||
print("Please connect to KMD daemon first!") |
|||
input("Press [Enter] to continue...") |
|||
break |
|||
else: |
|||
list(menuItems[int(choice)].values())[0](rpc_connection) |
|||
except (ValueError, IndexError): |
|||
pass |
|||
|
|||
|
|||
if __name__ == "__main__": |
|||
while True: |
|||
try: |
|||
print(tuilib.colorize("Welcome to the GatewaysCC TUI!\nPlease provide RPC connection details for initialization", "blue")) |
|||
rpc_connection = tuilib.rpc_connection_tui() |
|||
rpclib.getinfo(rpc_connection) |
|||
except Exception: |
|||
print(tuilib.colorize("Cant connect to RPC! Please re-check credentials.", "pink")) |
|||
else: |
|||
print(tuilib.colorize("Succesfully connected!\n", "green")) |
|||
with (open("lib/logo.txt", "r")) as logo: |
|||
for line in logo: |
|||
print(line, end='') |
|||
time.sleep(0.04) |
|||
print("\n") |
|||
break |
|||
main() |
@ -0,0 +1,68 @@ |
|||
#!/usr/bin/env python3 |
|||
|
|||
from lib import rpclib, tuilib |
|||
import os |
|||
import time |
|||
|
|||
|
|||
header = "\ |
|||
___ ___ _____ _ _ _____ \n\ |
|||
| \/ | |_ _| | | |_ _|\n\ |
|||
| . . | __ _ _ __ _ __ ___ __ _ _ __ __ _ | | | | | | | |\n\ |
|||
| |\/| |/ _` | '__| '_ ` _ \ / _` | '__/ _` | | | | | | | | |\n\ |
|||
| | | | (_| | | | | | | | | (_| | | | (_| | | | | |_| |_| |_\n\ |
|||
\_| |_/\__,_|_| |_| |_| |_|\__,_|_| \__,_| \_/ \___/ \___/\n" |
|||
|
|||
|
|||
menuItems = [ |
|||
{"Check current connection": tuilib.getinfo_tui}, |
|||
{"Check mempool": tuilib.print_mempool}, |
|||
{"Check MARMARA info": tuilib.marmara_info_tui}, |
|||
{"Lock funds for MARMARA": tuilib.marmara_lock_tui}, |
|||
{"Request MARMARA cheque": tuilib.marmara_receive_tui}, |
|||
{"Issue MARMARA cheque": tuilib.marmara_issue_tui}, |
|||
{"Check credit loop status": tuilib.marmara_creditloop_tui}, |
|||
{"Settle MARMARA loop": tuilib.marmara_settlement_tui}, |
|||
{"Exit": exit} |
|||
] |
|||
|
|||
|
|||
def main(): |
|||
while True: |
|||
os.system('clear') |
|||
print(tuilib.colorize(header, 'pink')) |
|||
print(tuilib.colorize('CLI version 0.1\n', 'green')) |
|||
for item in menuItems: |
|||
print(tuilib.colorize("[" + str(menuItems.index(item)) + "] ", 'blue') + list(item.keys())[0]) |
|||
choice = input(">> ") |
|||
try: |
|||
if int(choice) < 0: |
|||
raise ValueError |
|||
# Call the matching function |
|||
if list(menuItems[int(choice)].keys())[0] == "Exit": |
|||
list(menuItems[int(choice)].values())[0]() |
|||
else: |
|||
list(menuItems[int(choice)].values())[0](rpc_connection) |
|||
except (ValueError, IndexError): |
|||
pass |
|||
|
|||
|
|||
if __name__ == "__main__": |
|||
while True: |
|||
chain = input("Input assetchain name (-ac_name= value) you want to work with: ") |
|||
try: |
|||
print(tuilib.colorize("Welcome to the MarmaraCC TUI!\n" |
|||
"Please provide asset chain RPC connection details for initialization", "blue")) |
|||
rpc_connection = tuilib.def_credentials(chain) |
|||
rpclib.getinfo(rpc_connection) |
|||
except Exception: |
|||
print(tuilib.colorize("Cant connect to RPC! Please re-check credentials.", "pink")) |
|||
else: |
|||
print(tuilib.colorize("Succesfully connected!\n", "green")) |
|||
with (open("lib/logo.txt", "r")) as logo: |
|||
for line in logo: |
|||
print(line, end='') |
|||
time.sleep(0.04) |
|||
print("\n") |
|||
break |
|||
main() |
@ -0,0 +1,67 @@ |
|||
#!/usr/bin/env python3 |
|||
|
|||
from lib import rpclib, tuilib |
|||
import os |
|||
import time |
|||
|
|||
header = "\ |
|||
_____ _ _____ _____ \n\ |
|||
| _ | | | / __ \/ __ \\\n\ |
|||
| | | | _ __ __ _ ___ | | ___ ___ | / \/| / \/\n\ |
|||
| | | || '__| / _` | / __|| | / _ \/ __|| | | |\n\ |
|||
\ \_/ /| | | (_| || (__ | || __/\__ \| \__/\| \__/\\\n\ |
|||
\___/ |_| \__,_| \___||_| \___||___/ \____/ \____/\n" |
|||
|
|||
menuItems = [ |
|||
# TODO: Have to implement here native oracle file uploader / reader, should be dope |
|||
# TODO: data publisher / converter for different types |
|||
{"Check current connection": tuilib.getinfo_tui}, |
|||
{"Check mempool": tuilib.print_mempool}, |
|||
{"Create oracle": tuilib.oracle_create_tui}, |
|||
{"Register as publisher for oracle": tuilib.oracle_register_tui}, |
|||
{"Subscribe on oracle (+UTXO generator)": tuilib.oracle_subscription_utxogen}, |
|||
{"Upload file to oracle": tuilib.convert_file_oracle_D}, |
|||
{"Display list of files uploaded to this AC": tuilib.display_files_list}, |
|||
{"Download files from oracle": tuilib.files_downloader}, |
|||
{"Exit": exit} |
|||
] |
|||
|
|||
|
|||
def main(): |
|||
while True: |
|||
os.system('clear') |
|||
print(tuilib.colorize(header, 'pink')) |
|||
print(tuilib.colorize('CLI version 0.2 by Anton Lysakov\n', 'green')) |
|||
for item in menuItems: |
|||
print(tuilib.colorize("[" + str(menuItems.index(item)) + "] ", 'blue') + list(item.keys())[0]) |
|||
choice = input(">> ") |
|||
try: |
|||
if int(choice) < 0: |
|||
raise ValueError |
|||
# Call the matching function |
|||
if list(menuItems[int(choice)].keys())[0] == "Exit": |
|||
list(menuItems[int(choice)].values())[0]() |
|||
else: |
|||
list(menuItems[int(choice)].values())[0](rpc_connection) |
|||
except (ValueError, IndexError): |
|||
pass |
|||
|
|||
|
|||
if __name__ == "__main__": |
|||
while True: |
|||
try: |
|||
print(tuilib.colorize("Welcome to the GatewaysCC TUI!\n" |
|||
"Please provide asset chain RPC connection details for initialization", "blue")) |
|||
rpc_connection = tuilib.rpc_connection_tui() |
|||
rpclib.getinfo(rpc_connection) |
|||
except Exception: |
|||
print(tuilib.colorize("Cant connect to RPC! Please re-check credentials.", "pink")) |
|||
else: |
|||
print(tuilib.colorize("Succesfully connected!\n", "green")) |
|||
with (open("lib/logo.txt", "r")) as logo: |
|||
for line in logo: |
|||
print(line, end='') |
|||
time.sleep(0.04) |
|||
print("\n") |
|||
break |
|||
main() |
@ -0,0 +1,116 @@ |
|||
#!/usr/bin/env python3 |
|||
|
|||
from lib import rpclib, tuilib |
|||
import os |
|||
import time |
|||
import sys |
|||
import platform |
|||
|
|||
header = "\ |
|||
______ _____ _____ \n\ |
|||
| ___ \ / __ \/ __ \\\n\ |
|||
| |_/ /___ __ _ _ _ ___| / \/| / \/\n\ |
|||
| // _ \ / _` | | | |/ _ \ | | |\n\ |
|||
| |\ \ (_) | (_| | |_| | __/ \__/\| \__/\\\n\ |
|||
\_| \_\___/ \__, |\__,_|\___|\____/ \____/\n\ |
|||
__/ |\n\ |
|||
|___/\n" |
|||
|
|||
|
|||
menuItems = [ |
|||
{"Check current connection": tuilib.getinfo_tui}, |
|||
{"Check mempool": tuilib.print_mempool}, |
|||
{"Check my warriors list": tuilib.print_players_list}, |
|||
{"Transfer warrior to other pubkey": tuilib.warrior_trasnfer}, |
|||
{"TOP-20 ROGUE Warriors": tuilib.top_warriors_rating}, |
|||
{"Set warriors name": tuilib.set_warriors_name}, |
|||
{"Start singleplayer training game (creating, registering and starting game)": tuilib.rogue_newgame_singleplayer}, |
|||
{"Create multiplayer game": tuilib.rogue_newgame_multiplayer}, |
|||
{"Join (register) multiplayer game": tuilib.rogue_join_multiplayer_game}, |
|||
{"Check my multiplayer games status / start": tuilib.play_multiplayer_game}, |
|||
{"Check if somebody wants to buy your warrior (incoming bids)": tuilib.print_icoming_bids}, |
|||
{"Place order to sell warrior": tuilib.sell_warrior}, |
|||
{"Place order to buy someones warrior": tuilib.place_bid_on_warriror}, |
|||
{"Check if somebody selling warrior": tuilib.find_warriors_asks}, |
|||
{"Check / cancel my warriors trade orders": tuilib.warriors_orders_check}, |
|||
# {"Manually exit the game (bailout)": "test"}, |
|||
# {"Manually claim ROGUE coins for game (highlander)": "test"}, |
|||
{"Exit": tuilib.exit} |
|||
] |
|||
|
|||
def main(): |
|||
while True: |
|||
operating_system = platform.system() |
|||
if operating_system != 'Win64' and operating_system != 'Windows': |
|||
os.system('clear') |
|||
else: |
|||
os.system('cls') |
|||
print(tuilib.colorize(header, 'pink')) |
|||
print(tuilib.colorize('TUI v0.0.3\n', 'green')) |
|||
menu_items_counter = 0 |
|||
for item in menuItems: |
|||
if menu_items_counter == 0: |
|||
print("\nUtility:\n") |
|||
menu_items_counter = menu_items_counter + 1 |
|||
print(tuilib.colorize("[" + str(menuItems.index(item)) + "] ", 'blue') + list(item.keys())[0]) |
|||
if menu_items_counter == 6: |
|||
print("\nNew singleplayer game:\n") |
|||
if menu_items_counter == 7: |
|||
print("\nMultiplayer games:\n") |
|||
if menu_items_counter == 10: |
|||
print("\nDEX features:\n") |
|||
choice = input(">> ") |
|||
try: |
|||
if int(choice) < 0: |
|||
raise ValueError |
|||
# Call the matching function |
|||
if list(menuItems[int(choice)].keys())[0] == "Exit": |
|||
list(menuItems[int(choice)].values())[0]() |
|||
else: |
|||
list(menuItems[int(choice)].values())[0](rpc_connection) |
|||
except (ValueError, IndexError): |
|||
pass |
|||
|
|||
|
|||
if __name__ == "__main__": |
|||
while True: |
|||
chain = "ROGUE" |
|||
try: |
|||
print(tuilib.colorize("Welcome to the RogueCC TUI!\n" |
|||
"Please provide asset chain RPC connection details for initialization", "blue")) |
|||
rpc_connection = tuilib.def_credentials(chain) |
|||
rpclib.getinfo(rpc_connection) |
|||
# waiting until chain is in sync |
|||
while True: |
|||
have_blocks = rpclib.getinfo(rpc_connection)["blocks"] |
|||
longest_chain = rpclib.getinfo(rpc_connection)["longestchain"] |
|||
if have_blocks != longest_chain: |
|||
print(tuilib.colorize("ROGUE not synced yet.", "red")) |
|||
print("Have " + str(have_blocks) + " from " + str(longest_chain) + " blocks") |
|||
time.sleep(5) |
|||
else: |
|||
print(tuilib.colorize("Chain is synced!", "green")) |
|||
break |
|||
# checking if pubkey is set and set valid if not |
|||
info = rpclib.getinfo(rpc_connection) |
|||
if "pubkey" in info.keys(): |
|||
print("Pubkey is already set") |
|||
else: |
|||
valid_address = rpc_connection.getaccountaddress("") |
|||
valid_pubkey = rpc_connection.validateaddress(valid_address)["pubkey"] |
|||
rpc_connection.setpubkey(valid_pubkey) |
|||
print(tuilib.colorize("Pubkey is succesfully set!", "green")) |
|||
# copy ROGUE config to current daemon directory if it's not here |
|||
tuilib.check_if_config_is_here(rpc_connection, "ROGUE") |
|||
except Exception: |
|||
print(tuilib.colorize("Cant connect to ROGUE daemon RPC! Please check if daemon is up.", "pink")) |
|||
tuilib.exit() |
|||
else: |
|||
print(tuilib.colorize("Succesfully connected!\n", "green")) |
|||
with (open("lib/logo.txt", "r")) as logo: |
|||
for line in logo: |
|||
print(line, end='') |
|||
time.sleep(0.04) |
|||
print("\n") |
|||
break |
|||
main() |
@ -0,0 +1,96 @@ |
|||
#!/usr/bin/env python3 |
|||
|
|||
from lib import rpclib, tuilib |
|||
import os |
|||
import time |
|||
import sys |
|||
import platform |
|||
|
|||
header = "\ |
|||
_____ _ _ ______\n\ |
|||
|_ _| | | (_) | _ \n\ |
|||
| | ___| |_ _ __ _ ___| | | |__ _ _ __ _ __\n\ |
|||
| |/ _ \ __| '__| / __| | | / _` | '_ \| '_ \\\n\ |
|||
| | __/ |_| | | \__ \ |/ / (_| | |_) | |_) |\n\ |
|||
\_/\___|\__|_| |_|___/___/ \__,_| .__/| .__/\n\ |
|||
| | | |\n\ |
|||
|_| |_|" |
|||
|
|||
|
|||
menuItems = [ |
|||
{"Check current connection": tuilib.getinfo_tui}, |
|||
{"Check mempool": tuilib.print_mempool}, |
|||
{"Start singleplayer tetris game (creating, registering and starting game)": tuilib.rogue_newgame_singleplayer}, |
|||
{"Exit": tuilib.exit} |
|||
] |
|||
|
|||
|
|||
def main(): |
|||
while True: |
|||
operating_system = platform.system() |
|||
if operating_system != 'Win64' and operating_system != 'Windows': |
|||
os.system('clear') |
|||
else: |
|||
os.system('cls') |
|||
print(tuilib.colorize(header, 'pink')) |
|||
print(tuilib.colorize('TUI v0.0.3\n', 'green')) |
|||
menu_items_counter = 0 |
|||
for item in menuItems: |
|||
print(tuilib.colorize("[" + str(menuItems.index(item)) + "] ", 'blue') + list(item.keys())[0]) |
|||
choice = input(">> ") |
|||
try: |
|||
if int(choice) < 0: |
|||
raise ValueError |
|||
# Call the matching function |
|||
if list(menuItems[int(choice)].keys())[0] == "Exit": |
|||
list(menuItems[int(choice)].values())[0]() |
|||
elif list(menuItems[int(choice)].keys())[0] == "Start singleplayer tetris game (creating, registering and starting game)": |
|||
list(menuItems[int(choice)].values())[0](rpc_connection, False) |
|||
else: |
|||
list(menuItems[int(choice)].values())[0](rpc_connection) |
|||
except (ValueError, IndexError): |
|||
pass |
|||
|
|||
|
|||
if __name__ == "__main__": |
|||
while True: |
|||
chain = "GTEST" |
|||
try: |
|||
print(tuilib.colorize("Welcome to the Tetris TUI!\n" |
|||
"Please provide asset chain RPC connection details for initialization", "blue")) |
|||
rpc_connection = tuilib.def_credentials(chain) |
|||
rpclib.getinfo(rpc_connection) |
|||
# waiting until chain is in sync |
|||
while True: |
|||
have_blocks = rpclib.getinfo(rpc_connection)["blocks"] |
|||
longest_chain = rpclib.getinfo(rpc_connection)["longestchain"] |
|||
if have_blocks != longest_chain: |
|||
print(tuilib.colorize("GTEST not synced yet.", "red")) |
|||
print("Have " + str(have_blocks) + " from " + str(longest_chain) + " blocks") |
|||
time.sleep(5) |
|||
else: |
|||
print(tuilib.colorize("Chain is synced!", "green")) |
|||
break |
|||
# checking if pubkey is set and set valid if not |
|||
info = rpclib.getinfo(rpc_connection) |
|||
if "pubkey" in info.keys(): |
|||
print("Pubkey is already set") |
|||
else: |
|||
valid_address = rpc_connection.getaccountaddress("") |
|||
valid_pubkey = rpc_connection.validateaddress(valid_address)["pubkey"] |
|||
rpc_connection.setpubkey(valid_pubkey) |
|||
print(tuilib.colorize("Pubkey is succesfully set!", "green")) |
|||
# copy ROGUE config to current daemon directory if it's not here |
|||
tuilib.check_if_config_is_here(rpc_connection, "GTEST") |
|||
except Exception: |
|||
print(tuilib.colorize("Cant connect to GTEST daemon RPC! Please check if daemon is up.", "pink")) |
|||
tuilib.exit() |
|||
else: |
|||
print(tuilib.colorize("Succesfully connected!\n", "green")) |
|||
with (open("lib/logo.txt", "r")) as logo: |
|||
for line in logo: |
|||
print(line, end='') |
|||
time.sleep(0.04) |
|||
print("\n") |
|||
break |
|||
main() |
Loading…
Reference in new issue