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