Timing of HTLC Transactions: At what point is the HTLC transaction broadcasted on the network? Is it created during the initial setup of the payment channel, or only when the contract is executed?
In normal case (no cheating attempt or someone offline for long time), usually it's when you open and close channel.
Just clarifying this a bit more:
When you create a Lightning channel, you still don't broadcast a HTLC transaction to the Bitcoin network. This means the HTLC will
not be confirmed on-chain when the channel is created.
Instead, both parties create a multisig transaction, called the Funding Transaction, with the funds to be used in the channel, and broadcast it on-chain.
One of the keys to understand the LN workings is that
before the Funding Transaction is broadcast, a set of commitment transactions is exchanged off-chain -- without broadcasting -- between the channel partners, which allow both partners to send their funds back to another address owned by them, and contains the outputs of the Funding Transaction as inputs. This ensures that both partners always have the option to close the channel if the other party doesn't cooperate anymore.
In contrast, the HTLCs are created when a payment is made and the "state" of the channel is changed (including "routings through the channel"). With each payment a new set of HTLCs is exchanged, invalidating the previous set. But they are only exchanged by the channel partners, like the commitment transactions.
HTLCs only need to be broadcast to the Bitcoin network in the case of a conflict.
I personally found it relatively easy to understand reading the
original white paper, but the ebook linked by ABCbits may be much better for a deeper understanding.