Skip to content

Added test for testing sciptpubkey of closing message per bolt 2 spec #193

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

Conversation

SWvheerden
Copy link
Contributor

@SWvheerden SWvheerden commented Sep 20, 2018

I added a test to check if the sciptpubkey is either one of the 4 required scriptbupkey's.

I flagged another test, I am not sure if that is not required. I will update the code pending the review.

@@ -2098,7 +2102,7 @@ impl Channel {
if !self.pending_inbound_htlcs.is_empty() || !self.pending_outbound_htlcs.is_empty() {
return Err(HandleError{err: "Remote end sent us a closing_signed while there were still pending HTLCs", action: None});
}
if msg.fee_satoshis > 21000000 * 10000000 {
if msg.fee_satoshis > 21000000 * 10000000 { //is this test required? We check for a much lower amount below, thus if that one will fail, this one will always fail?
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can almost certainly cause an overflow in build_closing_transaction if we dont (which results in a panic in rust in debug mode).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok cwl, wasnt exactly sure, I will leave a comment about this.

@TheBlueMatt
Copy link
Collaborator

I'd actually kinda like to figure out why the BOLT suggests that we check it against an acceptable type. Like, checking the size is definitely useful for fee reasons, but if its within the right size, why should we care what script they want to use?

@SWvheerden
Copy link
Contributor Author

This is the reason they give in the official bolt specs:
The scriptpubkey forms include only standard forms accepted by the Bitcoin network, which ensures the resulting transaction will propagate to miners
Which I guess is valid as you want to make sure the transaction goes through.

@SWvheerden SWvheerden force-pushed the Bolt2-specs-errors-of-closing-messages- branch from 25a6350 to 9f6ce0a Compare September 20, 2018 19:36
//TODO: Check shutdown_scriptpubkey form as BOLT says we must? WHYYY

//Check shutdown_scriptpubkey form as BOLT says we must
if !(msg.scriptpubkey.is_p2pkh())&&!(msg.scriptpubkey.is_p2sh())&&!(msg.scriptpubkey.is_v0_p2wpkh())&&!(msg.scriptpubkey.is_v0_p2wsh()){
Copy link

Choose a reason for hiding this comment

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

nit: adding a space before/after AND operator isn't nicer for code readability ?

@SWvheerden SWvheerden force-pushed the Bolt2-specs-errors-of-closing-messages- branch from f7fff08 to b58bab0 Compare September 21, 2018 08:21

//Check shutdown_scriptpubkey form as BOLT says we must
if !(msg.scriptpubkey.is_p2pkh()) && !(msg.scriptpubkey.is_p2sh())
&& !(msg.scriptpubkey.is_v0_p2wpkh()) && !(msg.scriptpubkey.is_v0_p2wsh()){
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: having the same indentation on the second line of an if as the body looks confusing to me. I usually double-indent this kind of thing, but I've also seen people prefer just an extra linebreak after the {

Copy link
Contributor

Choose a reason for hiding this comment

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

@TheBlueMatt TheBlueMatt merged commit 0112394 into lightningdevkit:master Sep 21, 2018
@SWvheerden SWvheerden deleted the Bolt2-specs-errors-of-closing-messages- branch September 26, 2018 09:35
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.

4 participants