All the SDK is now tested via our extensive test suite, we now gurantee to find all changes in electrum if they happen.
All the code is now following our code style.
Features
Async/sync support in one library
Before, `rdwv` and `rdwv-async` packages existed, one providing sync API, another one async API.
Now both use cases are supported in a single `rdwv` package.
You can use either:
python
btc.help()
Or
python
async def main():
await btc.help()
Better exceptions
It is now possible to catch specific exceptions in commands, not just a general one.
python
from rdwv import errors
from rdwv.errors import generate_exception, ConnectionFailedError
try:
coin.help()
except ConnectionFailedError:
print("Failed connecting to daemon")
except errors.LoadingWalletError:
print("Error loading wallet")
except RequestError as e:
print(e)
New `ConnectionFailedError` is raised when SDK failed to connect to daemon.
`UnknownError` is raised when server returned an error code not from the spec, or spec failed loading.
`RequestError` is a base error from all errors returned from server.
generate_exception function creates a new dynamic exception by passing it's name to it, used for except.
`generate_exception("test") == errors.test`
errors object is just a convenience wrapper around `generate_exception`.
All other errors are raised and created dynamically, by the spec.
You can find your version of the spec at daemon's `/spec` endpoint.
[Most recent spec url](https://github.com/rdwvcc/rdwv/blob/master/daemons/spec/btc.json)
APIManager
APIManager provides an easy-to-use interface to manage multiple wallets/currencies.
It is useful for tracking payments on many wallets at once, for example.
[APIManager documentation](https://sdk.rdwvcc.com/en/latest/apimanager.html)
New utilities
New module `rdwv.utils` was added.
It has the following functions:
- `satoshis(amount: Decimal) -> int` converts btc amount to satoshis
- `bitcoins(amount: int) -> Decimal` converts satoshis amount to btc
- `json_encode(obj: Any) -> Any` `json.dumps` supporting decimals
New list_peers method
`list_peers(gossip=False)` method will list all the lightning peers.
COINS variable
Now `COINS` variable is available, it's a dict, where keys are strings, values are coins of respective types.
It allows introspection of available coins.
python
from rdwv import COINS
COINS["BTC"] rdwv.BTC class
Coins instances now can be compared
You can now check if two coin instances are the same like so:
python
if coin1 == coin2:
print("equal")
Two coin objects are equal, if their xpubs are equal, and their `coin_name` is equal.
All methods now support passing Decimals to it
It is needed to work with latest breaking changes, see below.