refactor __init__ functions of Wallets (funding sources)

- better error messages when a conf variable is not provided
- unify approaches among different source files
This commit is contained in:
Pavol Rusnak
2024-01-22 10:06:22 -06:00
parent a3b7c76523
commit 824a8fa7c8
12 changed files with 131 additions and 69 deletions
+12 -4
View File
@@ -20,15 +20,23 @@ class OpenNodeWallet(Wallet):
"""https://developers.opennode.com/"""
def __init__(self):
endpoint = settings.opennode_api_endpoint
self.key = (
if not settings.opennode_api_endpoint:
raise ValueError(
"cannot initialize OpenNodeWallet: missing opennode_api_endpoint"
)
key = (
settings.opennode_key
or settings.opennode_admin_key
or settings.opennode_invoice_key
)
if not endpoint or not self.key:
raise Exception("cannot initialize opennode")
if not key:
raise ValueError(
"cannot initialize OpenNodeWallet: "
"missing opennode_key or opennode_admin_key or opennode_invoice_key"
)
self.key = key
endpoint = settings.opennode_api_endpoint
self.endpoint = endpoint[:-1] if endpoint.endswith("/") else endpoint
headers = {
"Authorization": self.key,