MCPcopy Create free account
hub / github.com/ElementsProject/lightning / broadcast_tx

Function broadcast_tx

lightningd/chaintopology.c:218–248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216}
217
218void 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
250static enum watch_result closeinfo_txid_confirmed(struct lightningd *ld,
251 struct channel *channel,

Callers 2

sign_and_send_lastFunction · 0.70

Calls 6

linearize_txFunction · 0.85
tal_hexFunction · 0.85
tal_freeFunction · 0.85
bitcoin_txidClass · 0.70
type_to_stringClass · 0.50
wallet_transaction_addFunction · 0.50

Tested by

no test coverage detected