| 810 | } |
| 811 | |
| 812 | bool channel_tell_depth(struct lightningd *ld, |
| 813 | struct channel *channel, |
| 814 | const struct bitcoin_txid *txid, |
| 815 | u32 depth) |
| 816 | { |
| 817 | const char *txidstr; |
| 818 | |
| 819 | txidstr = type_to_string(tmpctx, struct bitcoin_txid, txid); |
| 820 | channel->depth = depth; |
| 821 | |
| 822 | if (!channel->owner) { |
| 823 | log_debug(channel->log, |
| 824 | "Funding tx %s confirmed, but peer disconnected", |
| 825 | txidstr); |
| 826 | return false; |
| 827 | } |
| 828 | |
| 829 | if (streq(channel->owner->name, "dualopend")) { |
| 830 | if (channel->state != DUALOPEND_AWAITING_LOCKIN) { |
| 831 | log_debug(channel->log, |
| 832 | "Funding tx %s confirmed, but peer in" |
| 833 | " state %s", |
| 834 | txidstr, channel_state_name(channel)); |
| 835 | return true; |
| 836 | } |
| 837 | |
| 838 | log_debug(channel->log, |
| 839 | "Funding tx %s confirmed, telling peer", txidstr); |
| 840 | dualopen_tell_depth(channel->owner, channel, |
| 841 | txid, depth); |
| 842 | return true; |
| 843 | } else if (channel->state != CHANNELD_AWAITING_LOCKIN |
| 844 | && channel->state != CHANNELD_NORMAL) { |
| 845 | /* If not awaiting lockin/announce, it doesn't |
| 846 | * care any more */ |
| 847 | log_debug(channel->log, |
| 848 | "Funding tx %s confirmed, but peer in state %s", |
| 849 | txidstr, channel_state_name(channel)); |
| 850 | return true; |
| 851 | } |
| 852 | |
| 853 | subd_send_msg(channel->owner, |
| 854 | take(towire_channeld_funding_depth( |
| 855 | NULL, channel->scid, channel->alias[LOCAL], depth))); |
| 856 | |
| 857 | if (channel->remote_channel_ready && |
| 858 | channel->state == CHANNELD_AWAITING_LOCKIN && |
| 859 | depth >= channel->minimum_depth) { |
| 860 | lockin_complete(channel); |
| 861 | } else if (depth == 1 && channel->minimum_depth == 0) { |
| 862 | /* If we have a zeroconf channel, i.e., no scid yet |
| 863 | * but have exchange `channel_ready` messages, then we |
| 864 | * need to fire a second time, in order to trigger the |
| 865 | * `coin_movement` event. This is a subset of the |
| 866 | * `lockin_complete` function below. */ |
| 867 | |
| 868 | assert(channel->scid != NULL); |
| 869 | /* Fees might have changed (and we use IMMEDIATE once we're |
no test coverage detected