import json from grapheneapi import GrapheneWebsocket, GrapheneWebsocketProtocol import time import config import subprocess from time import gmtime, strftime from producer1 import producer1 from producer2 import producer2 # # # rpc = GrapheneWebsocket("localhost", 8092, "", "") def unlockWallet(): if config.feed_script_active == True or config.switching_active == True: print("unlocking wallet") time.sleep(5) rpc.unlock(config.wallet_password) time.sleep(1) def closeScreens(): print("closing wallet") subprocess.call(["screen","-S","local-wallet","-p","0","-X","quit"]) time.sleep(2) print("closing witness") subprocess.call(["screen","-S","witness","-p","0","-X","quit"]) time.sleep(2)
# Request to Faucet headers = {'content-type': 'text/plain'} query = "refcode[code]=%s&refcode[account]=%s&refcode[asset_symbol]=%s&refcode[asset_amount]=%s&refcode[send_to]=%s" % ( ref_code, from_account["name"], amount_asset["symbol"], op["amount"]["amount"], email) print("--- query: %s" % query) response = requests.post(config.faucet_url, params=query, headers=headers) if __name__ == '__main__': ## Monitor definitions protocol = GrapheneMonitor protocol.last_op = config.last_op ## last operation logged protocol.account_id = "1.2.%s" % config.accountID.split(".")[ 2] ## account to monitor ## Open Up Graphene Websocket API api = GrapheneWebsocket(config.host, config.port, config.user, config.password, protocol) print(api) ## Set Callback for object changes api.setObjectCallbacks({config.accountID: protocol.onAccountUpdate}) ## Run the Websocket connection continuously api.connect() api.run_forever()
# Print out print("last_op: %s | block:%s | from %s -> to: %s | fee: %f %s | amount: %f %s | memo: %s" % ( opID, block, from_account["name"], to_account["name"], fee_amount, fee_asset["symbol"], amount_amount, amount_asset["symbol"], memomsg)) if __name__ == '__main__': ## RPC connections host = "localhost" port = 8090 user = "" password = "" ## Monitor definitions protocol = GrapheneMonitor protocol.last_op = last_op ## last operation logged protocol.account_id = "1.2.%s" % accountID.split(".")[2] ## account to monitor ## Open Up Graphene Websocket API api = GrapheneWebsocket(host, port, user, password, protocol) ## Set Callback for object changes api.setObjectCallbacks({accountID : protocol.onAccountUpdate}) ## Run the Websocket connection continuously api.connect() api.run_forever()
wallet_password = "******" remote_ws = "ws://159.203.246.155:8090" private_active_key = "5JVVeSuCHviTJSY3LKyQJ4t4s4coiVN7qw3M4XzWYQgZ2XzaJu1" witnessname = "test.dele-puppy" producer_number = 2 rpc_port = "8094" wallet_name = "wallet2.json" rpc = GrapheneWebsocket("ws://localhost:%d" % rpc_port, "", "") local_port = "127.0.0.1:" + rpc_port rpc = GrapheneWebsocket("ws://localhost:%d" % rpc_port, "", "") local_port = "127.0.0.1:" + rpc_port def tryProducer(): attempt = 0 while attempt < 5: attempt += 1 print("attempt #" + attempt + " to reconnect to " + wallet_name) subprocess.call([ "screen", "-dmS", wallet_name, path_to_cli_wallet, "-H", local_port, "-s", remote_ws, "-w", "producer2/" + wallet_name, "--chain-id",
try : # if possible privkey = PrivateKey(config.memo_wif_key) pubkey = PublicKey(memo["from"], prefix=prefix) memomsg = Memo.decode_memo(privkey, pubkey, memo["nonce"], memo["message"]) except Exception as e: # if not possible memomsg = "--cannot decode-- %s" % str(e) # Print out print("last_op: %s | block:%s | from %s -> to: %s | fee: %f %s | amount: %f %s | memo: %s" % ( opID, block, from_account["name"], to_account["name"], fee_amount, fee_asset["symbol"], amount_amount, amount_asset["symbol"], memomsg)) if __name__ == '__main__': # Monitor definitions protocol = GrapheneMonitor protocol.last_op = config.last_op # last operation logged protocol.account_id = "1.2.%s" % config.accountID.split(".")[2] # account to monitor # Open Up Graphene Websocket API api = GrapheneWebsocket(config.url, config.user, config.password, protocol) # Set Callback for object changes api.setObjectCallbacks({config.accountID : protocol.onAccountUpdate}) api.setEventCallbacks({"registered-history" : protocol.onAccountUpdate}) # Run the Websocket connection continuously api.connect() api.run_forever()
### witnessname = <the name of your witness> ### publickeys = <tuple of public keys as strings> i.e. ("GPH57pBVHtJzfsZZ117e5dBfaMTJxbfzfZQRFFMVuompRQAidAEwK", "GPH75xxKG4ZeztPpnhmFch99smunUWMvDy9mB6Le497vpAA3XUXaD") must have at least 2 ### strictness = <the number of blocks missed before a new public key is switched to> must be set to 1 or higher. ### emergencykeys = <tuple of emergency public keys as strings> If no emergency nodes are used set emergency keys = 0. If keys are used, must have at least two entries. Can use same key twice if only running single emergency node ### If all public keys fail to produce blocks after two rotations, then emergencykeys will be used. ### If all emergency keys fail to produce blocks after two rotations, then attempt will be made to switch back to primary keys ### If emegergency keys produce blocks attempt will still be made to switch back to primary keys after 30ish minutes import sys import json from grapheneapi import GrapheneWebsocket, GrapheneWebsocketProtocol import time import config rpc = GrapheneWebsocket("localhost", 8092, "", "") ### returns total missed blocks from witnessname def getmissed(witnessname): witness = rpc.get_witness(witnessname) missed = witness["total_missed"] return missed ### work on cleaning up these preliminary variables missed = getmissed(config.witnessname) recentmissed = 0 witness = rpc.get_witness(config.witnessname) lastblock = witness["last_confirmed_block_num"] emergency = False ### switches to next public key after config.strictness missed blocks
remote_ws = "ws://159.203.246.155:8090" private_active_key = "5JVVeSuCHviTJSY3LKyQJ4t4s4coiVN7qw3M4XzWYQgZ2XzaJu1" witnessname = "test.dele-puppy" producer_number = 2 rpc_port = "8094" wallet_name = "wallet2.json" rpc = GrapheneWebsocket("localhost", rpc_port, "", "") local_port = "127.0.0.1:" + rpc_port rpc = GrapheneWebsocket("localhost", rpc_port, "", "") local_port = "127.0.0.1:" + rpc_port def tryProducer(): attempt = 0 while attempt < 5: attempt +=1 print("attempt #" + attempt + " to reconnect to " + wallet_name) subprocess.call(["screen","-dmS",wallet_name,path_to_cli_wallet,"-H",local_port,"-s",remote_ws,"-w","producer2/" + wallet_name,"--chain-id","16362d305df19018476052eed629bb4052903c7655a586a0e0cfbdb0eaf1bfd8"]) ### uncomment this line if running on testnet # subprocess.call(["screen","-dmS",wallet_name,path_to_cli_wallet,"-H",local_port,"-s",remote_ws,"-w","producer2/" + wallet_name"]) ### comment this line out if running on testnet time.sleep(1)
import sys import json from grapheneapi import GrapheneWebsocket, GrapheneWebsocketProtocol import time import config import subprocess from time import gmtime, strftime from producer1 import producer1 from producer2 import producer2 # # # rpc = GrapheneWebsocket("localhost", 8092, "", "") def unlockWallet(): if config.feed_script_active == True or config.switching_active == True: print("unlocking wallet") time.sleep(5) rpc.unlock(config.wallet_password) time.sleep(1) def closeScreens(): print("closing wallet") subprocess.call(["screen", "-S", "local-wallet", "-p", "0", "-X", "quit"]) time.sleep(2) print("closing witness")
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys import json from grapheneapi import GrapheneWebsocket, GrapheneWebsocketProtocol import time import config import subprocess from time import gmtime, strftime rpc = GrapheneWebsocket("localhost", 8092, "", "") def unlockWallet(): if config.feed_script_active == True: print("unlocking wallet") rpc.unlock(config.wallet_password) time.sleep(10) def closeScreens(): print("closing wallet") subprocess.call(["screen","-S","wallet","-p","0","-X","quit"]) time.sleep(2) print("closing witness") subprocess.call(["screen","-S","witness","-p","0","-X","quit"]) time.sleep(2) subprocess.call(["pkill","witness_node"]) time.sleep(2) def openScreens():
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys import json from grapheneapi import GrapheneWebsocket, GrapheneWebsocketProtocol import time import config import subprocess from time import gmtime, strftime rpc = GrapheneWebsocket("ws://localhost:8092", "", "") def unlockWallet(): if config.feed_script_active == True: print("unlocking wallet") rpc.unlock(config.wallet_password) time.sleep(10) def closeScreens(): print("closing wallet") subprocess.call(["screen", "-S", "wallet", "-p", "0", "-X", "quit"]) time.sleep(2) print("closing witness") subprocess.call(["screen", "-S", "witness", "-p", "0", "-X", "quit"]) time.sleep(2) subprocess.call(["pkill", "witness_node"]) time.sleep(2)
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys import json from grapheneapi import GrapheneWebsocket, GrapheneWebsocketProtocol import time import config import subprocess from time import gmtime, strftime rpc = GrapheneWebsocket("localhost", 8092, "", "") def closeScreens(): print("closing wallet") time.sleep(15) # adding this to give some time to ctrl-c before --resync if desired subprocess.call(["screen", "-S", "wallet", "-p", "0", "-X", "quit"]) time.sleep(2) print("closing witness") subprocess.call(["screen", "-S", "witness", "-p", "0", "-X", "quit"]) time.sleep(2) subprocess.call(["pkill", "witness_node"]) time.sleep(2) def openScreens(): print("opening witness") subprocess.call( ["screen", "-dmS", "witness", config.path_to_witness_node, "-d", config.path_to_data_dir, "--replay-blockchain"]
import sys import json from grapheneapi import GrapheneWebsocket, GrapheneWebsocketProtocol import time import config import subprocess from time import gmtime, strftime from producer1 import producer1 from producer2 import producer2 # # # rpc = GrapheneWebsocket("ws://localhost:8092", "", "") def unlockWallet(): if config.feed_script_active == True or config.switching_active == True: print("unlocking wallet") time.sleep(5) rpc.unlock(config.wallet_password) time.sleep(1) def closeScreens(): print("closing wallet") subprocess.call(["screen", "-S", "local-wallet", "-p", "0", "-X", "quit"]) time.sleep(2) print("closing witness")