Esempio n. 1
0
def createAccount():
    ACC = Account.create("RANDOMSTRINGTOINCREASETHEENTROPYOFTHEHASH!")
    print(term.SUCCESS + "Account public key: " + ACC.address)
    print(term.SENSITIVE + "Account PRIVATE KEY: " + ACC.privateKey.hex(),
          end=2 * "\n")

    return ACC
Esempio n. 2
0
 def get_random_eth_account():
     global pre_eth_acc
     if pre_eth_acc:
         acc = EthAccount(pre_eth_acc)
         pre_eth_acc = None
         return acc
     return EthAccount(Account.create())
Esempio n. 3
0
    def createAccount(self):
        self._master_gui.password_box1("Provide password for the key-store.")
        password = self._master_gui.blockFace.password
        self._master_gui.password_box1("Verify password for the key-store.")

        if (password != self._master_gui.blockFace.password):
            self._master_gui.error_box1("Passwords don't match")
            return

        account = Account.create()
        keystore = account.encrypt(password)
        if (self.keystore_name.get() == self.keystore_name_default):
            self.keystore_name.set(
                "new_keystore_" + datetime.now().strftime("%d-%m-%Y-%H:%M:%S"))
        try:
            print(self.keystore_name.get())
            with open("Key_Stores" + os.path.sep + self.keystore_name.get(),
                      'w') as handle:
                json.dump(keystore, handle)
            self._master_gui.message_box1(
                'Account created',
                'Address:\n' + account.address + '\n\nKeystore location:\n' +
                os.getcwd() + os.path.sep + "Key_Stores" + os.path.sep +
                '\n\nKeystore name:\n' + self.keystore_name.get())
            self.keystore_name.set(self.keystore_name_default)
        except Exception as err:
            self._master_gui.error_box1(err)
Esempio n. 4
0
def gen_eth_addr2():
    account = Account.create()

    priv_key = '0x' + str(binascii.hexlify(account.key), 'utf-8')

    print(priv_key)

    print(account.address)
def create_acc():
    acc = Account.create()
    # password = "******"
    keyfile_json = Account.encrypt(acc.privateKey, password)
    t = time.time()
    secondstr = str(time.time())[:9]
    timestr = time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime(t))
    filename = "UTC--" + timestr + "." + secondstr + "Z--" + str(acc.address[2:]).lower()
    file_path = fileroot + filename
    with open(file_path, "w") as f:
        json.dump(keyfile_json, f)
    return acc.address
Esempio n. 6
0
def generate_keystore(keystore_path: str, private_key: str):
    if path.exists(keystore_path):
        raise click.BadOptionUsage(  # type: ignore
            "--keystore-file", f"The file {keystore_path} does already exist!"
        )

    if private_key:
        account = Account.from_key(private_key)
    else:
        account = Account.create()

    password = click.prompt(
        "Please enter the password to encrypt the keystore",
        type=str,
        hide_input=True,
        confirmation_prompt=True,
    )
    keystore = account.encrypt(password=password)

    with open(keystore_path, "w") as file:
        file.write(json.dumps(keystore))
        file.close()

    click.echo(f"Stored keystore for {account.address} at {keystore_path}")
def get_rand_account():
    return Account.create()
    print('Default contract greeting: {}'.format(
        queue.functions.greet().call()))

    return w3, queue


def add_patient_to_queue(patient):
    tx_hash = queue.functions.enqueue(patient).transact()
    w3.eth.waitForTransactionReceipt(tx_hash)


def read_all_patient():
    patients = []
    lenght = queue.functions.lenght().call()
    print(lenght)

    for i in range(lenght + 1):
        patients.append(queue.functions.get_patient(i).call())

    return patients


w3, queue = connect_to_blockchain()

w3.eth.defaultAccount = w3.eth.accounts[0]
Account.create()

add_patient_to_queue("Damian")
add_patient_to_queue("Kasia")
print(read_all_patient())
Esempio n. 9
0
def get_rand_account():
    acc = Account.create()
    return acc