def sweep_their_ctx_htlc(
        ctx: Transaction,
        witness_script: bytes,
        preimage: Optional[bytes], output_idx: int,
        privkey: bytes, is_revocation: bool,
        cltv_abs: int,
        has_anchors: bool,
) -> Optional[PartialTxInput]:
    """Deals with normal (non-CSV timelocked) HTLC output sweeps."""
    assert type(cltv_abs) is int
    assert witness_script is not None
    preimage = preimage or b''  # preimage is required iff (not is_revocation and htlc is offered)
    val = ctx.outputs()[output_idx].value
    prevout = TxOutpoint(txid=bfh(ctx.txid()), out_idx=output_idx)
    txin = PartialTxInput(prevout=prevout)
    txin._trusted_value_sats = val
    txin.witness_script = witness_script
    txin.script_sig = b''
    txin.nsequence = 1 if has_anchors else 0xffffffff - 2
    txin.privkey = privkey
    if not is_revocation:
        txin.make_witness = lambda sig: construct_witness([sig, preimage, witness_script])
    else:
        revocation_pubkey = privkey_to_pubkey(privkey)
        txin.make_witness = lambda sig: construct_witness([sig, revocation_pubkey, witness_script])
    return txin
Deals with normal (non-CSV timelocked) HTLC output sweeps.
electrum/lnsweep.py