diff --git a/lightningd/closing_control.c b/lightningd/closing_control.c index 33589e28a..fea6dc864 100644 --- a/lightningd/closing_control.c +++ b/lightningd/closing_control.c @@ -55,12 +55,13 @@ static void resolve_one_close_command(struct close_command *cc, bool cooperative) { struct json_stream *result = json_stream_success(cc->cmd); - struct bitcoin_txid txid; - - bitcoin_txid(cc->channel->last_tx, &txid); json_add_tx(result, "tx", cc->channel->last_tx); - json_add_txid(result, "txid", &txid); + if (!invalid_last_tx(cc->channel->last_tx)) { + struct bitcoin_txid txid; + bitcoin_txid(cc->channel->last_tx, &txid); + json_add_txid(result, "txid", &txid); + } if (cooperative) json_add_string(result, "type", "mutual"); else diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index 0b817c5e5..40bb56812 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -220,7 +220,7 @@ static void remove_sig(struct bitcoin_tx *signed_tx) bitcoin_tx_input_set_witness(signed_tx, 0, NULL); } -static bool invalid_last_tx(const struct bitcoin_tx *tx) +bool invalid_last_tx(const struct bitcoin_tx *tx) { /* This problem goes back further, but was discovered just before the * 0.7.1 release. */ diff --git a/lightningd/peer_control.h b/lightningd/peer_control.h index 3f69729b1..4e9eb5b5d 100644 --- a/lightningd/peer_control.h +++ b/lightningd/peer_control.h @@ -121,4 +121,7 @@ command_find_channel(struct command *cmd, const char *buffer, const jsmntok_t *tok, struct channel **channel); +/* Ancient (0.7.0 and before) releases could create invalid commitment txs! */ +bool invalid_last_tx(const struct bitcoin_tx *tx); + #endif /* LIGHTNING_LIGHTNINGD_PEER_CONTROL_H */