Skip to content

[group key addrs 3/5]: misc refactor #1611

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

Merged
merged 6 commits into from
Jun 24, 2025
Merged

[group key addrs 3/5]: misc refactor #1611

merged 6 commits into from
Jun 24, 2025

Conversation

guggero
Copy link
Member

@guggero guggero commented Jun 19, 2025

Extracts some refactor commits out from #1587, which are mostly independent of the functionality in that PR and can be reviewed and merged individually.

@coveralls
Copy link

coveralls commented Jun 19, 2025

Pull Request Test Coverage Report for Build 15844222703

Details

  • 61 of 189 (32.28%) changed or added relevant lines in 19 files are covered.
  • 18 unchanged lines in 6 files lost coverage.
  • Overall coverage increased (+0.2%) to 38.419%

Changes Missing Coverage Covered Lines Changed/Added Lines %
tappsbt/interface.go 0 1 0.0%
tapchannel/aux_funding_controller.go 0 2 0.0%
asset/asset.go 0 3 0.0%
rpcutils/marshal.go 0 3 0.0%
key_ring.go 0 4 0.0%
psbt_channel_funder.go 0 4 0.0%
wallet_anchor.go 0 4 0.0%
itest/multisig.go 0 6 0.0%
tapdb/addrs.go 3 19 15.79%
tapgarden/mock.go 0 17 0.0%
Files with Coverage Reduction New Missed Lines %
address/book.go 1 36.14%
address/mock.go 2 96.08%
internal/test/helpers.go 2 86.95%
tapchannel/aux_leaf_signer.go 3 43.43%
asset/asset.go 4 47.09%
asset/mock.go 6 65.45%
Totals Coverage Status
Change from base Build 15838863953: 0.2%
Covered Lines: 29157
Relevant Lines: 75892

💛 - Coveralls

Copy link
Contributor

@ffranr ffranr left a comment

Choose a reason for hiding this comment

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

Easy to review 👍

fn/memory.go Outdated
Comment on lines 98 to 117
// Serializer is an interface that defines a method to serialize data
// into an io.Writer.
type Serializer interface {
Serialize(w io.Writer) error
}

// Serialize encodes the given Serializer into a byte slice.
func Serialize(s Serializer) ([]byte, error) {
if s == nil {
return nil, nil
}

var buf bytes.Buffer
err := s.Serialize(&buf)
if err != nil {
return nil, err
}

return buf.Bytes(), nil
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Drop these in favour of the encode style above? I think that having both in a core package like fn just leads to unnecessary confusion. Fundamental packages like fn provide future dev guidance.

Or perhaps there is some fundamental meaning difference between the terms "encode" and "serialize" that I don't know about? If there is please add to doc comments so that I know what one to use.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe also add a new file called encoding.go to fn to accommodate these changes. From my pov, I don't think they're related to memory.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure what you mean by "in favor of the encoding style above"? These are helper functions to easily convert existing types to bytes. And some types (e.g. wire.MsgTx, psbt.Packet) define a Serialize() method while other types have an Encode() method. And we want to support both.

Moved the definitions to encoding.go.

@guggero guggero force-pushed the misc-refactor branch 2 times, most recently from ec4345c to 81fbf58 Compare June 20, 2025 15:38
@guggero guggero changed the title [group key addrs 3/4]: misc refactor [group key addrs 3/5]: misc refactor Jun 23, 2025
Copy link
Member

@GeorgeTsagk GeorgeTsagk left a comment

Choose a reason for hiding this comment

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

Lgtm 🦫

@GeorgeTsagk GeorgeTsagk added this pull request to the merge queue Jun 23, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jun 23, 2025
guggero added 6 commits June 24, 2025 09:23
This commit adds a helper for serializing/encoding structs that
otherwise require the use of a buffer. In most situations this makes the
code a bit shorter and less repetitive.
We'll need to be able to derive a shared key using ECDH against a wallet
key (while supporting remote signing) for the ECIES encryption in part 4
of the on-chain group key address support PR series.
We can prepare for that by adding the already exising RPC method to the
lnd key ring.
This allows us to use an asset specifier when creating a new address,
which means we also have to be able to look up the asset group info
using a group key.
We can't test this on the RPC layer yet, because we don't actually allow
addresses to be created for group keys only (this will com in part 4 of
the group key address PR series).
@guggero guggero merged commit 49dd668 into main Jun 24, 2025
17 of 18 checks passed
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in Taproot-Assets Project Board Jun 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

5 participants