@staticmethod
def _check_invoice(invoice: str, *, amount_msat: int=None) -> LnAddr:
    addr = lndecode(invoice, expected_hrp=constants.net.SEGWIT_HRP)
    if addr.is_expired():
        raise InvoiceError(_('This invoice has expired'))
    if amount_msat:
        existing_amt_msat = addr.get_amount_msat()
        if (existing_amt_msat and (amount_msat < existing_amt_msat)):
            raise Exception('cannot pay lower amt than what is originally in LN invoice')
        addr.amount = ((Decimal(amount_msat) / COIN) / 1000)
    if (addr.amount is None):
        raise InvoiceError(_('Missing amount'))
    if (addr.get_min_final_cltv_expiry() > lnutil.NBLOCK_CLTV_EXPIRY_TOO_FAR_INTO_FUTURE):
        raise InvoiceError('{}\n{}'.format(_('Invoice wants us to risk locking funds for unreasonably long.'), f'min_final_cltv_expiry: {addr.get_min_final_cltv_expiry()}'))
    return addr
@staticmethod
def _check_invoice(invoice: str, *, amount_msat: int=None) -> LnAddr:
    addr = lndecode(invoice, expected_hrp=constants.net.SEGWIT_HRP)
    if addr.is_expired():
        raise InvoiceError(_('This invoice has expired'))
    if amount_msat:
        existing_amt_msat = addr.get_amount_msat()
        if (existing_amt_msat and (amount_msat < existing_amt_msat)):
            raise Exception('cannot pay lower amt than what is originally in LN invoice')
        addr.amount = ((Decimal(amount_msat) / COIN) / 1000)
    if (addr.amount is None):
        raise InvoiceError(_('Missing amount'))
    if (addr.get_min_final_cltv_expiry() > lnutil.NBLOCK_CLTV_EXPIRY_TOO_FAR_INTO_FUTURE):
        raise InvoiceError('{}\n{}'.format(_('Invoice wants us to risk locking funds for unreasonably long.'), f'min_final_cltv_expiry: {addr.get_min_final_cltv_expiry()}'))
    return addr