@@ -253,6 +253,16 @@ static struct command_result *handle_failure(struct routefail *r)
253
253
if (route -> hops )
254
254
path_len = tal_count (route -> hops );
255
255
256
+ enum onion_wire failcode ;
257
+ if (result -> failcode )
258
+ failcode = * result -> failcode ;
259
+ else {
260
+ payment_note (
261
+ payment , LOG_UNUSUAL ,
262
+ "The failcode is unknown we skip error handling" );
263
+ goto finish ;
264
+ }
265
+
256
266
if (!result -> erring_index ) {
257
267
payment_note (
258
268
payment , LOG_UNUSUAL ,
@@ -270,7 +280,7 @@ static struct command_result *handle_failure(struct routefail *r)
270
280
node_type = INTERMEDIATE_NODE ;
271
281
}
272
282
273
- switch (result -> failcode ) {
283
+ switch (failcode ) {
274
284
// intermediate only
275
285
case WIRE_INVALID_ONION_VERSION :
276
286
case WIRE_INVALID_ONION_HMAC :
@@ -280,8 +290,8 @@ static struct command_result *handle_failure(struct routefail *r)
280
290
payment_note (payment , LOG_UNUSUAL ,
281
291
"Final node reported strange "
282
292
"error code %04x (%s)" ,
283
- result -> failcode ,
284
- onion_wire_name (result -> failcode ));
293
+ failcode ,
294
+ onion_wire_name (failcode ));
285
295
break ;
286
296
case ORIGIN_NODE :
287
297
case INTERMEDIATE_NODE :
@@ -297,8 +307,8 @@ static struct command_result *handle_failure(struct routefail *r)
297
307
route_final_error (
298
308
route , PAY_DESTINATION_PERM_FAIL ,
299
309
"Received error code %04x (%s) at final node." ,
300
- result -> failcode ,
301
- onion_wire_name (result -> failcode ));
310
+ failcode ,
311
+ onion_wire_name (failcode ));
302
312
303
313
break ;
304
314
case INTERMEDIATE_NODE :
@@ -311,7 +321,7 @@ static struct command_result *handle_failure(struct routefail *r)
311
321
payment_disable_node (
312
322
payment , route -> hops [* result -> erring_index ].node_id ,
313
323
LOG_DBG , "received %s from previous hop" ,
314
- onion_wire_name (result -> failcode ));
324
+ onion_wire_name (failcode ));
315
325
break ;
316
326
case UNKNOWN_NODE :
317
327
break ;
@@ -353,8 +363,8 @@ static struct command_result *handle_failure(struct routefail *r)
353
363
payment_note (payment , LOG_UNUSUAL ,
354
364
"Intermediate node reported strange "
355
365
"error code %04x (%s)" ,
356
- result -> failcode ,
357
- onion_wire_name (result -> failcode ));
366
+ failcode ,
367
+ onion_wire_name (failcode ));
358
368
break ;
359
369
case ORIGIN_NODE :
360
370
case FINAL_NODE :
@@ -371,15 +381,15 @@ static struct command_result *handle_failure(struct routefail *r)
371
381
route_final_error (
372
382
route , PAY_DESTINATION_PERM_FAIL ,
373
383
"Received error code %04x (%s) at final node." ,
374
- result -> failcode ,
375
- onion_wire_name (result -> failcode ));
384
+ failcode ,
385
+ onion_wire_name (failcode ));
376
386
break ;
377
387
case ORIGIN_NODE :
378
388
route_final_error (
379
389
route , PAY_UNSPECIFIED_ERROR ,
380
390
"Error code %04x (%s) reported at the origin." ,
381
- result -> failcode ,
382
- onion_wire_name (result -> failcode ));
391
+ failcode ,
392
+ onion_wire_name (failcode ));
383
393
break ;
384
394
case INTERMEDIATE_NODE :
385
395
if (!route -> hops )
@@ -388,7 +398,7 @@ static struct command_result *handle_failure(struct routefail *r)
388
398
payment ,
389
399
route -> hops [* result -> erring_index - 1 ].node_id ,
390
400
LOG_INFORM , "received error %s" ,
391
- onion_wire_name (result -> failcode ));
401
+ onion_wire_name (failcode ));
392
402
break ;
393
403
case UNKNOWN_NODE :
394
404
break ;
@@ -406,22 +416,22 @@ static struct command_result *handle_failure(struct routefail *r)
406
416
payment_note (payment , LOG_UNUSUAL ,
407
417
"Final node reported strange "
408
418
"error code %04x (%s)" ,
409
- result -> failcode ,
410
- onion_wire_name (result -> failcode ));
419
+ failcode ,
420
+ onion_wire_name (failcode ));
411
421
412
422
route_final_error (
413
423
route , PAY_DESTINATION_PERM_FAIL ,
414
424
"Received error code %04x (%s) at final node." ,
415
- result -> failcode ,
416
- onion_wire_name (result -> failcode ));
425
+ failcode ,
426
+ onion_wire_name (failcode ));
417
427
418
428
break ;
419
429
case ORIGIN_NODE :
420
430
payment_note (payment , LOG_UNUSUAL ,
421
431
"First node reported strange "
422
432
"error code %04x (%s)" ,
423
- result -> failcode ,
424
- onion_wire_name (result -> failcode ));
433
+ failcode ,
434
+ onion_wire_name (failcode ));
425
435
426
436
break ;
427
437
case INTERMEDIATE_NODE :
@@ -431,7 +441,7 @@ static struct command_result *handle_failure(struct routefail *r)
431
441
.scid = route -> hops [* result -> erring_index ].scid ,
432
442
.dir = route -> hops [* result -> erring_index ].direction };
433
443
payment_disable_chan (payment , scidd , LOG_INFORM , "%s" ,
434
- onion_wire_name (result -> failcode ));
444
+ onion_wire_name (failcode ));
435
445
436
446
break ;
437
447
case UNKNOWN_NODE :
@@ -449,16 +459,16 @@ static struct command_result *handle_failure(struct routefail *r)
449
459
payment_note (payment , LOG_UNUSUAL ,
450
460
"Intermediate node reported strange "
451
461
"error code %04x (%s)" ,
452
- result -> failcode ,
453
- onion_wire_name (result -> failcode ));
462
+ failcode ,
463
+ onion_wire_name (failcode ));
454
464
455
465
if (!route -> hops )
456
466
break ;
457
467
payment_disable_node (
458
468
payment ,
459
469
route -> hops [* result -> erring_index - 1 ].node_id ,
460
470
LOG_INFORM , "received error %s" ,
461
- onion_wire_name (result -> failcode ));
471
+ onion_wire_name (failcode ));
462
472
463
473
break ;
464
474
case ORIGIN_NODE :
@@ -478,22 +488,22 @@ static struct command_result *handle_failure(struct routefail *r)
478
488
payment_note (payment , LOG_UNUSUAL ,
479
489
"Final node reported strange "
480
490
"error code %04x (%s)" ,
481
- result -> failcode ,
482
- onion_wire_name (result -> failcode ));
491
+ failcode ,
492
+ onion_wire_name (failcode ));
483
493
484
494
route_final_error (
485
495
route , PAY_DESTINATION_PERM_FAIL ,
486
496
"Received error code %04x (%s) at final node." ,
487
- result -> failcode ,
488
- onion_wire_name (result -> failcode ));
497
+ failcode ,
498
+ onion_wire_name (failcode ));
489
499
490
500
break ;
491
501
case ORIGIN_NODE :
492
502
payment_note (payment , LOG_UNUSUAL ,
493
503
"First node reported strange "
494
504
"error code %04x (%s)" ,
495
- result -> failcode ,
496
- onion_wire_name (result -> failcode ));
505
+ failcode ,
506
+ onion_wire_name (failcode ));
497
507
498
508
break ;
499
509
case INTERMEDIATE_NODE :
@@ -507,7 +517,7 @@ static struct command_result *handle_failure(struct routefail *r)
507
517
.dir = route -> hops [* result -> erring_index ].direction };
508
518
payment_warn_chan (payment , scidd , LOG_INFORM ,
509
519
"received error %s" ,
510
- onion_wire_name (result -> failcode ));
520
+ onion_wire_name (failcode ));
511
521
512
522
break ;
513
523
case UNKNOWN_NODE :
@@ -525,14 +535,14 @@ static struct command_result *handle_failure(struct routefail *r)
525
535
payment_note (payment , LOG_UNUSUAL ,
526
536
"Final node reported strange "
527
537
"error code %04x (%s)" ,
528
- result -> failcode ,
529
- onion_wire_name (result -> failcode ));
538
+ failcode ,
539
+ onion_wire_name (failcode ));
530
540
531
541
route_final_error (
532
542
route , PAY_DESTINATION_PERM_FAIL ,
533
543
"Received error code %04x (%s) at final node." ,
534
- result -> failcode ,
535
- onion_wire_name (result -> failcode ));
544
+ failcode ,
545
+ onion_wire_name (failcode ));
536
546
537
547
break ;
538
548
case INTERMEDIATE_NODE :
0 commit comments