Browse Source

fix #6859: height is must be passed to OnchainInvoice constructor

master
ThomasV 5 years ago
parent
commit
b08f9f3581
  1. 3
      electrum/invoices.py
  2. 5
      electrum/wallet.py

3
electrum/invoices.py

@ -128,7 +128,7 @@ class OnchainInvoice(Invoice):
return self.amount_sat or 0 return self.amount_sat or 0
@classmethod @classmethod
def from_bip70_payreq(cls, pr: 'PaymentRequest') -> 'OnchainInvoice': def from_bip70_payreq(cls, pr: 'PaymentRequest', height:int) -> 'OnchainInvoice':
return OnchainInvoice( return OnchainInvoice(
type=PR_TYPE_ONCHAIN, type=PR_TYPE_ONCHAIN,
amount_sat=pr.get_amount(), amount_sat=pr.get_amount(),
@ -139,6 +139,7 @@ class OnchainInvoice(Invoice):
exp=pr.get_expiration_date() - pr.get_time(), exp=pr.get_expiration_date() - pr.get_time(),
bip70=pr.raw.hex(), bip70=pr.raw.hex(),
requestor=pr.get_requestor(), requestor=pr.get_requestor(),
height=height,
) )
@attr.s @attr.s

5
electrum/wallet.py

@ -704,8 +704,9 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
} }
def create_invoice(self, *, outputs: List[PartialTxOutput], message, pr, URI) -> Invoice: def create_invoice(self, *, outputs: List[PartialTxOutput], message, pr, URI) -> Invoice:
height=self.get_local_height()
if pr: if pr:
return OnchainInvoice.from_bip70_payreq(pr) return OnchainInvoice.from_bip70_payreq(pr, height)
if '!' in (x.value for x in outputs): if '!' in (x.value for x in outputs):
amount = '!' amount = '!'
else: else:
@ -728,7 +729,7 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
exp=exp, exp=exp,
bip70=None, bip70=None,
requestor=None, requestor=None,
height=self.get_local_height(), height=height,
) )
return invoice return invoice

Loading…
Cancel
Save