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

Don't enforce owned values be written in legacy TLV writing #3648

Conversation

TheBlueMatt
Copy link
Collaborator

When writing legacy TLVs, we use a lambda that returns an Option over a specified type. To avoid implicit type confusion issues, we explicitly check that that lambda writes an Option<Type>. However, we may wish to occasionally write an Option<&Type> to avoid unnecessary allocations.

Here we replace the explicit type confusion check with a verification by reading the written contents back explicitly using the specified Type. This should catch most cases of type confusion as we will generally end up writing a different number of bytes.

When writing legacy TLVs, we use a lambda that returns an `Option`
over a specified type. To avoid implicit type confusion issues, we
explicitly check that that lambda writes an `Option<Type>`.
However, we may wish to occasionally write an `Option<&Type>` to
avoid unnecessary allocations.

Here we replace the explicit type confusion check with a
verification by reading the written contents back explicitly using
the specified Type. This should catch most cases of type confusion
as we will generally end up writing a different number of bytes.
@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Mar 5, 2025

I've assigned @wpaulino as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@ldk-reviews-bot ldk-reviews-bot requested a review from wpaulino March 5, 2025 14:40
@ldk-reviews-bot
Copy link

👋 The first review has been submitted!

Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer.

@ldk-reviews-bot ldk-reviews-bot requested a review from arik-so March 5, 2025 15:53
@ldk-reviews-bot
Copy link

✅ Added second reviewer: @arik-so

@TheBlueMatt TheBlueMatt merged commit f4a20fd into lightningdevkit:main Mar 5, 2025
26 of 27 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.

4 participants