|
30 | 30 | * WE ASSUME NO MALLEABILITY! This requires segregated witness. |
31 | 31 | */ |
32 | 32 | #include "config.h" |
| 33 | +#include <bitcoin/psbt.h> |
33 | 34 | #include <lightningd/chaintopology.h> |
34 | 35 | #include <lightningd/channel.h> |
35 | 36 | #include <lightningd/lightningd.h> |
@@ -235,12 +236,13 @@ void txwatch_fire(struct chain_topology *topo, |
235 | 236 | const struct bitcoin_txid *txid, |
236 | 237 | unsigned int depth) |
237 | 238 | { |
238 | | - struct txwatch *txw; |
| 239 | + struct txwatch_hash_iter it; |
239 | 240 |
|
240 | | - txw = txwatch_hash_get(topo->txwatches, txid); |
241 | | - |
242 | | - if (txw) |
| 241 | + for (struct txwatch *txw = txwatch_hash_getfirst(topo->txwatches, txid, &it); |
| 242 | + txw; |
| 243 | + txw = txwatch_hash_getnext(topo->txwatches, txid, &it)) { |
243 | 244 | txw_fire(txw, txid, depth); |
| 245 | + } |
244 | 246 | } |
245 | 247 |
|
246 | 248 | void txowatch_fire(const struct txowatch *txow, |
@@ -295,12 +297,22 @@ void watch_topology_changed(struct chain_topology *topo) |
295 | 297 |
|
296 | 298 | void txwatch_inform(const struct chain_topology *topo, |
297 | 299 | const struct bitcoin_txid *txid, |
298 | | - const struct bitcoin_tx *tx_may_steal) |
| 300 | + struct bitcoin_tx *tx TAKES) |
299 | 301 | { |
300 | | - struct txwatch *txw; |
301 | | - |
302 | | - txw = txwatch_hash_get(topo->txwatches, txid); |
| 302 | + struct txwatch_hash_iter it; |
| 303 | + |
| 304 | + for (struct txwatch *txw = txwatch_hash_getfirst(topo->txwatches, txid, &it); |
| 305 | + txw; |
| 306 | + txw = txwatch_hash_getnext(topo->txwatches, txid, &it)) { |
| 307 | + if (txw->tx) |
| 308 | + continue; |
| 309 | + /* FIXME: YUCK! These don't have PSBTs attached */ |
| 310 | + if (!tx->psbt) |
| 311 | + tx->psbt = new_psbt(tx, tx->wtx); |
| 312 | + txw->tx = clone_bitcoin_tx(txw, tx); |
| 313 | + } |
303 | 314 |
|
304 | | - if (txw && !txw->tx) |
305 | | - txw->tx = tal_steal(txw, tx_may_steal); |
| 315 | + /* If we don't clone above, handle take() now */ |
| 316 | + if (taken(tx)) |
| 317 | + tal_free(tx); |
306 | 318 | } |
0 commit comments