monero-ecosystem / monero-python

A comprehensive Python module for handling Monero cryptocurrency
BSD 3-Clause "New" or "Revised" License
246 stars 80 forks source link

Default backends for Daemon and Wallet #79

Closed jeffro256 closed 3 years ago

jeffro256 commented 3 years ago

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')
jeffro256 commented 3 years ago

This PR is backwards-compatible.

jeffro256 commented 3 years ago

I updated the docs. How does it look?

emesik commented 3 years ago

Good! I'll elaborate a bit more on replacable backends, perhaps creating another chapter on that.