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

Minor Bugfixes and new sweeptimelockmanual logic #63

Merged
merged 2 commits into from Apr 20, 2023

Conversation

ziggie1984
Copy link
Contributor

@ziggie1984 ziggie1984 commented Apr 20, 2023

This PR solves two Things.

  1. The first one is a small bugfix where the forceclose command would crash because a new btcd logic introduced a new logic for the sighashes

  2. The second one is that it adds a more detailed description regarding the shachain generation and also fixes a bug were we would not be able to derive the to_local script in case we opened channels when the old shachain root creation scheme was still active. It also adds tests to verify this new logic.

@ziggie1984 ziggie1984 force-pushed the sweep-tolocal-bugfix branch 2 times, most recently from 28e5e52 to 7314657 Compare April 20, 2023 09:45
Copy link
Member

@guggero guggero left a comment

Choose a reason for hiding this comment

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

Thank you very much for the fix, documentation and test cases!
Looks good, just two small things.

lnd/channel.go Outdated Show resolved Hide resolved
cmd/chantools/sweeptimelockmanual.go Outdated Show resolved Hide resolved
cmd/chantools/sweeptimelockmanual.go Outdated Show resolved Hide resolved
// Now we try to increase the index by 1 to account for the situation
// where the node was started with a version after (including)
// v0.13.0-beta
revPath3 := []uint32{
Copy link
Member

Choose a reason for hiding this comment

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

So this commit doesn't really change anything in the logic, it just changes the order in which things are tried? Increasing the success probability?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The commit changes the logic a bit, in prior versions you tried to increase the index but were using the old shachain root revocation scheme. But this case cannot happen, we need to test the 2 indices exactly with the new shachain root scheme to make sure we account for the case where the node was started with the old scheme and updated. There the new scheme is not 1 off.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Efficiency logic could be added later, but this makes sure we definitely are able to derive the to_local for every channel of a noderunner. Otherwise when a node started with 0.12 and wanted to sweep the to_local output created after updating to 0.13. or later then it would not be able to derive the secrets with the prior chantool version

Copy link
Member

Choose a reason for hiding this comment

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

Ah, now I see it. Thanks a lot for catching this!

cmd/chantools/sweeptimelockmanual_test.go Show resolved Hide resolved
Currently chantools crashes when trying to get the force-close
summary because the new btcd version needs a prevoutInput fetcher
otherwise we get a nil error.
When channel before the new shachain root creation scheme were
created we do not need to increase the idx for the shachain
generation.
// PubKey: (string) (len=5) "<nil>"
//
// For more details:
// https://github.com/lightningnetwork/lnd/commit/bb84f0ebc88620050dec7cf4be6283f5cba8b920
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this breaks the 80 line rule, should I split this comment into 2 lines , looks weird imo with 2 lines?

Copy link
Member

Choose a reason for hiding this comment

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

It's okay, I haven't enabled the line length linter rule in this repo.

Copy link
Member

@guggero guggero left a comment

Choose a reason for hiding this comment

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

Thank you, LGTM 🎉

@guggero guggero merged commit f35a469 into lightninglabs:master Apr 20, 2023
2 checks passed
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.

None yet

2 participants