diff --git a/lightningd/channel.c b/lightningd/channel.c index 4dbcce900..32b27475a 100644 --- a/lightningd/channel.c +++ b/lightningd/channel.c @@ -330,9 +330,9 @@ enum channel_add_err channel_add_htlc(struct channel *channel, /* BOLT #2: * - * A receiving node SHOULD fail the channel if a sending node - * adds more than `max-htlc-value-in-flight-msat` in HTLCs to - * its local commitment transaction. */ + * A receiving node SHOULD fail the channel if a sending node ... or + * adds more than its `max-htlc-value-in-flight-msat` worth of offered + * HTLCs to its local commitment transaction. */ if (msat_in_htlcs > max_htlc_value_in_flight_msat(channel, recipient)) { e = CHANNEL_ERR_MAX_HTLC_VALUE_EXCEEDED; goto out; diff --git a/lightningd/opening/opening.c b/lightningd/opening/opening.c index 7c1c5f879..f7fc11317 100644 --- a/lightningd/opening/opening.c +++ b/lightningd/opening/opening.c @@ -522,7 +522,7 @@ static u8 *recv_channel(struct state *state, const struct points *ours, "Parsing open_channel %s", tal_hex(peer_msg, peer_msg)); - /* BOLT #2: + /* BOLT #2 FIXME: * * The receiving node ... MUST fail the channel if `funding-satoshis` * is greater than or equal to 2^24 */ @@ -534,7 +534,7 @@ static u8 *recv_channel(struct state *state, const struct points *ours, /* BOLT #2: * * The receiving node ... MUST fail the channel if `push-msat` is - * greater than `funding-satoshis` * 1000. + * greater than `funding-amount` * 1000. */ if (state->push_msat > state->funding_satoshis * 1000) peer_failed(PEER_FD, &state->cs, NULL, WIRE_OPENING_PEER_BAD_FUNDING, @@ -542,7 +542,7 @@ static u8 *recv_channel(struct state *state, const struct points *ours, " too large for funding_satoshis %"PRIu64, state->push_msat, state->funding_satoshis); - /* BOLT #3: + /* BOLT #2: * * The receiver MUST fail the channel if it considers `feerate-per-kw` * too small for timely processing, or unreasonably large. diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index 64a7d45a5..b53ca765a 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -627,7 +627,7 @@ static void channel_config(struct lightningd *ld, ours->dust_limit_satoshis = 546; ours->max_htlc_value_in_flight_msat = UINT64_MAX; - /* BOLT #3: + /* BOLT #2: * * The sender SHOULD set `minimum-depth` to an amount where * the sender considers reorganizations to be low risk. @@ -637,7 +637,7 @@ static void channel_config(struct lightningd *ld, /* Don't care */ ours->htlc_minimum_msat = 0; - /* BOLT #3: + /* BOLT #2: * * The sender SHOULD set `to-self-delay` sufficient to ensure * the sender can irreversibly spend a commitment transaction diff --git a/lightningd/test/run-channel.c b/lightningd/test/run-channel.c index 48c020fa3..441a74261 100644 --- a/lightningd/test/run-channel.c +++ b/lightningd/test/run-channel.c @@ -40,25 +40,25 @@ static struct sha256_double txid_from_hex(const char *hex) * * local_feerate_per_kw: 0 * ... - * local_feerate_per_kw: 678 + * local_feerate_per_kw: 676 * ... - * local_feerate_per_kw: 679 + * local_feerate_per_kw: 677 * ... - * local_feerate_per_kw: 2168 + * local_feerate_per_kw: 2161 * ... - * local_feerate_per_kw: 2169 + * local_feerate_per_kw: 2162 * ... - * local_feerate_per_kw: 2294 + * local_feerate_per_kw: 2291 * ... - * local_feerate_per_kw: 2295 + * local_feerate_per_kw: 2292 * ... - * local_feerate_per_kw: 3872 + * local_feerate_per_kw: 3866 * ... - * local_feerate_per_kw: 3873 + * local_feerate_per_kw: 3867 * ... - * local_feerate_per_kw: 5149 + * local_feerate_per_kw: 5133 * ... - * local_feerate_per_kw: 5150 + * local_feerate_per_kw: 5134 * ... * local_feerate_per_kw: 9651180 * ... @@ -68,16 +68,16 @@ static struct sha256_double txid_from_hex(const char *hex) */ static u64 feerates[] = { 0, - 678, - 679, - 2168, - 2169, - 2294, - 2295, - 3872, - 3873, - 5149, - 5150, + 676, + 677, + 2161, + 2162, + 2291, + 2292, + 3866, + 3867, + 5133, + 5134, 9651180, 9651181, 9651936 diff --git a/lightningd/test/run-commit_tx.c b/lightningd/test/run-commit_tx.c index 0d8a02bdf..d31f51b55 100644 --- a/lightningd/test/run-commit_tx.c +++ b/lightningd/test/run-commit_tx.c @@ -358,6 +358,22 @@ static u64 increase(u64 feerate_per_kw) #else static u64 increase(u64 feerate_per_kw) { + /* BOLT #3: + * + * local_feerate_per_kw: 0 + * ... + * local_feerate_per_kw: 677 + * ... + * local_feerate_per_kw: 2162 + * ... + * local_feerate_per_kw: 2292 + * ... + * local_feerate_per_kw: 3867 + * ... + * local_feerate_per_kw: 5134 + * ... + * local_feerate_per_kw: 9651181 + */ const u64 rates[] = { 0, 677, 2162, 2292, 3867, 5134, 9651181 }; size_t i; @@ -876,6 +892,15 @@ int main(void) continue; } + /* BOLT #3: + * + * name: commitment tx with fee greater than funder amount + * to_local_msat: 6988000000 + * to_remote_msat: 3000000000 + * local_feerate_per_kw: 9651936 + */ + assert(feerate_per_kw == 9651936); + printf("\n" "name: commitment tx with fee greater than funder amount\n" "to_local_msat: %"PRIu64"\n"