channeld: reject wumbo payments with more style.

WIRE_REQUIRED_CHANNEL_FEATURE_MISSING anticipates a glorious Wumbo future,
and is closer to correct (it's a PERM failure).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2019-10-03 15:20:12 +09:30
parent 776674117b
commit fa686c5ca7
3 changed files with 14 additions and 4 deletions

View File

@@ -2642,11 +2642,11 @@ static void handle_offer_htlc(struct peer *peer, const u8 *inmsg)
status_failed(STATUS_FAIL_MASTER_IO, status_failed(STATUS_FAIL_MASTER_IO,
"Duplicate HTLC %"PRIu64, peer->htlc_id); "Duplicate HTLC %"PRIu64, peer->htlc_id);
/* FIXME: Fuzz the boundaries a bit to avoid probing? */
case CHANNEL_ERR_MAX_HTLC_VALUE_EXCEEDED: case CHANNEL_ERR_MAX_HTLC_VALUE_EXCEEDED:
failcode = WIRE_TEMPORARY_CHANNEL_FAILURE; failcode = WIRE_REQUIRED_CHANNEL_FEATURE_MISSING;
failmsg = tal_fmt(inmsg, "Maximum value exceeded"); failmsg = tal_fmt(inmsg, "Mini mode: maximum value exceeded");
goto failed; goto failed;
/* FIXME: Fuzz the boundaries a bit to avoid probing? */
case CHANNEL_ERR_CHANNEL_CAPACITY_EXCEEDED: case CHANNEL_ERR_CHANNEL_CAPACITY_EXCEEDED:
failcode = WIRE_TEMPORARY_CHANNEL_FAILURE; failcode = WIRE_TEMPORARY_CHANNEL_FAILURE;
failmsg = tal_fmt(inmsg, "Capacity exceeded - HTLC fee: %s", fmt_amount_sat(inmsg, &htlc_fee)); failmsg = tal_fmt(inmsg, "Capacity exceeded - HTLC fee: %s", fmt_amount_sat(inmsg, &htlc_fee));

View File

@@ -440,10 +440,13 @@ static enum channel_add_err add_htlc(struct channel *channel,
/* BOLT #2: /* BOLT #2:
* *
* A sending node:
*...
* - for channels with `chain_hash` identifying the Bitcoin blockchain: * - for channels with `chain_hash` identifying the Bitcoin blockchain:
* - MUST set the four most significant bytes of `amount_msat` to 0. * - MUST set the four most significant bytes of `amount_msat` to 0.
*/ */
if (amount_msat_greater(htlc->amount, channel->chainparams->max_payment)) { if (sender == LOCAL
&& amount_msat_greater(htlc->amount, channel->chainparams->max_payment)) {
return CHANNEL_ERR_MAX_HTLC_VALUE_EXCEEDED; return CHANNEL_ERR_MAX_HTLC_VALUE_EXCEEDED;
} }

View File

@@ -526,6 +526,13 @@ static void forward_htlc(struct htlc_in *hin,
goto fail; goto fail;
} }
if (amount_msat_greater(amt_to_forward,
get_chainparams(ld)->max_payment)) {
/* ENOWUMBO! */
failcode = WIRE_REQUIRED_CHANNEL_FEATURE_MISSING;
goto fail;
}
/* BOLT #2: /* BOLT #2:
* *
* An offering node: * An offering node: