You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Without any way of knowing the length to allocate, how do we call wally_psbt_to_bytes?
For the moment, we allocate 1k and loop, doubling each time.
But worse, it returns WALLY_EINVAL for reasons OTHER than "you didn't give enough room".
There are two ways of fixing this:
Expose psbt_get_length(). This is inefficient.
Change the semantics of bytes_written to "bytes_needed", and set it to the number of bytes you want. Then return WALLY_ENOMEM to distinguish from unrelated errors.
The second allows a more optimal implementation in future.
The text was updated successfully, but these errors were encountered:
rustyrussell
changed the title
wally_psbt_to_bytes() is almost unusable.
wally_psbt_to_bytes() difficult to use
May 15, 2020
Change the semantics of bytes_written to "bytes_needed", and set it to the number of bytes you want. Then return WALLY_ENOMEM to distinguish from unrelated errors.
I don't quite understand this. Do you mean that wally_psbt_to_bytes should compute how many bytes are needed and return that if the buffer is big enough (i.e. output the result of psbt_get_length)?
Without any way of knowing the length to allocate, how do we call wally_psbt_to_bytes?
For the moment, we allocate 1k and loop, doubling each time.
But worse, it returns WALLY_EINVAL for reasons OTHER than "you didn't give enough room".
There are two ways of fixing this:
The second allows a more optimal implementation in future.
The text was updated successfully, but these errors were encountered: