| 1167 | } |
| 1168 | |
| 1169 | struct command_result *json_cancelrecurringinvoice(struct command *cmd, |
| 1170 | const char *buffer, |
| 1171 | const jsmntok_t *params) |
| 1172 | { |
| 1173 | const struct offers_data *od = get_offers_data(cmd->plugin); |
| 1174 | const char *rec_label, *payer_note; |
| 1175 | struct out_req *req; |
| 1176 | struct tlv_invoice_request *invreq; |
| 1177 | struct sent *sent = tal(cmd, struct sent); |
| 1178 | struct bip_353_name *bip353; |
| 1179 | u32 *recurrence_counter, *recurrence_start; |
| 1180 | |
| 1181 | if (!param_check(cmd, buffer, params, |
| 1182 | p_req("offer", param_offer, &sent->offer), |
| 1183 | p_req("recurrence_counter", param_number, &recurrence_counter), |
| 1184 | p_req("recurrence_label", param_string, &rec_label), |
| 1185 | p_opt("recurrence_start", param_number, &recurrence_start), |
| 1186 | p_opt("payer_note", param_string, &payer_note), |
| 1187 | p_opt("bip353", param_bip353, &bip353), |
| 1188 | NULL)) |
| 1189 | return command_param_failed(); |
| 1190 | |
| 1191 | sent->their_paths = sent->offer->offer_paths; |
| 1192 | if (sent->their_paths) |
| 1193 | sent->direct_dest = NULL; |
| 1194 | else |
| 1195 | sent->direct_dest = sent->offer->offer_issuer_id; |
| 1196 | /* This is NULL if offer_issuer_id is missing, and set by try_establish */ |
| 1197 | sent->issuer_key = sent->offer->offer_issuer_id; |
| 1198 | |
| 1199 | /* BOLT #12: |
| 1200 | * The writer: |
| 1201 | * - if it is responding to an offer: |
| 1202 | * - MUST copy all fields from the offer (including unknown fields). |
| 1203 | */ |
| 1204 | invreq = invoice_request_for_offer(sent, sent->offer); |
| 1205 | invreq->invreq_recurrence_counter = tal_steal(invreq, recurrence_counter); |
| 1206 | invreq->invreq_recurrence_start = tal_steal(invreq, recurrence_start); |
| 1207 | invreq->invreq_bip_353_name = tal_steal(invreq, bip353); |
| 1208 | invreq->invreq_recurrence_cancel = talz(invreq, struct tlv_invoice_request_invreq_recurrence_cancel); |
| 1209 | |
| 1210 | /* BOLT-recurrence #12: |
| 1211 | * - if it sets `invreq_recurrence_cancel`: |
| 1212 | *... |
| 1213 | * - MAY omit `invreq_amount` and `invreq_quantity`. |
| 1214 | */ |
| 1215 | /* And we do */ |
| 1216 | if (!invreq_recurrence(invreq)) |
| 1217 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 1218 | "Not a recurring offer"); |
| 1219 | |
| 1220 | /* BOLT-recurrence #12: |
| 1221 | * - if `offer_recurrence_optional` or `offer_recurrence_compulsory` are present: |
| 1222 | * - for the initial request: |
| 1223 | *... |
| 1224 | * - MUST set `invreq_recurrence_counter` `counter` to 0. |
| 1225 | * - MUST NOT set `invreq_recurrence_cancel`. |
| 1226 | */ |
nothing calls this directly
no test coverage detected