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

Function payment_createonion_success

plugins/libplugin-pay.c:1554–1610  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1552}
1553
1554static struct command_result *payment_createonion_success(struct command *cmd,
1555 const char *buffer,
1556 const jsmntok_t *toks,
1557 struct payment *p)
1558{
1559 struct out_req *req;
1560 struct route_hop *first = &p->route[0];
1561 struct secret *secrets;
1562 struct payment *root = payment_root(p);
1563
1564 p->createonion_response = json_to_createonion_response(p, buffer, toks);
1565
1566 req = jsonrpc_request_start(p->plugin, NULL, "sendonion",
1567 payment_sendonion_success,
1568 payment_rpc_failure, p);
1569 json_add_hex_talarr(req->js, "onion", p->createonion_response->onion);
1570
1571 json_object_start(req->js, "first_hop");
1572 json_add_amount_msat_only(req->js, "amount_msat", first->amount);
1573 json_add_num(req->js, "delay", first->delay);
1574 json_add_node_id(req->js, "id", &first->node_id);
1575 json_object_end(req->js);
1576
1577 json_add_sha256(req->js, "payment_hash", p->payment_hash);
1578 json_add_amount_msat_only(req->js, "amount_msat", p->amount);
1579
1580 json_array_start(req->js, "shared_secrets");
1581 secrets = p->createonion_response->shared_secrets;
1582 for(size_t i=0; i<tal_count(secrets); i++)
1583 json_add_secret(req->js, NULL, &secrets[i]);
1584 json_array_end(req->js);
1585
1586 json_add_num(req->js, "partid", p->partid);
1587 json_add_u64(req->js, "groupid", p->groupid);
1588
1589 if (p->label)
1590 json_add_string(req->js, "label", p->label);
1591
1592 if (!root->invstring_used) {
1593 /* FIXME: rename parameter to invstring */
1594 json_add_string(req->js, "bolt11", p->invstring);
1595
1596 if (p->description)
1597 json_add_string(req->js, "description", p->description);
1598
1599 root->invstring_used = true;
1600 }
1601
1602 if (p->destination)
1603 json_add_node_id(req->js, "destination", p->destination);
1604
1605 if (p->local_offer_id)
1606 json_add_sha256(req->js, "localofferid", p->local_offer_id);
1607
1608 send_outreq(p->plugin, req);
1609 return command_still_pending(cmd);
1610}
1611

Callers

nothing calls this directly

Calls 15

payment_rootFunction · 0.85
send_outreqFunction · 0.70
command_still_pendingFunction · 0.70
json_add_hex_talarrFunction · 0.50
json_object_startFunction · 0.50
json_add_numFunction · 0.50
json_add_node_idFunction · 0.50
json_object_endFunction · 0.50
json_add_sha256Function · 0.50
json_array_startFunction · 0.50

Tested by

no test coverage detected