bitcoin/tx: move bitcoin_tx_from_file() to test-cli, expose bitcoin_tx_from_hex()

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2016-01-22 06:41:46 +10:30
parent 04fd2c861f
commit 3a803eefbb
10 changed files with 62 additions and 29 deletions

21
test-cli/tx_from_file.c Normal file
View File

@@ -0,0 +1,21 @@
#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);
if (!tx)
err(1, "Failed to decode tx '%s'", hex);
tal_free(hex);
return tx;
}