From 904ef32459af18054b61067d9c1a79e1f362f76f Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 5 Jun 2015 17:06:50 +0930 Subject: [PATCH] bitcoin_tx: handle \n at end of file for tx. Signed-off-by: Rusty Russell --- bitcoin_tx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bitcoin_tx.c b/bitcoin_tx.c index 87dffc39f..fd3e505ef 100644 --- a/bitcoin_tx.c +++ b/bitcoin_tx.c @@ -275,9 +275,11 @@ struct bitcoin_tx *bitcoin_tx_from_file(const tal_t *ctx, if (!hex) err(1, "Opening %s", filename); - len = hex_data_size(tal_count(hex)-1); + if (strends(hex, "\n")) + hex[strlen(hex)-1] = '\0'; + len = hex_data_size(strlen(hex)); p = linear_tx = tal_arr(hex, u8, len); - if (!hex_decode(hex, tal_count(hex)-1, linear_tx, len)) + if (!hex_decode(hex, strlen(hex), linear_tx, len)) errx(1, "Bad hex string in %s", filename); tx = pull_bitcoin_tx(ctx, &p, &len);