Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for taproot outputs to our "input info" class #2895

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

sstone
Copy link
Member

@sstone sstone commented Aug 7, 2024

This is a preparation PR for simple taproot channels, which extends InputInfo to support spending taproot outputs (to spend v0 outputs we need a redeem script, but to spend v1 taproot output we need a script tree and an internal public key).
Changes are generic (i.e. not tied to specific details of the simple taproot channels extension proposal).

@sstone sstone force-pushed the input-info-taproot branch 2 times, most recently from cf583ea to 8e147fb Compare September 10, 2024 16:06
Copy link
Contributor

@remyers remyers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like pretty safe refactors. I just had one scala related question for my own information.

@sstone sstone force-pushed the input-info-taproot branch 2 times, most recently from 4163f0e to e15cb29 Compare October 1, 2024 07:39
@sstone sstone force-pushed the input-info-taproot branch 2 times, most recently from f83f006 to bde8e07 Compare October 15, 2024 13:26
@sstone sstone force-pushed the input-info-taproot branch from bde8e07 to a35921c Compare October 21, 2024 14:37
@sstone
Copy link
Member Author

sstone commented Oct 21, 2024

This PR is now based on #2747

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 88.11594% with 41 lines in your changes missing coverage. Please review.

Project coverage is 86.19%. Comparing base (b8e6800) to head (a35921c).
Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
...in/scala/fr/acinq/eclair/channel/fsm/Channel.scala 84.09% 21 Missing ⚠️
...c/main/scala/fr/acinq/eclair/channel/Helpers.scala 88.88% 6 Missing ⚠️
...la/fr/acinq/eclair/channel/fsm/ErrorHandlers.scala 40.00% 6 Missing ⚠️
...la/fr/acinq/eclair/transactions/Transactions.scala 93.54% 4 Missing ⚠️
...n/scala/fr/acinq/eclair/balance/CheckBalance.scala 0.00% 1 Missing ⚠️
...inq/eclair/channel/fund/InteractiveTxBuilder.scala 66.66% 1 Missing ⚠️
...q/eclair/channel/publish/ReplaceableTxFunder.scala 66.66% 1 Missing ⚠️
...la/fr/acinq/eclair/io/OpenChannelInterceptor.scala 0.00% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2895      +/-   ##
==========================================
- Coverage   86.30%   86.19%   -0.12%     
==========================================
  Files         224      224              
  Lines       19867    20341     +474     
  Branches      795      836      +41     
==========================================
+ Hits        17147    17533     +386     
- Misses       2720     2808      +88     
Files with missing lines Coverage Δ
...core/src/main/scala/fr/acinq/eclair/Features.scala 100.00% <100.00%> (ø)
...in/scala/fr/acinq/eclair/channel/ChannelData.scala 100.00% <100.00%> (ø)
...in/scala/fr/acinq/eclair/channel/Commitments.scala 96.84% <100.00%> (+0.01%) ⬆️
...a/fr/acinq/eclair/channel/fsm/CommonHandlers.scala 89.36% <100.00%> (+4.06%) ⬆️
...air/crypto/keymanager/LocalChannelKeyManager.scala 100.00% <100.00%> (ø)
...n/scala/fr/acinq/eclair/io/PeerReadyNotifier.scala 71.75% <100.00%> (+0.21%) ⬆️
...n/scala/fr/acinq/eclair/json/JsonSerializers.scala 96.42% <ø> (ø)
...ire/internal/channel/version0/ChannelCodecs0.scala 95.85% <100.00%> (+0.02%) ⬆️
...wire/internal/channel/version0/ChannelTypes0.scala 100.00% <100.00%> (ø)
...ire/internal/channel/version1/ChannelCodecs1.scala 98.05% <100.00%> (+0.01%) ⬆️
... and 15 more

... and 7 files with indirect coverage changes

@sstone sstone force-pushed the input-info-taproot branch from a35921c to d560a8c Compare November 26, 2024 13:38
t-bast and others added 9 commits December 6, 2024 17:45
This feature adds two new messages:

- `closing_complete` sent after exchanging `shutdown`
- `closing_sig` sent in response to `closing_complete`
The spec allows the closer to use an OP_RETURN output if their amount is
too low when using `option_simple_close`.
We introduce a new `NEGOTIATING_SIMPLE` state where we exchange the
`closing_complete` and `closing_sig` messages, and allow RBF-ing previous
transactions and updating our closing script.

We stay in that state until one of the transactions confirms, or a force
close is detected. This is important to ensure we're able to correctly
reconnect and negotiate RBF candidates.

We keep this separate from the previous NEGOTIATING state to make it
easier to remove support for the older mutual close protocols once we're
confident the network has been upgraded.
Whenever one side sends `shutdown`, we restart a signing round from
scratch. To be compatible with future taproot channels, we require
the receiver to also send `shutdown` before moving on to exchanging
`closing_complete` and `closing_sig`. This will give nodes a message
to exchange fresh musig2 nonces before producing signatures.

On reconnection, we also restart a signing session from scratch and
discard pending partial signatures.
Whenever we exchange `shutdown`, we now require that new closing txs
are signed before allowing another `shutdown` message to be sent to
start a new signing round.

This creates more risk of deadlock when one side fails to send their
sigs, where we'll need to disconnect to start a new signing round.
But that shouldn't happen if nodes are honest and not buggy, so it
probably doesn't matter. If nodes are buggy or malicious, we will
need to force-close anyway.
Our InputInfo class contains a tx output and the matching redeem script, which is enough to spend segwit v0 transactions.
For taproot transactions, instead of a redeem script, we need a script tree instead, and the appropriate internal pubkey.
Co-authored-by: Pierre-Marie Padiou <[email protected]>
@sstone sstone force-pushed the input-info-taproot branch from d560a8c to 154235d Compare December 9, 2024 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants