mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-03 22:34:21 +01:00
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:
@@ -22,6 +22,7 @@
|
||||
#include "funding.h"
|
||||
#include "version.h"
|
||||
#include "bitcoin/locktime.h"
|
||||
#include "tx_from_file.h"
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "find_p2sh_out.h"
|
||||
#include "bitcoin/locktime.h"
|
||||
#include "version.h"
|
||||
#include "tx_from_file.h"
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "protobuf_convert.h"
|
||||
#include "version.h"
|
||||
#include "bitcoin/locktime.h"
|
||||
#include "tx_from_file.h"
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <time.h>
|
||||
#include "opt_bits.h"
|
||||
#include "version.h"
|
||||
#include "tx_from_file.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
21
test-cli/tx_from_file.c
Normal file
21
test-cli/tx_from_file.c
Normal 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;
|
||||
}
|
||||
7
test-cli/tx_from_file.h
Normal file
7
test-cli/tx_from_file.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef LIGHTNING_TEST_CLI_TX_FROM_FILE_H
|
||||
#define LIGHTNING_TEST_CLI_TX_FROM_FILE_H
|
||||
#include "config.h"
|
||||
#include "bitcoin/tx.h"
|
||||
|
||||
struct bitcoin_tx *bitcoin_tx_from_file(const tal_t *ctx, const char *filename);
|
||||
#endif /* LIGHTNING_TEST_CLI_TX_FROM_FILE_H */
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <ccan/err/err.h>
|
||||
#include "bitcoin/tx.h"
|
||||
#include "version.h"
|
||||
#include "tx_from_file.h"
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
||||
Reference in New Issue
Block a user