| 1849 | } |
| 1850 | |
| 1851 | void |
| 1852 | plugin_populate_init_request(struct plugin *plugin, struct jsonrpc_request *req) |
| 1853 | { |
| 1854 | const char *name; |
| 1855 | struct plugin_opt *opt; |
| 1856 | struct lightningd *ld = plugin->plugins->ld; |
| 1857 | |
| 1858 | /* Add .params.options */ |
| 1859 | json_object_start(req->stream, "options"); |
| 1860 | list_for_each(&plugin->plugin_opts, opt, list) { |
| 1861 | /* Trim the `--` that we added before */ |
| 1862 | name = opt->name + 2; |
| 1863 | |
| 1864 | /* If no values, assign default (if any!) */ |
| 1865 | if (tal_count(opt->values) == 0) { |
| 1866 | if (opt->def) |
| 1867 | tal_arr_expand(&opt->values, opt->def); |
| 1868 | else |
| 1869 | continue; |
| 1870 | } |
| 1871 | |
| 1872 | if (opt->multi) { |
| 1873 | json_array_start(req->stream, name); |
| 1874 | for (size_t i = 0; i < tal_count(opt->values); i++) |
| 1875 | json_add_plugin_opt(req->stream, NULL, |
| 1876 | opt->type, opt->values[i]); |
| 1877 | json_array_end(req->stream); |
| 1878 | } else { |
| 1879 | json_add_plugin_opt(req->stream, name, |
| 1880 | opt->type, opt->values[0]); |
| 1881 | } |
| 1882 | } |
| 1883 | json_object_end(req->stream); /* end of .params.options */ |
| 1884 | |
| 1885 | /* Add .params.configuration */ |
| 1886 | json_object_start(req->stream, "configuration"); |
| 1887 | json_add_string(req->stream, "lightning-dir", ld->config_netdir); |
| 1888 | json_add_string(req->stream, "rpc-file", ld->rpc_filename); |
| 1889 | json_add_bool(req->stream, "startup", plugin->plugins->startup); |
| 1890 | json_add_string(req->stream, "network", chainparams->network_name); |
| 1891 | if (ld->proxyaddr) { |
| 1892 | json_add_address(req->stream, "proxy", ld->proxyaddr); |
| 1893 | json_add_bool(req->stream, "torv3-enabled", true); |
| 1894 | json_add_bool(req->stream, "always_use_proxy", ld->always_use_proxy); |
| 1895 | } |
| 1896 | json_object_start(req->stream, "feature_set"); |
| 1897 | for (enum feature_place fp = 0; fp < NUM_FEATURE_PLACE; fp++) { |
| 1898 | if (feature_place_names[fp]) { |
| 1899 | json_add_hex_talarr(req->stream, |
| 1900 | feature_place_names[fp], |
| 1901 | ld->our_features->bits[fp]); |
| 1902 | } |
| 1903 | } |
| 1904 | json_object_end(req->stream); |
| 1905 | json_object_end(req->stream); |
| 1906 | } |
| 1907 | |
| 1908 | static void |
no test coverage detected