@@ -1272,6 +1272,27 @@ askrene_disable_channel_fail(struct command *cmd, const char *buf,
12721272 return askrene_disable_channel_done (cmd , buf , result , payment );
12731273}
12741274
1275+ static struct command_result *
1276+ askrene_disable_node_done (struct command * cmd , const char * buf UNUSED ,
1277+ const jsmntok_t * result UNUSED ,
1278+ struct payment * payment )
1279+ {
1280+ assert (payment -> pending_rpcs > 0 );
1281+ payment -> pending_rpcs -- ;
1282+ return payment_continue (payment );
1283+ }
1284+
1285+ static struct command_result * askrene_disable_node_fail (struct command * cmd ,
1286+ const char * buf ,
1287+ const jsmntok_t * result ,
1288+ struct payment * payment )
1289+ {
1290+ plugin_log (cmd -> plugin , LOG_UNUSUAL ,
1291+ "failed to disable node with askrene-disable-node: %.*s" ,
1292+ json_tok_full_len (result ), json_tok_full (buf , result ));
1293+ return askrene_disable_node_done (cmd , buf , result , payment );
1294+ }
1295+
12751296static struct command_result * channelfilter_cb (struct payment * payment )
12761297{
12771298 assert (payment );
@@ -1344,6 +1365,57 @@ static struct command_result *channelfilter_cb(struct payment *payment)
13441365
13451366REGISTER_PAYMENT_MODIFIER (channelfilter , channelfilter_cb );
13461367
1368+
1369+ /*****************************************************************************
1370+ * manualexclusions
1371+ *
1372+ * Disable some channels and nodes specified in the command line or during our
1373+ * internal workflow.
1374+ */
1375+
1376+ static struct command_result * manualexclusions_cb (struct payment * payment )
1377+ {
1378+ assert (payment );
1379+ struct command * cmd = payment_command (payment );
1380+ assert (cmd );
1381+
1382+ for (size_t i = 0 ;i < tal_count (payment -> exclusions );i ++ ){
1383+ const struct route_exclusion * ex = & payment -> exclusions [i ];
1384+ if (ex -> type == EXCLUDE_CHANNEL ) {
1385+ /* FIXME: there is no askrene-disable-channel,
1386+ * we will fake its disabling by setting its
1387+ * liquidity to 0 */
1388+ struct out_req * req = jsonrpc_request_start (
1389+ cmd -> plugin , cmd , "askrene-inform-channel" ,
1390+ askrene_disable_channel_done ,
1391+ askrene_disable_channel_fail , payment );
1392+ json_add_string (req -> js , "layer" ,
1393+ payment -> private_layer );
1394+ json_add_short_channel_id (req -> js , "short_channel_id" ,
1395+ ex -> u .chan_id .scid );
1396+ json_add_num (req -> js , "direction" , ex -> u .chan_id .dir );
1397+ json_add_amount_msat (req -> js , "maximum_msat" ,
1398+ AMOUNT_MSAT (0 ));
1399+ send_outreq (cmd -> plugin , req );
1400+ payment -> pending_rpcs ++ ;
1401+ } else {
1402+ struct out_req * req = jsonrpc_request_start (
1403+ cmd -> plugin , cmd , "askrene-disable-node" ,
1404+ askrene_disable_node_done ,
1405+ askrene_disable_node_fail , payment );
1406+ json_add_string (req -> js , "layer" ,
1407+ payment -> private_layer );
1408+ json_add_node_id (req -> js , "node" , & ex -> u .node_id );
1409+ send_outreq (cmd -> plugin , req );
1410+ payment -> pending_rpcs ++ ;
1411+ }
1412+ }
1413+ tal_resize (& payment -> exclusions , 0 );
1414+ return payment_continue (payment );
1415+ }
1416+
1417+ REGISTER_PAYMENT_MODIFIER (manualexclusions , manualexclusions_cb );
1418+
13471419/*****************************************************************************
13481420 * alwaystrue
13491421 *
@@ -1402,17 +1474,18 @@ void *payment_virtual_program[] = {
14021474 /*10*/ OP_CALL , & channelfilter_pay_mod ,
14031475 // TODO shadow_additions
14041476 /* do */
1405- /*12*/ OP_CALL , & pendingsendpays_pay_mod ,
1406- /*14*/ OP_CALL , & checktimeout_pay_mod ,
1407- /*16*/ OP_CALL , & compute_routes_pay_mod ,
1408- /*18*/ OP_CALL , & send_routes_pay_mod ,
1409- /*20*/ OP_CALL , & reserve_routes_pay_mod ,
1477+ /*12*/ OP_CALL , & manualexclusions_pay_mod ,
1478+ /*14*/ OP_CALL , & pendingsendpays_pay_mod ,
1479+ /*16*/ OP_CALL , & checktimeout_pay_mod ,
1480+ /*18*/ OP_CALL , & compute_routes_pay_mod ,
1481+ /*20*/ OP_CALL , & send_routes_pay_mod ,
1482+ /*22*/ OP_CALL , & reserve_routes_pay_mod ,
14101483 /*do*/
1411- /*22 */ OP_CALL , & sleep_pay_mod ,
1412- /*24 */ OP_CALL , & collect_results_pay_mod ,
1484+ /*24 */ OP_CALL , & sleep_pay_mod ,
1485+ /*26 */ OP_CALL , & collect_results_pay_mod ,
14131486 /*while*/
1414- /*26 */ OP_IF , & nothaveresults_pay_cond , (void * )22 ,
1487+ /*28 */ OP_IF , & nothaveresults_pay_cond , (void * )24 ,
14151488 /* while */
1416- /*29 */ OP_IF , & retry_pay_cond , (void * )12 ,
1417- /*32 */ OP_CALL , & end_pay_mod , /* safety net, default failure if reached */
1489+ /*31 */ OP_IF , & retry_pay_cond , (void * )12 ,
1490+ /*34 */ OP_CALL , & end_pay_mod , /* safety net, default failure if reached */
14181491 /*32*/ NULL };
0 commit comments