@@ -410,7 +410,6 @@ immediate_routing_failure(const tal_t *ctx,
410410static struct routing_failure *
411411local_routing_failure (const tal_t * ctx ,
412412 const struct lightningd * ld ,
413- const struct htlc_out * hout ,
414413 enum onion_wire failcode ,
415414 const struct wallet_payment * payment )
416415{
@@ -435,9 +434,6 @@ local_routing_failure(const tal_t *ctx,
435434
436435 routing_failure -> msg = NULL ;
437436
438- log_debug (hout -> key .channel -> log , "local_routing_failure: %u (%s)" ,
439- routing_failure -> failcode ,
440- onion_wire_name (routing_failure -> failcode ));
441437 return routing_failure ;
442438}
443439
@@ -545,28 +541,32 @@ remote_routing_failure(const tal_t *ctx,
545541 return routing_failure ;
546542}
547543
548- void payment_failed (struct lightningd * ld , const struct htlc_out * hout ,
544+ void payment_failed (struct lightningd * ld ,
545+ struct logger * log ,
546+ const struct sha256 * payment_hash ,
547+ u64 partid , u64 groupid ,
548+ const struct onionreply * failonion ,
549+ const u8 * failmsg ,
549550 const char * localfail )
550551{
551552 struct wallet_payment * payment ;
552553 struct routing_failure * fail = NULL ;
553554 const char * failstr ;
554555 enum jsonrpc_errcode pay_errcode ;
555- const u8 * failmsg ;
556556 int origin_index ;
557557
558558 payment = wallet_payment_by_hash (tmpctx , ld -> wallet ,
559- & hout -> payment_hash ,
560- hout -> partid , hout -> groupid );
559+ payment_hash ,
560+ partid , groupid );
561561
562562#ifdef COMPAT_V052
563563 /* Prior to "pay: delete HTLC when we delete payment." we would
564564 * delete a payment on retry, but leave the HTLC. */
565565 if (!payment ) {
566- log_unusual (hout -> key . channel -> log ,
566+ log_unusual (log ,
567567 "No payment for %s:"
568568 " was this an old database?" ,
569- fmt_sha256 (tmpctx , & hout -> payment_hash ));
569+ fmt_sha256 (tmpctx , payment_hash ));
570570 return ;
571571 }
572572#else
@@ -578,10 +578,12 @@ void payment_failed(struct lightningd *ld, const struct htlc_out *hout,
578578 if (localfail ) {
579579 /* Use temporary_channel_failure if failmsg has it */
580580 enum onion_wire failcode ;
581- failcode = fromwire_peektype (hout -> failmsg );
581+ failcode = fromwire_peektype (failmsg );
582582
583- fail = local_routing_failure (tmpctx , ld , hout , failcode ,
584- payment );
583+ fail = local_routing_failure (tmpctx , ld , failcode , payment );
584+ log_debug (log , "local_routing_failure: %u (%s)" ,
585+ fail -> failcode ,
586+ onion_wire_name (fail -> failcode ));
585587 failstr = localfail ;
586588 pay_errcode = PAY_TRY_OTHER_ROUTE ;
587589 } else if (payment -> path_secrets == NULL ) {
@@ -593,11 +595,10 @@ void payment_failed(struct lightningd *ld, const struct htlc_out *hout,
593595 pay_errcode = PAY_UNPARSEABLE_ONION ;
594596 fail = NULL ;
595597 failstr = NULL ;
596- } else if (hout -> failmsg ) {
598+ } else if (failmsg ) {
597599 /* This can happen when a direct peer told channeld it's a
598600 * malformed onion using update_fail_malformed_htlc. */
599601 failstr = "local failure" ;
600- failmsg = hout -> failmsg ;
601602 origin_index = 0 ;
602603 pay_errcode = PAY_TRY_OTHER_ROUTE ;
603604 goto use_failmsg ;
@@ -609,12 +610,11 @@ void payment_failed(struct lightningd *ld, const struct htlc_out *hout,
609610
610611 failmsg = unwrap_onionreply (tmpctx , path_secrets ,
611612 tal_count (path_secrets ),
612- hout -> failonion , & origin_index );
613+ failonion , & origin_index );
613614 if (!failmsg ) {
614- log_info (hout -> key .channel -> log ,
615- "htlc %" PRIu64 " failed with bad reply (%s)" ,
616- hout -> key .id ,
617- tal_hex (tmpctx , hout -> failonion -> contents ));
615+ log_info (log ,
616+ "htlc failed with bad reply (%s)" ,
617+ tal_hex (tmpctx , failonion -> contents ));
618618 /* Cannot record failure. */
619619 fail = NULL ;
620620 pay_errcode = PAY_UNPARSEABLE_ONION ;
@@ -623,28 +623,27 @@ void payment_failed(struct lightningd *ld, const struct htlc_out *hout,
623623
624624 use_failmsg :
625625 failcode = fromwire_peektype (failmsg );
626- log_info (hout -> key .channel -> log ,
627- "htlc %" PRIu64 " "
628- "failed from %ith node "
626+ log_info (log ,
627+ "htlc failed from %ith node "
629628 "with code 0x%04x (%s)" ,
630- hout -> key .id ,
631629 origin_index ,
632630 failcode , onion_wire_name (failcode ));
633631 fail = remote_routing_failure (tmpctx , ld ,
634632 payment , failmsg ,
635633 origin_index ,
636- hout -> key . channel -> log ,
634+ log ,
637635 & pay_errcode );
638636 }
639637 }
640638
641- wallet_payment_set_status (ld -> wallet , & hout -> payment_hash ,
642- hout -> partid , hout -> groupid ,
639+ wallet_payment_set_status (ld -> wallet , payment_hash ,
640+ partid , groupid ,
643641 PAYMENT_FAILED , NULL );
644642 wallet_payment_set_failinfo (ld -> wallet ,
645- & hout -> payment_hash ,
646- hout -> partid ,
647- fail ? NULL : hout -> failonion ,
643+ payment_hash ,
644+ partid ,
645+ /* We only save failonion if it's unparseable */
646+ fail ? NULL : failonion ,
648647 pay_errcode == PAY_DESTINATION_PERM_FAIL ,
649648 fail ? fail -> erring_index : -1 ,
650649 fail ? fail -> failcode : 0 ,
@@ -654,8 +653,8 @@ void payment_failed(struct lightningd *ld, const struct htlc_out *hout,
654653 failstr ,
655654 fail ? fail -> channel_dir : 0 );
656655
657- tell_waiters_failed (ld , & hout -> payment_hash , payment , pay_errcode ,
658- hout -> failonion , fail , failstr );
656+ tell_waiters_failed (ld , payment_hash , payment , pay_errcode ,
657+ failonion , fail , failstr );
659658}
660659
661660/* Wait for a payment. If cmd is deleted, then wait_payment()
0 commit comments