psbt: pass in NULL for script if script_len == 0 - #192
Conversation
|
on second thought, maybe a failure here is desirable behaviour? the current c-lightning implementation abuses the witness-utxo field as a placeholder for the input amount, so in some cases the scriptPubkey is set to NULL. |
|
see BYTES_VALID in transaction.c. that's the usual check in wally. an error is preferable. |
Yes, see #191 |
`wally_tx_output_init_alloc` will fail if the script_len == 0 but the buffer passed in for the script is not NULL; consequently if `script_len` is 0 we should pass in a NULL pointer for the script.
10385e2 to
17a18fc
Compare
Yes I have seen BYTES_VALID, that's the motivation for this patch. 😆 |
|
Hmm, in this case, it's invalid to have a zero-length witness script, so the return is correct (note that #191 has this exact same behavior, despite reworking this code). But that's actually indep of whether script is NULL or not (as it is in this path). |
|
Closing this in favour of #210 which includes/supersedes it. Please re-open if something you need got missed in the merge. |
wally_tx_output_init_allocwill fail if the script_len == 0 but thebuffer passed in for the script is not NULL; consequently if
script_lenis 0 we should pass in a NULL pointer for the script.