async def add_hold_invoice(
            self,
            preimage: str,
            amount: Optional[Decimal] = None,
            memo: str = "",
            expiry: int = 3600,
            min_final_cltv_expiry_delta: int = MIN_FINAL_CLTV_DELTA_FOR_INVOICE * 2,
            wallet: Abstract_Wallet = None
    ) -> dict:
        """
        Create a lightning hold invoice for the given preimage. Hold invoices have to get settled manually later.
        HTLCs will get failed automatically if block_height + 144 > htlc.cltv_abs.

        arg:str:preimage:Hex encoded preimage to be used for the invoice
        arg:decimal:amount:Optional requested amount (in btc)
        arg:str:memo:Optional description of the invoice
        arg:int:expiry:Optional expiry in seconds (default: 3600s)
        arg:int:min_final_cltv_expiry_delta:Optional min final cltv expiry delta (default: 294 blocks)
        """
        assert len(preimage) == 64, f"Invalid preimage length: {len(preimage)} != 64"
        payment_hash: str = crypto.sha256(bfh(preimage)).hex()
        assert payment_hash not in wallet.lnworker._preimages, "Preimage already in use!"
        assert payment_hash not in wallet.lnworker.payment_info, "Payment hash already used!"
        assert payment_hash not in wallet.lnworker.dont_settle_htlcs, "Payment hash already used!"
        assert MIN_FINAL_CLTV_DELTA_FOR_INVOICE < min_final_cltv_expiry_delta < 576, "Use a sane min_final_cltv_expiry_delta value"
        amount = amount if amount and satoshis(amount) > 0 else None  # make amount either >0 or None
        inbound_capacity = wallet.lnworker.num_sats_can_receive()
        assert inbound_capacity > satoshis(amount or 0), \
            f"Not enough inbound capacity [{inbound_capacity} sat] to receive this payment"

        lnaddr, invoice = wallet.lnworker.get_bolt11_invoice(
            payment_hash=bfh(payment_hash),
            amount_msat=satoshis(amount) * 1000 if amount else None,
            message=memo,
            expiry=expiry,
            min_final_cltv_expiry_delta=min_final_cltv_expiry_delta,
            fallback_address=None
        )
        wallet.lnworker.add_payment_info_for_hold_invoice(
            bfh(payment_hash),
            satoshis(amount) if amount else None,
        )
        wallet.lnworker.dont_settle_htlcs[payment_hash] = None
        wallet.lnworker.save_preimage(bfh(payment_hash), bfh(preimage))
        wallet.set_label(payment_hash, memo)
        result = {
            "invoice": invoice
        }
        return result

        Create a lightning hold invoice for the given preimage. Hold invoices have to get settled manually later.
        HTLCs will get failed automatically if block_height + 144 > htlc.cltv_abs.

        arg:str:preimage:Hex encoded preimage to be used for the invoice
        arg:decimal:amount:Optional requested amount (in btc)
        arg:str:memo:Optional description of the invoice
        arg:int:expiry:Optional expiry in seconds (default: 3600s)
        arg:int:min_final_cltv_expiry_delta:Optional min final cltv expiry delta (default: 294 blocks)
        
electrum/commands.py