When I wrote the output code, I made the assumption that if a transaction
was not in the transaction pool then its "output_indices" atrribute would
be present. However, upon further testing I found that for transactions
with 0 outputs, such as at height 202612, the Monero daemon returns a JSON
object with no "output_indices" attribute. This PR should keep a KeyError
from occurring.
If you called daemon.block(height=0) then the expression:
if not height and not bhash:
Is `True` because 0 is falsey. I changed that line to a slightly more wordy, but more accurate:
if height is None and bhash is None:
Tweaks to Commands:
1. Now catches and raises a more descriptive error when the node returns malformed JSON or JSON with non-unicode characters in it.
2. Removed get_txpool_backlog and get_output_distribution because they are actually binary RPC commands in disguise, maybe they can be added later.
3. Improved input validation for start_mining.
4. Catches NOT MINING status in set_log_hash_rate and raises descriptive error.
5. Adds abaility in out_peers and in_peers to set unlimited peers by passing -1 as arg.
6. Make input more intuitive in get_outs.
7. Shortened names of get_all_known_log_levels and get_all_known_log_categories.
8. Other very minor tweaks.
Changes:
1. Added test cases for the JSON_RPC methods (not the old RPC methods)
2. Tweaked a couple of the methods to make input and output more intuitive
Instead of passing a list a specificly crafted dictionaries, you can now
just pass the ip, ban, and seconds parameters each. They can be single
elements or lists of the same size.
Changes:
1. Added a JSONRPCDaemon method for every Monero Daemon RPC Command that is not obsolete or binary.
2. Added a restricted() method to JSONRPCDaemon which returns whether the node is in restricted mode.
3. Added the ability to not pass any POST data to raw_request().
4. Added RestrictedRPC exception to monero/backends/jsonrpc/exceptions.py
5. Added a DaemonIsBusy exception to monero/exceptions.py
Motivation: I wanted to add comprehensive daemon RPC functionality to JSONRPCDaemon, which right now only
supports a handful of all the available commands. While it is possible to perform any RPC command with
raw_request() and raw_jsonrpc_request(), I wanted the user to able to know which commands are available,
what inputs the command takes, what output it gives, and leverage the command's power while knowing the
least amount of implementaton details as possible. The Monero Daemon RPC commands do not necessarily have
the most consistent and simple interface, and that is what this commit brings to the table. The new
methods also have the benefit of local input validation, which allows for fewer, more easily decipherable
bugs for the user.
Note: The vast majority of the lines in this commit are documentation. I tried to be as comprehensive as
possible.
I changed one file: `monero.backends.jsonrpc.daemon` to add one line.
This send the `"prune": True` option along with the `get_transactions` call.
The data that is pruned is not used by the `_do_get_transactions` call but
it can save up to 80% in bandwidth.
* Add `OneTimeOutput` Class
* Add `output_indices` attribute to `Transaction`
* Add `outputs` property to `Transaction`
* `do_get_transactions` now populates `output_indices` with fetched data
* Updated test cases
* Retains backwards compatibility
Future plans:
* Add `inputs` property to `Transaction` which would return list of rings
* Add `TransactionRing` or similar to `transaction.py`
This PR is extremely similar to PR #78. However, it now is based off of the backends refactor
in PR #82.
Changes:
1. Added `OneTimeOutput` class in `transaction.py`
2. Added `output_indices` attribute to `Transaction`
3. Added `outputs` property to `Transaction`
4. Changed `_do_get_transactions` code to populate `output_indices` with fetched data
5. Updated tests
Thanks for your hard work.
If no backend is specified, then the backend defaults to
JSONRPCDaemon and JSONRPCWallet for Daemon and Wallet, respectively.
Also if no backend is specified, then any kwargs passed to Daemon
and Wallet initializers will be used to construct a backend with
the default JSONRPC- backends. This will make using Daemon and
Wallet much more seamless for the user.
The following code snippets are functionally identical:
Old:
```
from monero.daemon import Daemon
from monero.backends.jsonrpc import JSONRPCDaemon
daemon1 = Daemon(JSONRPCDaemon())
daemon2 = Daemon(JSONRPCDaemon(host='node.xmr.to'))
```
New:
```
from monero.daemon import Daemon
daemon1 = Daemon()
daemon2 = Daemon(host='node.xmr.to')
```