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

Future ChannelKeys API #606

Open
TheBlueMatt opened this issue Apr 23, 2020 · 3 comments
Open

Future ChannelKeys API #606

TheBlueMatt opened this issue Apr 23, 2020 · 3 comments

Comments

@TheBlueMatt
Copy link
Collaborator

Figured I should document the goal I had in my head for ChannelKeys. I think we should:
a) cache the local keys currently fetched via ChannelKeys::pubkeys() in Channel and ChannelMonitor,
b) only ever have one instance of a ChannelKeys per channel - fetching it during Channel init, shoving it into the created ChannelMonitor (this implies finally removing the channel_monitor from Channel, but we're really close to that), and then moving it into the OnchainTxHandler.
c) Drop the Clone requirement from ChannelKeys (though maybe implementing Clone for ChannelMonitor only if ChannelKeys has it, and documenting this).

@ariard
Copy link

ariard commented Apr 25, 2020

Okay I spend a bit of time on this, I finally agree with you we should store LocalOnchainCommitment and RemoteCommitment in ChannelMonitor, and just have OnchainRequest exchanged between ChannelMonitor and OnchainTxHandler

OnchainRequest {
     aggregation: bool,
     bump_strategy: BumpStrategy::{RBF,CPFP},
     timelock: u32,
     height: u32,
     tx_template: TxTemplate
}
TxTemplate {
       LocalCommitmentTransaction
       PreSignedJusticeTx
       MalleableJusticeTx
       RemoteHTLC
}

I think middle-term OnchainTxHandler should be its own trait to serve other component like splicing/dual-funding. And so with watchtower integration I've something like this in mind

               ___________________________
              |                          |
              |  MultiPartyTxComposition | (dual-funding/splicing)
              |__________________________|
                           |
                           | OnchainRequest
                           |                                   __________________
                           |                                  |                  |
                           |                       |----------|  ChannelMonitor  |--- LocalOnchainCommitment+RemoteCommitment
                           |                       |          |__________________|
                           |                       |                    |
                           |                       |                    |
                           |    OnchainRequest     |           _________|___________
                           |_______________________|          |                     |
                           |                                  | ConfidentialWatcher |
                           |                                  |_____________________|
                  _________V_________
                 |                   |
                 |  OnchainTxHandler |
                 |___________________|
                           ^
                           |
                           |
                           |
                           |
                    _______V______
                   |              |
                   |  ChanSigner  |
                   |______________|

And ConfidentialWatcher would be trait to implement a privacy-preserving watchtower

ConfidentialWatcher::is_channel_commitment(commitment_tx) --> bool
ConfidentialWatcher::get_template_output(commitment_tx.output[i]) --> TxTemplate::{PreSignedTx, MalleableTx}
ConfidentialWatcher::provide_revocation_secret(Secret) // actual stuff
ConfidentialWatcher::provide_bolt13_blob(Blob)

@TheBlueMatt
Copy link
Collaborator Author

Wow, yea, I think at a high level that's the right design, thanks for putting it together! Refactoring the OnchainTxHandler/ConfidentialWatchtower design a bit to share common code for the actual transaction generation I think will also need to happen, but most of those can probably be static functions (though maybe long-term functions on the ChanSigner or some other struct - I think moderately long-term we need to also be thinking about how to let users change the scripts that appear in the transactions themselves).

@ariard
Copy link

ariard commented Apr 26, 2020

Refactoring the OnchainTxHandler/ConfidentialWatchtower design a bit to share common code

Yes of course getting helpers as we have in chan_utils

though maybe long-term functions on the ChanSigner or some other struct - I think moderately long-term we need to also be thinking about how to let users change the scripts that appear in the transactions themselves

Yes, I exactly made the point for in #605 for PTLC experimentation it should be doable to swap scripts in ChanSigner, that way avoid any state machine disruption. We would have to abstract verification too, but that's few lines of changes

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

No branches or pull requests

2 participants