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

wally_psbt_from_bytes() is difficult to use #188

Open
rustyrussell opened this issue May 15, 2020 · 0 comments
Open

wally_psbt_from_bytes() is difficult to use #188

rustyrussell opened this issue May 15, 2020 · 0 comments

Comments

@rustyrussell
Copy link
Contributor

It does not tell the caller how many bytes it actually used, which is problematic if you're reading from a stream.

We work around this by calling wally_psbt_to_bytes() again!

Also, looking through the implementation, I am not convinced that you don't read past the end of the buffer in various cases. The usual way of handling this is to have all your internal demarshal functions take a "unsigned char **cursor, size_t *max", rather than having explicit length checks.

This has the strong advantage that you can simply continue demarshaling even if you run over the end, and just do the checks at the end.

See: https://github.com/ElementsProject/lightning/blob/master/wire/fromwire.c

@rustyrussell rustyrussell changed the title wally_psbt_from_bytes() is almost unusable wally_psbt_from_bytes() is difficult to use May 15, 2020
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

No branches or pull requests

1 participant