Browse Source

channel: use u64 for fee_rate everywhere.

It fits in a u32, but we mix it with other values which could cause
overflow, so let's just use u64 everywhere.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 9 years ago
parent
commit
7275aa9c32
  1. 10
      daemon/channel.c
  2. 8
      daemon/channel.h

10
daemon/channel.c

@ -7,7 +7,7 @@
#include <ccan/structeq/structeq.h>
#include <string.h>
uint64_t fee_by_feerate(size_t txsize, uint32_t fee_rate)
uint64_t fee_by_feerate(size_t txsize, uint64_t fee_rate)
{
/* BOLT #2:
*
@ -19,7 +19,7 @@ uint64_t fee_by_feerate(size_t txsize, uint32_t fee_rate)
}
static uint64_t calculate_fee_msat(size_t num_nondust_htlcs,
uint32_t fee_rate)
uint64_t fee_rate)
{
uint64_t bytes;
@ -86,7 +86,7 @@ static void recalculate_fees(struct channel_oneside *a,
/* a transfers htlc_msat to a HTLC (gains it, if -ve) */
static bool change_funding(uint64_t anchor_satoshis,
uint32_t fee_rate,
uint64_t fee_rate,
int64_t htlc_msat,
struct channel_oneside *a,
struct channel_oneside *b,
@ -118,7 +118,7 @@ static bool change_funding(uint64_t anchor_satoshis,
struct channel_state *initial_cstate(const tal_t *ctx,
uint64_t anchor_satoshis,
uint32_t fee_rate,
uint64_t fee_rate,
enum channel_side funding)
{
uint64_t fee_msat;
@ -155,7 +155,7 @@ struct channel_state *initial_cstate(const tal_t *ctx,
return cstate;
}
void adjust_fee(struct channel_state *cstate, uint32_t fee_rate)
void adjust_fee(struct channel_state *cstate, uint64_t fee_rate)
{
uint64_t fee_msat;

8
daemon/channel.h

@ -26,7 +26,7 @@ struct channel_state {
/* Satoshis paid by anchor. */
uint64_t anchor;
/* Satoshis per 1000 bytes. */
uint32_t fee_rate;
uint64_t fee_rate;
/* Number of non-dust htlcs (to calculate txsize) */
unsigned int num_nondust;
struct channel_oneside side[2];
@ -43,7 +43,7 @@ struct channel_state {
*/
struct channel_state *initial_cstate(const tal_t *ctx,
uint64_t anchor_satoshis,
uint32_t fee_rate,
uint64_t fee_rate,
enum channel_side side);
/**
@ -89,7 +89,7 @@ void cstate_fulfill_htlc(struct channel_state *cstate, const struct htlc *htlc);
* @cstate: The channel state
* @fee_rate: fee in satoshi per 1000 bytes.
*/
void adjust_fee(struct channel_state *cstate, uint32_t fee_rate);
void adjust_fee(struct channel_state *cstate, uint64_t fee_rate);
/**
* force_fee: Change fee to a specific value.
@ -107,6 +107,6 @@ bool force_fee(struct channel_state *cstate, uint64_t fee);
* @txsize: transaction size in bytes.
* @fee_rate: satoshi per 1000 bytes.
*/
uint64_t fee_by_feerate(size_t txsize, uint32_t fee_rate);
uint64_t fee_by_feerate(size_t txsize, uint64_t fee_rate);
#endif /* LIGHTNING_DAEMON_CHANNEL_H */

Loading…
Cancel
Save