OnchainInvoice: make get_amount_sat return 0 instead of None. fixes #6203
This commit is contained in:
@@ -125,8 +125,8 @@ class OnchainInvoice(Invoice):
|
|||||||
assert len(self.outputs) == 1
|
assert len(self.outputs) == 1
|
||||||
return self.outputs[0].address
|
return self.outputs[0].address
|
||||||
|
|
||||||
def get_amount_sat(self) -> Union[int, str, None]:
|
def get_amount_sat(self) -> Union[int, str]:
|
||||||
return self.amount_sat
|
return self.amount_sat or 0
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_bip70_payreq(cls, pr: 'PaymentRequest') -> 'OnchainInvoice':
|
def from_bip70_payreq(cls, pr: 'PaymentRequest') -> 'OnchainInvoice':
|
||||||
|
|||||||
@@ -1671,7 +1671,7 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
|
|||||||
status = self.lnworker.get_payment_status(bfh(r.rhash)) if self.lnworker else PR_UNKNOWN
|
status = self.lnworker.get_payment_status(bfh(r.rhash)) if self.lnworker else PR_UNKNOWN
|
||||||
else:
|
else:
|
||||||
assert isinstance(r, OnchainInvoice)
|
assert isinstance(r, OnchainInvoice)
|
||||||
paid, conf = self.get_payment_status(r.get_address(), r.amount_sat)
|
paid, conf = self.get_payment_status(r.get_address(), r.get_amount_sat())
|
||||||
status = PR_PAID if paid else PR_UNPAID
|
status = PR_PAID if paid else PR_UNPAID
|
||||||
return self.check_expired_status(r, status)
|
return self.check_expired_status(r, status)
|
||||||
|
|
||||||
@@ -1712,10 +1712,9 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
|
|||||||
else:
|
else:
|
||||||
assert isinstance(x, OnchainInvoice)
|
assert isinstance(x, OnchainInvoice)
|
||||||
amount_sat = x.get_amount_sat()
|
amount_sat = x.get_amount_sat()
|
||||||
assert isinstance(amount_sat, (int, str, type(None)))
|
|
||||||
d['amount_sat'] = amount_sat
|
|
||||||
addr = x.get_address()
|
addr = x.get_address()
|
||||||
paid, conf = self.get_payment_status(addr, x.amount_sat)
|
paid, conf = self.get_payment_status(addr, amount_sat)
|
||||||
|
d['amount_sat'] = amount_sat
|
||||||
d['address'] = addr
|
d['address'] = addr
|
||||||
d['URI'] = self.get_request_URI(x)
|
d['URI'] = self.get_request_URI(x)
|
||||||
if conf is not None:
|
if conf is not None:
|
||||||
|
|||||||
Reference in New Issue
Block a user