diff --git a/channeld/channeld.c b/channeld/channeld.c index a0eedef87..058115870 100644 --- a/channeld/channeld.c +++ b/channeld/channeld.c @@ -690,31 +690,20 @@ static void handle_peer_add_htlc(struct peer *peer, const u8 *msg) u8 onion_routing_packet[TOTAL_PACKET_SIZE(ROUTING_INFO_SIZE)]; enum channel_add_err add_err; struct htlc *htlc; -#if EXPERIMENTAL_FEATURES struct tlv_update_add_tlvs *tlvs; -#endif - struct pubkey *blinding = NULL; - if (!fromwire_update_add_htlc -#if EXPERIMENTAL_FEATURES - (msg, msg, &channel_id, &id, &amount, - &payment_hash, &cltv_expiry, - onion_routing_packet, &tlvs) -#else - (msg, &channel_id, &id, &amount, - &payment_hash, &cltv_expiry, - onion_routing_packet) -#endif - ) + if (!fromwire_update_add_htlc(msg, msg, &channel_id, &id, &amount, + &payment_hash, &cltv_expiry, + onion_routing_packet, &tlvs) + /* This is an *even* field: don't send if we didn't understand */ + || (tlvs->blinding && !feature_offered(peer->our_features->bits[INIT_FEATURE], + OPT_ROUTE_BLINDING))) { peer_failed_warn(peer->pps, &peer->channel_id, "Bad peer_add_htlc %s", tal_hex(msg, msg)); - -#if EXPERIMENTAL_FEATURES - blinding = tlvs->blinding; -#endif + } add_err = channel_add_htlc(peer->channel, REMOTE, id, amount, cltv_expiry, &payment_hash, - onion_routing_packet, blinding, &htlc, NULL, + onion_routing_packet, tlvs->blinding, &htlc, NULL, /* We don't immediately fail incoming htlcs, * instead we wait and fail them after * they've been committed */ @@ -2431,7 +2420,6 @@ static void resend_commitment(struct peer *peer, struct changed_htlc *last) last[i].id); if (h->state == SENT_ADD_COMMIT) { -#if EXPERIMENTAL_FEATURES struct tlv_update_add_tlvs *tlvs; if (h->blinding) { tlvs = tlv_update_add_tlvs_new(tmpctx); @@ -2439,17 +2427,12 @@ static void resend_commitment(struct peer *peer, struct changed_htlc *last) h->blinding); } else tlvs = NULL; -#endif msg = towire_update_add_htlc(NULL, &peer->channel_id, h->id, h->amount, &h->rhash, abs_locktime_to_blocks( &h->expiry), - h->routing -#if EXPERIMENTAL_FEATURES - , tlvs -#endif - ); + h->routing, tlvs); peer_write(peer->pps, take(msg)); } } @@ -3315,6 +3298,7 @@ static void handle_offer_htlc(struct peer *peer, const u8 *inmsg) const char *failstr; struct amount_sat htlc_fee; struct pubkey *blinding; + struct tlv_update_add_tlvs *tlvs; if (!peer->channel_ready[LOCAL] || !peer->channel_ready[REMOTE]) status_failed(STATUS_FAIL_MASTER_IO, @@ -3325,14 +3309,11 @@ static void handle_offer_htlc(struct peer *peer, const u8 *inmsg) onion_routing_packet, &blinding)) master_badmsg(WIRE_CHANNELD_OFFER_HTLC, inmsg); -#if EXPERIMENTAL_FEATURES - struct tlv_update_add_tlvs *tlvs; if (blinding) { tlvs = tlv_update_add_tlvs_new(tmpctx); tlvs->blinding = tal_dup(tlvs, struct pubkey, blinding); } else tlvs = NULL; -#endif e = channel_add_htlc(peer->channel, LOCAL, peer->htlc_id, amount, cltv_expiry, &payment_hash, @@ -3350,11 +3331,7 @@ static void handle_offer_htlc(struct peer *peer, const u8 *inmsg) msg = towire_update_add_htlc(NULL, &peer->channel_id, peer->htlc_id, amount, &payment_hash, cltv_expiry, - onion_routing_packet -#if EXPERIMENTAL_FEATURES - , tlvs -#endif - ); + onion_routing_packet, tlvs); peer_write(peer->pps, take(msg)); start_commit_timer(peer); /* Tell the master. */ diff --git a/lightningd/peer_htlcs.c b/lightningd/peer_htlcs.c index bfac59955..64ee72cce 100644 --- a/lightningd/peer_htlcs.c +++ b/lightningd/peer_htlcs.c @@ -149,7 +149,6 @@ static void fail_in_htlc(struct htlc_in *hin, htlc_in_update_state(hin->key.channel, hin, SENT_REMOVE_HTLC); htlc_in_check(hin, __func__); -#if EXPERIMENTAL_FEATURES /* BOLT-route-blinding #4: * - If `blinding_point` is set in the incoming `update_add_htlc`: * - MUST return `invalid_onion_blinding` on any error, including @@ -159,7 +158,6 @@ static void fail_in_htlc(struct htlc_in *hin, failed_htlc = mk_failed_htlc_badonion(tmpctx, hin, WIRE_INVALID_ONION_BLINDING); } else -#endif failed_htlc = mk_failed_htlc(tmpctx, hin, hin->failonion); bool we_filled = false; @@ -1149,7 +1147,6 @@ static bool ecdh_maybe_blinding(const struct pubkey *ephemeral_key, { struct pubkey point = *ephemeral_key; -#if EXPERIMENTAL_FEATURES if (blinding) { struct secret hmac; struct secret blinding_ss; @@ -1167,7 +1164,6 @@ static bool ecdh_maybe_blinding(const struct pubkey *ephemeral_key, return false; } } -#endif /* EXPERIMENTAL_FEATURES */ ecdh(&point, ss); return true; } @@ -1234,6 +1230,10 @@ static bool peer_accepted_htlc(const tal_t *ctx, struct onionpacket *op; struct lightningd *ld = channel->peer->ld; struct htlc_accepted_hook_payload *hook_payload; + const bool opt_blinding + = feature_offered(ld->our_features->bits[INIT_FEATURE], + OPT_ROUTE_BLINDING); + *failmsg = NULL; *badonion = 0; @@ -1335,9 +1335,9 @@ static bool peer_accepted_htlc(const tal_t *ctx, hook_payload->channel = channel; hook_payload->next_onion = serialize_onionpacket(hook_payload, rs->next); -#if EXPERIMENTAL_FEATURES /* We could have blinding from hin or from inside onion. */ - if (hook_payload->payload && hook_payload->payload->blinding) { + if (opt_blinding + && hook_payload->payload && hook_payload->payload->blinding) { struct sha256 sha; blinding_hash_e_and_ss(hook_payload->payload->blinding, &hook_payload->payload->blinding_ss, @@ -1346,7 +1346,6 @@ static bool peer_accepted_htlc(const tal_t *ctx, blinding_next_pubkey(hook_payload->payload->blinding, &sha, hook_payload->next_blinding); } else -#endif hook_payload->next_blinding = NULL; /* The scid is merely used to indicate the next peer, it is not @@ -1365,13 +1364,11 @@ static bool peer_accepted_htlc(const tal_t *ctx, return true; fail: -#if EXPERIMENTAL_FEATURES /* In a blinded path, *all* failures are "invalid_onion_blinding" */ if (hin->blinding) { *failmsg = tal_free(*failmsg); *badonion = WIRE_INVALID_ONION_BLINDING; } -#endif return false; } diff --git a/wire/extracted_peer_exp_add_htlc-plus-blinding.patch b/wire/extracted_peer_add_htlc-plus-blinding.patch similarity index 100% rename from wire/extracted_peer_exp_add_htlc-plus-blinding.patch rename to wire/extracted_peer_add_htlc-plus-blinding.patch diff --git a/wire/peer_wire.csv b/wire/peer_wire.csv index 2b4349879..ee1290464 100644 --- a/wire/peer_wire.csv +++ b/wire/peer_wire.csv @@ -214,6 +214,9 @@ msgdata,update_add_htlc,amount_msat,u64, msgdata,update_add_htlc,payment_hash,sha256, msgdata,update_add_htlc,cltv_expiry,u32, msgdata,update_add_htlc,onion_routing_packet,byte,1366 +msgdata,update_add_htlc,tlvs,update_add_tlvs, +tlvtype,update_add_tlvs,blinding,2 +tlvdata,update_add_tlvs,blinding,blinding,point, msgtype,update_fulfill_htlc,130 msgdata,update_fulfill_htlc,channel_id,channel_id, msgdata,update_fulfill_htlc,id,u64, diff --git a/wire/test/run-peer-wire.c b/wire/test/run-peer-wire.c index c6e5393cc..c5a8179ff 100644 --- a/wire/test/run-peer-wire.c +++ b/wire/test/run-peer-wire.c @@ -680,37 +680,21 @@ static void *towire_struct_update_add_htlc(const tal_t *ctx, s->amount_msat, &s->payment_hash, s->expiry, - s->onion_routing_packet -#if EXPERIMENTAL_FEATURES - ,NULL -#endif - ); + s->onion_routing_packet, NULL); } static struct msg_update_add_htlc *fromwire_struct_update_add_htlc(const tal_t *ctx, const void *p) { struct msg_update_add_htlc *s = tal(ctx, struct msg_update_add_htlc); - if (fromwire_update_add_htlc -#if EXPERIMENTAL_FEATURES - (s, p, + if (fromwire_update_add_htlc(s, p, &s->channel_id, &s->id, &s->amount_msat, &s->payment_hash, &s->expiry, s->onion_routing_packet, - &s->tlvs -#else - (p, - &s->channel_id, - &s->id, - &s->amount_msat, - &s->payment_hash, - &s->expiry, - s->onion_routing_packet -#endif - )) + &s->tlvs)) return s; return tal_free(s); }