-
Notifications
You must be signed in to change notification settings - Fork 385
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
Make CounterpartyCommitmentSecrets public #1299
Make CounterpartyCommitmentSecrets public #1299
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1299 +/- ##
==========================================
- Coverage 90.51% 90.49% -0.02%
==========================================
Files 71 71
Lines 39012 39012
==========================================
- Hits 35310 35304 -6
- Misses 3702 3708 +6
Continue to review full report at Codecov.
|
12d5dc2
to
8fdf255
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM aside from the wrong link.
lightning/src/ln/chan_utils.rs
Outdated
/// Can only fail if idx is < get_min_seen_secret | ||
pub(crate) fn get_secret(&self, idx: u64) -> Option<[u8; 32]> { | ||
/// Returns the secret at index `idx`. | ||
/// Returns `None` if idx is < [CounterpartyCommitmentSecrets::get_min_secret]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that CI is failing cause this link is bad - its get_min_seen_secret
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed sorry, I doubled check locally it should be good now 🤞
8fdf255
to
76cb45c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some nits on the doc style
lightning/src/ln/chan_utils.rs
Outdated
@@ -197,7 +200,9 @@ impl CounterpartyCommitmentSecrets { | |||
res | |||
} | |||
|
|||
pub(crate) fn provide_secret(&mut self, idx: u64, secret: [u8; 32]) -> Result<(), ()> { | |||
/// Inserts the secret `secret` at index `idx`. Returns Ok(()) if the secret |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can leave off the leading non-ticked words "secret" and "index". Likewise elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done I hope I got them all
lightning/src/ln/chan_utils.rs
Outdated
@@ -197,7 +200,9 @@ impl CounterpartyCommitmentSecrets { | |||
res | |||
} | |||
|
|||
pub(crate) fn provide_secret(&mut self, idx: u64, secret: [u8; 32]) -> Result<(), ()> { | |||
/// Inserts the secret `secret` at index `idx`. Returns Ok(()) if the secret |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add ticks around Ok(())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
lightning/src/ln/chan_utils.rs
Outdated
/// Can only fail if idx is < get_min_seen_secret | ||
pub(crate) fn get_secret(&self, idx: u64) -> Option<[u8; 32]> { | ||
/// Returns the secret at index `idx`. | ||
/// Returns `None` if idx is < [CounterpartyCommitmentSecrets::get_min_seen_secret]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use ticks around identifiers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done (I think it was only idx
on second line missing?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also: [`CounterpartyCommitmentSecrets::get_min_seen_secret`]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed thanks, need to read up more on doc formatting.
lightning/src/ln/chan_utils.rs
Outdated
@@ -173,7 +174,9 @@ impl CounterpartyCommitmentSecrets { | |||
48 | |||
} | |||
|
|||
pub(crate) fn get_min_seen_secret(&self) -> u64 { | |||
/// Return the minimum index of all stored secrets. Note that indexes start |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/Return/Returns
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
76cb45c
to
131cb8c
Compare
lightning/src/ln/chan_utils.rs
Outdated
@@ -140,10 +140,10 @@ pub fn build_closing_transaction(to_holder_value_sat: u64, to_counterparty_value | |||
/// Implements the per-commitment secret storage scheme from | |||
/// [BOLT 3](https://github.com/lightningnetwork/lightning-rfc/blob/dcbf8583976df087c79c3ce0b535311212e6812d/03-transactions.md#efficient-per-commitment-secret-storage). | |||
/// | |||
/// Allows us to keep track of all of the revocation secrets of counterarties in just 50*32 bytes | |||
/// Allows us to keep track of all of the revocation secrets of counter parties in just 50*32 bytes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI fixed a typo here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
counterparty
is one word, not two, so I believe counterparties
would be correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed, my spellchecker didn't like counterparties
I guess I'll have to teach him :)
131cb8c
to
23b32ef
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
heh, one more nit, but feel free to ignore it, it doesn't matter that much.
lightning/src/ln/chan_utils.rs
Outdated
@@ -140,10 +140,10 @@ pub fn build_closing_transaction(to_holder_value_sat: u64, to_counterparty_value | |||
/// Implements the per-commitment secret storage scheme from | |||
/// [BOLT 3](https://github.com/lightningnetwork/lightning-rfc/blob/dcbf8583976df087c79c3ce0b535311212e6812d/03-transactions.md#efficient-per-commitment-secret-storage). | |||
/// | |||
/// Allows us to keep track of all of the revocation secrets of counterarties in just 50*32 bytes | |||
/// Allows us to keep track of all of the revocation secrets of counterparties in just 50*32 bytes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, lol, this shoulnd't be plural anyway. s/counterparties/our counterparty/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed :)
23b32ef
to
b901df2
Compare
b901df2
to
ba289b8
Compare
I'm working on implementation and specifications of DLC channels (not on LN for now) and I thought it'd be a good idea to reuse the secret commitment scheme, and thus would like to reuse the
CounterpartyCommitmentSecrets
struct in my code.I mainly added some comments, let me know if something is off.