* Entrypoint for the txwatch callback, calls onchain_tx_depth. */
| 153 | * Entrypoint for the txwatch callback, calls onchain_tx_depth. |
| 154 | */ |
| 155 | static enum watch_result onchain_tx_watched(struct lightningd *ld, |
| 156 | struct channel *channel, |
| 157 | const struct bitcoin_txid *txid, |
| 158 | const struct bitcoin_tx *tx, |
| 159 | unsigned int depth) |
| 160 | { |
| 161 | u32 blockheight = get_block_height(ld->topology); |
| 162 | |
| 163 | if (tx != NULL) { |
| 164 | struct bitcoin_txid txid2; |
| 165 | |
| 166 | bitcoin_txid(tx, &txid2); |
| 167 | if (!bitcoin_txid_eq(txid, &txid2)) { |
| 168 | channel_internal_error(channel, "Txid for %s is not %s", |
| 169 | type_to_string(tmpctx, |
| 170 | struct bitcoin_tx, |
| 171 | tx), |
| 172 | type_to_string(tmpctx, |
| 173 | struct bitcoin_txid, |
| 174 | txid)); |
| 175 | return DELETE_WATCH; |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | if (depth == 0) { |
| 180 | log_unusual(channel->log, "Chain reorganization!"); |
| 181 | channel_set_owner(channel, NULL); |
| 182 | |
| 183 | /* We will most likely be freed, so this is a noop */ |
| 184 | return KEEP_WATCHING; |
| 185 | } |
| 186 | |
| 187 | /* Store the channeltx so we can replay later */ |
| 188 | wallet_channeltxs_add(ld->wallet, channel, |
| 189 | WIRE_ONCHAIND_DEPTH, txid, 0, blockheight); |
| 190 | |
| 191 | onchain_tx_depth(channel, txid, depth); |
| 192 | return KEEP_WATCHING; |
| 193 | } |
| 194 | |
| 195 | static void watch_tx_and_outputs(struct channel *channel, |
| 196 | const struct bitcoin_tx *tx); |
nothing calls this directly
no test coverage detected