@@ -266,8 +266,6 @@ static bool print_blindedpaths(const char *fieldname,
266266 struct blinded_path * * paths ,
267267 struct blinded_payinfo * * blindedpay )
268268{
269- size_t bp_idx = 0 ;
270-
271269 for (size_t i = 0 ; i < tal_count (paths ); i ++ ) {
272270 struct blinded_path_hop * * p = paths [i ]-> path ;
273271 printf ("%s %zu/%zu: first_path_key %s " ,
@@ -282,22 +280,24 @@ static bool print_blindedpaths(const char *fieldname,
282280 fmt_pubkey (tmpctx ,
283281 & p [j ]-> blinded_node_id ),
284282 tal_hex (tmpctx , p [j ]-> encrypted_recipient_data ));
285- if (blindedpay ) {
286- if (bp_idx < tal_count (blindedpay ))
287- printf ("fee=%u/%u,cltv=%u,features=%s" ,
288- blindedpay [bp_idx ]-> fee_base_msat ,
289- blindedpay [bp_idx ]-> fee_proportional_millionths ,
290- blindedpay [bp_idx ]-> cltv_expiry_delta ,
291- tal_hex (tmpctx ,
292- blindedpay [bp_idx ]-> features ));
293- bp_idx ++ ;
294- }
283+ }
284+ if (i < tal_count (blindedpay )) {
285+ printf (" blindedpay: fee=%u/%u,cltv=%u,features=%s" ,
286+ blindedpay [i ]-> fee_base_msat ,
287+ blindedpay [i ]-> fee_proportional_millionths ,
288+ blindedpay [i ]-> cltv_expiry_delta ,
289+ tal_hex (tmpctx , blindedpay [i ]-> features ));
295290 }
296291 printf ("\n" );
297292 }
298- if (blindedpay && tal_count (blindedpay ) != bp_idx ) {
293+ /* BOLT #12:
294+ * - MUST reject the invoice if `invoice_blindedpay` does not
295+ * contain exactly one `blinded_payinfo` per
296+ * `invoice_paths`.`blinded_path`.
297+ */
298+ if (blindedpay && tal_count (blindedpay ) != tal_count (paths )) {
299299 fprintf (stderr , "Expected %zu blindedpay fields, got %zu\n" ,
300- bp_idx , tal_count (blindedpay ));
300+ tal_count ( paths ) , tal_count (blindedpay ));
301301 return false;
302302 }
303303 return true;
@@ -893,7 +893,11 @@ int main(int argc, char *argv[])
893893 well_formed &= print_offer_amount (invreq -> offer_chains ,
894894 invreq -> offer_currency ,
895895 * invreq -> offer_amount );
896- if (must_have (invreq , offer_description ))
896+ if (invreq -> offer_amount && !invreq -> offer_description ) {
897+ fprintf (stderr , "Missing offer_description (with offer_amount)\n" );
898+ well_formed = false;
899+ }
900+ if (invreq -> offer_description )
897901 well_formed &= print_utf8 ("offer_description" , invreq -> offer_description );
898902 if (invreq -> offer_features )
899903 print_features ("offer_features" , invreq -> offer_features );
@@ -971,7 +975,11 @@ int main(int argc, char *argv[])
971975 well_formed &= print_offer_amount (invoice -> offer_chains ,
972976 invoice -> offer_currency ,
973977 * invoice -> offer_amount );
974- if (must_have (invoice , offer_description ))
978+ if (invoice -> offer_amount && !invoice -> offer_description ) {
979+ fprintf (stderr , "Missing offer_description (with offer_amount)\n" );
980+ well_formed = false;
981+ }
982+ if (invoice -> offer_description )
975983 well_formed &= print_utf8 ("offer_description" , invoice -> offer_description );
976984 if (invoice -> offer_features )
977985 print_features ("offer_features" , invoice -> offer_features );
0 commit comments