Returns true if we fired a callback */
| 209 | |
| 210 | /* Returns true if we fired a callback */ |
| 211 | static bool txw_fire(struct txwatch *txw, |
| 212 | const struct bitcoin_txid *txid, |
| 213 | unsigned int depth) |
| 214 | { |
| 215 | enum watch_result r; |
| 216 | struct log *log; |
| 217 | |
| 218 | if (depth == txw->depth) |
| 219 | return false; |
| 220 | if (txw->channel) |
| 221 | log = txw->channel->log; |
| 222 | else |
| 223 | log = txw->topo->log; |
| 224 | |
| 225 | /* We assume zero depth signals a reorganization */ |
| 226 | log_debug(log, |
| 227 | "Got depth change %u->%u for %s%s", |
| 228 | txw->depth, depth, |
| 229 | type_to_string(tmpctx, struct bitcoin_txid, &txw->txid), |
| 230 | depth ? "" : " REORG"); |
| 231 | txw->depth = depth; |
| 232 | r = txw->cb(txw->topo->bitcoind->ld, txw->channel, txid, txw->tx, |
| 233 | txw->depth); |
| 234 | switch (r) { |
| 235 | case DELETE_WATCH: |
| 236 | tal_free(txw); |
| 237 | return true; |
| 238 | case KEEP_WATCHING: |
| 239 | return true; |
| 240 | } |
| 241 | fatal("txwatch callback %p returned %i\n", txw->cb, r); |
| 242 | } |
| 243 | |
| 244 | void txwatch_fire(struct chain_topology *topo, |
| 245 | const struct bitcoin_txid *txid, |
no test coverage detected