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

Function json_add_address_internal

common/json_stream.c:548–601  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

546}
547
548void json_add_address_internal(struct json_stream *response,
549 const char *fieldname,
550 const struct wireaddr_internal *addr)
551{
552 switch (addr->itype) {
553 case ADDR_INTERNAL_SOCKNAME:
554 json_object_start(response, fieldname);
555 json_add_string(response, "type", "local socket");
556 json_add_string(response, "socket", addr->u.sockname);
557 json_object_end(response);
558 return;
559 case ADDR_INTERNAL_ALLPROTO:
560 json_object_start(response, fieldname);
561 if (addr->u.allproto.is_websocket) {
562 json_add_string(response, "type", "websocket");
563 json_add_string(response, "subtype", "any protocol");
564 } else {
565 json_add_string(response, "type", "any protocol");
566 }
567 json_add_num(response, "port", addr->u.allproto.port);
568 json_object_end(response);
569 return;
570 case ADDR_INTERNAL_AUTOTOR:
571 json_object_start(response, fieldname);
572 json_add_string(response, "type", "Tor generated address");
573 json_add_address(response, "service", &addr->u.torservice.address);
574 json_object_end(response);
575 return;
576 case ADDR_INTERNAL_STATICTOR:
577 json_object_start(response, fieldname);
578 json_add_string(response, "type", "Tor from blob generated static address");
579 json_add_address(response, "service", &addr->u.torservice.address);
580 json_object_end(response);
581 return;
582 case ADDR_INTERNAL_FORPROXY:
583 json_object_start(response, fieldname);
584 json_add_string(response, "type", "unresolved");
585 json_add_string(response, "name", addr->u.unresolved.name);
586 json_add_num(response, "port", addr->u.unresolved.port);
587 json_object_end(response);
588 return;
589 case ADDR_INTERNAL_WIREADDR:
590 json_object_start(response, fieldname);
591 if (addr->u.wireaddr.is_websocket) {
592 json_add_string(response, "type", "websocket");
593 json_add_address_fields(response, &addr->u.wireaddr.wireaddr, "subtype");
594 } else {
595 json_add_address_fields(response, &addr->u.wireaddr.wireaddr, "type");
596 }
597 json_object_end(response);
598 return;
599 }
600 abort();
601}
602
603void json_add_tx(struct json_stream *result,
604 const char *fieldname,

Callers 3

json_getinfoFunction · 0.85
connect_cmd_succeedFunction · 0.85

Calls 7

json_object_startFunction · 0.85
json_object_endFunction · 0.85
json_add_numFunction · 0.85
json_add_addressFunction · 0.85
json_add_address_fieldsFunction · 0.85
abortFunction · 0.85
json_add_stringFunction · 0.70

Tested by

no test coverage detected