Skip to content

Commit

Permalink
bitcoin/tx: use NULL for empty input scripts, not a zero-len array.
Browse files Browse the repository at this point in the history
The signing code asserts these are NULL, and if we unmarshal from the
wire then sign them, it gets upset.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Aug 20, 2017
1 parent dbfac68 commit 253b3e6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion bitcoin/tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,14 @@ static u64 pull_length(const u8 **cursor, size_t *max)
static void pull_input(const tal_t *ctx, const u8 **cursor, size_t *max,
struct bitcoin_tx_input *input)
{
u64 script_len;
pull_sha256_double(cursor, max, &input->txid);
input->index = pull_le32(cursor, max);
input->script = tal_arr(ctx, u8, pull_length(cursor, max));
script_len = pull_length(cursor, max);
if (script_len)
input->script = tal_arr(ctx, u8, script_len);
else
input->script = NULL;
pull(cursor, max, input->script, tal_len(input->script));
input->sequence_number = pull_le32(cursor, max);
}
Expand Down

0 comments on commit 253b3e6

Please sign in to comment.