MCPcopy Create free account
hub / github.com/ElementsProject/lightning / json_cancelrecurringinvoice

Function json_cancelrecurringinvoice

plugins/fetchinvoice.c:1260–1412  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1258}
1259
1260struct command_result *json_cancelrecurringinvoice(struct command *cmd,
1261 const char *buffer,
1262 const jsmntok_t *params)
1263{
1264 const struct offers_data *od = get_offers_data(cmd->plugin);
1265 const char *rec_label, *payer_note;
1266 struct out_req *req;
1267 struct tlv_invoice_request *invreq;
1268 struct sent *sent = tal(cmd, struct sent);
1269 struct bip_353_name *bip353;
1270 u32 *recurrence_counter, *recurrence_start;
1271
1272 if (!param_check(cmd, buffer, params,
1273 p_req("offer", param_offer, &sent->offer),
1274 p_req("recurrence_counter", param_number, &recurrence_counter),
1275 p_req("recurrence_label", param_string, &rec_label),
1276 p_opt("recurrence_start", param_number, &recurrence_start),
1277 p_opt("payer_note", param_string, &payer_note),
1278 p_opt("bip353", param_bip353, &bip353),
1279 NULL))
1280 return command_param_failed();
1281
1282 sent->their_paths = sent->offer->offer_paths;
1283 if (sent->their_paths)
1284 sent->direct_dest = NULL;
1285 else
1286 sent->direct_dest = sent->offer->offer_issuer_id;
1287 /* This is NULL if offer_issuer_id is missing, and set by try_establish */
1288 sent->issuer_key = sent->offer->offer_issuer_id;
1289
1290 /* BOLT #12:
1291 * The writer:
1292 * - if it is responding to an offer:
1293 * - MUST copy all fields from the offer (including unknown fields).
1294 */
1295 invreq = invoice_request_for_offer(sent, sent->offer);
1296 invreq->invreq_recurrence_counter = tal_steal(invreq, recurrence_counter);
1297 invreq->invreq_recurrence_start = tal_steal(invreq, recurrence_start);
1298 invreq->invreq_bip_353_name = tal_steal(invreq, bip353);
1299 invreq->invreq_recurrence_cancel = talz(invreq, struct tlv_invoice_request_invreq_recurrence_cancel);
1300
1301 /* BOLT-recurrence #12:
1302 * - if it sets `invreq_recurrence_cancel`:
1303 *...
1304 * - MAY omit `invreq_amount` and `invreq_quantity`.
1305 */
1306 /* And we do */
1307 if (!invreq_recurrence(invreq))
1308 return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
1309 "Not a recurring offer");
1310
1311 /* BOLT-recurrence #12:
1312 * - if `offer_recurrence_optional` or `offer_recurrence_compulsory` are present:
1313 * - for the initial request:
1314 *...
1315 * - MUST set `invreq_recurrence_counter` `counter` to 0.
1316 * - MUST NOT set `invreq_recurrence_cancel`.
1317 */

Callers

nothing calls this directly

Calls 15

get_offers_dataFunction · 0.85
param_checkFunction · 0.85
invreq_recurrenceFunction · 0.85
tal_bytelenFunction · 0.85
invrequest_encodeFunction · 0.85
json_add_boolFunction · 0.85
command_param_failedFunction · 0.70
command_failFunction · 0.70
payer_keyFunction · 0.70
plugin_feature_setFunction · 0.70

Tested by

no test coverage detected