Resolve a single close command. */
| 35 | |
| 36 | /* Resolve a single close command. */ |
| 37 | static void |
| 38 | resolve_one_close_command(struct close_command *cc, bool cooperative, |
| 39 | const struct bitcoin_tx **close_txs) |
| 40 | { |
| 41 | struct json_stream *result = json_stream_success(cc->cmd); |
| 42 | |
| 43 | json_array_start(result, "txs"); |
| 44 | for (int i = 0; i < tal_count(close_txs); i++) |
| 45 | json_add_tx(result, NULL, close_txs[i]); |
| 46 | json_array_end(result); |
| 47 | |
| 48 | json_array_start(result, "txids"); |
| 49 | for (int i = 0; i < tal_count(close_txs); i++) { |
| 50 | if (invalid_last_tx(close_txs[i])) { |
| 51 | json_add_string(result, NULL, "INVALID_TXID"); |
| 52 | } else { |
| 53 | struct bitcoin_txid txid; |
| 54 | bitcoin_txid(close_txs[i], &txid); |
| 55 | json_add_txid(result, NULL, &txid); |
| 56 | } |
| 57 | } |
| 58 | json_array_end(result); |
| 59 | |
| 60 | if (cooperative) |
| 61 | json_add_string(result, "type", "mutual"); |
| 62 | else |
| 63 | json_add_string(result, "type", "unilateral"); |
| 64 | |
| 65 | was_pending(command_success(cc->cmd, result)); |
| 66 | } |
| 67 | |
| 68 | const char *cmd_id_from_close_command(const tal_t *ctx, |
| 69 | struct lightningd *ld, struct channel *channel) |
no test coverage detected