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

commitment: fix pointer comparison of family keys #53

Merged
merged 1 commit into from
Jun 29, 2022

Conversation

bhandras
Copy link
Member

This PR fixes a bug where we compared pointers of family keys instead of their equivalency when creating asset commitments.

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.

Found that issue as well, I think I commented on it in #46. Cool to have this fixed!

asset/asset.go Outdated
// IsEqual returns true if this family key is equivalent to the passed other
// family key.
func (f *FamilyKey) IsEqual(otherFamilyKey *FamilyKey) bool {
return f.Key.IsEqual(&otherFamilyKey.Key) &&
Copy link
Member

Choose a reason for hiding this comment

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

Could move the nil checks here, since in Golang you don't run into a nil reference issue when you call this method on a nil pointer (only when you de-reference something like f.Key or otherFamilyKey.Key).

Copy link
Member Author

@bhandras bhandras Jun 29, 2022

Choose a reason for hiding this comment

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

ptal, also ended up a bit more complicated as I forgot to rebase and the FamilyKey changed slightly.

@bhandras
Copy link
Member Author

Found that issue as well, I think I commented on it in #46. Cool to have this fixed!

Ah, missed your comment sorry. Should I close this so we fix this bug in that PR?

@guggero
Copy link
Member

guggero commented Jun 29, 2022

Ah, it was actually here: #27 (comment)

No, I think it's fine to have this as a separate PR.

Signed-off-by: Andras Banki-Horvath <bhandras@gmail.com>
Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

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

LGTM 🌍

@@ -81,7 +81,7 @@ func parseCommon(assets ...*asset.Asset) (*AssetCommitment, error) {
assetFamilyKey := assets[0].FamilyKey
assetsMap := make(map[[32]byte]*asset.Asset, len(assets))
for _, asset := range assets {
if assetFamilyKey != asset.FamilyKey {
Copy link
Member

Choose a reason for hiding this comment

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

Nice catch! I think this was introduced when a change the family keys to be a nested struct, instead of just a normal btcec.PublicKey.

@Roasbeef Roasbeef merged commit 6a79abf into lightninglabs:main Jun 29, 2022
@bhandras bhandras deleted the family-key-mismatch-fix branch June 29, 2022 18:14
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

3 participants