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

Function listsendpays_done

plugins/fetchinvoice.c:1455–1532  ·  view source on GitHub ↗

They're offering a refund, so we need to sign with same key as used * in initial payment. */

Source from the content-addressed store, hash-verified

1453/* They're offering a refund, so we need to sign with same key as used
1454 * in initial payment. */
1455static struct command_result *listsendpays_done(struct command *cmd,
1456 const char *buf,
1457 const jsmntok_t *result,
1458 struct sent *sent)
1459{
1460 const jsmntok_t *t, *arr = json_get_member(buf, result, "payments");
1461 size_t i;
1462 const u8 *public_tweak = NULL, *p;
1463 u8 *msg;
1464 size_t len;
1465 struct sha256 merkle;
1466 struct out_req *req;
1467
1468 /* Linearize populates ->fields */
1469 msg = tal_arr(tmpctx, u8, 0);
1470 towire_tlv_invoice(&msg, sent->inv);
1471 p = msg;
1472 len = tal_bytelen(msg);
1473 sent->inv = fromwire_tlv_invoice(cmd, &p, &len);
1474 if (!sent->inv)
1475 plugin_err(cmd->plugin,
1476 "Could not remarshall %s", tal_hex(tmpctx, msg));
1477
1478 merkle_tlv(sent->inv->fields, &merkle);
1479
1480 json_for_each_arr(i, t, arr) {
1481 const jsmntok_t *b12tok;
1482 struct tlv_invoice *inv;
1483 char *fail;
1484
1485 b12tok = json_get_member(buf, t, "bolt12");
1486 if (!b12tok) {
1487 /* This could happen if they try to refund a bolt11 */
1488 plugin_log(cmd->plugin, LOG_UNUSUAL,
1489 "Not bolt12 string in %.*s?",
1490 json_tok_full_len(t),
1491 json_tok_full(buf, t));
1492 continue;
1493 }
1494
1495 inv = invoice_decode(tmpctx, buf + b12tok->start,
1496 b12tok->end - b12tok->start,
1497 plugin_feature_set(cmd->plugin),
1498 chainparams,
1499 &fail);
1500 if (!inv) {
1501 plugin_log(cmd->plugin, LOG_BROKEN,
1502 "Bad bolt12 string in %.*s?",
1503 json_tok_full_len(t),
1504 json_tok_full(buf, t));
1505 continue;
1506 }
1507
1508 public_tweak = inv->payer_info;
1509 break;
1510 }
1511
1512 if (!public_tweak)

Callers

nothing calls this directly

Calls 15

tal_bytelenFunction · 0.85
tal_hexFunction · 0.85
plugin_feature_setFunction · 0.85
plugin_errFunction · 0.70
plugin_logFunction · 0.70
command_failFunction · 0.70
send_outreqFunction · 0.70
json_get_memberFunction · 0.50
towire_tlv_invoiceFunction · 0.50
fromwire_tlv_invoiceFunction · 0.50
merkle_tlvFunction · 0.50
json_tok_full_lenFunction · 0.50

Tested by

no test coverage detected