| 216 | } |
| 217 | |
| 218 | void broadcast_tx(struct chain_topology *topo, |
| 219 | struct channel *channel, const struct bitcoin_tx *tx, |
| 220 | const char *cmd_id, bool allowhighfees, |
| 221 | void (*failed)(struct channel *channel, |
| 222 | bool success, |
| 223 | const char *err)) |
| 224 | { |
| 225 | /* Channel might vanish: topo owns it to start with. */ |
| 226 | struct outgoing_tx *otx = tal(topo, struct outgoing_tx); |
| 227 | const u8 *rawtx = linearize_tx(otx, tx); |
| 228 | |
| 229 | otx->channel = channel; |
| 230 | bitcoin_txid(tx, &otx->txid); |
| 231 | otx->hextx = tal_hex(otx, rawtx); |
| 232 | otx->failed_or_success = failed; |
| 233 | if (cmd_id) |
| 234 | otx->cmd_id = tal_strdup(otx, cmd_id); |
| 235 | else |
| 236 | otx->cmd_id = NULL; |
| 237 | tal_free(rawtx); |
| 238 | tal_add_destructor2(channel, clear_otx_channel, otx); |
| 239 | |
| 240 | log_debug(topo->log, "Broadcasting txid %s%s%s", |
| 241 | type_to_string(tmpctx, struct bitcoin_txid, &otx->txid), |
| 242 | cmd_id ? " for " : "", cmd_id ? cmd_id : ""); |
| 243 | |
| 244 | wallet_transaction_add(topo->ld->wallet, tx->wtx, 0, 0); |
| 245 | bitcoind_sendrawtx(topo->bitcoind, otx->cmd_id, otx->hextx, |
| 246 | allowhighfees, |
| 247 | broadcast_done, otx); |
| 248 | } |
| 249 | |
| 250 | static enum watch_result closeinfo_txid_confirmed(struct lightningd *ld, |
| 251 | struct channel *channel, |
no test coverage detected