# Lightning transactions with v3 and ephemeral anchors

**URL:** <https://delvingbitcoin.org/t/lightning-transactions-with-v3-and-ephemeral-anchors/418>\
**Category:** Protocol Design\
**Tags:** mempool, lightning\
**Created:** [January 16, 2024, 5:28pm UTC](https://delvingbitcoin.org/t/lightning-transactions-with-v3-and-ephemeral-anchors/418 "2024-01-16T17:28:44Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![morehouse](https://delvingbitcoin.org/letter_avatar_proxy/v4/letter/m/df705f/32.png) [@morehouse](https://delvingbitcoin.org/u/morehouse)\
**Post date:** [January 17, 2024, 10:45pm UTC](https://delvingbitcoin.org/t/lightning-transactions-with-v3-and-ephemeral-anchors/418/12 "2024-01-17T22:45:18Z")

</div>

> [@t-bast](#):
>
> ## HTLC transactions
> 
> When using `option_anchors_zero_fee_htlc_tx`, HTLC transactions don’t pay any mining fees: they are signed with `SIGHASH_SINGLE | SIGHASH_ANYONECANPAY` to allow the broadcaster to add inputs. We don’t need to change this behavior, it will keep working exactly the same after changing the format of the commitment transaction. I don’t think we should change anything for HTLC transactions, but maybe I’m missing an interesting opportunity here?

At a minimum, we probably want to make HTLC transactions v3. If we really want to fix pinning, we may also need to make _all_ HTLC spending paths use presigned v3 transactions.

#### Why make HTLC transactions v3?

- v3 allows them to be relayed as part of the commitment package.
- I think v3 also prevents MitM pinning attacks where someone extracts the `SIGHASH_SINGLE | SIGHASH_ANYONECANPAY` signature and uses it to construct and pin a low feerate conflicting transaction.

#### Fixing HTLC pinning

With no other changes, HTLC transactions are still vulnerable to pinning attacks since the remote path can be spent by non-v3 transactions. For example:

1. Alice offers HTLC1 to Mallory, which times out at block T. Alice also offers HTLC2 to Mallory, which times out at block T+5.
2. Mallory has preimages for both HTLCs, but she withholds them.
3. At block T-1, Alice broadcasts her commitment with a single child transaction that spends the ephemeral anchor, Alice’s local balance, and HTLC1 via the presigned HTLC-timeout transaction.
  - Mallory is unable to pin any competing transaction in this case, due to v3 policy.

4. The commitment and child transaction confirm in block T.
5. At block T+4, Alice broadcasts her HTLC-timeout transaction claiming HTLC2. At the same time, Mallory broadcasts a low feerate preimage spend of HTLC2 and pins it in mempools. With good connectivity and timing, Mallory can partition mempools such that Alice’s mempool contains the HTLC-timeout and all other mempools contain the pinned preimage spend.

Because Mallory’s preimage spend can opt out of v3 policy, she is able to pin her transaction in mempools while preventing Alice from learning the preimage or confirming her HTLC-timeout transaction.

One way to fix this pinning vector is to start requiring presigned v3 transactions for HTLC remote spends.

---

_[View the full topic](https://delvingbitcoin.org/t/lightning-transactions-with-v3-and-ephemeral-anchors/418)._
