Skip to content

Commit

Permalink
Modified fromwire_witscript to return NULL instead of struct w/ NULL …
Browse files Browse the repository at this point in the history
…ptr.
  • Loading branch information
ksedgwic committed Jan 28, 2020
1 parent c1e1634 commit c85c05b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
13 changes: 6 additions & 7 deletions wire/fromwire.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,14 +403,13 @@ struct bitcoin_tx_output *fromwire_bitcoin_tx_output(const tal_t *ctx,

struct witscript *fromwire_witscript(const tal_t *ctx, const u8 **cursor, size_t *max)
{
struct witscript *retval = tal(ctx, struct witscript);
struct witscript *retval;
u16 len = fromwire_u16(cursor, max);
if (len == 0) {
retval->ptr = NULL;
} else {
retval->ptr = tal_arr(retval, u8, len);
fromwire_u8_array(cursor, max, retval->ptr, len);
}
if (!len)
return NULL;
retval = tal(ctx, struct witscript);
retval->ptr = tal_arr(retval, u8, len);
fromwire_u8_array(cursor, max, retval->ptr, len);
return retval;
}

Expand Down
3 changes: 2 additions & 1 deletion wire/towire.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,10 @@ void towire_bitcoin_tx_output(u8 **pptr, const struct bitcoin_tx_output *output)

void towire_witscript(u8 **pptr, const struct witscript *script)
{
if (script == NULL || script->ptr == NULL) {
if (script == NULL) {
towire_u16(pptr, 0);
} else {
assert(script->ptr != NULL);
towire_u16(pptr, tal_count(script->ptr));
towire_u8_array(pptr, script->ptr, tal_count(script->ptr));
}
Expand Down

0 comments on commit c85c05b

Please sign in to comment.