Esempio n. 1
0
    def load_node_json(self):
        if not path.exists("node_data.json"):
            create_file = open("node_data.json", "x")
            create_file.close()
        read_file = open("node_data.json", "r")
        raw = read_file.read()
        if len(raw) == 0:
            addr = Address()
            add_data = addr.export()
            my_node = {**add_data, 'address': addr.get_public_address()}
            write_file = open("node_data.json", 'w')
            write_file.write(json.dumps(my_node))
            write_file.close()

            return my_node
        else:
            try:
                my_node = json.loads(raw)
                return my_node
            except ValueError:
                print(
                    'Error: The json is malformed in node_data.json. Please fix the file or delete it.\n(Note: Deleting this file will cause your node main wallet signing key to be lost.)'
                )
                exit()
            read_file.close()
Esempio n. 2
0
from trucoin.Address import Address
add = Address()
pub_address = add.get_public_address()
keys = add.export()
print(pub_address)
print(keys)