@@ -628,7 +628,6 @@ func (s *SQLStore) DeletePayment(paymentHash lntypes.Hash,
628628 // Be careful to not use s.db here, because we are in a
629629 // transaction, is there a way to make this more secure?
630630 return db .DeletePayment (ctx , fetchPayment .Payment .ID )
631-
632631 }, func () {
633632 })
634633 if err != nil {
@@ -746,10 +745,12 @@ func (s *SQLStore) InitPayment(paymentHash lntypes.Hash,
746745 intentIDParam = sqldb .SQLInt64 (* intentID )
747746 }
748747
748+ timeCreated := paymentCreationInfo .CreationTime .UTC ()
749+
749750 err = db .InsertPayment (ctx , sqlc.InsertPaymentParams {
750751 IntentID : intentIDParam ,
751752 AmountMsat : int64 (paymentCreationInfo .Value ),
752- CreatedAt : paymentCreationInfo . CreationTime . UTC () ,
753+ CreatedAt : timeCreated ,
753754 PaymentIdentifier : paymentHash [:],
754755 })
755756 if err != nil {
@@ -760,9 +761,11 @@ func (s *SQLStore) InitPayment(paymentHash lntypes.Hash,
760761 // We need to fetch the payment we just inserted to get its ID
761762 insertedPayment , err := db .FetchPayment (ctx , paymentHash [:])
762763 if err != nil {
763- return fmt .Errorf ("failed to fetch inserted payment: %w" , err )
764+ return fmt .Errorf ("failed to fetch inserted " +
765+ "payment: %w" , err )
764766 }
765767
768+ //nolint:ll
766769 for key , value := range paymentCreationInfo .FirstHopCustomRecords {
767770 err = db .InsertPaymentFirstHopCustomRecord (ctx ,
768771 sqlc.InsertPaymentFirstHopCustomRecordParams {
@@ -811,26 +814,31 @@ func (s *SQLStore) insertRouteHops(ctx context.Context, db SQLQueries,
811814 // Insert the per-hop custom records
812815 if len (hop .CustomRecords ) > 0 {
813816 for key , value := range hop .CustomRecords {
814- err = db .InsertPaymentHopCustomRecord (ctx , sqlc.InsertPaymentHopCustomRecordParams {
815- HopID : hopID ,
816- Key : int64 (key ),
817- Value : value ,
818- })
817+ err = db .InsertPaymentHopCustomRecord (ctx ,
818+ sqlc.InsertPaymentHopCustomRecordParams {
819+ HopID : hopID ,
820+ Key : int64 (key ),
821+ Value : value ,
822+ },
823+ )
819824 if err != nil {
820825 return fmt .Errorf ("failed to insert " +
821- "payment hop custom record: %w" , err )
826+ "payment hop custom " +
827+ "records: %w" , err )
822828 }
823829 }
824830 }
825831
826832 // Insert MPP data if present
827833 if hop .MPP != nil {
828834 paymentAddr := hop .MPP .PaymentAddr ()
829- err = db .InsertRouteHopMpp (ctx , sqlc.InsertRouteHopMppParams {
830- HopID : hopID ,
831- PaymentAddr : paymentAddr [:],
832- TotalMsat : int64 (hop .MPP .TotalMsat ()),
833- })
835+ err = db .InsertRouteHopMpp (ctx ,
836+ sqlc.InsertRouteHopMppParams {
837+ HopID : hopID ,
838+ PaymentAddr : paymentAddr [:],
839+ TotalMsat : int64 (hop .MPP .TotalMsat ()),
840+ },
841+ )
834842 if err != nil {
835843 return fmt .Errorf ("failed to insert " +
836844 "route hop MPP: %w" , err )
@@ -841,11 +849,13 @@ func (s *SQLStore) insertRouteHops(ctx context.Context, db SQLQueries,
841849 if hop .AMP != nil {
842850 rootShare := hop .AMP .RootShare ()
843851 setID := hop .AMP .SetID ()
844- err = db .InsertRouteHopAmp (ctx , sqlc.InsertRouteHopAmpParams {
845- HopID : hopID ,
846- RootShare : rootShare [:],
847- SetID : setID [:],
848- })
852+ err = db .InsertRouteHopAmp (ctx ,
853+ sqlc.InsertRouteHopAmpParams {
854+ HopID : hopID ,
855+ RootShare : rootShare [:],
856+ SetID : setID [:],
857+ },
858+ )
849859 if err != nil {
850860 return fmt .Errorf ("failed to insert " +
851861 "route hop AMP: %w" , err )
@@ -856,15 +866,19 @@ func (s *SQLStore) insertRouteHops(ctx context.Context, db SQLQueries,
856866 if hop .EncryptedData != nil || hop .BlindingPoint != nil {
857867 var blindingPointBytes []byte
858868 if hop .BlindingPoint != nil {
869+ //nolint:ll
859870 blindingPointBytes = hop .BlindingPoint .SerializeCompressed ()
860871 }
861872
862- err = db .InsertRouteHopBlinded (ctx , sqlc.InsertRouteHopBlindedParams {
863- HopID : hopID ,
864- EncryptedData : hop .EncryptedData ,
865- BlindingPoint : blindingPointBytes ,
866- BlindedPathTotalAmt : sqldb .SQLInt64 (hop .TotalAmtMsat ),
867- })
873+ err = db .InsertRouteHopBlinded (ctx ,
874+ //nolint:ll
875+ sqlc.InsertRouteHopBlindedParams {
876+ HopID : hopID ,
877+ EncryptedData : hop .EncryptedData ,
878+ BlindingPoint : blindingPointBytes ,
879+ BlindedPathTotalAmt : sqldb .SQLInt64 (hop .TotalAmtMsat ),
880+ },
881+ )
868882 if err != nil {
869883 return fmt .Errorf ("failed to insert " +
870884 "route hop blinded: %w" , err )
@@ -934,8 +948,10 @@ func (s *SQLStore) RegisterAttempt(paymentHash lntypes.Hash,
934948 }
935949
936950 // Insert the route level first hop custom records.
951+ //nolint:ll
937952 for key , value := range attempt .Route .FirstHopWireCustomRecords {
938953 err = db .InsertPaymentAttemptFirstHopCustomRecord (ctx ,
954+ //nolint:ll
939955 sqlc.InsertPaymentAttemptFirstHopCustomRecordParams {
940956 HtlcAttemptIndex : int64 (attempt .AttemptID ),
941957 Key : int64 (key ),
@@ -1057,6 +1073,7 @@ func (s *SQLStore) FailAttempt(paymentHash lntypes.Hash,
10571073 }
10581074 }
10591075
1076+ //nolint:ll
10601077 err = db .FailAttempt (ctx , sqlc.FailAttemptParams {
10611078 AttemptIndex : int64 (attemptID ),
10621079 ResolutionTime : time .Now (),
@@ -1069,9 +1086,12 @@ func (s *SQLStore) FailAttempt(paymentHash lntypes.Hash,
10691086 return fmt .Errorf ("failed to fail attempt: %w" , err )
10701087 }
10711088
1072- mpPayment , err = s .fetchPaymentWithCompleteData (ctx , db , payment )
1089+ mpPayment , err = s .fetchPaymentWithCompleteData (
1090+ ctx , db , payment ,
1091+ )
10731092 if err != nil {
1074- return fmt .Errorf ("failed to fetch payment with complete data: %w" , err )
1093+ return fmt .Errorf ("failed to fetch payment with" +
1094+ "complete data: %w" , err )
10751095 }
10761096
10771097 return nil
@@ -1220,7 +1240,6 @@ func (s *SQLStore) DeletePayments(failedOnly, failedHtlcsOnly bool) (int,
12201240 ctx , s .cfg .QueryCfg , int64 (- 1 ), queryFunc ,
12211241 extractCursor , processPayment ,
12221242 )
1223-
12241243 }, func () {
12251244 numPayments = 0
12261245 })
0 commit comments