ElementsProject / ElementsProject/libwally-core

wally_psbt_to_bytes() difficult to use

Open
#187 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
307
Forks
159
Avg merge
2h 56m
Merged PRs (30d)
4

Description

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:
1. Expose psbt_get_length(). This is inefficient.
2. 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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.