コード例 #1
0
ファイル: accounts.py プロジェクト: christianbrb/raiden
    def pubkey(self) -> Optional[PublicKey]:
        """The account's public key or `None` if the account is locked"""
        if not self.locked:
            assert self.privkey is not None
            return privatekey_to_publickey(self.privkey)

        return None
コード例 #2
0
def test_privatekey_to_publickey():
    privkey = sha3(b"secret")
    pubkey = (
        "c283b0507c4ec6903a49fac84a5aead951f3c38b2c72b69da8a70a5bac91e9c"
        "705f70c7554b26e82b90d2d1bbbaf711b10c6c8b807077f4070200a8fb4c6b771")

    assert pubkey == privatekey_to_publickey(privkey).hex()
コード例 #3
0
ファイル: accounts.py プロジェクト: zointblackbriar/raiden
    def pubkey(self) -> Optional[PublicKey]:
        """The account's public key or `None` if the account is locked"""
        if not self.locked:
            assert self.privkey is not None, "`privkey` not set, maybe call `unlock` before."
            return privatekey_to_publickey(self.privkey)

        return None
コード例 #4
0
def eth_node_config(node_pkey: bytes, p2p_port: Port, rpc_port: Port,
                    **extra_config: Any) -> Dict[str, Any]:
    address = privatekey_to_address(node_pkey)
    pub = privatekey_to_publickey(node_pkey).hex()

    config = extra_config.copy()
    config.update({
        "nodekey": node_pkey,
        "nodekeyhex": remove_0x_prefix(encode_hex(node_pkey)),
        "pub": pub,
        "address": address,
        "port": p2p_port,
        "rpcport": rpc_port,
        "enode": f"enode://{pub}@127.0.0.1:{p2p_port}",
    })

    return config
コード例 #5
0
def test_account_from_keystore():
    keystore = dict(KEYSTORE)
    account = Account(keystore)
    assert account.locked
    assert account.privkey is None
    assert account.uuid == KEYSTORE["id"]
    assert account.address == decode_hex(KEYSTORE["address"])

    with pytest.raises(ValueError):
        account.unlock("wrong-password")
    assert account.locked

    account.unlock(PASSWORD)
    account.unlock("wrong-password")  # ignored as the account is not locked
    assert not account.locked
    assert account.privkey == PRIVKEY
    assert account.pubkey == privatekey_to_publickey(PRIVKEY)

    account.lock()
    assert account.locked
    assert account.privkey is None
    assert account.pubkey is None