@@ -32,11 +32,30 @@ func convertProtobufToClaim(protobuf map[int]any, transactions map[string]any) m
3232 }
3333 }
3434
35+ if len (claimScript .ClaimData ) < 85 {
36+ // TODO: Older schemes
37+ return claim
38+ }
39+
3540 decodedProtobufClaimData , _ := DecodeRawProto (claimScript .ClaimData [85 :])
3641
37- claimID := claimScript .ClaimID
38- slices .Reverse (claimID )
39- claim ["claim_id" ] = hex .EncodeToString (claimID )
42+ noutValue , noutOk := protobuf [2 ]
43+ if noutOk {
44+ nout := noutValue .(uint64 )
45+ claim ["nout" ] = nout
46+ }
47+
48+ claimID := claimScript .ClaimID
49+ if claimID == nil {
50+ var nout uint32
51+ noutValue , ok := noutValue .(uint32 )
52+ if ok {
53+ nout = noutValue
54+ }
55+ claimID = ComputeClaimID (txidValue .([]byte ),nout )
56+ }
57+ //slices.Reverse(claimID)
58+ claim ["claim_id" ] = hex .EncodeToString (claimID )
4059
4160 heightValue , heightOk := protobuf [3 ]
4261 if heightOk {
@@ -51,14 +70,18 @@ func convertProtobufToClaim(protobuf map[int]any, transactions map[string]any) m
5170
5271 shortURLValue , shortURLOk := meta [3 ]
5372 if shortURLOk {
54- shortURL := string (shortURLValue .([]uint8 ))
55- claim ["short_url" ] = "lbry://" + shortURL
73+ shortURL , ok := shortURLValue .([]uint8 )
74+ if ok {
75+ claim ["short_url" ] = "lbry://" + string (shortURL )
76+ }
5677 }
5778
5879 canonicalURLValue , canonicalURLOk := meta [4 ]
5980 if canonicalURLOk {
60- canonicalURL := string (canonicalURLValue .([]uint8 ))
61- claim ["canonical_url" ] = "lbry://" + canonicalURL
81+ canonicalURL , ok := canonicalURLValue .([]uint8 )
82+ if ok {
83+ claim ["canonical_url" ] = "lbry://" + string (canonicalURL )
84+ }
6285 }
6386
6487 isControllingValue , isControllingOk := meta [5 ]
@@ -206,10 +229,16 @@ func convertProtobufToClaim(protobuf map[int]any, transactions map[string]any) m
206229 tagsValue , tagsOk := decodedProtobufClaimData [11 ]
207230 if tagsOk {
208231 var tags []string
209- for _ , tagValue := range tagsValue .([]any ) {
210- tags = append (tags , string (tagValue .([]uint8 )))
232+ _ , ok := tagsValue .([]any )
233+ if ok {
234+ for _ , tagValue := range tagsValue .([]any ) {
235+ tag , ok := tagValue .([]uint8 )
236+ if ok {
237+ tags = append (tags , string (tag ))
238+ }
239+ }
240+ claimValue ["tags" ] = tags
211241 }
212- claimValue ["tags" ] = tags
213242 }
214243
215244 claim ["value" ] = claimValue
0 commit comments