mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 14:42:40 +01:00
channeld: cleanup: use the channel_feerate() accessor everywhere.
And also move it to initial_channel, so we can use it there. This saves churn in the next patch. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
b9d6e8bbaa
commit
8ffd9d570b
4 changed files with 21 additions and 14 deletions
|
@ -1392,11 +1392,11 @@ static void handle_peer_commit_sig(struct peer *peer, const u8 *msg)
|
|||
/* We were supposed to check this was affordable as we go. */
|
||||
if (peer->channel->funder == REMOTE) {
|
||||
status_debug("Feerates are %u/%u",
|
||||
peer->channel->view[LOCAL].feerate_per_kw,
|
||||
peer->channel->view[REMOTE].feerate_per_kw);
|
||||
channel_feerate(peer->channel, LOCAL),
|
||||
channel_feerate(peer->channel, REMOTE));
|
||||
assert(can_funder_afford_feerate(peer->channel,
|
||||
peer->channel->view[LOCAL]
|
||||
.feerate_per_kw));
|
||||
channel_feerate(peer->channel,
|
||||
LOCAL)));
|
||||
}
|
||||
|
||||
if (!fromwire_commitment_signed(tmpctx, msg,
|
||||
|
@ -1443,7 +1443,7 @@ static void handle_peer_commit_sig(struct peer *peer, const u8 *msg)
|
|||
type_to_string(msg, struct pubkey,
|
||||
&peer->channel->funding_pubkey
|
||||
[REMOTE]),
|
||||
peer->channel->view[LOCAL].feerate_per_kw);
|
||||
channel_feerate(peer->channel, LOCAL));
|
||||
}
|
||||
|
||||
/* BOLT #2:
|
||||
|
|
|
@ -231,7 +231,7 @@ static void add_htlcs(struct bitcoin_tx ***txs,
|
|||
{
|
||||
size_t i;
|
||||
struct bitcoin_txid txid;
|
||||
u32 feerate_per_kw = channel->view[side].feerate_per_kw;
|
||||
u32 feerate_per_kw = channel_feerate(channel, side);
|
||||
|
||||
/* Get txid of commitment transaction */
|
||||
bitcoin_txid((*txs)[0], &txid);
|
||||
|
@ -306,7 +306,7 @@ struct bitcoin_tx **channel_txs(const tal_t *ctx,
|
|||
ctx, &channel->funding_txid, channel->funding_txout,
|
||||
channel->funding, channel->funder,
|
||||
channel->config[!side].to_self_delay, &keyset,
|
||||
channel->view[side].feerate_per_kw,
|
||||
channel_feerate(channel, side),
|
||||
channel->config[side].dust_limit, channel->view[side].owed[side],
|
||||
channel->view[side].owed[!side], committed, htlcmap,
|
||||
commitment_number ^ channel->commitment_number_obscurer, side);
|
||||
|
@ -370,7 +370,7 @@ static struct amount_sat fee_for_htlcs(const struct channel *channel,
|
|||
const struct htlc **removing,
|
||||
enum side side)
|
||||
{
|
||||
u32 feerate = view->feerate_per_kw;
|
||||
u32 feerate = channel_feerate(channel, side);
|
||||
struct amount_sat dust_limit = channel->config[side].dust_limit;
|
||||
size_t untrimmed;
|
||||
|
||||
|
@ -972,11 +972,6 @@ bool channel_update_feerate(struct channel *channel, u32 feerate_per_kw)
|
|||
return true;
|
||||
}
|
||||
|
||||
u32 channel_feerate(const struct channel *channel, enum side side)
|
||||
{
|
||||
return channel->view[side].feerate_per_kw;
|
||||
}
|
||||
|
||||
bool channel_sending_commit(struct channel *channel,
|
||||
const struct htlc ***htlcs)
|
||||
{
|
||||
|
|
|
@ -100,7 +100,7 @@ struct bitcoin_tx *initial_channel_tx(const tal_t *ctx,
|
|||
/* They specify our to_self_delay and v.v. */
|
||||
channel->config[!side].to_self_delay,
|
||||
&keyset,
|
||||
channel->view[side].feerate_per_kw,
|
||||
channel_feerate(channel, side),
|
||||
channel->config[side].dust_limit,
|
||||
channel->view[side].owed[side],
|
||||
channel->view[side].owed[!side],
|
||||
|
@ -110,6 +110,11 @@ struct bitcoin_tx *initial_channel_tx(const tal_t *ctx,
|
|||
err_reason);
|
||||
}
|
||||
|
||||
u32 channel_feerate(const struct channel *channel, enum side side)
|
||||
{
|
||||
return channel->view[side].feerate_per_kw;
|
||||
}
|
||||
|
||||
static char *fmt_channel_view(const tal_t *ctx, const struct channel_view *view)
|
||||
{
|
||||
return tal_fmt(ctx, "{ feerate_per_kw=%"PRIu32","
|
||||
|
|
|
@ -122,4 +122,11 @@ struct bitcoin_tx *initial_channel_tx(const tal_t *ctx,
|
|||
enum side side,
|
||||
char** err_reason);
|
||||
|
||||
/**
|
||||
* channel_feerate: Get fee rate for this side of channel.
|
||||
* @channel: The channel
|
||||
* @side: the side
|
||||
*/
|
||||
u32 channel_feerate(const struct channel *channel, enum side side);
|
||||
|
||||
#endif /* LIGHTNING_COMMON_INITIAL_CHANNEL_H */
|
||||
|
|
Loading…
Add table
Reference in a new issue