Browse Source

MAX_FUNDING_SATOSHI: clean up def to be max, fix name, share with openingd.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
committed by Christian Decker
parent
commit
904a3e4ae3
  1. 5
      lightningd/peer_control.c
  2. 1
      lightningd/peer_control.h
  3. 7
      openingd/opening.c
  4. 6
      wire/peer_wire.h

5
lightningd/peer_control.c

@ -2559,8 +2559,9 @@ static void json_fund_channel(struct command *cmd,
return;
}
if (fc->funding_satoshi >= MAX_FUNDING_MSATOSHI) {
command_fail(cmd, "Funding msatoshi must be < %d", MAX_FUNDING_MSATOSHI);
if (fc->funding_satoshi > MAX_FUNDING_SATOSHI) {
command_fail(cmd, "Funding satoshi must be <= %d",
MAX_FUNDING_SATOSHI);
return;
}

1
lightningd/peer_control.h

@ -14,7 +14,6 @@
#include <wire/peer_wire.h>
#define ANNOUNCE_MIN_DEPTH 6
#define MAX_FUNDING_MSATOSHI (1 << 24)
struct crypto_state;

7
openingd/opening.c

@ -284,10 +284,7 @@ static u8 *funder_channel(struct state *state,
temporary_channel_id(&state->channel_id);
/* BOLT #2:
*
* The sender MUST set `funding_satoshis` to less than 2^24 satoshi. */
if (state->funding_satoshis >= 1 << 24)
if (state->funding_satoshis > MAX_FUNDING_SATOSHI)
status_failed(STATUS_FAIL_MASTER_IO,
"funding_satoshis must be < 2^24, not %"PRIu64,
state->funding_satoshis);
@ -581,7 +578,7 @@ static u8 *fundee_channel(struct state *state,
*
* The receiving node ... MUST fail the channel if `funding-satoshis`
* is greater than or equal to 2^24 */
if (state->funding_satoshis >= 1 << 24)
if (state->funding_satoshis > MAX_FUNDING_SATOSHI)
peer_failed(PEER_FD, &state->cs, &state->channel_id,
"funding_satoshis %"PRIu64" too large",
state->funding_satoshis);

6
wire/peer_wire.h

@ -44,6 +44,12 @@ bool extract_channel_id(const u8 *in_pkt, struct channel_id *channel_id);
*/
#define LOCALFEATURES_INITIAL_ROUTING_SYNC 0x08
/* BOLT #2:
*
* The sender MUST set `funding_satoshis` to less than 2^24 satoshi.
*/
#define MAX_FUNDING_SATOSHI ((1 << 24) - 1)
/* Compare two short_channel_ids and return true if they are the equal */
bool short_channel_id_eq(const struct short_channel_id *a,
const struct short_channel_id *b);

Loading…
Cancel
Save