@@ -333,9 +333,9 @@ const char *fmt_flow_full(const tal_t *ctx,
333
333
334
334
struct getroutes_info {
335
335
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 ;
339
339
const char * * layers ;
340
340
struct additional_cost_htable * additional_costs ;
341
341
/* Non-NULL if we are told to use "auto.localchans" */
@@ -527,7 +527,7 @@ static struct command_result *do_getroutes(struct command *cmd,
527
527
rq -> additional_costs = info -> additional_costs ;
528
528
529
529
/* 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 ,
531
531
info -> layers , info -> local_layer );
532
532
533
533
/* 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,
549
549
550
550
/* checkout the source */
551
551
const struct gossmap_node * srcnode =
552
- gossmap_find_node (askrene -> gossmap , info -> source );
552
+ gossmap_find_node (askrene -> gossmap , & info -> source );
553
553
if (!srcnode ) {
554
554
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 ));
556
556
goto fail ;
557
557
}
558
558
559
559
/* checkout the destination */
560
560
const struct gossmap_node * dstnode =
561
- gossmap_find_node (askrene -> gossmap , info -> dest );
561
+ gossmap_find_node (askrene -> gossmap , & info -> dest );
562
562
if (!dstnode ) {
563
563
err = rq_log (tmpctx , rq , LOG_INFORM ,
564
564
"Unknown destination node %s" ,
565
- fmt_node_id (tmpctx , info -> dest ));
565
+ fmt_node_id (tmpctx , & info -> dest ));
566
566
goto fail ;
567
567
}
568
568
569
569
/* Compute the routes. At this point we might select between multiple
570
570
* algorithms. */
571
571
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 ,
573
573
/* only one path? = */
574
574
have_layer (info -> layers , "auto.no_mpp_support" ),
575
- * info -> maxfee , * info -> finalcltv , * info -> maxdelay ,
575
+ info -> maxfee , info -> finalcltv , info -> maxdelay ,
576
576
& flows , & probability );
577
577
struct timerel time_delta = timemono_between (time_mono (), time_start );
578
578
@@ -589,7 +589,7 @@ static struct command_result *do_getroutes(struct command *cmd,
589
589
tal_count (flows ));
590
590
591
591
/* 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 ,
593
593
& amounts );
594
594
assert (tal_count (routes ) == tal_count (flows ));
595
595
assert (tal_count (amounts ) == tal_count (flows ));
@@ -600,7 +600,7 @@ static struct command_result *do_getroutes(struct command *cmd,
600
600
/* output the results */
601
601
response = jsonrpc_stream_success (cmd );
602
602
json_add_getroutes (response , routes , amounts , probability ,
603
- * info -> finalcltv );
603
+ info -> finalcltv );
604
604
return command_finished (cmd , response );
605
605
606
606
fail :
@@ -718,36 +718,46 @@ static struct command_result *json_getroutes(struct command *cmd,
718
718
/* FIXME: Typo in spec for CLTV in descripton! But it breaks our spelling check, so we omit it above */
719
719
const u32 maxdelay_allowed = 2016 ;
720
720
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 ;
721
725
722
726
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 ),
726
730
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 ,
730
734
maxdelay_allowed ),
731
735
NULL ))
732
736
return command_param_failed ();
733
737
plugin_log (cmd -> plugin , LOG_TRACE , "%s called: %.*s" , __func__ ,
734
738
json_tok_full_len (params ), json_tok_full (buffer , params ));
735
739
736
- if (amount_msat_is_zero (* info -> amount )) {
740
+ if (amount_msat_is_zero (* amount )) {
737
741
return command_fail (cmd , JSONRPC2_INVALID_PARAMS ,
738
742
"amount must be non-zero" );
739
743
}
740
744
741
- if (command_check_only (cmd ))
742
- return command_check_done (cmd );
743
-
744
- if (* info -> maxdelay > maxdelay_allowed ) {
745
+ if (* maxdelay > maxdelay_allowed ) {
745
746
return command_fail (cmd , PAY_USER_ERROR ,
746
747
"maximum delay allowed is %d" ,
747
748
maxdelay_allowed );
748
749
}
749
750
751
+ if (command_check_only (cmd ))
752
+ return command_check_done (cmd );
753
+
750
754
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 ;
751
761
info -> additional_costs = tal (info , struct additional_cost_htable );
752
762
additional_cost_htable_init (info -> additional_costs );
753
763
0 commit comments