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

Function set_remote_upfront_shutdown

openingd/openingd.c:287–319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

285}
286
287static void set_remote_upfront_shutdown(struct state *state,
288 u8 *shutdown_scriptpubkey STEALS)
289{
290 bool anysegwit = feature_negotiated(state->our_features,
291 state->their_features,
292 OPT_SHUTDOWN_ANYSEGWIT);
293 bool anchors = feature_negotiated(state->our_features,
294 state->their_features,
295 OPT_ANCHOR_OUTPUTS)
296 || feature_negotiated(state->our_features,
297 state->their_features,
298 OPT_ANCHORS_ZERO_FEE_HTLC_TX);
299
300 /* BOLT #2:
301 *
302 * - MUST include `upfront_shutdown_script` with either a valid
303 * `shutdown_scriptpubkey` as required by `shutdown` `scriptpubkey`,
304 * or a zero-length `shutdown_scriptpubkey` (ie. `0x0000`).
305 */
306 /* We turn empty into NULL. */
307 if (tal_bytelen(shutdown_scriptpubkey) == 0)
308 shutdown_scriptpubkey = tal_free(shutdown_scriptpubkey);
309
310 state->upfront_shutdown_script[REMOTE]
311 = tal_steal(state, shutdown_scriptpubkey);
312
313 if (shutdown_scriptpubkey
314 && !valid_shutdown_scriptpubkey(shutdown_scriptpubkey, anysegwit, anchors))
315 peer_failed_err(state->pps,
316 &state->channel_id,
317 "Unacceptable upfront_shutdown_script %s",
318 tal_hex(tmpctx, shutdown_scriptpubkey));
319}
320
321/* We start the 'open a channel' negotation with the supplied peer, but
322 * stop when we get to the part where we need the funding txid */

Callers 2

funder_channel_startFunction · 0.85
fundee_channelFunction · 0.85

Calls 6

tal_bytelenFunction · 0.85
tal_freeFunction · 0.85
peer_failed_errFunction · 0.85
tal_hexFunction · 0.85
feature_negotiatedFunction · 0.50

Tested by

no test coverage detected