File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
src/DotNetLightning.Core/Utils Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ open DotNetLightning.Core.Utils.Extensions
12
12
13
13
open ResultUtils
14
14
open ResultUtils.Portability
15
+ open System.ComponentModel
15
16
16
17
[<AutoOpen>]
17
18
module Primitives =
@@ -395,12 +396,29 @@ module Primitives =
395
396
#if ! NoDUsAsStructs
396
397
[<Struct>]
397
398
#endif
399
+ [<TypeConverter( typeof< HTLCIdToStringTypeConverter>) >]
398
400
type HTLCId = | HTLCId of uint64 with
399
401
static member Zero = HTLCId( 0 UL)
400
402
member x.Value = let ( HTLCId v ) = x in v
401
403
402
404
static member (+) ( a : HTLCId , b : uint64 ) = ( a.Value + b) |> HTLCId
403
405
406
+ override self.ToString () =
407
+ self.Value.ToString()
408
+
409
+ and private HTLCIdToStringTypeConverter () =
410
+ inherit TypeConverter()
411
+ override __.CanConvertFrom ( _context , sourceType ) =
412
+ sourceType = typeof< string>
413
+ override __.ConvertFrom ( _context , _culture , value ) =
414
+ match value with
415
+ | :? string as stringValue ->
416
+ stringValue
417
+ |> UInt64.Parse
418
+ |> HTLCId.HTLCId
419
+ |> box
420
+ | _ -> failwith " should not happen"
421
+
404
422
#if ! NoDUsAsStructs
405
423
[<Struct>]
406
424
#endif
You can’t perform that action at this time.
0 commit comments