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

Let ChannelSigner set and spend LN scriptpubkeys #3512

Draft
wants to merge 26 commits into
base: main
Choose a base branch
from

Conversation

tankyleo
Copy link
Contributor

@tankyleo tankyleo commented Jan 8, 2025

This PR allows the customization of different outputs of the commitment transaction, in preparation for taproot channels and also to allow people to set the outputs to arbitrary scripts if they don't require compatibility with the formal LN spec.

My approach is to ask the channel signers to do more work (but not more than that of most hardware wallets):

  • Set the appropriate SPK's for the different outputs of the commitment transaction.
  • Let the various transaction builders know of the expected weight of the witness to spend such an output - the transaction builders can then set appropriate feerates when building the transactions.
  • At spend time, return a transaction with the specified input completely finalized (witness field is fully finalized - previously the EcdsaChannelSigner would return just the signature). I am considering having the ChannelSigner return just the witness here, instead of the full transaction.

This PR assumes that if the scripts in a channel are customized to something outside the LN spec, that channel supports zero fee htlc tx.

I mark it as draft. I understand this is a huge PR. I hope to show the full picture of how the current approach works to get approach ACKs, then happy to break it down into smaller PRs.

Remaining TODOs:

  • Update SpendableOutputDescriptor to accomodate taproot / arbitrary scripts.
  • Finalize EcdsaChannelSigner vs ChannelSigner APIs.
  • Documentation, and more detailed commit msgs.
  • Customize the funding output.
  • Consider asking the ChannelSigner to return just the witness that finalizes the given input, instead of returning the full transaction with the given input finalized.
  • Figure out a mechanism to guide people who want to implement a ChannelSigner inline with the LN spec. One possible route: have the ChannelSigner trait offer "ProvidedMethods" for implementers who want to stay in-line with the LN specification - people who want to depart from the spec would then override these methods.

Supersedes #3454

This allows the `to_remote` output to easily be changed according to the
features of the channel, or the evolution of the LN specification.

`to_remote` could even be set to completely arbitrary scripts if
compatibility with the formal LN spec is not required.
This allows the `to_local` output to easily be changed according to the
features of the channel, or the evolution of the LN specification.

`to_local` could even be set to completely arbitrary scripts if
compatibility with the formal LN spec is not required.
This allows the htlc tx output to easily be changed according to the
features of the channel, or the evolution of the LN specification.

The output could even be set to completely arbitrary scripts if
compatibility with the formal LN spec is not required.

Builders of htlc transactions now ask a `ChannelSigner` for the
appropriate revokeable script pubkey to use, and then pass it to the
htlc transaction constructors.
All LN-Penalty channel signers need to be able to punish the
counterparty in case they broadcast an old state. In this commit, we
ask implementers of `ChannelSigner` to produce the full transaction with
the given input finalized to punish the corresponding previous output.
Consumers of the `ChannelSigner` trait can now be agnostic to the
specific scripts used in revokeable outputs.

We leave passing to the `ChannelSigner` all the previous `TxOut`'s
needed to produce valid schnorr signatures under BIP 341 spending rules
to a later patch.
for the revokeable scripts in the `to_local` and the htlc
tx outputs.
All LN-Penalty channel signers need to be able to punish the
counterparty in case they broadcast an old state. In this commit, we
ask implementers of `ChannelSigner` to produce the full transaction with
the given input finalized to punish the corresponding previous output.
Consumers of the `ChannelSigner` trait can now be agnostic to the
specific scripts used in HTLC outputs of commitment transactions.

We leave passing to the `ChannelSigner` all the previous `TxOut`'s
needed to produce valid schnorr signatures under BIP 341 spending rules
to a later patch.
Add `ChannelSigner::sweep_counterparty_offered_htlc_output`
Add `ChannelSigner::sweep_counterparty_received_htlc_output`
@tankyleo tankyleo force-pushed the 2025-01-signer-spks branch from 508d577 to 5b57776 Compare January 10, 2025 22:54
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.

1 participant