mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-20 10:39:49 +01:00
3374ddd2a6
Our json parser doesn't use nul-terminated strings. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
22 lines
485 B
C
22 lines
485 B
C
#include "tx_from_file.h"
|
|
#include "bitcoin/tx.h"
|
|
#include <ccan/err/err.h>
|
|
#include <ccan/tal/grab_file/grab_file.h>
|
|
|
|
struct bitcoin_tx *bitcoin_tx_from_file(const tal_t *ctx, const char *filename)
|
|
{
|
|
char *hex;
|
|
struct bitcoin_tx *tx;
|
|
|
|
/* Grabs file, add nul at end. */
|
|
hex = grab_file(ctx, filename);
|
|
if (!hex)
|
|
err(1, "Opening %s", filename);
|
|
|
|
tx = bitcoin_tx_from_hex(ctx, hex, strlen(hex));
|
|
if (!tx)
|
|
err(1, "Failed to decode tx '%s'", hex);
|
|
tal_free(hex);
|
|
return tx;
|
|
}
|