lightningd: remember if they set "allowhighfees" when we rebroadcast.

We would only set it the first time, which was OK for how we were using it
before.  Now we want to also set it for rebroadcast.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2023-04-07 14:30:01 +09:30
parent 5582970715
commit 3754e283f8
2 changed files with 8 additions and 1 deletions

View file

@ -122,6 +122,9 @@ struct txs_to_broadcast {
/* IDs to attach to each tx (could be NULL!) */
const char **cmd_id;
/* allowhighfees flags for each tx */
bool *allowhighfees;
};
/* We just sent the last entry in txs[]. Shrink and send the next last. */
@ -143,7 +146,7 @@ static void broadcast_remainder(struct bitcoind *bitcoind,
/* Broadcast next one. */
bitcoind_sendrawtx(bitcoind,
txs->cmd_id[txs->cursor], txs->txs[txs->cursor],
false,
txs->allowhighfees[txs->cursor],
broadcast_remainder, txs);
}
@ -162,6 +165,7 @@ static void rebroadcast_txs(struct chain_topology *topo)
/* Put any txs we want to broadcast in ->txs. */
txs->txs = tal_arr(txs, const char *, 0);
txs->allowhighfees = tal_arr(txs, bool, 0);
for (otx = outgoing_tx_map_first(topo->outgoing_txs, &it); otx;
otx = outgoing_tx_map_next(topo->outgoing_txs, &it)) {
@ -181,6 +185,7 @@ static void rebroadcast_txs(struct chain_topology *topo)
}
tal_arr_expand(&txs->txs, fmt_bitcoin_tx(txs->txs, otx->tx));
tal_arr_expand(&txs->allowhighfees, otx->allowhighfees);
tal_arr_expand(&txs->cmd_id,
otx->cmd_id ? tal_strdup(txs, otx->cmd_id) : NULL);
}
@ -252,6 +257,7 @@ void broadcast_tx_(struct chain_topology *topo,
bitcoin_txid(tx, &otx->txid);
otx->tx = clone_bitcoin_tx(otx, tx);
otx->minblock = minblock;
otx->allowhighfees = allowhighfees;
otx->finished = finished;
otx->refresh = refresh;
otx->refresh_arg = refresh_arg;

View file

@ -22,6 +22,7 @@ struct outgoing_tx {
const struct bitcoin_tx *tx;
struct bitcoin_txid txid;
u32 minblock;
bool allowhighfees;
const char *cmd_id;
void (*finished)(struct channel *channel, bool success, const char *err);
bool (*refresh)(struct channel *, const struct bitcoin_tx **, void *arg);