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>
This commit is contained in:
Rusty Russell 2017-08-18 14:13:52 +09:30
parent dbfac68c3f
commit 253b3e679e
1 changed files with 6 additions and 1 deletions

View File

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