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

Function delete_channel

lightningd/channel.c:88–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86}
87
88void delete_channel(struct channel *channel STEALS,
89 bool completely_eliminate)
90{
91 const u8 *msg;
92 struct peer *peer = channel->peer;
93 struct lightningd *ld = peer->ld;
94
95 if (channel->dbid != 0) {
96 /* We no longer care about the funding transaction */
97 channel_unwatch_funding(ld, channel);
98
99 wallet_channel_close(ld->wallet, channel);
100 /* Never open at all, not ours. */
101 if (completely_eliminate)
102 wallet_channel_delete(ld->wallet, channel);
103 else
104 wallet_load_one_closed_channel(ld->wallet, ld->closed_channels, channel->dbid);
105 }
106
107 /* Tell the hsm to forget the channel, needs to be after it's
108 * been forgotten here */
109 if (hsm_capable(ld, WIRE_HSMD_FORGET_CHANNEL)) {
110 msg = towire_hsmd_forget_channel(NULL, &peer->id, channel->dbid);
111 msg = hsm_sync_req(tmpctx, ld, take(msg));
112 if (!fromwire_hsmd_forget_channel_reply(msg))
113 fatal("HSM gave bad hsm_forget_channel_reply %s", tal_hex(msg, msg));
114 }
115
116 notify_channel_state_changed(channel->peer->ld,
117 &channel->peer->id,
118 &channel->cid,
119 channel->scid,
120 clock_time(),
121 channel->state,
122 CLOSED,
123 REASON_UNKNOWN,
124 NULL);
125
126 tal_free(channel);
127
128 maybe_delete_peer(peer);
129}
130
131bool maybe_cleanup_last_inflight(struct channel *channel)
132{

Callers 12

dualopen_errmsgFunction · 0.70
channel_fail_permFunction · 0.70
channel_fail_forgetFunction · 0.70
channel_internal_errorFunction · 0.70
drop_to_chainFunction · 0.70
channel_errmsgFunction · 0.70
forgetFunction · 0.70
channel_notify_new_blockFunction · 0.70

Calls 14

channel_unwatch_fundingFunction · 0.85
wallet_channel_closeFunction · 0.85
wallet_channel_deleteFunction · 0.85
tal_hexFunction · 0.85
clock_timeFunction · 0.85
tal_freeFunction · 0.85
maybe_delete_peerFunction · 0.85
hsm_capableFunction · 0.70
hsm_sync_reqFunction · 0.70

Tested by 1