| 1377 | } |
| 1378 | |
| 1379 | static struct command_result *createinvoice_done(struct command *cmd, |
| 1380 | const char *buf, |
| 1381 | const jsmntok_t *result, |
| 1382 | struct sent *sent) |
| 1383 | { |
| 1384 | const jsmntok_t *invtok = json_get_member(buf, result, "bolt12"); |
| 1385 | char *fail; |
| 1386 | enum nodeid_parity parity; |
| 1387 | |
| 1388 | /* Replace invoice with signed one */ |
| 1389 | tal_free(sent->inv); |
| 1390 | sent->inv = invoice_decode(sent, |
| 1391 | buf + invtok->start, |
| 1392 | invtok->end - invtok->start, |
| 1393 | plugin_feature_set(cmd->plugin), |
| 1394 | chainparams, |
| 1395 | &fail); |
| 1396 | if (!sent->inv) { |
| 1397 | plugin_log(cmd->plugin, LOG_BROKEN, |
| 1398 | "Bad createinvoice %.*s: %s", |
| 1399 | json_tok_full_len(invtok), |
| 1400 | json_tok_full(buf, invtok), |
| 1401 | fail); |
| 1402 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 1403 | "Bad createinvoice response %s", fail); |
| 1404 | } |
| 1405 | |
| 1406 | sent->path = path_to_node(sent, cmd->plugin, |
| 1407 | sent->offer->node_id, |
| 1408 | &parity); |
| 1409 | if (!sent->path) |
| 1410 | return connect_direct(cmd, sent->offer->node_id, parity, |
| 1411 | sendinvoice_after_connect, sent); |
| 1412 | |
| 1413 | return sendinvoice_after_connect(cmd, NULL, NULL, sent); |
| 1414 | } |
| 1415 | |
| 1416 | static struct command_result *sign_invoice(struct command *cmd, |
| 1417 | struct sent *sent) |
nothing calls this directly
no test coverage detected