| 1595 | } |
| 1596 | |
| 1597 | void peer_disconnect_done(struct lightningd *ld, const u8 *msg) |
| 1598 | { |
| 1599 | struct node_id id; |
| 1600 | u64 connectd_counter; |
| 1601 | struct disconnect_command *i, *next; |
| 1602 | struct peer *p; |
| 1603 | |
| 1604 | if (!fromwire_connectd_peer_disconnect_done(msg, &id, &connectd_counter)) |
| 1605 | fatal("Connectd gave bad PEER_DISCONNECT_DONE message %s", |
| 1606 | tal_hex(msg, msg)); |
| 1607 | |
| 1608 | /* If we still have peer, it's disconnected now */ |
| 1609 | /* FIXME: We should keep peers until it tells us they're disconnected, |
| 1610 | * and not free when no more channels. */ |
| 1611 | p = peer_by_id(ld, &id); |
| 1612 | if (p) { |
| 1613 | assert(p->connectd_counter == connectd_counter); |
| 1614 | log_peer_debug(ld->log, &id, "peer_disconnect_done"); |
| 1615 | p->connected = PEER_DISCONNECTED; |
| 1616 | } |
| 1617 | |
| 1618 | /* If you were trying to connect, it failed. */ |
| 1619 | connect_failed_disconnect(ld, &id, |
| 1620 | p && !p->connected_incoming ? &p->addr : NULL); |
| 1621 | |
| 1622 | /* Fire off plugin notifications */ |
| 1623 | notify_disconnect(ld, &id); |
| 1624 | |
| 1625 | /* Wake any disconnect commands (removes self from list) */ |
| 1626 | list_for_each_safe(&ld->disconnect_commands, i, next, list) { |
| 1627 | if (!node_id_eq(&i->id, &id)) |
| 1628 | continue; |
| 1629 | |
| 1630 | was_pending(command_success(i->cmd, |
| 1631 | json_stream_success(i->cmd))); |
| 1632 | } |
| 1633 | |
| 1634 | /* If connection was only thing keeping it, this will delete it. */ |
| 1635 | if (p) |
| 1636 | maybe_delete_peer(p); |
| 1637 | } |
| 1638 | |
| 1639 | static bool check_funding_details(const struct bitcoin_tx *tx, |
| 1640 | const u8 *wscript, |
no test coverage detected