| 553 | } |
| 554 | |
| 555 | static void enable_notifications(int fd) |
| 556 | { |
| 557 | const char *enable; |
| 558 | char rbuf[100]; |
| 559 | |
| 560 | enable = tal_fmt(tmpctx, |
| 561 | "{\"jsonrpc\":\"2.0\"," |
| 562 | "\"method\":\"notifications\"," |
| 563 | "\"id\":\"cli:notifications#%i\"," |
| 564 | "\"params\":{\"enable\":true}}", |
| 565 | getpid()); |
| 566 | if (!write_all(fd, enable, strlen(enable))) |
| 567 | err(ERROR_TALKING_TO_LIGHTNINGD, "Writing enable command"); |
| 568 | |
| 569 | /* We get a very simple response, ending in \n\n. */ |
| 570 | memset(rbuf, 0, sizeof(rbuf)); |
| 571 | while (!strends(rbuf, "\n\n")) { |
| 572 | size_t len = strlen(rbuf); |
| 573 | if (cli_read(fd, rbuf + len, sizeof(rbuf) - len) <= 0) |
| 574 | err(ERROR_TALKING_TO_LIGHTNINGD, |
| 575 | "Reading enable response"); |
| 576 | } |
| 577 | } |
| 578 | |
| 579 | static char *opt_set_level(const char *arg, enum log_level *level) |
| 580 | { |