mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-01 09:45:18 +00:00
invoices: always validate that LNInvoice.invoice can be decoded
related: #6559 The LNInvoice.from_json() method previously did not validate, which is used by e.g. wallet.import_invoices.
This commit is contained in:
parent
9d2ede8796
commit
261ad804ca
2 changed files with 6 additions and 1 deletions
|
@ -149,6 +149,10 @@ class LNInvoice(Invoice):
|
||||||
|
|
||||||
__lnaddr = None
|
__lnaddr = None
|
||||||
|
|
||||||
|
@invoice.validator
|
||||||
|
def check(self, attribute, value):
|
||||||
|
lndecode(value) # this checks the str can be decoded
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _lnaddr(self) -> LnAddr:
|
def _lnaddr(self) -> LnAddr:
|
||||||
if self.__lnaddr is None:
|
if self.__lnaddr is None:
|
||||||
|
|
|
@ -1036,7 +1036,8 @@ def validate_features(features: int) -> None:
|
||||||
if (1 << fbit) & LN_FEATURES_IMPLEMENTED == 0 and fbit % 2 == 0:
|
if (1 << fbit) & LN_FEATURES_IMPLEMENTED == 0 and fbit % 2 == 0:
|
||||||
raise UnknownEvenFeatureBits(fbit)
|
raise UnknownEvenFeatureBits(fbit)
|
||||||
if not features.validate_transitive_dependecies():
|
if not features.validate_transitive_dependecies():
|
||||||
raise IncompatibleOrInsaneFeatures("not all transitive dependencies are set")
|
raise IncompatibleOrInsaneFeatures(f"not all transitive dependencies are set. "
|
||||||
|
f"features={features}")
|
||||||
|
|
||||||
|
|
||||||
def derive_payment_secret_from_payment_preimage(payment_preimage: bytes) -> bytes:
|
def derive_payment_secret_from_payment_preimage(payment_preimage: bytes) -> bytes:
|
||||||
|
|
Loading…
Add table
Reference in a new issue