fix: description_hash as an optional param to create_invoice.

fixes https://github.com/lnbits/lnbits/issues/74
This commit is contained in:
fiatjaf
2020-08-30 23:54:50 -03:00
parent 660d56d400
commit 68b0adfe66
11 changed files with 77 additions and 50 deletions
+7 -2
View File
@@ -1,6 +1,7 @@
import random
import requests
from os import getenv
from typing import Optional
from .base import InvoiceResponse, PaymentResponse, PaymentStatus, Wallet
@@ -38,7 +39,9 @@ class SparkWallet(Wallet):
return call
def create_invoice(self, amount: int, memo: str = "", description_hash: bytes = b"") -> InvoiceResponse:
def create_invoice(
self, amount: int, memo: Optional[str] = None, description_hash: Optional[bytes] = None
) -> InvoiceResponse:
label = "lbs{}".format(random.random())
checking_id = label
@@ -48,7 +51,9 @@ class SparkWallet(Wallet):
msatoshi=amount * 1000, label=label, description_hash=description_hash.hex(),
)
else:
r = self.invoice(msatoshi=amount * 1000, label=label, description=memo, exposeprivatechannels=True)
r = self.invoice(
msatoshi=amount * 1000, label=label, description=memo or "", exposeprivatechannels=True
)
ok, payment_request, error_message = True, r["bolt11"], ""
except (SparkError, UnknownError) as e:
ok, payment_request, error_message = False, None, str(e)