def sweep_their_htlctx_justice(
        chan: 'Channel',
        ctx: Transaction,
        htlc_tx: Transaction,
) -> Dict[str, SweepInfo]:
    """Creates justice transactions for every output in the HTLC transaction.
    Due to anchor type channels it can happen that a remote party batches HTLC transactions,
    which is why this method can return multiple SweepInfos.
    """
    x = extract_ctx_secrets(chan, ctx)
    if not x:
        return {}
    ctn, their_pcp, is_revocation, per_commitment_secret = x
    if not is_revocation:
        return {}

    # get HTLC constraints (secrets and locktime)
    pcp = ecc.ECPrivkey(per_commitment_secret).get_public_key_bytes(compressed=True)
    this_conf, other_conf = get_ordered_channel_configs(chan=chan, for_us=False)
    other_revocation_privkey = derive_blinded_privkey(
        other_conf.revocation_basepoint.privkey,
        per_commitment_secret)
    to_self_delay = other_conf.to_self_delay
    this_delayed_pubkey = derive_pubkey(this_conf.delayed_basepoint.pubkey, pcp)
    revocation_pubkey = ecc.ECPrivkey(other_revocation_privkey).get_public_key_bytes(compressed=True)
    # uses the same witness script as to_local
    witness_script = make_commitment_output_to_local_witness_script(
        revocation_pubkey, to_self_delay, this_delayed_pubkey)
    htlc_address = redeem_script_to_address('p2wsh', witness_script)
    # check that htlc transaction contains at least an output that is supposed to be
    # spent via a second stage htlc transaction
    htlc_outputs_idxs = [idx for idx, output in enumerate(htlc_tx.outputs()) if output.address == htlc_address]
    if not htlc_outputs_idxs:
        return {}

    # generate justice transactions
    def justice_txin(output_idx):
        return sweep_htlctx_output(
            output_idx=output_idx,
            htlc_tx=htlc_tx,
            htlctx_witness_script=witness_script,
            privkey=other_revocation_privkey,
            is_revocation=True,
        )
    index_to_sweepinfo = {}
    for output_idx in htlc_outputs_idxs:
        if txin := justice_txin(output_idx):
            prevout = htlc_tx.txid() + f':{output_idx}'
            index_to_sweepinfo[prevout] = SweepInfo(
                name=f'second-stage-htlc:{output_idx}',
                cltv_abs=None,
                txin=txin,
                txout=None,
                can_be_batched=False,
            )
    return index_to_sweepinfo
Creates justice transactions for every output in the HTLC transaction.
    Due to anchor type channels it can happen that a remote party batches HTLC transactions,
    which is why this method can return multiple SweepInfos.
    
electrum/lnsweep.py