From 253b3e679e2b7592bed9347519f7da13f609c46b Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 18 Aug 2017 14:13:52 +0930 Subject: [PATCH] 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 --- bitcoin/tx.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bitcoin/tx.c b/bitcoin/tx.c index b64e901f0..21d4aad2e 100644 --- a/bitcoin/tx.c +++ b/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); }