From f7f7f3f1bb55fb491255baf9a44181b968a576dd Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 5 Jun 2015 06:32:11 +0930 Subject: [PATCH] check-anchor-scriptsigs: don't require txs. It's convenient to double-check that commit txs spend anchor, but it's misleading since we wouldn't have access to the other side's tx, and in practice we wouldn't even sign ours until we need it. Signed-off-by: Rusty Russell --- check-anchor-scriptsigs.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/check-anchor-scriptsigs.c b/check-anchor-scriptsigs.c index 8485ff729..49765055a 100644 --- a/check-anchor-scriptsigs.c +++ b/check-anchor-scriptsigs.c @@ -1,6 +1,6 @@ /* My example: - * ./check-anchor-scriptsigs A-open.pb B-open.pb A-anchor-scriptsigs.pb B-anchor-scriptsigs.pb A-commit.tx B-commit.tx > A-anchor.tx - * ./check-anchor-scriptsigs B-open.pb A-open.pb B-anchor-scriptsigs.pb A-anchor-scriptsigs.pb B-commit.tx A-commit.tx > B-anchor.tx + * ./check-anchor-scriptsigs A-open.pb B-open.pb A-anchor-scriptsigs.pb B-anchor-scriptsigs.pb > A-anchor.tx + * ./check-anchor-scriptsigs B-open.pb A-open.pb B-anchor-scriptsigs.pb A-anchor-scriptsigs.pb > B-anchor.tx */ #include #include @@ -27,7 +27,7 @@ int main(int argc, char *argv[]) const tal_t *ctx = tal_arr(NULL, char, 0); OpenChannel *o1, *o2; OpenAnchorScriptsigs *ss1, *ss2; - struct bitcoin_tx *anchor, *commit1, *commit2; + struct bitcoin_tx *anchor; struct sha256_double txid; u8 *tx_arr; size_t *inmap, *outmap; @@ -36,13 +36,13 @@ int main(int argc, char *argv[]) err_set_progname(argv[0]); opt_register_noarg("--help|-h", opt_usage_and_exit, - " \n" + " \n" "Output the anchor transaction by merging the scriptsigs", "Print this message."); opt_parse(&argc, argv, opt_log_stderr_exit); - if (argc != 7) + if (argc != 5) opt_usage_exit_fail("Expected 6 arguments"); o1 = pkt_from_file(argv[1], PKT__PKT_OPEN)->open; @@ -51,8 +51,6 @@ int main(int argc, char *argv[]) ->open_anchor_scriptsigs; ss2 = pkt_from_file(argv[4], PKT__PKT_OPEN_ANCHOR_SCRIPTSIGS) ->open_anchor_scriptsigs; - commit1 = bitcoin_tx_from_file(ctx, argv[5]); - commit2 = bitcoin_tx_from_file(ctx, argv[6]); anchor = anchor_tx_create(ctx, o1, o2, &inmap, &outmap); if (!anchor) @@ -62,13 +60,6 @@ int main(int argc, char *argv[]) bitcoin_txid(anchor, &txid); - /* Now check that the txid is spent by the commitment txs we created */ - assert(commit1->input_count == 1 && commit2->input_count == 1); - if (!structeq(&txid, &commit1->input[0].txid)) - errx(1, "%s doesn't spend this anchor", argv[5]); - if (!structeq(&txid, &commit2->input[0].txid)) - errx(1, "%s doesn't spend this anchor", argv[6]); - /* Print it out in hex. */ tx_arr = linearize_tx(ctx, anchor); tx_hex = tal_arr(tx_arr, char, hex_str_size(tal_count(tx_arr)));