File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
src/DotNetLightning.Core/Utils Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ open NBitcoin.Crypto
66open System
77open System.Net
88open System.Linq
9-
9+ open System. ComponentModel
1010open System.Diagnostics
1111open DotNetLightning.Core .Utils .Extensions
1212
@@ -395,12 +395,29 @@ module Primitives =
395395#if ! NoDUsAsStructs
396396 [<Struct>]
397397#endif
398+ [<TypeConverter( typeof< HTLCIdToStringTypeConverter>) >]
398399 type HTLCId = | HTLCId of uint64 with
399400 static member Zero = HTLCId( 0 UL)
400401 member this.Value = let ( HTLCId v ) = this in v
401402
402403 static member (+) ( a : HTLCId , b : uint64 ) = ( a.Value + b) |> HTLCId
403404
405+ override self.ToString () =
406+ self.Value.ToString()
407+
408+ and private HTLCIdToStringTypeConverter () =
409+ inherit TypeConverter()
410+ override __.CanConvertFrom ( _context , sourceType ) =
411+ sourceType = typeof< string>
412+ override __.ConvertFrom ( _context , _culture , value ) =
413+ match value with
414+ | :? string as stringValue ->
415+ stringValue
416+ |> UInt64.Parse
417+ |> HTLCId.HTLCId
418+ |> box
419+ | _ -> failwith " CanConvertFrom should not return true for any other types except string so this never happens"
420+
404421#if ! NoDUsAsStructs
405422 [<Struct>]
406423#endif
You can’t perform that action at this time.
0 commit comments