| 1054 | } |
| 1055 | |
| 1056 | static enum watch_result opening_depth_cb(struct lightningd *ld, |
| 1057 | unsigned int depth, |
| 1058 | struct channel_inflight *inflight) |
| 1059 | { |
| 1060 | struct channel *channel = inflight->channel; |
| 1061 | |
| 1062 | /* Usually, we're here because we're awaiting a lockin, but |
| 1063 | * we could also mutual shutdown */ |
| 1064 | if (channel->state != DUALOPEND_AWAITING_LOCKIN) |
| 1065 | return DELETE_WATCH; |
| 1066 | |
| 1067 | /*~ Now we commit the channel to *this* candidate. Both halves have to |
| 1068 | * move together: the scid says "we're confirmed", channel->funding says |
| 1069 | * "and this is the tx we confirmed". We used to set the scid the |
| 1070 | * instant we saw the tx in a block (inline, while the block was being |
| 1071 | * processed) but only get here -- and so only update channel->funding -- |
| 1072 | * once we'd caught up on every queued block. A reconnect landing in |
| 1073 | * between saw a mixed state and happily locked in whatever RBF candidate |
| 1074 | * was last negotiated, which may never have been mined at all. */ |
| 1075 | if (depth >= channel->minimum_depth) { |
| 1076 | struct amount_msat our_msat; |
| 1077 | |
| 1078 | assert(inflight->scid); |
| 1079 | update_channel_from_inflight(ld, channel, inflight, false); |
| 1080 | |
| 1081 | /*~ Balances only ever move with the *latest* RBF attempt: |
| 1082 | * wallet_update_channel() writes our_msat/msat_to_us_min/ |
| 1083 | * msat_to_us_max whenever a new attempt is negotiated. If a |
| 1084 | * non-last candidate is the one that got mined, they'd name a |
| 1085 | * different contribution than the funding we just promoted to, |
| 1086 | * and peer_start_channeld() would hand channeld a balance the |
| 1087 | * peer doesn't agree with. Recompute them from the promoted |
| 1088 | * inflight's contribution; a fresh channel has no payment |
| 1089 | * history, so min == max == our_msat. */ |
| 1090 | if (!amount_sat_to_msat(&our_msat, channel->our_funds)) { |
| 1091 | channel_internal_error(channel, |
| 1092 | "Unable to convert funds"); |
| 1093 | return DELETE_WATCH; |
| 1094 | } |
| 1095 | channel->our_msat = our_msat; |
| 1096 | channel->msat_to_us_min = our_msat; |
| 1097 | channel->msat_to_us_max = our_msat; |
| 1098 | |
| 1099 | channel_apply_scid(channel, &inflight->funding->outpoint, |
| 1100 | *inflight->scid); |
| 1101 | } |
| 1102 | |
| 1103 | dualopend_tell_depth(channel, &inflight->funding->outpoint.txid, depth); |
| 1104 | return KEEP_WATCHING; |
| 1105 | } |
| 1106 | |
| 1107 | static enum watch_result opening_reorged_cb(struct lightningd *ld, struct channel_inflight *inflight) |
| 1108 | { |
nothing calls this directly
no test coverage detected