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
+11 -3
View File
@@ -20,14 +20,22 @@ from .base import (
class LnTipsWallet(Wallet):
def __init__(self):
endpoint = settings.lntips_api_endpoint
if not settings.lntips_api_endpoint:
raise ValueError(
"cannot initialize LnTipsWallet: missing lntips_api_endpoint"
)
key = (
settings.lntips_api_key
or settings.lntips_admin_key
or settings.lntips_invoice_key
)
if not endpoint or not key:
raise Exception("cannot initialize lntxbod")
if not key:
raise ValueError(
"cannot initialize LnTipsWallet: "
"missing lntips_api_key or lntips_admin_key or lntips_invoice_key"
)
endpoint = settings.lntips_api_endpoint
self.endpoint = endpoint[:-1] if endpoint.endswith("/") else endpoint
headers = {
"Authorization": f"Basic {key}",