Browse Source

bitcoin/tx: use NULL for empty input scripts, not a zero-len array.

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 <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
parent
commit
253b3e679e
  1. 7
      bitcoin/tx.c

7
bitcoin/tx.c

@ -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);
}

Loading…
Cancel
Save