| 1552 | } |
| 1553 | |
| 1554 | static 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 |
nothing calls this directly
no test coverage detected