lightningd: rebroadcast code save actual tx, not just hex encoding.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2023-03-23 16:14:52 +10:30
parent 528f44c2d3
commit 0b7c2bf519
2 changed files with 7 additions and 7 deletions

View file

@ -167,7 +167,7 @@ static void rebroadcast_txs(struct chain_topology *topo)
if (wallet_transaction_height(topo->ld->wallet, &otx->txid))
continue;
tal_arr_expand(&txs->txs, tal_strdup(txs, otx->hextx));
tal_arr_expand(&txs->txs, fmt_bitcoin_tx(txs->txs, otx->tx));
tal_arr_expand(&txs->cmd_id,
otx->cmd_id ? tal_strdup(txs, otx->cmd_id) : NULL);
}
@ -229,17 +229,15 @@ void broadcast_tx(struct chain_topology *topo,
{
/* Channel might vanish: topo owns it to start with. */
struct outgoing_tx *otx = tal(topo, struct outgoing_tx);
const u8 *rawtx = linearize_tx(otx, tx);
otx->channel = channel;
bitcoin_txid(tx, &otx->txid);
otx->hextx = tal_hex(otx, rawtx);
otx->tx = clone_bitcoin_tx(otx, tx);
otx->finished = finished;
if (cmd_id)
otx->cmd_id = tal_strdup(otx, cmd_id);
else
otx->cmd_id = NULL;
tal_free(rawtx);
tal_add_destructor2(channel, clear_otx_channel, otx);
log_debug(topo->log, "Broadcasting txid %s%s%s",
@ -247,7 +245,8 @@ void broadcast_tx(struct chain_topology *topo,
cmd_id ? " for " : "", cmd_id ? cmd_id : "");
wallet_transaction_add(topo->ld->wallet, tx->wtx, 0, 0);
bitcoind_sendrawtx(topo->bitcoind, otx->cmd_id, otx->hextx,
bitcoind_sendrawtx(topo->bitcoind, otx->cmd_id,
fmt_bitcoin_tx(tmpctx, otx->tx),
allowhighfees,
broadcast_done, otx);
}

View file

@ -19,7 +19,7 @@ struct txwatch;
/* Off topology->outgoing_txs */
struct outgoing_tx {
struct channel *channel;
const char *hextx;
const struct bitcoin_tx *tx;
struct bitcoin_txid txid;
const char *cmd_id;
void (*finished)(struct channel *channel, bool success, const char *err);
@ -181,7 +181,8 @@ u32 penalty_feerate(struct chain_topology *topo);
* @finished: if non-NULL, call that and don't rebroadcast.
*/
void broadcast_tx(struct chain_topology *topo,
struct channel *channel, const struct bitcoin_tx *tx,
struct channel *channel,
const struct bitcoin_tx *tx TAKES,
const char *cmd_id, bool allowhighfees,
void (*finished)(struct channel *,
bool success,