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