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

Function connect_activate_subd

lightningd/peer_control.c:1075–1159  ·  view source on GitHub ↗

Talk to connectd about an active channel */

Source from the content-addressed store, hash-verified

1073
1074/* Talk to connectd about an active channel */
1075static void connect_activate_subd(struct lightningd *ld, struct channel *channel)
1076{
1077 const u8 *error;
1078 int fds[2];
1079
1080 /* If we have a canned error for this channel, send it now */
1081 if (channel->error) {
1082 error = channel->error;
1083 goto send_error;
1084 }
1085
1086 switch (channel->state) {
1087 case ONCHAIN:
1088 case FUNDING_SPEND_SEEN:
1089 case CLOSINGD_COMPLETE:
1090 case CLOSED:
1091 /* Channel is active */
1092 abort();
1093 case AWAITING_UNILATERAL:
1094 /* channel->error is not saved in db, so this can
1095 * happen if we restart. */
1096 error = towire_errorfmt(tmpctx, &channel->cid,
1097 "Awaiting unilateral close");
1098 goto send_error;
1099
1100 case DUALOPEND_OPEN_INIT:
1101 case DUALOPEND_AWAITING_LOCKIN:
1102 assert(!channel->owner);
1103 if (socketpair(AF_LOCAL, SOCK_STREAM, 0, fds) != 0) {
1104 log_broken(channel->log,
1105 "Failed to create socketpair: %s",
1106 strerror(errno));
1107 error = towire_warningfmt(tmpctx, &channel->cid,
1108 "Trouble in paradise?");
1109 goto send_error;
1110 }
1111 if (peer_restart_dualopend(channel->peer,
1112 new_peer_fd(tmpctx, fds[0]),
1113 channel))
1114 goto tell_connectd;
1115 close(fds[1]);
1116 return;
1117
1118 case CHANNELD_AWAITING_LOCKIN:
1119 case CHANNELD_NORMAL:
1120 case CHANNELD_SHUTTING_DOWN:
1121 case CLOSINGD_SIGEXCHANGE:
1122 assert(!channel->owner);
1123 if (socketpair(AF_LOCAL, SOCK_STREAM, 0, fds) != 0) {
1124 log_broken(channel->log,
1125 "Failed to create socketpair: %s",
1126 strerror(errno));
1127 error = towire_warningfmt(tmpctx, &channel->cid,
1128 "Trouble in paradise?");
1129 goto send_error;
1130 }
1131 if (peer_start_channeld(channel,
1132 new_peer_fd(tmpctx, fds[0]),

Callers 1

Calls 11

abortFunction · 0.85
tal_hexFunction · 0.85
peer_restart_dualopendFunction · 0.70
new_peer_fdFunction · 0.70
peer_start_channeldFunction · 0.70
subd_send_msgFunction · 0.70
subd_send_fdFunction · 0.70
towire_errorfmtFunction · 0.50
towire_warningfmtFunction · 0.50

Tested by

no test coverage detected