From dd7b3c78e493e1cfe0e64c8afb0a25ccd2618946 Mon Sep 17 00:00:00 2001 From: Piper Merriam Date: Wed, 7 Sep 2016 13:33:00 -0600 Subject: [PATCH] personal API documented --- docs/index.rst | 2 +- docs/web3.db.rst | 7 --- docs/web3.eth.rst | 9 ++-- docs/web3.main.rst | 4 -- docs/web3.personal.rst | 96 +++++++++++++++++++++++++++++++++++++++++- docs/web3.shh.rst | 33 ++++++++++++++- web3/personal.py | 4 +- 7 files changed, 136 insertions(+), 19 deletions(-) delete mode 100644 docs/web3.db.rst diff --git a/docs/index.rst b/docs/index.rst index a762ef1..9337a9c 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -15,7 +15,7 @@ Contents quickstart overview conventions - web3 + web3.main web3.eth web3.db web3.shh diff --git a/docs/web3.db.rst b/docs/web3.db.rst deleted file mode 100644 index 7d2a01d..0000000 --- a/docs/web3.db.rst +++ /dev/null @@ -1,7 +0,0 @@ -DB API -====== - -.. py:class:: DB - -The ``web3.db`` object exposes methods to interact with the RPC APIs under the -``db_`` namespace. diff --git a/docs/web3.eth.rst b/docs/web3.eth.rst index 8811efd..adf6a05 100644 --- a/docs/web3.eth.rst +++ b/docs/web3.eth.rst @@ -1,6 +1,9 @@ Eth API ======= +.. py:module:: web3.eth +.. py:currentmodule:: web3.eth + .. py:class:: Eth The ``web3.eth`` object exposes the following properties and methods to @@ -10,7 +13,7 @@ interact with the RPC APIs under the ``eth_`` namespace. Properties ---------- -The following properties are available on the ``web3.eth`` object. +The following properties are available on the ``web3.eth`` namespace. .. py:attribute:: Eth.defaultAccount @@ -119,7 +122,7 @@ The following properties are available on the ``web3.eth`` object. Methods ------- -The following methods are available on the ``web3.eth`` object. +The following methods are available on the ``web3.eth`` namespace. .. py:method:: Eth.getBalance(account, block_identifier=eth.defaultBlock) @@ -225,7 +228,7 @@ The following methods are available on the ``web3.eth`` object. .. py:method:: Eth.getUncle(block_identifier) - .. attention:: Not Implemented + .. note:: Not Implemented .. py:method:: Eth.getTransaction(transaction_hash) diff --git a/docs/web3.main.rst b/docs/web3.main.rst index 8ac404e..8ae1830 100644 --- a/docs/web3.main.rst +++ b/docs/web3.main.rst @@ -124,10 +124,6 @@ Each ``web3`` instance also exposes these namespaced APIs. See :doc:`./web3.eth` -.. py:attribute:: Web3.db - - See :doc:`./web3.db` - .. py:attribute:: Web3.shh See :doc:`./web3.shh` diff --git a/docs/web3.personal.rst b/docs/web3.personal.rst index bbb806f..008b118 100644 --- a/docs/web3.personal.rst +++ b/docs/web3.personal.rst @@ -1,7 +1,101 @@ Personal API ============ -.. py:class:: DB +.. py:module:: web3.personal + +.. py:class:: Personal The ``web3.personal`` object exposes methods to interact with the RPC APIs under the ``personal_`` namespace. + + +Properties +---------- + +The following properties are available on the ``web3.personal`` namespace. + +.. py:attribute:: listAccounts + + * Delegates to ``personal_listAccounts`` RPC Method + + Returns the list of known accounts. + + .. code-block:: python + + >>> web3.personal.listAccounts + ['0xd3cda913deb6f67967b99d67acdfa1712c293601'] + + +Methods +------- + +The following methods are available on the ``web3.personal`` namespace. + +.. py:method:: importRawKey(self, private_key, passphrase) + + * Delegates to ``personal_importRawKey`` RPC Method + + Adds the given ``private_key`` to the node's keychain, encrypted with the + given ``passphrase``. Returns the address of the imported account. + + .. code-block:: python + + >>> web3.personal.importRawKey(some_private_key, 'the-passphrase') + ['0xd3cda913deb6f67967b99d67acdfa1712c293601'] + + +.. py:method:: newAccount(self, password=None) + + * Delegates to ``personal_newAccount`` RPC Method + + Generates a new account in the node's keychain encrypted with the + given ``passphrase``. Returns the address of the created account. + + .. code-block:: python + + >>> web3.personal.newAccount('the-passphrase') + ['0xd3cda913deb6f67967b99d67acdfa1712c293601'] + + +.. py:method:: signAndSendTransaction(self, tx, passphrase) + + * Delegates to ``personal_signAndSendTransaction`` RPC Method + + Signs and sends the given ``transaction`` without requiring the ``from`` + account to be unlocked. ``passphrase`` must be the passphrase for the + ``from`` account for the provided ``transaction``. + + Behaves in the same manner as + :py:method::`web3.eth.Eth.sendTransaction(transaction)`. + + .. code-block:: python + + >>> web3.personal.signAndSendTransaction({'to': '0xd3cda913deb6f67967b99d67acdfa1712c293601', 'from': web3.eth.coinbase, 'value': 12345}, 'the-passphrase') + '0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331' + + +.. py:method:: lockAccount(self, account) + + * Delegates to ``personal_lockAccount`` RPC Method + + Locks the given ``account``. + + .. code-block:: python + + >>> web3.personal.lockAccount('0xd3cda913deb6f67967b99d67acdfa1712c293601') + + +.. py:method:: unlockAccount(self, account, passphrase, duration=None) + + * Delegates to ``personal_unlockAccount`` RPC Method + + Unlocks the given ``account`` for ``duration`` seconds. If ``duration`` is + ``None`` then the account will remain unlocked indefinitely. Returns + boolean as to whether the account was successfully unlocked. + + .. code-block:: python + + >>> web3.personal.unlockAccount('0xd3cda913deb6f67967b99d67acdfa1712c293601', 'wrong-passphrase') + False + >>> web3.personal.unlockAccount('0xd3cda913deb6f67967b99d67acdfa1712c293601', 'the-passphrase') + True diff --git a/docs/web3.shh.rst b/docs/web3.shh.rst index a132572..c16a515 100644 --- a/docs/web3.shh.rst +++ b/docs/web3.shh.rst @@ -1,7 +1,38 @@ SHH API ======= -.. py:class:: DB +.. py:module:: web3.shh +.. py:class:: Shh The ``web3.shh`` object exposes methods to interact with the RPC APIs under the ``shh_`` namespace. + +Methods +------- + +The following methods are available on the ``web3.personal`` namespace. + + +.. py:method:: Shh.post(self, *args, **kwargs) + + .. note:: Not Implemented + + +.. py:method:: Shh.newIdentity(self, *args, **kwargs) + + .. note:: Not Implemented + + +.. py:method:: Shh.hasIdentity(self, *args, **kwargs) + + .. note:: Not Implemented + + +.. py:method:: Shh.newGroup(self, *args, **kwargs) + + .. note:: Not Implemented + + +.. py:method:: Shh.addToGroup(self, *args, **kwargs) + + .. note:: Not Implemented diff --git a/web3/personal.py b/web3/personal.py index d577472..a77e30c 100644 --- a/web3/personal.py +++ b/web3/personal.py @@ -49,11 +49,11 @@ class Personal(object): def getListAccounts(self, *args, **kwargs): raise NotImplementedError("Async calling has not been implemented") - def signAndSendTransaction(self, tx, passphrase): + def signAndSendTransaction(self, transaction, passphrase): return self.request_manager.request_blocking( # "personal_sendTransaction", "personal_signAndSendTransaction", - [tx, passphrase], + [transaction, passphrase], ) def lockAccount(self, account):