| 2756 | |
| 2757 | #if DEVELOPER |
| 2758 | static struct command_result *json_sign_last_tx(struct command *cmd, |
| 2759 | const char *buffer, |
| 2760 | const jsmntok_t *obj UNNEEDED, |
| 2761 | const jsmntok_t *params) |
| 2762 | { |
| 2763 | struct node_id *peerid; |
| 2764 | struct peer *peer; |
| 2765 | struct json_stream *response; |
| 2766 | struct channel *channel; |
| 2767 | bool more_than_one; |
| 2768 | |
| 2769 | if (!param(cmd, buffer, params, |
| 2770 | p_req("id", param_node_id, &peerid), |
| 2771 | NULL)) |
| 2772 | return command_param_failed(); |
| 2773 | |
| 2774 | peer = peer_by_id(cmd->ld, peerid); |
| 2775 | if (!peer) { |
| 2776 | return command_fail(cmd, LIGHTNINGD, |
| 2777 | "Could not find peer with that id"); |
| 2778 | } |
| 2779 | channel = peer_any_active_channel(peer, &more_than_one); |
| 2780 | if (!channel || more_than_one) { |
| 2781 | return command_fail(cmd, LIGHTNINGD, |
| 2782 | "Could not find single active channel"); |
| 2783 | } |
| 2784 | |
| 2785 | response = json_stream_success(cmd); |
| 2786 | log_debug(channel->log, "dev-sign-last-tx: signing tx with %zu outputs", |
| 2787 | channel->last_tx->wtx->num_outputs); |
| 2788 | |
| 2789 | sign_last_tx(channel, channel->last_tx, &channel->last_sig); |
| 2790 | json_add_tx(response, "tx", channel->last_tx); |
| 2791 | remove_sig(channel->last_tx); |
| 2792 | |
| 2793 | /* If we've got inflights, return them */ |
| 2794 | if (!list_empty(&channel->inflights)) { |
| 2795 | struct channel_inflight *inflight; |
| 2796 | |
| 2797 | json_array_start(response, "inflights"); |
| 2798 | list_for_each(&channel->inflights, inflight, list) { |
| 2799 | sign_last_tx(channel, inflight->last_tx, |
| 2800 | &inflight->last_sig); |
| 2801 | json_object_start(response, NULL); |
| 2802 | json_add_txid(response, "funding_txid", |
| 2803 | &inflight->funding->outpoint.txid); |
| 2804 | remove_sig(inflight->last_tx); |
| 2805 | json_add_tx(response, "tx", channel->last_tx); |
| 2806 | json_object_end(response); |
| 2807 | } |
| 2808 | json_array_end(response); |
| 2809 | } |
| 2810 | |
| 2811 | return command_success(cmd, response); |
| 2812 | } |
| 2813 | |
| 2814 | static const struct json_command dev_sign_last_tx = { |
| 2815 | "dev-sign-last-tx", |
nothing calls this directly
no test coverage detected