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

Function delete_channel

lightningd/channel.c:89–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 12

forget_channel_openFunction · 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