| 285 | } |
| 286 | |
| 287 | static 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 */ |
no test coverage detected