@@ -827,12 +827,6 @@ func (n *namespacedDB) purge() error {
827
827
}, func () {})
828
828
}
829
829
830
- // paymentFailure represents the presence of a payment failure. It may or may
831
- // not include additional information about said failure.
832
- type paymentFailure struct {
833
- info tlv.OptionalRecordT [tlv.TlvType0 , paymentFailureInfo ]
834
- }
835
-
836
830
// newPaymentFailure constructs a new paymentFailure struct. If the source
837
831
// index is nil, then an empty paymentFailure is returned. This represents a
838
832
// failure with unknown details. Otherwise, the index and failure message are
@@ -844,7 +838,7 @@ func newPaymentFailure(sourceIdx *int,
844
838
return & paymentFailure {}
845
839
}
846
840
847
- info := paymentFailureInfo {
841
+ return & paymentFailure {
848
842
sourceIdx : tlv .SomeRecordT (
849
843
tlv.NewPrimitiveRecord [tlv.TlvType0 ](
850
844
uint8 (* sourceIdx ),
@@ -855,77 +849,10 @@ func newPaymentFailure(sourceIdx *int,
855
849
),
856
850
),
857
851
}
858
-
859
- return & paymentFailure {
860
- info : tlv .SomeRecordT (tlv.NewRecordT [tlv.TlvType0 ](info )),
861
- }
862
- }
863
-
864
- // Record returns a TLV record that can be used to encode/decode a
865
- // paymentFailure to/from a TLV stream.
866
- func (r * paymentFailure ) Record () tlv.Record {
867
- recordSize := func () uint64 {
868
- var (
869
- b bytes.Buffer
870
- buf [8 ]byte
871
- )
872
- if err := encodePaymentFailure (& b , r , & buf ); err != nil {
873
- panic (err )
874
- }
875
-
876
- return uint64 (len (b .Bytes ()))
877
- }
878
-
879
- return tlv .MakeDynamicRecord (
880
- 0 , r , recordSize , encodePaymentFailure , decodePaymentFailure ,
881
- )
882
- }
883
-
884
- func encodePaymentFailure (w io.Writer , val interface {}, _ * [8 ]byte ) error {
885
- if v , ok := val .(* paymentFailure ); ok {
886
- var recordProducers []tlv.RecordProducer
887
- v .info .WhenSome (
888
- func (r tlv.RecordT [tlv.TlvType0 , paymentFailureInfo ]) {
889
- recordProducers = append (recordProducers , & r )
890
- },
891
- )
892
-
893
- return lnwire .EncodeRecordsTo (
894
- w , lnwire .ProduceRecordsSorted (recordProducers ... ),
895
- )
896
- }
897
-
898
- return tlv .NewTypeForEncodingErr (val , "routing.paymentFailure" )
899
852
}
900
853
901
- func decodePaymentFailure (r io.Reader , val interface {}, _ * [8 ]byte ,
902
- l uint64 ) error {
903
-
904
- if v , ok := val .(* paymentFailure ); ok {
905
- var h paymentFailure
906
-
907
- info := tlv .ZeroRecordT [tlv.TlvType0 , paymentFailureInfo ]()
908
- typeMap , err := lnwire .DecodeRecords (
909
- r , lnwire .ProduceRecordsSorted (& info )... ,
910
- )
911
- if err != nil {
912
- return err
913
- }
914
-
915
- if _ , ok := typeMap [h .info .TlvType ()]; ok {
916
- h .info = tlv .SomeRecordT (info )
917
- }
918
-
919
- * v = h
920
-
921
- return nil
922
- }
923
-
924
- return tlv .NewTypeForDecodingErr (val , "routing.paymentFailure" , l , l )
925
- }
926
-
927
- // paymentFailureInfo holds additional information about a payment failure.
928
- type paymentFailureInfo struct {
854
+ // paymentFailure holds additional information about a payment failure.
855
+ type paymentFailure struct {
929
856
// sourceIdx is the hop the error was reported from. In order to be able
930
857
// to decrypt the error message, we need to know the source, which is
931
858
// why an error message can only be present if the source is known.
@@ -938,28 +865,28 @@ type paymentFailureInfo struct {
938
865
}
939
866
940
867
// Record returns a TLV record that can be used to encode/decode a
941
- // paymentFailureInfo to/from a TLV stream.
942
- func (r * paymentFailureInfo ) Record () tlv.Record {
868
+ // paymentFailure to/from a TLV stream.
869
+ func (r * paymentFailure ) Record () tlv.Record {
943
870
recordSize := func () uint64 {
944
871
var (
945
872
b bytes.Buffer
946
873
buf [8 ]byte
947
874
)
948
- if err := encodePaymentFailureInfo (& b , r , & buf ); err != nil {
875
+ if err := encodePaymentFailure (& b , r , & buf ); err != nil {
949
876
panic (err )
950
877
}
951
878
952
879
return uint64 (len (b .Bytes ()))
953
880
}
954
881
955
882
return tlv .MakeDynamicRecord (
956
- 0 , r , recordSize , encodePaymentFailureInfo ,
957
- decodePaymentFailureInfo ,
883
+ 0 , r , recordSize , encodePaymentFailure ,
884
+ decodePaymentFailure ,
958
885
)
959
886
}
960
887
961
- func encodePaymentFailureInfo (w io.Writer , val interface {}, _ * [8 ]byte ) error {
962
- if v , ok := val .(* paymentFailureInfo ); ok {
888
+ func encodePaymentFailure (w io.Writer , val interface {}, _ * [8 ]byte ) error {
889
+ if v , ok := val .(* paymentFailure ); ok {
963
890
var recordProducers []tlv.RecordProducer
964
891
965
892
v .sourceIdx .WhenSome (
@@ -985,14 +912,14 @@ func encodePaymentFailureInfo(w io.Writer, val interface{}, _ *[8]byte) error {
985
912
)
986
913
}
987
914
988
- return tlv .NewTypeForEncodingErr (val , "routing.paymentFailureInfo " )
915
+ return tlv .NewTypeForEncodingErr (val , "routing.paymentFailure " )
989
916
}
990
917
991
- func decodePaymentFailureInfo (r io.Reader , val interface {}, _ * [8 ]byte ,
918
+ func decodePaymentFailure (r io.Reader , val interface {}, _ * [8 ]byte ,
992
919
l uint64 ) error {
993
920
994
- if v , ok := val .(* paymentFailureInfo ); ok {
995
- var h paymentFailureInfo
921
+ if v , ok := val .(* paymentFailure ); ok {
922
+ var h paymentFailure
996
923
997
924
sourceIdx := tlv .ZeroRecordT [tlv.TlvType0 , uint8 ]()
998
925
msg := tlv .ZeroRecordT [tlv.TlvType1 , failureMessage ]()
@@ -1020,6 +947,6 @@ func decodePaymentFailureInfo(r io.Reader, val interface{}, _ *[8]byte,
1020
947
}
1021
948
1022
949
return tlv .NewTypeForDecodingErr (
1023
- val , "routing.paymentFailureInfo " , l , l ,
950
+ val , "routing.paymentFailure " , l , l ,
1024
951
)
1025
952
}
0 commit comments