If there are any channels with unsigned PSBTs in AWAITING_LOCKIN, * sign them now (assume we crashed) */
| 1081 | /* If there are any channels with unsigned PSBTs in AWAITING_LOCKIN, |
| 1082 | * sign them now (assume we crashed) */ |
| 1083 | static void list_awaiting_channels(struct command *init_cmd) |
| 1084 | { |
| 1085 | const char *buf; |
| 1086 | size_t i; |
| 1087 | const jsmntok_t *resp, *t, *channels; |
| 1088 | |
| 1089 | resp = jsonrpc_request_sync(tmpctx, init_cmd, |
| 1090 | "listpeerchannels", |
| 1091 | NULL, &buf); |
| 1092 | channels = json_get_member(buf, resp, "channels"); |
| 1093 | json_for_each_arr(i, t, channels) { |
| 1094 | struct out_req *req; |
| 1095 | const char *state; |
| 1096 | struct channel_id cid; |
| 1097 | struct command *aux_cmd; |
| 1098 | struct wally_psbt *psbt; |
| 1099 | bool withheld; |
| 1100 | |
| 1101 | if (json_scan(tmpctx, buf, t, "{state:%,channel_id:%,funding:{withheld:%,psbt:%}}", |
| 1102 | JSON_SCAN_TAL(tmpctx, json_strdup, &state), |
| 1103 | JSON_SCAN(json_tok_channel_id, &cid), |
| 1104 | JSON_SCAN(json_to_bool, &withheld), |
| 1105 | JSON_SCAN_TAL(tmpctx, json_to_psbt, &psbt)) != NULL) |
| 1106 | continue; |
| 1107 | |
| 1108 | if (!streq(state, "CHANNELD_AWAITING_LOCKIN") |
| 1109 | && !streq(state, "DUALOPEND_AWAITING_LOCKIN")) |
| 1110 | continue; |
| 1111 | |
| 1112 | if (withheld) |
| 1113 | continue; |
| 1114 | |
| 1115 | /* Don't do this sync, as it can reasonably fail! */ |
| 1116 | aux_cmd = aux_command(init_cmd); |
| 1117 | req = jsonrpc_request_start(aux_cmd, "signpsbt", |
| 1118 | signpsbt_done, psbt_error, |
| 1119 | tal_dup(aux_cmd, struct channel_id, &cid)); |
| 1120 | json_add_psbt(req->js, "psbt", psbt); |
| 1121 | send_outreq(req); |
| 1122 | } |
| 1123 | } |
| 1124 | |
| 1125 | void openchannel_init(struct command *init_cmd, const char *b, const jsmntok_t *t) |
| 1126 | { |
no test coverage detected