channel: fix max feelevel calculation.

We were out by 1000, and also derived it from the previous, not current
state.

Reported-by: Christian Decker
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2016-10-07 14:00:17 +10:30
parent ab569c069f
commit 25b3dc0038
2 changed files with 3 additions and 2 deletions

View File

@ -172,7 +172,7 @@ uint64_t approx_max_feerate(const struct channel_state *cstate,
max_funds = cstate->side[side].pay_msat + cstate->side[side].fee_msat;
return max_funds * 1000 / tx_bytes(cstate->num_nondust);
return max_funds / tx_bytes(cstate->num_nondust);
}
bool can_afford_feerate(const struct channel_state *cstate, uint64_t fee_rate,

View File

@ -2119,7 +2119,8 @@ static void maybe_propose_new_feerate(struct peer *peer)
u64 rate, max_rate;
rate = desired_commit_feerate(peer->dstate);
max_rate = approx_max_feerate(peer->remote.commit->cstate, LOCAL);
max_rate = approx_max_feerate(peer->remote.staging_cstate, LOCAL);
assert(can_afford_feerate(peer->remote.staging_cstate, max_rate, LOCAL));
/* BOLT #2:
*