| 2413 | } |
| 2414 | |
| 2415 | static enum watch_result funding_depth_cb(struct lightningd *ld, |
| 2416 | unsigned int depth, |
| 2417 | struct channel *channel) |
| 2418 | { |
| 2419 | channel->depth = depth; |
| 2420 | |
| 2421 | log_debug(channel->log, "Funding tx %s depth %u of %u", |
| 2422 | fmt_bitcoin_txid(tmpctx, &channel->funding.txid), |
| 2423 | depth, channel->minimum_depth); |
| 2424 | |
| 2425 | switch (channel->state) { |
| 2426 | /* We should not be in the callback! */ |
| 2427 | case DUALOPEND_AWAITING_LOCKIN: |
| 2428 | case DUALOPEND_OPEN_INIT: |
| 2429 | case DUALOPEND_OPEN_COMMIT_READY: |
| 2430 | case DUALOPEND_OPEN_COMMITTED: |
| 2431 | abort(); |
| 2432 | |
| 2433 | case AWAITING_UNILATERAL: |
| 2434 | case CHANNELD_SHUTTING_DOWN: |
| 2435 | case CLOSINGD_SIGEXCHANGE: |
| 2436 | case CLOSINGD_COMPLETE: |
| 2437 | case FUNDING_SPEND_SEEN: |
| 2438 | case ONCHAIN: |
| 2439 | case CLOSED: |
| 2440 | /* If not awaiting lockin/announce, it doesn't care any more */ |
| 2441 | log_debug(channel->log, |
| 2442 | "Funding tx %s confirmed, but peer in state %s", |
| 2443 | fmt_bitcoin_txid(tmpctx, &channel->funding.txid), |
| 2444 | channel_state_name(channel)); |
| 2445 | return DELETE_WATCH; |
| 2446 | |
| 2447 | case CHANNELD_AWAITING_LOCKIN: |
| 2448 | /* This may be redundant, and may be public later, but |
| 2449 | * make sure we tell gossipd at least once */ |
| 2450 | if (depth >= channel->minimum_depth |
| 2451 | && channel->remote_channel_ready) { |
| 2452 | lockin_complete(channel, CHANNELD_AWAITING_LOCKIN); |
| 2453 | } |
| 2454 | /* Fall thru */ |
| 2455 | case CHANNELD_NORMAL: |
| 2456 | case CHANNELD_AWAITING_SPLICE: |
| 2457 | channeld_tell_depth(channel, &channel->funding.txid, depth); |
| 2458 | |
| 2459 | if (depth < ANNOUNCE_MIN_DEPTH || depth < channel->minimum_depth) |
| 2460 | return KEEP_WATCHING; |
| 2461 | /* Normal state and past announce depth? Stop bothering us! */ |
| 2462 | return DELETE_WATCH; |
| 2463 | } |
| 2464 | abort(); |
| 2465 | } |
| 2466 | |
| 2467 | void channel_watch_depth(struct lightningd *ld, |
| 2468 | u32 blockheight, |
nothing calls this directly
no test coverage detected