tx: centralize transaction writing, append amounts for alpha.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2015-07-01 13:44:31 +09:30
parent 5dc9cd16f9
commit ae31431168
9 changed files with 72 additions and 54 deletions

View File

@@ -4,7 +4,6 @@
#include <ccan/opt/opt.h>
#include <ccan/str/hex/hex.h>
#include <ccan/err/err.h>
#include <ccan/read_write_all/read_write_all.h>
#include "lightning.pb-c.h"
#include "anchor.h"
#include "bitcoin/base58.h"
@@ -26,8 +25,7 @@ int main(int argc, char *argv[])
struct sha256_double anchor_txid;
struct bitcoin_signature sig1, sig2;
struct pubkey pubkey1, pubkey2;
u8 *redeemscript, *tx_arr;
char *tx_hex;
u8 *redeemscript;
CloseChannel *close;
CloseChannelComplete *closecomplete;
size_t i;
@@ -92,11 +90,7 @@ int main(int argc, char *argv[])
close_tx->input[0].script_length = tal_count(close_tx->input[0].script);
/* Print it out in hex. */
tx_arr = linearize_tx(ctx, close_tx);
tx_hex = tal_arr(tx_arr, char, hex_str_size(tal_count(tx_arr)));
hex_encode(tx_arr, tal_count(tx_arr), tx_hex, tal_count(tx_hex));
if (!write_all(STDOUT_FILENO, tx_hex, strlen(tx_hex)))
if (!bitcoin_tx_write(STDOUT_FILENO, close_tx))
err(1, "Writing out transaction");
tal_free(ctx);