| 340 | } |
| 341 | |
| 342 | struct channel *new_unsaved_channel(struct peer *peer, |
| 343 | u32 feerate_base, |
| 344 | u32 feerate_ppm) |
| 345 | { |
| 346 | struct lightningd *ld = peer->ld; |
| 347 | struct channel *channel = tal(ld, struct channel); |
| 348 | const u8 *msg; |
| 349 | |
| 350 | channel->peer = peer; |
| 351 | /* Not saved to the database yet! */ |
| 352 | channel->unsaved_dbid = wallet_get_channel_dbid(ld->wallet); |
| 353 | /* A zero value database id means it's not saved in the database yet */ |
| 354 | channel->dbid = 0; |
| 355 | channel->error = NULL; |
| 356 | channel->openchannel_signed_cmd = NULL; |
| 357 | channel->state = DUALOPEND_OPEN_INIT; |
| 358 | channel->owner = NULL; |
| 359 | channel->reestablished = false; |
| 360 | memset(&channel->billboard, 0, sizeof(channel->billboard)); |
| 361 | channel->billboard.transient = tal_fmt(channel, "%s", |
| 362 | "Empty channel init'd"); |
| 363 | channel->log = new_logger(channel, ld->log_book, |
| 364 | &peer->id, |
| 365 | "chan#%"PRIu64, |
| 366 | channel->unsaved_dbid); |
| 367 | |
| 368 | channel->our_config.id = 0; |
| 369 | channel->open_attempt = NULL; |
| 370 | |
| 371 | channel->last_htlc_sigs = NULL; |
| 372 | channel->remote_channel_ready = false; |
| 373 | channel->scid = NULL; |
| 374 | channel->old_scids = NULL; |
| 375 | channel->next_index[LOCAL] = 1; |
| 376 | channel->next_index[REMOTE] = 1; |
| 377 | channel->next_htlc_id = 0; |
| 378 | channel->funding_spend_watch = NULL; |
| 379 | /* FIXME: remove push when v1 deprecated */ |
| 380 | channel->push = AMOUNT_MSAT(0); |
| 381 | channel->closing_fee_negotiation_step = 50; |
| 382 | channel->closing_fee_negotiation_step_unit |
| 383 | = CLOSING_FEE_NEGOTIATION_STEP_UNIT_PERCENTAGE; |
| 384 | channel->shutdown_wrong_funding = NULL; |
| 385 | channel->closing_feerate_range = NULL; |
| 386 | channel->alias[REMOTE] = NULL; |
| 387 | channel->alias[LOCAL] = tal(channel, struct short_channel_id); |
| 388 | *channel->alias[LOCAL] = random_scid(); |
| 389 | /* We don't check for uniqueness. We would crash on a clash, but your machine is |
| 390 | * probably broken beyond repair if it gets two equal 64 bit numbers */ |
| 391 | chanmap_add(channel->peer->ld, channel, *channel->alias[LOCAL]); |
| 392 | |
| 393 | channel->shutdown_scriptpubkey[REMOTE] = NULL; |
| 394 | channel->last_was_revoke = false; |
| 395 | channel->last_sent_commit = NULL; |
| 396 | |
| 397 | channel->feerate_base = feerate_base; |
| 398 | channel->feerate_ppm = feerate_ppm; |
| 399 | channel->old_feerate_timeout.ts.tv_sec = 0; |
no test coverage detected