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

Function connect_activate_subd

lightningd/peer_control.c:1391–1500  ·  view source on GitHub ↗

Talk to connectd about an active channel */

Source from the content-addressed store, hash-verified

1389
1390/* Talk to connectd about an active channel */
1391static void connect_activate_subd(struct lightningd *ld, struct channel *channel)
1392{
1393 const u8 *error;
1394 struct peer_fd *pfd;
1395 int other_fd;
1396
1397 /* If we have a canned error for this channel, send it now */
1398 if (channel->error) {
1399 error = channel->error;
1400 goto send_error;
1401 }
1402
1403 switch (channel->state) {
1404 case ONCHAIN:
1405 case FUNDING_SPEND_SEEN:
1406 case CLOSINGD_COMPLETE:
1407 case CLOSED:
1408 case DUALOPEND_OPEN_INIT:
1409 /* Channel is active */
1410 abort();
1411 case AWAITING_UNILATERAL:
1412 /* channel->error is not saved in db, so this can
1413 * happen if we restart. */
1414 error = towire_errorfmt(tmpctx, &channel->cid,
1415 "Awaiting unilateral close");
1416 goto send_error;
1417
1418 case DUALOPEND_OPEN_COMMIT_READY:
1419 case DUALOPEND_OPEN_COMMITTED:
1420 case DUALOPEND_AWAITING_LOCKIN:
1421 assert(!channel->owner);
1422 pfd = sockpair(tmpctx, channel, &other_fd, &error);
1423 if (!pfd)
1424 goto send_error;
1425
1426 if (peer_restart_dualopend(channel->peer,
1427 pfd,
1428 channel, false))
1429 goto tell_connectd;
1430 close(other_fd);
1431 return;
1432
1433 case CHANNELD_AWAITING_LOCKIN:
1434 case CHANNELD_NORMAL:
1435 case CHANNELD_AWAITING_SPLICE:
1436 case CHANNELD_SHUTTING_DOWN:
1437 case CLOSINGD_SIGEXCHANGE:
1438 assert(!channel->owner);
1439 pfd = sockpair(tmpctx, channel, &other_fd, &error);
1440 if (!pfd)
1441 goto send_error;
1442
1443 if (peer_start_channeld(channel,
1444 pfd,
1445 NULL, true)) {
1446 goto tell_connectd;
1447 }
1448 close(other_fd);

Callers 1

Calls 12

abortFunction · 0.85
towire_errorfmtFunction · 0.85
sockpairFunction · 0.85
tal_hexFunction · 0.85
is_stub_scidFunction · 0.85
peer_restart_dualopendFunction · 0.70
peer_start_channeldFunction · 0.70
subd_send_msgFunction · 0.70
subd_send_fdFunction · 0.70

Tested by

no test coverage detected