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:
@@ -30,15 +30,17 @@ class UnknownError(Exception):
|
||||
|
||||
class EclairWallet(Wallet):
|
||||
def __init__(self):
|
||||
url = settings.eclair_url
|
||||
passw = settings.eclair_pass
|
||||
if not url or not passw:
|
||||
raise Exception("cannot initialize eclair")
|
||||
if not settings.eclair_url:
|
||||
raise ValueError("cannot initialize EclairWallet: missing eclair_url")
|
||||
if not settings.eclair_pass:
|
||||
raise ValueError("cannot initialize EclairWallet: missing eclair_pass")
|
||||
|
||||
url = settings.eclair_url
|
||||
self.url = url[:-1] if url.endswith("/") else url
|
||||
self.ws_url = f"ws://{urllib.parse.urlsplit(self.url).netloc}/ws"
|
||||
|
||||
encodedAuth = base64.b64encode(f":{passw}".encode())
|
||||
password = settings.eclair_pass
|
||||
encodedAuth = base64.b64encode(f":{password}".encode())
|
||||
auth = str(encodedAuth, "utf-8")
|
||||
self.headers = {
|
||||
"Authorization": f"Basic {auth}",
|
||||
|
||||
Reference in New Issue
Block a user