feerate: keep feerates separately for each side.

When we support changing them, they can be different during the transition.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2017-11-21 14:14:35 +10:30
committed by Christian Decker
parent 24b4326b30
commit b836b452dc
11 changed files with 50 additions and 32 deletions

View File

@@ -1893,7 +1893,8 @@ static void peer_start_closingd(struct peer *peer,
* calculated in [BOLT
* #3](03-transactions.md#fee-calculation).
*/
feelimit = commit_tx_base_fee(peer->channel_info->feerate_per_kw, 0);
feelimit = commit_tx_base_fee(peer->channel_info->feerate_per_kw[LOCAL],
0);
maxfee = commit_tx_base_fee(get_feerate(peer->ld->topology,
FEERATE_IMMEDIATE), 0);
@@ -2193,11 +2194,14 @@ static void opening_funder_finished(struct subd *opening, const u8 *resp,
&fc->peer->minimum_depth,
&channel_info->remote_fundingkey,
&funding_txid,
&channel_info->feerate_per_kw)) {
&channel_info->feerate_per_kw[REMOTE])) {
peer_internal_error(fc->peer, "bad funder_reply: %s",
tal_hex(resp, resp));
return;
}
/* Feerates begin identical. */
channel_info->feerate_per_kw[LOCAL]
= channel_info->feerate_per_kw[REMOTE];
/* old_remote_per_commit not valid yet, copy valid one. */
channel_info->old_remote_per_commit = channel_info->remote_per_commit;
@@ -2312,13 +2316,17 @@ static void opening_fundee_finished(struct subd *opening,
&peer->funding_satoshi,
&peer->push_msat,
&peer->channel_flags,
&channel_info->feerate_per_kw,
&channel_info->feerate_per_kw[REMOTE],
&funding_signed)) {
peer_internal_error(peer, "bad OPENING_FUNDEE_REPLY %s",
tal_hex(reply, reply));
return;
}
/* Feerates begin identical. */
channel_info->feerate_per_kw[LOCAL]
= channel_info->feerate_per_kw[REMOTE];
/* old_remote_per_commit not valid yet, copy valid one. */
channel_info->old_remote_per_commit = channel_info->remote_per_commit;

View File

@@ -14,7 +14,8 @@ struct channel_info {
/* The old_remote_per_commit is for the locked-in remote commit_tx,
* and the remote_per_commit is for the commit_tx we're modifying now. */
struct pubkey remote_per_commit, old_remote_per_commit;
u32 feerate_per_kw;
/* In transition, these can be different! */
u32 feerate_per_kw[NUM_SIDES];
};
/* Get all HTLCs for a peer, to send in init message. */