@@ -333,9 +333,9 @@ const char *fmt_flow_full(const tal_t *ctx,
333333
334334struct getroutes_info {
335335 struct command * cmd ;
336- struct node_id * source , * dest ;
337- struct amount_msat * amount , * maxfee ;
338- u32 * finalcltv , * maxdelay ;
336+ struct node_id source , dest ;
337+ struct amount_msat amount , maxfee ;
338+ u32 finalcltv , maxdelay ;
339339 const char * * layers ;
340340 struct additional_cost_htable * additional_costs ;
341341 /* Non-NULL if we are told to use "auto.localchans" */
@@ -527,7 +527,7 @@ static struct command_result *do_getroutes(struct command *cmd,
527527 rq -> additional_costs = info -> additional_costs ;
528528
529529 /* apply selected layers to the localmods */
530- apply_layers (askrene , rq , info -> source , * info -> amount , localmods ,
530+ apply_layers (askrene , rq , & info -> source , info -> amount , localmods ,
531531 info -> layers , info -> local_layer );
532532
533533 /* Clear scids with reservations, too, so we don't have to look up
@@ -549,30 +549,30 @@ static struct command_result *do_getroutes(struct command *cmd,
549549
550550 /* checkout the source */
551551 const struct gossmap_node * srcnode =
552- gossmap_find_node (askrene -> gossmap , info -> source );
552+ gossmap_find_node (askrene -> gossmap , & info -> source );
553553 if (!srcnode ) {
554554 err = rq_log (tmpctx , rq , LOG_INFORM , "Unknown source node %s" ,
555- fmt_node_id (tmpctx , info -> source ));
555+ fmt_node_id (tmpctx , & info -> source ));
556556 goto fail ;
557557 }
558558
559559 /* checkout the destination */
560560 const struct gossmap_node * dstnode =
561- gossmap_find_node (askrene -> gossmap , info -> dest );
561+ gossmap_find_node (askrene -> gossmap , & info -> dest );
562562 if (!dstnode ) {
563563 err = rq_log (tmpctx , rq , LOG_INFORM ,
564564 "Unknown destination node %s" ,
565- fmt_node_id (tmpctx , info -> dest ));
565+ fmt_node_id (tmpctx , & info -> dest ));
566566 goto fail ;
567567 }
568568
569569 /* Compute the routes. At this point we might select between multiple
570570 * algorithms. */
571571 struct timemono time_start = time_mono ();
572- err = default_routes (rq , rq , srcnode , dstnode , * info -> amount ,
572+ err = default_routes (rq , rq , srcnode , dstnode , info -> amount ,
573573 /* only one path? = */
574574 have_layer (info -> layers , "auto.no_mpp_support" ),
575- * info -> maxfee , * info -> finalcltv , * info -> maxdelay ,
575+ info -> maxfee , info -> finalcltv , info -> maxdelay ,
576576 & flows , & probability );
577577 struct timerel time_delta = timemono_between (time_mono (), time_start );
578578
@@ -589,7 +589,7 @@ static struct command_result *do_getroutes(struct command *cmd,
589589 tal_count (flows ));
590590
591591 /* convert flows to routes */
592- routes = convert_flows_to_routes (rq , rq , * info -> finalcltv , flows ,
592+ routes = convert_flows_to_routes (rq , rq , info -> finalcltv , flows ,
593593 & amounts );
594594 assert (tal_count (routes ) == tal_count (flows ));
595595 assert (tal_count (amounts ) == tal_count (flows ));
@@ -600,7 +600,7 @@ static struct command_result *do_getroutes(struct command *cmd,
600600 /* output the results */
601601 response = jsonrpc_stream_success (cmd );
602602 json_add_getroutes (response , routes , amounts , probability ,
603- * info -> finalcltv );
603+ info -> finalcltv );
604604 return command_finished (cmd , response );
605605
606606fail :
@@ -718,36 +718,46 @@ static struct command_result *json_getroutes(struct command *cmd,
718718 /* FIXME: Typo in spec for CLTV in descripton! But it breaks our spelling check, so we omit it above */
719719 const u32 maxdelay_allowed = 2016 ;
720720 struct getroutes_info * info = tal (cmd , struct getroutes_info );
721+ /* param functions require pointers */
722+ struct node_id * source , * dest ;
723+ struct amount_msat * amount , * maxfee ;
724+ u32 * finalcltv , * maxdelay ;
721725
722726 if (!param_check (cmd , buffer , params ,
723- p_req ("source" , param_node_id , & info -> source ),
724- p_req ("destination" , param_node_id , & info -> dest ),
725- p_req ("amount_msat" , param_msat , & info -> amount ),
727+ p_req ("source" , param_node_id , & source ),
728+ p_req ("destination" , param_node_id , & dest ),
729+ p_req ("amount_msat" , param_msat , & amount ),
726730 p_req ("layers" , param_layer_names , & info -> layers ),
727- p_req ("maxfee_msat" , param_msat , & info -> maxfee ),
728- p_req ("final_cltv" , param_u32 , & info -> finalcltv ),
729- p_opt_def ("maxdelay" , param_u32 , & info -> maxdelay ,
731+ p_req ("maxfee_msat" , param_msat , & maxfee ),
732+ p_req ("final_cltv" , param_u32 , & finalcltv ),
733+ p_opt_def ("maxdelay" , param_u32 , & maxdelay ,
730734 maxdelay_allowed ),
731735 NULL ))
732736 return command_param_failed ();
733737 plugin_log (cmd -> plugin , LOG_TRACE , "%s called: %.*s" , __func__ ,
734738 json_tok_full_len (params ), json_tok_full (buffer , params ));
735739
736- if (amount_msat_is_zero (* info -> amount )) {
740+ if (amount_msat_is_zero (* amount )) {
737741 return command_fail (cmd , JSONRPC2_INVALID_PARAMS ,
738742 "amount must be non-zero" );
739743 }
740744
741- if (command_check_only (cmd ))
742- return command_check_done (cmd );
743-
744- if (* info -> maxdelay > maxdelay_allowed ) {
745+ if (* maxdelay > maxdelay_allowed ) {
745746 return command_fail (cmd , PAY_USER_ERROR ,
746747 "maximum delay allowed is %d" ,
747748 maxdelay_allowed );
748749 }
749750
751+ if (command_check_only (cmd ))
752+ return command_check_done (cmd );
753+
750754 info -> cmd = cmd ;
755+ info -> source = * source ;
756+ info -> dest = * dest ;
757+ info -> amount = * amount ;
758+ info -> maxfee = * maxfee ;
759+ info -> finalcltv = * finalcltv ;
760+ info -> maxdelay = * maxdelay ;
751761 info -> additional_costs = tal (info , struct additional_cost_htable );
752762 additional_cost_htable_init (info -> additional_costs );
753763
0 commit comments