|
25 | 25 |
|
26 | 26 |
|
27 | 27 | class Account: |
28 | | - """ |
29 | 28 |
|
30 | | - The Convex account class, contains the public/private keys and possibly an address. |
| 29 | + def __init__(self, private_key, address=None): |
| 30 | + """ |
31 | 31 |
|
32 | | - You can create a new account object, it will only have it's public/private keys but does not have a valid account address. |
33 | | - To obtain a new account address, you need to call the :py:meth:`.ConvexAPI.create_account` with the new account object. |
| 32 | + Create a new account with a private key as a Ed25519PrivateKey. It is better to use |
| 33 | + one of the following static methods to create an Account object: |
34 | 34 |
|
35 | | - This is so that you can use the same public/private keys for multiple convex accounts. |
| 35 | + * :meth:`.create` |
| 36 | + * :meth:`import_from_bytes` |
| 37 | + * :meth:`import_from_file` |
| 38 | + * :meth:`import_from_mnemonic` |
| 39 | + * :meth:`import_from_text` |
36 | 40 |
|
37 | | - Once you have your new account you need to save the public/private keys using the `export..` methods and also you |
38 | | - need to save the account address. |
| 41 | + :param Ed25519PrivateKey private_key: The public/private key as an Ed25519PrivateKey object |
39 | 42 |
|
40 | | - To re-use the account again, you can import the keys and set the account address using one of the `import..` methods. |
| 43 | + :param int address: address of the account |
41 | 44 |
|
42 | | - **Note** |
43 | | - For security reasons all of the keys, and text returned by the accounts are only truncated ending with a **`...`** |
44 | 45 |
|
45 | | - .. code-block:: python |
| 46 | + The Convex account class, contains the public/private keys and possibly an address. |
46 | 47 |
|
47 | | - >>> # import convex-api |
48 | | - >>> from convex_api import ConvexAPI |
| 48 | + You can create a new account object, it will only have it's public/private keys but does not have a valid account address. |
| 49 | + To obtain a new account address, you need to call the :py:meth:`.ConvexAPI.create_account` with the new account object. |
49 | 50 |
|
50 | | - >>> # setup the network connection |
51 | | - >>> convex_api = ConvexAPI('https://convex.world') |
| 51 | + This is so that you can use the same public/private keys for multiple convex accounts. |
52 | 52 |
|
53 | | - >>> # create a new account and address |
54 | | - >>> account = convex_api.create_account() |
| 53 | + Once you have your new account you need to save the public/private keys using the `export..` methods and also you |
| 54 | + need to save the account address. |
55 | 55 |
|
56 | | - >>> # export the private key to a file |
57 | | - >>> account.export_to_file('/tmp/my_account.pem', 'my secret password') |
| 56 | + To re-use the account again, you can import the keys and set the account address using one of the `import..` methods. |
58 | 57 |
|
59 | | - >>> # save the address for later |
60 | | - >>> my_address = account.address |
| 58 | + **Note** |
| 59 | + For security reasons all of the keys, and text returned by the accounts are only truncated ending with a **`...`** |
61 | 60 |
|
62 | | - >>> # ---- |
| 61 | + .. code-block:: python |
63 | 62 |
|
64 | | - >>> # now import the account and address for later use |
65 | | - >>> reload_account = Account.import_from_file('/tmp/my_account.pem', 'my secret password', my_address) |
| 63 | + >>> # import convex-api |
| 64 | + >>> from convex_api import ConvexAPI |
66 | 65 |
|
67 | | - """ |
68 | | - def __init__(self, private_key, address=None): |
69 | | - """ |
| 66 | + >>> # setup the network connection |
| 67 | + >>> convex_api = ConvexAPI('https://convex.world') |
70 | 68 |
|
71 | | - Create a new account with a private key as a Ed25519PrivateKey. It is better to use |
72 | | - one of the `create` or `import` methods instead of creating this object directly. |
| 69 | + >>> # create a new account and address |
| 70 | + >>> account = convex_api.create_account() |
73 | 71 |
|
74 | | - :param Ed25519PrivateKey private_key: The public/private key as an Ed25519PrivateKey object |
| 72 | + >>> # export the private key to a file |
| 73 | + >>> account.export_to_file('/tmp/my_account.pem', 'my secret password') |
75 | 74 |
|
76 | | - :param int address: address of the account |
| 75 | + >>> # save the address for later |
| 76 | + >>> my_address = account.address |
77 | 77 |
|
| 78 | + >>> # ---- |
78 | 79 |
|
| 80 | + >>> # now import the account and address for later use |
| 81 | + >>> reload_account = Account.import_from_file('/tmp/my_account.pem', 'my secret password', my_address) |
79 | 82 |
|
80 | 83 | """ |
81 | 84 | self._private_key = private_key |
|
0 commit comments