@@ -640,30 +640,25 @@ static bool peer_accepted_htlc(struct channel *channel,
640640 * a subset of the cltv check done in handle_localpay and
641641 * forward_htlc. */
642642
643- /* channeld tests this, so it should have set ss to zeroes. */
644- op = parse_onionpacket (tmpctx , hin -> onion_routing_packet ,
645- sizeof (hin -> onion_routing_packet ));
646- if (!op ) {
647- if (!memeqzero (& hin -> shared_secret , sizeof (hin -> shared_secret ))){
648- channel_internal_error (channel ,
649- "bad onion in got_revoke: %s" ,
650- tal_hexstr (channel , hin -> onion_routing_packet ,
651- sizeof (hin -> onion_routing_packet )));
652- return false;
653- }
654- /* FIXME: could be bad version, bad key. */
655- * failcode = WIRE_INVALID_ONION_VERSION ;
643+ /* Channeld sets this to NULL if couldn't parse onion */
644+ if (!hin -> shared_secret ) {
645+ * failcode = WIRE_INVALID_ONION_KEY ;
656646 goto out ;
657647 }
658648
659- /* Channeld sets this to zero if HSM won't ecdh it */
660- if (memeqzero (& hin -> shared_secret , sizeof (hin -> shared_secret ))) {
661- * failcode = WIRE_INVALID_ONION_KEY ;
662- goto out ;
649+ /* channeld tests this, so it should pass. */
650+ op = parse_onionpacket (tmpctx , hin -> onion_routing_packet ,
651+ sizeof (hin -> onion_routing_packet ));
652+ if (!op ) {
653+ channel_internal_error (channel ,
654+ "bad onion in got_revoke: %s" ,
655+ tal_hexstr (channel , hin -> onion_routing_packet ,
656+ sizeof (hin -> onion_routing_packet )));
657+ return false;
663658 }
664659
665660 /* If it's crap, not channeld's fault, just fail it */
666- rs = process_onionpacket (tmpctx , op , hin -> shared_secret . data ,
661+ rs = process_onionpacket (tmpctx , op , hin -> shared_secret -> data ,
667662 hin -> payment_hash .u .u8 ,
668663 sizeof (hin -> payment_hash ));
669664 if (!rs ) {
@@ -1115,6 +1110,11 @@ static bool channel_added_their_htlc(struct channel *channel,
11151110 return false;
11161111 }
11171112
1113+ /* FIXME: Our wire generator can't handle optional elems in arrays,
1114+ * so we translate all-zero-shared-secret to NULL. */
1115+ if (memeqzero (shared_secret , sizeof (& shared_secret )))
1116+ shared_secret = NULL ;
1117+
11181118 /* This stays around even if we fail it immediately: it *is*
11191119 * part of the current commitment. */
11201120 hin = new_htlc_in (channel , channel , added -> id , added -> amount_msat ,
0 commit comments