From 8357b8e589989d1f52f08d987237bb226298b33b Mon Sep 17 00:00:00 2001 From: "joe.miyamoto" Date: Sun, 24 Apr 2022 15:14:22 +0900 Subject: [PATCH] add DotNetLightning.ClnRpc This commit adds a new project for calling c-lightning from .NET in a typesafe way. Most of the codes are auto-generated from client generator built in ref: https://github.com/ElementsProject/lightning/pull/5201 It must be updated after https://github.com/ElementsProject/lightning/pull/5216 gets merged. So that all the generation logics is defined in this repo. But this is good enough for temporary solution. --- DotNetLightning.sln | 15 + src/DotNetLightning.ClnRpc/Client.Methods.fs | 153 + src/DotNetLightning.ClnRpc/Client.fs | 244 ++ .../DotNetLightning.ClnRpc.fsproj | 18 + src/DotNetLightning.ClnRpc/Requests.fs | 3103 +++++++++++++++++ 5 files changed, 3533 insertions(+) create mode 100644 src/DotNetLightning.ClnRpc/Client.Methods.fs create mode 100644 src/DotNetLightning.ClnRpc/Client.fs create mode 100644 src/DotNetLightning.ClnRpc/DotNetLightning.ClnRpc.fsproj create mode 100644 src/DotNetLightning.ClnRpc/Requests.fs diff --git a/DotNetLightning.sln b/DotNetLightning.sln index 69a5d1609..13b88a31f 100644 --- a/DotNetLightning.sln +++ b/DotNetLightning.sln @@ -31,6 +31,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AEZ", "src\AEZ\AEZ.csproj", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AEZ.Tests", "tests\AEZ.Tests\AEZ.Tests.csproj", "{95F08554-B415-4B0F-8E65-754A1CFE7513}" EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "DotNetLightning.ClnRpc", "src\DotNetLightning.ClnRpc\DotNetLightning.ClnRpc.fsproj", "{39ED1BF2-14D8-45C1-B062-F8B5B612C75F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -176,6 +178,18 @@ Global {95F08554-B415-4B0F-8E65-754A1CFE7513}.Release|x64.Build.0 = Release|Any CPU {95F08554-B415-4B0F-8E65-754A1CFE7513}.Release|x86.ActiveCfg = Release|Any CPU {95F08554-B415-4B0F-8E65-754A1CFE7513}.Release|x86.Build.0 = Release|Any CPU + {39ED1BF2-14D8-45C1-B062-F8B5B612C75F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {39ED1BF2-14D8-45C1-B062-F8B5B612C75F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {39ED1BF2-14D8-45C1-B062-F8B5B612C75F}.Debug|x64.ActiveCfg = Debug|Any CPU + {39ED1BF2-14D8-45C1-B062-F8B5B612C75F}.Debug|x64.Build.0 = Debug|Any CPU + {39ED1BF2-14D8-45C1-B062-F8B5B612C75F}.Debug|x86.ActiveCfg = Debug|Any CPU + {39ED1BF2-14D8-45C1-B062-F8B5B612C75F}.Debug|x86.Build.0 = Debug|Any CPU + {39ED1BF2-14D8-45C1-B062-F8B5B612C75F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {39ED1BF2-14D8-45C1-B062-F8B5B612C75F}.Release|Any CPU.Build.0 = Release|Any CPU + {39ED1BF2-14D8-45C1-B062-F8B5B612C75F}.Release|x64.ActiveCfg = Release|Any CPU + {39ED1BF2-14D8-45C1-B062-F8B5B612C75F}.Release|x64.Build.0 = Release|Any CPU + {39ED1BF2-14D8-45C1-B062-F8B5B612C75F}.Release|x86.ActiveCfg = Release|Any CPU + {39ED1BF2-14D8-45C1-B062-F8B5B612C75F}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {594F2275-AF8E-4AFC-B8DC-7D6048C872CA} = {84B95569-6BD8-48B4-A942-CBBC9462B6D4} @@ -190,5 +204,6 @@ Global {C34D4C62-BEBE-4333-8EB8-9CDDEF331E1B} = {E6F1DC30-D346-4E86-8F58-20CFAAB19448} {411563BA-49FA-4707-B3ED-E66C5B288264} = {84B95569-6BD8-48B4-A942-CBBC9462B6D4} {95F08554-B415-4B0F-8E65-754A1CFE7513} = {E6F1DC30-D346-4E86-8F58-20CFAAB19448} + {39ED1BF2-14D8-45C1-B062-F8B5B612C75F} = {84B95569-6BD8-48B4-A942-CBBC9462B6D4} EndGlobalSection EndGlobal diff --git a/src/DotNetLightning.ClnRpc/Client.Methods.fs b/src/DotNetLightning.ClnRpc/Client.Methods.fs new file mode 100644 index 000000000..4000e4b5d --- /dev/null +++ b/src/DotNetLightning.ClnRpc/Client.Methods.fs @@ -0,0 +1,153 @@ + +/// This file was automatically generated using following command: +/// ```bash +/// msggen +/// ``` +/// +/// Do not edit this file, it'll be overwritten. Rather edit the schema that +/// This file was generated from +namespace ClnSharp + + +open System.Runtime.InteropServices +open System.Runtime.CompilerServices +open System.Threading +open System.Threading.Tasks + + + +[] +[] +type ClnClientExtensions = + [] + static member GetinfoAsync(this: ClnClient, [] ct: CancellationToken) = + this.SendCommandAsync("getinfo", null, ct=ct) + [] + static member ListPeersAsync(this: ClnClient, req: Requests.ListpeersRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.ListPeers req, ct=ct) + [] + static member ListFundsAsync(this: ClnClient, req: Requests.ListfundsRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.ListFunds req, ct=ct) + [] + static member SendPayAsync(this: ClnClient, req: Requests.SendpayRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.SendPay req, ct=ct) + [] + static member ListChannelsAsync(this: ClnClient, req: Requests.ListchannelsRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.ListChannels req, ct=ct) + [] + static member AddGossipAsync(this: ClnClient, req: Requests.AddgossipRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.AddGossip req, ct=ct) :> Task + [] + static member AutoCleanInvoiceAsync(this: ClnClient, req: Requests.AutocleaninvoiceRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.AutoCleanInvoice req, ct=ct) + [] + static member CheckMessageAsync(this: ClnClient, req: Requests.CheckmessageRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.CheckMessage req, ct=ct) + [] + static member CloseAsync(this: ClnClient, req: Requests.CloseRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.Close req, ct=ct) + [] + static member ConnectPeerAsync(this: ClnClient, req: Requests.ConnectRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.ConnectPeer req, ct=ct) + [] + static member CreateInvoiceAsync(this: ClnClient, req: Requests.CreateinvoiceRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.CreateInvoice req, ct=ct) + [] + static member DatastoreAsync(this: ClnClient, req: Requests.DatastoreRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.Datastore req, ct=ct) + [] + static member CreateOnionAsync(this: ClnClient, req: Requests.CreateonionRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.CreateOnion req, ct=ct) + [] + static member DelDatastoreAsync(this: ClnClient, req: Requests.DeldatastoreRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.DelDatastore req, ct=ct) + [] + static member DelExpiredInvoiceAsync(this: ClnClient, req: Requests.DelexpiredinvoiceRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.DelExpiredInvoice req, ct=ct) :> Task + [] + static member DelInvoiceAsync(this: ClnClient, req: Requests.DelinvoiceRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.DelInvoice req, ct=ct) + [] + static member InvoiceAsync(this: ClnClient, req: Requests.InvoiceRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.Invoice req, ct=ct) + [] + static member ListDatastoreAsync(this: ClnClient, req: Requests.ListdatastoreRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.ListDatastore req, ct=ct) + [] + static member ListInvoicesAsync(this: ClnClient, req: Requests.ListinvoicesRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.ListInvoices req, ct=ct) + [] + static member SendOnionAsync(this: ClnClient, req: Requests.SendonionRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.SendOnion req, ct=ct) + [] + static member ListSendPaysAsync(this: ClnClient, req: Requests.ListsendpaysRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.ListSendPays req, ct=ct) + [] + static member ListTransactionsAsync(this: ClnClient, [] ct: CancellationToken) = + this.SendCommandAsync("listtransactions", null, ct=ct) + [] + static member PayAsync(this: ClnClient, req: Requests.PayRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.Pay req, ct=ct) + [] + static member ListNodesAsync(this: ClnClient, req: Requests.ListnodesRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.ListNodes req, ct=ct) + [] + static member WaitAnyInvoiceAsync(this: ClnClient, req: Requests.WaitanyinvoiceRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.WaitAnyInvoice req, ct=ct) + [] + static member WaitInvoiceAsync(this: ClnClient, req: Requests.WaitinvoiceRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.WaitInvoice req, ct=ct) + [] + static member WaitSendPayAsync(this: ClnClient, req: Requests.WaitsendpayRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.WaitSendPay req, ct=ct) + [] + static member NewAddrAsync(this: ClnClient, req: Requests.NewaddrRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.NewAddr req, ct=ct) + [] + static member WithdrawAsync(this: ClnClient, req: Requests.WithdrawRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.Withdraw req, ct=ct) + [] + static member KeySendAsync(this: ClnClient, req: Requests.KeysendRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.KeySend req, ct=ct) + [] + static member FundPsbtAsync(this: ClnClient, req: Requests.FundpsbtRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.FundPsbt req, ct=ct) + [] + static member SendPsbtAsync(this: ClnClient, req: Requests.SendpsbtRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.SendPsbt req, ct=ct) + [] + static member SignPsbtAsync(this: ClnClient, req: Requests.SignpsbtRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.SignPsbt req, ct=ct) + [] + static member UtxoPsbtAsync(this: ClnClient, req: Requests.UtxopsbtRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.UtxoPsbt req, ct=ct) + [] + static member TxDiscardAsync(this: ClnClient, req: Requests.TxdiscardRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.TxDiscard req, ct=ct) + [] + static member TxPrepareAsync(this: ClnClient, req: Requests.TxprepareRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.TxPrepare req, ct=ct) + [] + static member TxSendAsync(this: ClnClient, req: Requests.TxsendRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.TxSend req, ct=ct) + [] + static member DisconnectAsync(this: ClnClient, req: Requests.DisconnectRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.Disconnect req, ct=ct) :> Task + [] + static member FeeratesAsync(this: ClnClient, req: Requests.FeeratesRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.Feerates req, ct=ct) + [] + static member GetRouteAsync(this: ClnClient, req: Requests.GetrouteRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.GetRoute req, ct=ct) + [] + static member ListForwardsAsync(this: ClnClient, req: Requests.ListforwardsRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.ListForwards req, ct=ct) + [] + static member ListPaysAsync(this: ClnClient, req: Requests.ListpaysRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.ListPays req, ct=ct) + [] + static member PingAsync(this: ClnClient, req: Requests.PingRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.Ping req, ct=ct) + [] + static member SignMessageAsync(this: ClnClient, req: Requests.SignmessageRequest, [] ct: CancellationToken) = + this.SendCommandAsync(Request.SignMessage req, ct=ct) diff --git a/src/DotNetLightning.ClnRpc/Client.fs b/src/DotNetLightning.ClnRpc/Client.fs new file mode 100644 index 000000000..aa6ad4000 --- /dev/null +++ b/src/DotNetLightning.ClnRpc/Client.fs @@ -0,0 +1,244 @@ +namespace ClnSharp + +open System +open System.Net +open System.Net.Sockets +open System.Runtime.InteropServices +open System.Text.Json +open System.Text.Json.Nodes +open System.Threading +open System.Threading.Tasks +open NBitcoin + +[] +module ClnSharpClientHelpers = + type JsonSerializerOptions + with + member this.AddDNLJsonConverters(n: Network) = + this.Converters.Add(MSatJsonConverter()) + this.Converters.Add(PubKeyJsonConverter()) + this.Converters.Add(ShortChannelIdJsonConverter()) + this.Converters.Add(KeyJsonConverter()) + this.Converters.Add(uint256JsonConverter()) + this.Converters.Add(AmountOrAnyJsonConverter()) + this.Converters.Add(OutPointJsonConverter()) + this.Converters.Add(FeerateJsonConverter()) + this.Converters.Add(OutputDescriptorJsonConverter(n)) + +type CLightningClientErrorCodeEnum = + // -- errors from `pay`, `sendpay` or `waitsendpay` commands -- + | IN_PROGRESS = 200 + | RHASH_ALREADY_USED = 201 + | UNPARSABLE_ONION = 202 + | DESTINATION_PERM_FAIL = 203 + | TRY_OTHER_ROUTE = 204 + | ROUTE_NOT_FOUND = 205 + | ROUTE_TOO_EXPENSIVE = 206 + | INVOICE_EXPIRED = 207 + | NO_SUCH_PAYMENT = 208 + | UNSPECIFIED_ERROR = 209 + | STOPPED_RETRYING = 210 + | PAY_STATUS_UNEXPECTED = 211 + | PAY_OFFER_INVALID = 212 + + // -- `fundchannel` or `withdraw` errors -- + | MAX_EXCEEDED = 300 + | CANNOT_AFFORD = 301 + | FUND_OUTPUT_IS_DUST = 302 + | FUNDING_BROADCAST_FAIL = 303 + | FUNDING_STILL_SYNCING_BITCOIN = 304 + | FUNDING_PEER_NOT_CONNECTED = 305 + | FUNDING_UNKNOWN_PEER = 306 + | FUNDING_NOTHING_TO_CANCEL = 307 + | FUNDING_CANCEL_NOT_SAFE = 308 + | FUNDING_PSBT_INVALID = 309 + | FUNDING_V2_NOT_SUPPORTED = 310 + | FUNDING_UNKNOWN_CHANNEL = 311 + | FUNDING_STATE_INVALID = 312 + + // -- `connect` errors -- + | CONNECT_NO_KNOWN_ADDRESS = 400 + | CONNECT_ALL_ADDRESSES_FAILED = 401 + + // -- Errors from `invoice` or `delinvoice` commands + | INVOICE_LABEL_ALREADY_EXISTS = 900 + | INVOICE_PREIMAGE_ALREADY_EXISTS = 901 + | INVOICE_HINTS_GAVE_NO_ROUTES = 902 + | INVOICE_EXPIRED_DURING_WAIT = 903 + | INVOICE_WAIT_TIMED_OUT = 904 + | INVOICE_NOT_FOUND = 905 + | INVOICE_STATUS_UNEXPECTED = 906 + | INVOICE_OFFER_INACTIVE = 907 + + // -- Errors from HSM crypto operations. -- + | HSM_ECDH_FAILED = 800 + + // -- Errors from `offer` commands -- + | OFFER_ALREADY_EXISTS = 1000 + | OFFER_ALREADY_DISABLED = 1001 + | OFFER_EXPIRED = 1002 + | OFFER_ROUTE_NOT_FOUND = 1003 + | OFFER_BAD_INREQ_REPLY = 1004 + | OFFER_TIMEOUT = 1005 + + // -- Errors from datastore command -- + | DATASTORE_DEL_DOES_NOT_EXIST = 1200 + | DATASTORE_DEL_WRONG_GENERATION = 1201 + | DATASTORE_UPDATE_ALREADY_EXISTS = 1201 + | DATASTORE_UPDATE_DOES_NOT_EXIST = 1203 + | DATASTORE_UPDATE_WRONG_GENERATION = 1204 + | DATASTORE_UPDATE_HAS_CHILDREN = 1205 + | DATASTORE_UPDATE_NO_CHILDREN = 1206 + + // -- Errors from `wait` commands -- + | WAIT_TIMEOUT = 2000 + +/// see 5.1: "Error object" in https://www.jsonrpc.org/specification +type JsonRPCErrorCodeEnum = + | ParseError = -32700 + | InvalidRequest = -32600 + | MethodNotFound = -32601 + | InvalidParams = -32602 + | InternalError = -32603 + +[] +type CLightningClientErrorCode = + | Known of knownCode: CLightningClientErrorCodeEnum + | Unknown of unknownCode: int + | KnownReservedJsonRPCError of knownJsonErrorCode: JsonRPCErrorCodeEnum + | UnknownReservedJsonRPCError of unknownJsonErrorCode: int + with + static member FromInt(i: int) = + if Enum.IsDefined(typeof, i) then + Known (LanguagePrimitives.EnumOfValue i) + else if Enum.IsDefined(typeof, i) then + KnownReservedJsonRPCError (LanguagePrimitives.EnumOfValue i) + else if -32099 < i && i < -32000 then + UnknownReservedJsonRPCError i + else + Unknown i + member this.AsInt = + match this with + | Known s -> LanguagePrimitives.EnumToValue s + | Unknown s -> s + | KnownReservedJsonRPCError s -> LanguagePrimitives.EnumToValue s + | UnknownReservedJsonRPCError s -> s + +[] +type CLightningRPCError = { + Code: CLightningClientErrorCode + Msg: string +} + +exception CLightningRPCException of CLightningRPCError + +type ClnClient(address: Uri, network: Network) = + + let getAddr (domain: string) = + task { + match IPAddress.TryParse domain with + | true, addr -> + return addr + | false, _ -> + let! a = Dns.GetHostAddressesAsync(domain).ConfigureAwait false + return a |> Array.tryHead |> Option.defaultWith (fun () -> failwith "Host not found") + } + let mutable _nextId = 0 + + let jsonOpts = JsonSerializerOptions() + do + jsonOpts.AddDNLJsonConverters(network) + + member val JsonSerializerOptions = jsonOpts with get, set + + member this.NextId + with private get() = + Interlocked.Increment(ref _nextId) |> ignore + _nextId + + member private this.Connect(ct) = + task { + let! socket, endpoint = + if address.Scheme = "tcp" then + task { + let domain = address.DnsSafeHost + let! addr = getAddr domain + let socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) + let endpoint = IPEndPoint(addr, address.Port) :> EndPoint + return socket, endpoint + } + else if address.Scheme = "unix" then + task { + let mutable path = address.AbsoluteUri.Remove(0, "unix:".Length) + if not <| path.StartsWith "/" then + path <- $"/{path}" + while path.Length >= 2 && (path.[0] <> '/' || path.[1] = '/') do + path <- path.Remove(0, 1) + if path.Length < 2 then + raise <| FormatException "Invalid unix url" + return + (new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.IP), UnixDomainSocketEndPoint(path) :> EndPoint) + } + else + raise <| NotSupportedException $"Protocol {address.Scheme} for clightning not supported" + do! socket.ConnectAsync(endpoint, ct) + return socket + } + member internal this.SendCommandAsync(methodName: string, + req: obj, + returnType: Type, + [] noReturn: bool, + [] ct: CancellationToken): Task<'T> = + backgroundTask { + use! socket = this.Connect(ct) + use networkStream = new NetworkStream(socket) + use jsonWriter = new Utf8JsonWriter(networkStream) + + let _ = + let reqObject = JsonObject() + reqObject.set_Item("id", JsonNode.op_Implicit(this.NextId)) + reqObject.set_Item("method", JsonNode.op_Implicit(methodName)) + if req |> isNull then + reqObject.set_Item("params", JsonArray()) + else + reqObject.set_Item("params", JsonSerializer.SerializeToNode(req)) + reqObject.WriteTo(jsonWriter) + do! jsonWriter.FlushAsync(ct) + do! networkStream.FlushAsync(ct) + + + let buf = Array.zeroCreate(65535) + let length = networkStream.Read(buf.AsSpan()) + if length = 0 then return Activator.CreateInstance() else + + let result = + let bufSpan = ReadOnlySpan.op_Implicit buf + JsonSerializer.Deserialize(bufSpan.Slice(0, length), jsonOpts) + + use _ = ct.Register(fun () -> socket.Dispose()) + try + match result.TryGetProperty("error") with + | true, err -> + let code = err.GetProperty("code").GetInt32() |> CLightningClientErrorCode.FromInt + let msg = err.GetProperty("message").GetString() + return raise <| CLightningRPCException { Code = code; Msg = msg } + | false, _ -> + if noReturn then + return Activator.CreateInstance returnType |> unbox + else + let jObj = + result.GetProperty("result") + return jObj.Deserialize(jsonOpts) + with + | _ when ct.IsCancellationRequested -> + ct.ThrowIfCancellationRequested() + return failwith "unreachable" + } + + member this.SendCommandAsync<'T>(methodName: string, + req: obj, + [] noReturn: bool, + [] ct: CancellationToken): Task<'T> = + this.SendCommandAsync(methodName, req, typeof<'T>, noReturn, ct) + member internal this.SendCommandAsync<'T>(req: Request, ct) = + this.SendCommandAsync<'T>(req.MethodName, req.Data, false, ct) diff --git a/src/DotNetLightning.ClnRpc/DotNetLightning.ClnRpc.fsproj b/src/DotNetLightning.ClnRpc/DotNetLightning.ClnRpc.fsproj new file mode 100644 index 000000000..5aebb767f --- /dev/null +++ b/src/DotNetLightning.ClnRpc/DotNetLightning.ClnRpc.fsproj @@ -0,0 +1,18 @@ + + + + net6.0 + true + + + + + + + + + + + + + diff --git a/src/DotNetLightning.ClnRpc/Requests.fs b/src/DotNetLightning.ClnRpc/Requests.fs new file mode 100644 index 000000000..536cb871a --- /dev/null +++ b/src/DotNetLightning.ClnRpc/Requests.fs @@ -0,0 +1,3103 @@ + +/// This file was automatically generated using following command: +/// ```bash +/// msggen +/// ``` +/// +/// Do not edit this file, it'll be overwritten. Rather edit the schema that +/// This file was generated from +namespace ClnSharp + +open System +open System.Text.Json +open System.Text.Json.Serialization + +open NBitcoin +open NBitcoin.Scripting +open DotNetLightning.Utils + +type ChannelState = + | OPENINGD = 0 + | CHANNELD_AWAITING_LOCKIN = 1 + | CHANNELD_NORMAL = 2 + | CHANNELD_SHUTTING_DOWN = 3 + | CLOSINGD_SIGEXCHANGE = 4 + | CLOSINGD_COMPLETE = 5 + | AWAITING_UNILATERAL = 6 + | FUNDING_SPEND_SEEN = 7 + | ONCHAIN = 8 + | DUALOPEND_OPEN_INIT = 9 + | DUALOPEND_AWAITING_LOCKIN = 10 + +type ChannelStateChangeCause = + | [] UNKNOWN = 0 + | [] LOCAL = 1 + | [] USER = 2 + | [] REMOTE = 3 + | [] PROTOCOL = 4 + | [] ONCHAIN = 5 + +type [] msat + +type AmountOrAny = + | Amount of int64 + | Any + +type AmountOrAll = + | Amount of int64 + | All + +type Feerate = + | Slow + | Normal + | Urgent + | PerKb of uint32 + | PerKw of uint32 + + with + override this.ToString() = + match this with + | Slow -> "slow" + | Normal -> "normal" + | Urgent -> "urgent" + | PerKb v -> $"{v} perkb" + | PerKw v -> $"{v} perkw" + +type ChannelSide = + | [] LOCAL = 0 + | [] REMOTE = 1 + +open System.Runtime.CompilerServices + +[] +module private PrimitiveExtensions = + let parseClnAmount(s: string): int64 = + if s |> String.IsNullOrWhiteSpace then + raise <| FormatException($"Invalid string for money. null") + else if s.EndsWith("msat") then + s.Substring(0, s.Length - 4) |> int64 |> unbox + else if s.EndsWith("sat") then + s.Substring(0, s.Length - 3) |> int64 |> unbox + else if s.EndsWith("btc") then + s.Substring(0, s.Length - 3) |> int64 |> unbox + else + raise <| FormatException $"Invalid string for money {s}" + + +[] +module private ClnRpcJsonConverters = + type MSatJsonConverter() = + inherit JsonConverter>() + override this.Write(writer, value, options) = + writer.WriteStringValue(value.ToString() + "msat") + override this.Read(reader, _typeToConvert, _options) = + reader.GetString() + |> parseClnAmount + + type PubKeyJsonConverter() = + inherit JsonConverter() + + override this.Write(writer, value, _options) = + value.ToString() + |> writer.WriteStringValue + override this.Read(reader, _typeToConvert, _options) = + let b = reader.GetString() |> Convert.FromHexString + if b.Length <> 33 then + raise <| JsonException($"Invalid length for pubkey: {b.Length}, it must be 33") + else + b |> PubKey + + type ShortChannelIdJsonConverter() = + inherit JsonConverter() + override this.Write(writer, value, _options) = + value.ToString() + |> writer.WriteStringValue + override this.Read(reader, _typeToConvert, _options) = + let s = reader.GetString() + match ShortChannelId.TryParse s with + | Ok c -> c + | Error e -> + raise <| JsonException e + + type KeyJsonConverter() = + inherit JsonConverter() + + override this.Write(writer, value, _options) = + value.ToString() + |> writer.WriteStringValue + + override this.Read(reader, _typeToConvert, _options) = + let b = reader.GetString() |> Convert.FromHexString + new Key(b) + + type uint256JsonConverter() = + inherit JsonConverter() + override this.Write(writer, value, _options) = + value.ToString() + |> writer.WriteStringValue + + override this.Read(reader, _typeToConvert, _options) = + reader.GetString() + |> Convert.FromHexString + |> uint256 + + type AmountOrAnyJsonConverter() = + inherit JsonConverter() + + override this.Write(writer, value, options) = + match value with + | AmountOrAny.Any -> + writer.WriteStringValue "any" + | AmountOrAny.Amount a -> + writer.WriteStringValue(a.ToString() + "msat") + override this.Read(reader, _typeToConvert, _options) = + match reader.GetString() with + | "any" -> + AmountOrAny.Any + | x -> + parseClnAmount x + |> AmountOrAny.Amount + + type AmountOrAllJsonConverter() = + inherit JsonConverter() + + override this.Write(writer, value, options) = + match value with + | AmountOrAll.All -> + writer.WriteStringValue "all" + | AmountOrAll.Amount a -> + writer.WriteStringValue(a.ToString() + "msat") + override this.Read(reader, _typeToConvert, _options) = + match reader.GetString() with + | "all" -> + AmountOrAll.All + | x -> + parseClnAmount x + |> AmountOrAll.Amount + + type OutPointJsonConverter() = + inherit JsonConverter() + + override this.Write(writer, value, options) = + writer.WriteStringValue(value.ToString()) + + override this.Read(reader, _typeToConvert, _options) = + let splits = reader.GetString().Split ":" + if splits.Length <> 2 then + raise <| JsonException("not a valid txid:output tuple") + else + let o = OutPoint() + o.Hash <- + splits.[0] |> uint256.Parse + o.N <- splits.[1] |> uint32 + o + + type FeerateJsonConverter() = + inherit JsonConverter() + + override this.Write(writer, value, options) = + value.ToString() |> writer.WriteStringValue + + override this.Read(reader, _typeToConvert, _options) = + let s = reader.GetString() + let number = + s + |> Seq.choose(fun c -> match UInt32.TryParse($"{c}") with | true, v -> Some v | _ -> None) + |> Seq.fold(fun acc d -> acc * 10u + d) 0u + + let s = s.ToLowerInvariant() + if s.EndsWith "perkw" then + Feerate.PerKw(number) + else if s.EndsWith "perkb" then + Feerate.PerKb number + else if s = "slow" then + Feerate.Slow + else if s = "normal" then + Feerate.Normal + else if s = "urgent" then + Feerate.Urgent + else + raise <| JsonException $"Unable to parse feerate from string {s}" + + type OutputDescriptorJsonConverter(network: Network) = + inherit JsonConverter() + + override this.Write(writer, value, options) = + value.ToString() |> writer.WriteStringValue + + override this.Read(reader, _typeToConvert, _options) = + reader.GetString() + |> fun s -> OutputDescriptor.Parse(s, network) + +type RouteHop = { + [] + [)>] + Id: PubKey + + [] + [)>] + Scid: ShortChannelId + + [] + [)>] + Feebase: int64 + + [] + Feeprop: uint32 + + [] + Expirydelta: uint16 +} + +type Routehint = { + [] + Hops: RouteHop[] +} + +type RoutehintList = { + [] + Hints: Routehint [] +} + +[] +module Requests = + type GetinfoRequest = unit + + [] + [] + type ListpeersRequest = { + [)>] + [] + [] + Id: PubKey option + [] + [] + Level: string option + } + + [] + [] + type ListfundsRequest = { + [] + [] + Spent: bool option + } + + [] + [] + type SendpayRoute = { + [)>] + [] + Msatoshi: int64 + [)>] + [] + Id: PubKey + [] + Delay: uint16 + [)>] + [] + Channel: ShortChannelId + } + + [] + [] + type SendpayRequest = { + [] + Route: SendpayRoute [] + [)>] + [] + PaymentHash: uint256 + [] + [] + Label: string option + [)>] + [] + [] + Msatoshi: int64 option + [] + [] + Bolt11: string option + [)>] + [] + [] + PaymentSecret: Key option + [] + [] + Partid: uint16 option + [] + [] + Localofferid: string option + [] + [] + Groupid: uint64 option + } + + [] + [] + type ListchannelsRequest = { + [)>] + [] + [] + ShortChannelId: ShortChannelId option + [)>] + [] + [] + Source: PubKey option + [)>] + [] + [] + Destination: PubKey option + } + + [] + [] + type AddgossipRequest = { + [] + Message: string + } + + [] + [] + type AutocleaninvoiceRequest = { + [] + [] + ExpiredBy: uint64 option + [] + [] + CycleSeconds: uint64 option + } + + [] + [] + type CheckmessageRequest = { + [] + Message: string + [] + Zbase: string + [)>] + [] + [] + Pubkey: PubKey option + } + + [] + [] + type CloseRequest = { + [] + Id: string + [] + [] + Unilateraltimeout: uint32 option + [] + [] + Destination: string option + [] + [] + FeeNegotiationStep: string option + [] + [] + WrongFunding: string option + [] + [] + ForceLeaseClosed: bool option + [] + [] + Feerange: Feerate [] option + } + + [] + [] + type ConnectRequest = { + [] + Id: string + [] + [] + Host: string option + [] + [] + Port: uint16 option + } + + [] + [] + type CreateinvoiceRequest = { + [] + Invstring: string + [] + Label: string + [] + Preimage: string + } + + [] + type DatastoreMode = + | [] MUST_CREATE = 0 + | [] MUST_REPLACE = 1 + | [] CREATE_OR_REPLACE = 2 + | [] MUST_APPEND = 3 + | [] CREATE_OR_APPEND = 4 + + + [] + [] + type DatastoreRequest = { + [] + Key: string [] + [] + [] + String: string option + [] + [] + Hex: string option + [] + [] + Mode: DatastoreMode option + [] + [] + Generation: uint64 option + } + + [] + [] + type CreateonionHops = { + [)>] + [] + Pubkey: PubKey + [] + Payload: string + } + + [] + [] + type CreateonionRequest = { + [] + Hops: CreateonionHops [] + [] + Assocdata: string + [)>] + [] + [] + SessionKey: Key option + [] + [] + OnionSize: uint16 option + } + + [] + [] + type DeldatastoreRequest = { + [] + Key: string [] + [] + [] + Generation: uint64 option + } + + [] + [] + type DelexpiredinvoiceRequest = { + [] + [] + Maxexpirytime: uint64 option + } + + [] + type DelinvoiceStatus = + | [] PAID = 0 + | [] EXPIRED = 1 + | [] UNPAID = 2 + + + [] + [] + type DelinvoiceRequest = { + [] + Label: string + // Path `DelInvoice.status` + [] + [)>] + Status: DelinvoiceStatus + [] + [] + Desconly: bool option + } + + [] + [] + type InvoiceRequest = { + [)>] + [] + Msatoshi: AmountOrAny + [] + Description: string + [] + Label: string + [] + [] + Expiry: uint64 option + [] + [] + Fallbacks: string [] option + [] + [] + Preimage: string option + [] + [] + Exposeprivatechannels: bool option + [] + [] + Cltv: uint32 option + [] + [] + Deschashonly: bool option + } + + [] + [] + type ListdatastoreRequest = { + [] + [] + Key: string [] option + } + + [] + [] + type ListinvoicesRequest = { + [] + [] + Label: string option + [] + [] + Invstring: string option + [] + [] + PaymentHash: string option + [] + [] + OfferId: string option + } + + [] + [] + type SendonionFirst_hop = { + [)>] + [] + Id: PubKey + [)>] + [] + AmountMsat: int64 + [] + Delay: uint16 + } + + [] + [] + type SendonionRequest = { + [] + Onion: string + [)>] + [] + PaymentHash: uint256 + [] + [] + Label: string option + [] + [] + SharedSecrets: Key [] option + [] + [] + Partid: uint16 option + [] + [] + Bolt11: string option + [)>] + [] + [] + Msatoshi: int64 option + [)>] + [] + [] + Destination: PubKey option + [)>] + [] + [] + Localofferid: uint256 option + [] + [] + Groupid: uint64 option + } + + [] + type ListsendpaysStatus = + | [] PENDING = 0 + | [] COMPLETE = 1 + | [] FAILED = 2 + + + [] + [] + type ListsendpaysRequest = { + [] + [] + Bolt11: string option + [)>] + [] + [] + PaymentHash: uint256 option + [] + [] + Status: ListsendpaysStatus option + } + + type ListtransactionsRequest = unit + + [] + [] + type PayRequest = { + [] + Bolt11: string + [)>] + [] + [] + Msatoshi: int64 option + [] + [] + Label: string option + [] + [] + Riskfactor: int64 option + [] + [] + Maxfeepercent: int64 option + [] + [] + RetryFor: uint16 option + [] + [] + Maxdelay: uint16 option + [)>] + [] + [] + Exemptfee: int64 option + [] + [] + Localofferid: string option + [] + [] + Exclude: string [] option + [)>] + [] + [] + Maxfee: int64 option + [] + [] + Description: string option + } + + [] + [] + type ListnodesRequest = { + [)>] + [] + [] + Id: PubKey option + } + + [] + [] + type WaitanyinvoiceRequest = { + [] + [] + LastpayIndex: uint64 option + [] + [] + Timeout: uint64 option + } + + [] + [] + type WaitinvoiceRequest = { + [] + Label: string + } + + [] + [] + type WaitsendpayRequest = { + [)>] + [] + PaymentHash: uint256 + [] + [] + Timeout: uint32 option + [] + [] + Partid: uint64 option + [] + [] + Groupid: uint64 option + } + + [] + type NewaddrAddresstype = + | [] BECH32 = 0 + | [] P2SH_SEGWIT = 1 + | [] ALL = 2 + + + [] + [] + type NewaddrRequest = { + [] + [] + Addresstype: NewaddrAddresstype option + } + + [] + [] + type WithdrawRequest = { + [] + Destination: string + [)>] + [] + [] + Satoshi: AmountOrAll option + [)>] + [] + [] + Feerate: Feerate option + [] + [] + Minconf: uint16 option + [] + [] + Utxos: OutPoint [] option + } + + type KeysendExtratlvs = unit + + [] + [] + type KeysendRequest = { + [)>] + [] + Destination: PubKey + [)>] + [] + Msatoshi: int64 + [] + [] + Label: string option + [] + [] + Maxfeepercent: int64 option + [] + [] + RetryFor: uint32 option + [] + [] + Maxdelay: uint32 option + [)>] + [] + [] + Exemptfee: int64 option + [] + [] + Routehints: RoutehintList option + } + + [] + [] + type FundpsbtRequest = { + [)>] + [] + Satoshi: int64 + [)>] + [] + Feerate: Feerate + [] + Startweight: uint32 + [] + [] + Minconf: uint32 option + [] + [] + Reserve: uint32 option + [] + [] + Locktime: uint32 option + [] + [] + MinWitnessWeight: uint32 option + [] + [] + ExcessAsChange: bool option + } + + [] + [] + type SendpsbtRequest = { + [] + Psbt: string + [] + [] + Reserve: bool option + } + + [] + [] + type SignpsbtRequest = { + [] + Psbt: string + [] + [] + Signonly: uint32 [] option + } + + [] + [] + type UtxopsbtRequest = { + [)>] + [] + Satoshi: int64 + [)>] + [] + Feerate: Feerate + [] + Startweight: uint32 + [] + Utxos: OutPoint [] + [] + [] + Reserve: uint32 option + [] + [] + Reservedok: bool option + [] + [] + Locktime: uint32 option + [] + [] + MinWitnessWeight: uint32 option + [] + [] + ExcessAsChange: bool option + } + + [] + [] + type TxdiscardRequest = { + [] + Txid: string + } + + [] + [] + type TxprepareRequest = { + [] + Outputs: OutputDescriptor [] + [)>] + [] + [] + Feerate: Feerate option + [] + [] + Minconf: uint32 option + [] + [] + Utxos: OutPoint [] option + } + + [] + [] + type TxsendRequest = { + [] + Txid: string + } + + [] + [] + type DisconnectRequest = { + [)>] + [] + Id: PubKey + [] + [] + Force: bool option + } + + [] + type FeeratesStyle = + | [] PERKB = 0 + | [] PERKW = 1 + + + [] + [] + type FeeratesRequest = { + // Path `Feerates.style` + [] + [)>] + Style: FeeratesStyle + } + + [] + [] + type GetrouteRequest = { + [)>] + [] + Id: PubKey + [)>] + [] + Msatoshi: int64 + [] + Riskfactor: uint64 + [] + [] + Cltv: int64 option + [)>] + [] + [] + Fromid: PubKey option + [] + [] + Fuzzpercent: uint32 option + [] + [] + Exclude: string [] option + [] + [] + Maxhops: uint32 option + } + + [] + type ListforwardsStatus = + | [] OFFERED = 0 + | [] SETTLED = 1 + | [] LOCAL_FAILED = 2 + | [] FAILED = 3 + + + [] + [] + type ListforwardsRequest = { + [] + [] + Status: ListforwardsStatus option + [)>] + [] + [] + InChannel: ShortChannelId option + [)>] + [] + [] + OutChannel: ShortChannelId option + } + + [] + type ListpaysStatus = + | [] PENDING = 0 + | [] COMPLETE = 1 + | [] FAILED = 2 + + + [] + [] + type ListpaysRequest = { + [] + [] + Bolt11: string option + [)>] + [] + [] + PaymentHash: uint256 option + [] + [] + Status: ListpaysStatus option + } + + [] + [] + type PingRequest = { + [)>] + [] + Id: PubKey + [] + [] + Len: int64 option + [] + [] + Pongbytes: int64 option + } + + [] + [] + type SignmessageRequest = { + [] + Message: string + } + + + +[] +module Responses = + [] + [] + type GetinfoOur_features = { + [] + Init: string + [] + Node: string + [] + Channel: string + [] + Invoice: string + } + + /// Type of connection + [] + type GetinfoAddressType = + | [] DNS = 0 + | [] IPV4 = 1 + | [] IPV6 = 2 + | [] TORV2 = 3 + | [] TORV3 = 4 + | [] WEBSOCKET = 5 + + + [] + [] + type GetinfoAddress = { + // Path `Getinfo.address[].type` + [] + [)>] + ItemType: GetinfoAddressType + [] + Port: uint16 + [] + [] + Address: string option + } + + /// Type of connection + [] + type GetinfoBindingType = + | [] LOCAL_SOCKET = 0 + | [] IPV4 = 1 + | [] IPV6 = 2 + | [] TORV2 = 3 + | [] TORV3 = 4 + + + [] + [] + type GetinfoBinding = { + // Path `Getinfo.binding[].type` + [] + [)>] + ItemType: GetinfoBindingType + [] + [] + Address: string option + [] + [] + Port: uint16 option + [] + [] + Socket: string option + } + + [] + [] + type GetinfoResponse = { + [)>] + [] + Id: PubKey + [] + Alias: string + [] + Color: string + [] + NumPeers: uint32 + [] + NumPendingChannels: uint32 + [] + NumActiveChannels: uint32 + [] + NumInactiveChannels: uint32 + [] + Version: string + [] + LightningDir: string + [] + Blockheight: uint32 + [] + Network: string + [)>] + [] + FeesCollectedMsat: int64 + [] + [] + Address: GetinfoAddress [] option + [] + [] + Binding: GetinfoBinding [] option + [] + [] + WarningBitcoindSync: string option + [] + [] + WarningLightningdSync: string option + } + + [] + type ListpeersPeersLogType = + | [] SKIPPED = 0 + | [] BROKEN = 1 + | [] UNUSUAL = 2 + | [] INFO = 3 + | [] DEBUG = 4 + | [] IO_IN = 5 + | [] IO_OUT = 6 + + + [] + [] + type ListpeersPeersLog = { + // Path `ListPeers.peers[].log[].type` + [] + [)>] + ItemType: ListpeersPeersLogType + [] + [] + NumSkipped: uint32 option + [] + [] + Time: string option + [] + [] + Source: string option + [] + [] + Log: string option + [)>] + [] + [] + NodeId: PubKey option + [] + [] + Data: string option + } + + /// the channel state, in particular "CHANNELD_NORMAL" means the channel can be used normally + [] + type ListpeersPeersChannelsState = + | [] OPENINGD = 0 + | [] CHANNELD_AWAITING_LOCKIN = 1 + | [] CHANNELD_NORMAL = 2 + | [] CHANNELD_SHUTTING_DOWN = 3 + | [] CLOSINGD_SIGEXCHANGE = 4 + | [] CLOSINGD_COMPLETE = 5 + | [] AWAITING_UNILATERAL = 6 + | [] FUNDING_SPEND_SEEN = 7 + | [] ONCHAIN = 8 + | [] DUALOPEND_OPEN_INIT = 9 + | [] DUALOPEND_AWAITING_LOCKIN = 10 + + + [] + [] + type ListpeersPeersChannelsFeerate = { + [] + Perkw: uint32 + [] + Perkb: uint32 + } + + [] + [] + type ListpeersPeersChannelsInflight = { + [] + FundingTxid: string + [] + FundingOutnum: uint32 + [] + Feerate: string + [)>] + [] + TotalFundingMsat: int64 + [)>] + [] + OurFundingMsat: int64 + [] + ScratchTxid: string + } + + [] + [] + type ListpeersPeersChannelsFunding = { + [)>] + [] + LocalMsat: int64 + [)>] + [] + RemoteMsat: int64 + [)>] + [] + PushedMsat: int64 + } + + [] + [] + type ListpeersPeersChannelsState_changes = { + [] + Timestamp: string + // Path `ListPeers.peers[].channels[].state_changes[].old_state` + [] + [)>] + OldState: ChannelState + // Path `ListPeers.peers[].channels[].state_changes[].new_state` + [] + [)>] + NewState: ChannelState + // Path `ListPeers.peers[].channels[].state_changes[].cause` + [] + [)>] + Cause: ChannelStateChangeCause + [] + Message: string + } + + /// Whether it came from peer, or is going to peer + [] + type ListpeersPeersChannelsHtlcsDirection = + | [] IN = 0 + | [] OUT = 1 + + + [] + [] + type ListpeersPeersChannelsHtlcs = { + // Path `ListPeers.peers[].channels[].htlcs[].direction` + [] + [)>] + Direction: ListpeersPeersChannelsHtlcsDirection + [] + Id: uint64 + [)>] + [] + AmountMsat: int64 + [] + Expiry: uint32 + [)>] + [] + PaymentHash: uint256 + [] + [] + LocalTrimmed: bool option + [] + [] + Status: string option + } + + [] + [] + type ListpeersPeersChannels = { + // Path `ListPeers.peers[].channels[].state` + [] + [)>] + State: ListpeersPeersChannelsState + [] + [] + ScratchTxid: string option + [] + [] + Owner: string option + [)>] + [] + [] + ShortChannelId: ShortChannelId option + [)>] + [] + [] + ChannelId: uint256 option + [] + [] + FundingTxid: string option + [] + [] + FundingOutnum: uint32 option + [] + [] + InitialFeerate: string option + [] + [] + LastFeerate: string option + [] + [] + NextFeerate: string option + [] + [] + NextFeeStep: uint32 option + [] + [] + Inflight: ListpeersPeersChannelsInflight [] option + [] + [] + CloseTo: string option + [] + [] + Private: bool option + // Path `ListPeers.peers[].channels[].opener` + [] + [)>] + Opener: ChannelSide + [] + Features: string [] + [)>] + [] + [] + ToUsMsat: int64 option + [)>] + [] + [] + MinToUsMsat: int64 option + [)>] + [] + [] + MaxToUsMsat: int64 option + [)>] + [] + [] + TotalMsat: int64 option + [)>] + [] + [] + FeeBaseMsat: int64 option + [] + [] + FeeProportionalMillionths: uint32 option + [)>] + [] + [] + DustLimitMsat: int64 option + [)>] + [] + [] + MaxTotalHtlcInMsat: int64 option + [)>] + [] + [] + TheirReserveMsat: int64 option + [)>] + [] + [] + OurReserveMsat: int64 option + [)>] + [] + [] + SpendableMsat: int64 option + [)>] + [] + [] + ReceivableMsat: int64 option + [)>] + [] + [] + MinimumHtlcInMsat: int64 option + [)>] + [] + [] + MinimumHtlcOutMsat: int64 option + [)>] + [] + [] + MaximumHtlcOutMsat: int64 option + [] + [] + TheirToSelfDelay: uint32 option + [] + [] + OurToSelfDelay: uint32 option + [] + [] + MaxAcceptedHtlcs: uint32 option + [] + [] + StateChanges: ListpeersPeersChannelsState_changes [] option + [] + [] + Status: string [] option + [] + [] + InPaymentsOffered: uint64 option + [)>] + [] + [] + InOfferedMsat: int64 option + [] + [] + InPaymentsFulfilled: uint64 option + [)>] + [] + [] + InFulfilledMsat: int64 option + [] + [] + OutPaymentsOffered: uint64 option + [)>] + [] + [] + OutOfferedMsat: int64 option + [] + [] + OutPaymentsFulfilled: uint64 option + [)>] + [] + [] + OutFulfilledMsat: int64 option + [] + [] + Htlcs: ListpeersPeersChannelsHtlcs [] option + [] + [] + CloseToAddr: string option + } + + [] + [] + type ListpeersPeers = { + [)>] + [] + Id: PubKey + [] + Connected: bool + [] + [] + Log: ListpeersPeersLog [] option + [] + Channels: ListpeersPeersChannels [] + [] + [] + Netaddr: string [] option + [] + [] + Features: string option + } + + [] + [] + type ListpeersResponse = { + [] + Peers: ListpeersPeers [] + } + + [] + type ListfundsOutputsStatus = + | [] UNCONFIRMED = 0 + | [] CONFIRMED = 1 + | [] SPENT = 2 + + + [] + [] + type ListfundsOutputs = { + [] + Txid: string + [] + Output: uint32 + [)>] + [] + AmountMsat: int64 + [] + Scriptpubkey: string + [] + [] + Address: string option + [] + [] + Redeemscript: string option + // Path `ListFunds.outputs[].status` + [] + [)>] + Status: ListfundsOutputsStatus + [] + [] + Blockheight: uint32 option + } + + [] + [] + type ListfundsChannels = { + [)>] + [] + PeerId: PubKey + [)>] + [] + OurAmountMsat: int64 + [)>] + [] + AmountMsat: int64 + [] + FundingTxid: string + [] + FundingOutput: uint32 + [] + Connected: bool + // Path `ListFunds.channels[].state` + [] + [)>] + State: ChannelState + [)>] + [] + [] + ShortChannelId: ShortChannelId option + } + + [] + [] + type ListfundsResponse = { + [] + Outputs: ListfundsOutputs [] + [] + Channels: ListfundsChannels [] + } + + /// status of the payment (could be complete if already sent previously) + [] + type SendpayStatus = + | [] PENDING = 0 + | [] COMPLETE = 1 + + + [] + [] + type SendpayResponse = { + [] + Id: uint64 + [] + [] + Groupid: uint64 option + [)>] + [] + PaymentHash: uint256 + // Path `SendPay.status` + [] + [)>] + Status: SendpayStatus + [)>] + [] + [] + AmountMsat: int64 option + [)>] + [] + [] + Destination: PubKey option + [] + CreatedAt: uint64 + [)>] + [] + AmountSentMsat: int64 + [] + [] + Label: string option + [] + [] + Partid: uint64 option + [] + [] + Bolt11: string option + [] + [] + Bolt12: string option + [)>] + [] + [] + PaymentPreimage: Key option + [] + [] + Message: string option + } + + [] + [] + type ListchannelsChannels = { + [)>] + [] + Source: PubKey + [)>] + [] + Destination: PubKey + [)>] + [] + ShortChannelId: ShortChannelId + [] + Public: bool + [)>] + [] + AmountMsat: int64 + [] + MessageFlags: byte + [] + ChannelFlags: byte + [] + Active: bool + [] + LastUpdate: uint32 + [] + BaseFeeMillisatoshi: uint32 + [] + FeePerMillionth: uint32 + [] + Delay: uint32 + [)>] + [] + HtlcMinimumMsat: int64 + [)>] + [] + [] + HtlcMaximumMsat: int64 option + [] + Features: string + } + + [] + [] + type ListchannelsResponse = { + [] + Channels: ListchannelsChannels [] + } + + type AddgossipResponse = unit + + [] + [] + type AutocleaninvoiceResponse = { + [] + Enabled: bool + [] + [] + ExpiredBy: uint64 option + [] + [] + CycleSeconds: uint64 option + } + + [] + [] + type CheckmessageResponse = { + [] + Verified: bool + [)>] + [] + [] + Pubkey: PubKey option + } + + /// Whether we successfully negotiated a mutual close, closed without them, or discarded not-yet-opened channel + [] + type CloseType = + | [] MUTUAL = 0 + | [] UNILATERAL = 1 + | [] UNOPENED = 2 + + + [] + [] + type CloseResponse = { + // Path `Close.type` + [] + [)>] + ItemType: CloseType + [] + [] + Tx: string option + [] + [] + Txid: string option + } + + /// Whether they initiated connection or we did + [] + type ConnectDirection = + | [] IN = 0 + | [] OUT = 1 + + + /// Type of connection (*torv2*/*torv3* only if **direction** is *out*) + [] + type ConnectAddressType = + | [] LOCAL_SOCKET = 0 + | [] IPV4 = 1 + | [] IPV6 = 2 + | [] TORV2 = 3 + | [] TORV3 = 4 + + + [] + [] + type ConnectAddress = { + // Path `Connect.address.type` + [] + [)>] + ItemType: ConnectAddressType + [] + [] + Socket: string option + [] + [] + Address: string option + [] + [] + Port: uint16 option + } + + [] + [] + type ConnectResponse = { + [)>] + [] + Id: PubKey + [] + Features: string + // Path `Connect.direction` + [] + [)>] + Direction: ConnectDirection + } + + /// Whether it has been paid, or can no longer be paid + [] + type CreateinvoiceStatus = + | [] PAID = 0 + | [] EXPIRED = 1 + | [] UNPAID = 2 + + + [] + [] + type CreateinvoiceResponse = { + [] + Label: string + [] + [] + Bolt11: string option + [] + [] + Bolt12: string option + [)>] + [] + PaymentHash: uint256 + [)>] + [] + [] + AmountMsat: int64 option + // Path `CreateInvoice.status` + [] + [)>] + Status: CreateinvoiceStatus + [] + Description: string + [] + ExpiresAt: uint64 + [] + [] + PayIndex: uint64 option + [)>] + [] + [] + AmountReceivedMsat: int64 option + [] + [] + PaidAt: uint64 option + [)>] + [] + [] + PaymentPreimage: Key option + [] + [] + LocalOfferId: string option + [] + [] + PayerNote: string option + } + + [] + [] + type DatastoreResponse = { + [] + Key: string [] + [] + [] + Generation: uint64 option + [] + [] + Hex: string option + [] + [] + String: string option + } + + [] + [] + type CreateonionResponse = { + [] + Onion: string + [] + SharedSecrets: Key [] + } + + [] + [] + type DeldatastoreResponse = { + [] + Key: string [] + [] + [] + Generation: uint64 option + [] + [] + Hex: string option + [] + [] + String: string option + } + + type DelexpiredinvoiceResponse = unit + + /// State of invoice + [] + type DelinvoiceStatus = + | [] PAID = 0 + | [] EXPIRED = 1 + | [] UNPAID = 2 + + + [] + [] + type DelinvoiceResponse = { + [] + Label: string + [] + [] + Bolt11: string option + [] + [] + Bolt12: string option + [)>] + [] + [] + AmountMsat: int64 option + [] + [] + Description: string option + [)>] + [] + PaymentHash: uint256 + // Path `DelInvoice.status` + [] + [)>] + Status: DelinvoiceStatus + [] + ExpiresAt: uint64 + [] + [] + LocalOfferId: string option + [] + [] + PayerNote: string option + } + + [] + [] + type InvoiceResponse = { + [] + Bolt11: string + [)>] + [] + PaymentHash: uint256 + [)>] + [] + PaymentSecret: Key + [] + ExpiresAt: uint64 + [] + [] + WarningCapacity: string option + [] + [] + WarningOffline: string option + [] + [] + WarningDeadends: string option + [] + [] + WarningPrivateUnused: string option + [] + [] + WarningMpp: string option + } + + [] + [] + type ListdatastoreDatastore = { + [] + Key: string [] + [] + [] + Generation: uint64 option + [] + [] + Hex: string option + [] + [] + String: string option + } + + [] + [] + type ListdatastoreResponse = { + [] + Datastore: ListdatastoreDatastore [] + } + + /// Whether it's paid, unpaid or unpayable + [] + type ListinvoicesInvoicesStatus = + | [] UNPAID = 0 + | [] PAID = 1 + | [] EXPIRED = 2 + + + [] + [] + type ListinvoicesInvoices = { + [] + Label: string + [] + [] + Description: string option + [)>] + [] + PaymentHash: uint256 + // Path `ListInvoices.invoices[].status` + [] + [)>] + Status: ListinvoicesInvoicesStatus + [] + ExpiresAt: uint64 + [)>] + [] + [] + AmountMsat: int64 option + [] + [] + Bolt11: string option + [] + [] + Bolt12: string option + [] + [] + LocalOfferId: string option + [] + [] + PayerNote: string option + [] + [] + PayIndex: uint64 option + [)>] + [] + [] + AmountReceivedMsat: int64 option + [] + [] + PaidAt: uint64 option + [)>] + [] + [] + PaymentPreimage: Key option + } + + [] + [] + type ListinvoicesResponse = { + [] + Invoices: ListinvoicesInvoices [] + } + + /// status of the payment (could be complete if already sent previously) + [] + type SendonionStatus = + | [] PENDING = 0 + | [] COMPLETE = 1 + + + [] + [] + type SendonionResponse = { + [] + Id: uint64 + [)>] + [] + PaymentHash: uint256 + // Path `SendOnion.status` + [] + [)>] + Status: SendonionStatus + [)>] + [] + [] + AmountMsat: int64 option + [)>] + [] + [] + Destination: PubKey option + [] + CreatedAt: uint64 + [)>] + [] + AmountSentMsat: int64 + [] + [] + Label: string option + [] + [] + Bolt11: string option + [] + [] + Bolt12: string option + [] + [] + Partid: uint64 option + [)>] + [] + [] + PaymentPreimage: Key option + [] + [] + Message: string option + } + + /// status of the payment + [] + type ListsendpaysPaymentsStatus = + | [] PENDING = 0 + | [] FAILED = 1 + | [] COMPLETE = 2 + + + [] + [] + type ListsendpaysPayments = { + [] + Id: uint64 + [] + [] + Groupid: uint64 option + [)>] + [] + PaymentHash: uint256 + // Path `ListSendPays.payments[].status` + [] + [)>] + Status: ListsendpaysPaymentsStatus + [)>] + [] + [] + AmountMsat: int64 option + [)>] + [] + [] + Destination: PubKey option + [] + CreatedAt: uint64 + [)>] + [] + AmountSentMsat: int64 + [] + [] + Label: string option + [] + [] + Bolt11: string option + [] + [] + Description: string option + [] + [] + Bolt12: string option + [)>] + [] + [] + PaymentPreimage: Key option + [] + [] + Erroronion: string option + } + + [] + [] + type ListsendpaysResponse = { + [] + Payments: ListsendpaysPayments [] + } + + /// the purpose of this input (*EXPERIMENTAL_FEATURES* only) + [] + type ListtransactionsTransactionsInputsType = + | [] THEIRS = 0 + | [] DEPOSIT = 1 + | [] WITHDRAW = 2 + | [] CHANNEL_FUNDING = 3 + | [] CHANNEL_MUTUAL_CLOSE = 4 + | [] CHANNEL_UNILATERAL_CLOSE = 5 + | [] CHANNEL_SWEEP = 6 + | [] CHANNEL_HTLC_SUCCESS = 7 + | [] CHANNEL_HTLC_TIMEOUT = 8 + | [] CHANNEL_PENALTY = 9 + | [] CHANNEL_UNILATERAL_CHEAT = 10 + + + [] + [] + type ListtransactionsTransactionsInputs = { + [] + Txid: string + [] + Index: uint32 + [] + Sequence: uint32 + [] + [] + ItemType: ListtransactionsTransactionsInputsType option + [)>] + [] + [] + Channel: ShortChannelId option + } + + /// the purpose of this output (*EXPERIMENTAL_FEATURES* only) + [] + type ListtransactionsTransactionsOutputsType = + | [] THEIRS = 0 + | [] DEPOSIT = 1 + | [] WITHDRAW = 2 + | [] CHANNEL_FUNDING = 3 + | [] CHANNEL_MUTUAL_CLOSE = 4 + | [] CHANNEL_UNILATERAL_CLOSE = 5 + | [] CHANNEL_SWEEP = 6 + | [] CHANNEL_HTLC_SUCCESS = 7 + | [] CHANNEL_HTLC_TIMEOUT = 8 + | [] CHANNEL_PENALTY = 9 + | [] CHANNEL_UNILATERAL_CHEAT = 10 + + + [] + [] + type ListtransactionsTransactionsOutputs = { + [] + Index: uint32 + [)>] + [] + Msat: int64 + [] + ScriptPubKey: string + [] + [] + ItemType: ListtransactionsTransactionsOutputsType option + [)>] + [] + [] + Channel: ShortChannelId option + } + + [] + [] + type ListtransactionsTransactions = { + [] + Hash: string + [] + Rawtx: string + [] + Blockheight: uint32 + [] + Txindex: uint32 + [)>] + [] + [] + Channel: ShortChannelId option + [] + Locktime: uint32 + [] + Version: uint32 + [] + Inputs: ListtransactionsTransactionsInputs [] + [] + Outputs: ListtransactionsTransactionsOutputs [] + } + + [] + [] + type ListtransactionsResponse = { + [] + Transactions: ListtransactionsTransactions [] + } + + /// status of payment + [] + type PayStatus = + | [] COMPLETE = 0 + | [] PENDING = 1 + | [] FAILED = 2 + + + [] + [] + type PayResponse = { + [)>] + [] + PaymentPreimage: Key + [)>] + [] + [] + Destination: PubKey option + [)>] + [] + PaymentHash: uint256 + [] + CreatedAt: int64 + [] + Parts: uint32 + [)>] + [] + AmountMsat: int64 + [)>] + [] + AmountSentMsat: int64 + [] + [] + WarningPartialCompletion: string option + // Path `Pay.status` + [] + [)>] + Status: PayStatus + } + + /// Type of connection + [] + type ListnodesNodesAddressesType = + | [] DNS = 0 + | [] IPV4 = 1 + | [] IPV6 = 2 + | [] TORV2 = 3 + | [] TORV3 = 4 + | [] WEBSOCKET = 5 + + + [] + [] + type ListnodesNodesAddresses = { + // Path `ListNodes.nodes[].addresses[].type` + [] + [)>] + ItemType: ListnodesNodesAddressesType + [] + Port: uint16 + [] + [] + Address: string option + } + + [] + [] + type ListnodesNodes = { + [)>] + [] + Nodeid: PubKey + [] + [] + LastTimestamp: uint32 option + [] + [] + Alias: string option + [] + [] + Color: string option + [] + [] + Features: string option + [] + [] + Addresses: ListnodesNodesAddresses [] option + } + + [] + [] + type ListnodesResponse = { + [] + Nodes: ListnodesNodes [] + } + + /// Whether it's paid or expired + [] + type WaitanyinvoiceStatus = + | [] PAID = 0 + | [] EXPIRED = 1 + + + [] + [] + type WaitanyinvoiceResponse = { + [] + Label: string + [] + Description: string + [)>] + [] + PaymentHash: uint256 + // Path `WaitAnyInvoice.status` + [] + [)>] + Status: WaitanyinvoiceStatus + [] + ExpiresAt: uint64 + [)>] + [] + [] + AmountMsat: int64 option + [] + [] + Bolt11: string option + [] + [] + Bolt12: string option + [] + [] + PayIndex: uint64 option + [)>] + [] + [] + AmountReceivedMsat: int64 option + [] + [] + PaidAt: uint64 option + [)>] + [] + [] + PaymentPreimage: Key option + } + + /// Whether it's paid or expired + [] + type WaitinvoiceStatus = + | [] PAID = 0 + | [] EXPIRED = 1 + + + [] + [] + type WaitinvoiceResponse = { + [] + Label: string + [] + Description: string + [)>] + [] + PaymentHash: uint256 + // Path `WaitInvoice.status` + [] + [)>] + Status: WaitinvoiceStatus + [] + ExpiresAt: uint64 + [)>] + [] + [] + AmountMsat: int64 option + [] + [] + Bolt11: string option + [] + [] + Bolt12: string option + [] + [] + PayIndex: uint64 option + [)>] + [] + [] + AmountReceivedMsat: int64 option + [] + [] + PaidAt: uint64 option + [)>] + [] + [] + PaymentPreimage: Key option + } + + /// status of the payment + [] + type WaitsendpayStatus = + | [] COMPLETE = 0 + + + [] + [] + type WaitsendpayResponse = { + [] + Id: uint64 + [] + [] + Groupid: uint64 option + [)>] + [] + PaymentHash: uint256 + // Path `WaitSendPay.status` + [] + [)>] + Status: WaitsendpayStatus + [)>] + [] + [] + AmountMsat: int64 option + [)>] + [] + [] + Destination: PubKey option + [] + CreatedAt: uint64 + [)>] + [] + AmountSentMsat: int64 + [] + [] + Label: string option + [] + [] + Partid: uint64 option + [] + [] + Bolt11: string option + [] + [] + Bolt12: string option + [)>] + [] + [] + PaymentPreimage: Key option + } + + [] + [] + type NewaddrResponse = { + [] + [] + Bech32: string option + [] + [] + P2ShSegwit: string option + } + + [] + [] + type WithdrawResponse = { + [] + Tx: string + [] + Txid: string + [] + Psbt: string + } + + /// status of payment + [] + type KeysendStatus = + | [] COMPLETE = 0 + + + [] + [] + type KeysendResponse = { + [)>] + [] + PaymentPreimage: Key + [)>] + [] + [] + Destination: PubKey option + [)>] + [] + PaymentHash: uint256 + [] + CreatedAt: int64 + [] + Parts: uint32 + [)>] + [] + AmountMsat: int64 + [)>] + [] + AmountSentMsat: int64 + [] + [] + WarningPartialCompletion: string option + // Path `KeySend.status` + [] + [)>] + Status: KeysendStatus + } + + [] + [] + type FundpsbtReservations = { + [] + Txid: string + [] + Vout: uint32 + [] + WasReserved: bool + [] + Reserved: bool + [] + ReservedToBlock: uint32 + } + + [] + [] + type FundpsbtResponse = { + [] + Psbt: string + [] + FeeratePerKw: uint32 + [] + EstimatedFinalWeight: uint32 + [)>] + [] + ExcessMsat: int64 + [] + [] + ChangeOutnum: uint32 option + [] + [] + Reservations: FundpsbtReservations [] option + } + + [] + [] + type SendpsbtResponse = { + [] + Tx: string + [] + Txid: string + } + + [] + [] + type SignpsbtResponse = { + [] + SignedPsbt: string + } + + [] + [] + type UtxopsbtReservations = { + [] + Txid: string + [] + Vout: uint32 + [] + WasReserved: bool + [] + Reserved: bool + [] + ReservedToBlock: uint32 + } + + [] + [] + type UtxopsbtResponse = { + [] + Psbt: string + [] + FeeratePerKw: uint32 + [] + EstimatedFinalWeight: uint32 + [)>] + [] + ExcessMsat: int64 + [] + [] + ChangeOutnum: uint32 option + [] + [] + Reservations: UtxopsbtReservations [] option + } + + [] + [] + type TxdiscardResponse = { + [] + UnsignedTx: string + [] + Txid: string + } + + [] + [] + type TxprepareResponse = { + [] + Psbt: string + [] + UnsignedTx: string + [] + Txid: string + } + + [] + [] + type TxsendResponse = { + [] + Psbt: string + [] + Tx: string + [] + Txid: string + } + + type DisconnectResponse = unit + + [] + [] + type FeeratesPerkb = { + [] + MinAcceptable: uint32 + [] + MaxAcceptable: uint32 + [] + [] + Opening: uint32 option + [] + [] + MutualClose: uint32 option + [] + [] + UnilateralClose: uint32 option + [] + [] + DelayedToUs: uint32 option + [] + [] + HtlcResolution: uint32 option + [] + [] + Penalty: uint32 option + } + + [] + [] + type FeeratesPerkw = { + [] + MinAcceptable: uint32 + [] + MaxAcceptable: uint32 + [] + [] + Opening: uint32 option + [] + [] + MutualClose: uint32 option + [] + [] + UnilateralClose: uint32 option + [] + [] + DelayedToUs: uint32 option + [] + [] + HtlcResolution: uint32 option + [] + [] + Penalty: uint32 option + } + + [] + [] + type FeeratesOnchain_fee_estimates = { + [] + OpeningChannelSatoshis: uint64 + [] + MutualCloseSatoshis: uint64 + [] + UnilateralCloseSatoshis: uint64 + [] + HtlcTimeoutSatoshis: uint64 + [] + HtlcSuccessSatoshis: uint64 + } + + [] + [] + type FeeratesResponse = { + [] + [] + WarningMissingFeerates: string option + } + + /// The features understood by the destination node + [] + type GetrouteRouteStyle = + | [] TLV = 0 + + + [] + [] + type GetrouteRoute = { + [)>] + [] + Id: PubKey + [)>] + [] + Channel: ShortChannelId + [] + Direction: uint32 + [)>] + [] + AmountMsat: int64 + [] + Delay: uint32 + // Path `GetRoute.route[].style` + [] + [)>] + Style: GetrouteRouteStyle + } + + [] + [] + type GetrouteResponse = { + [] + Route: GetrouteRoute [] + } + + /// still ongoing, completed, failed locally, or failed after forwarding + [] + type ListforwardsForwardsStatus = + | [] OFFERED = 0 + | [] SETTLED = 1 + | [] LOCAL_FAILED = 2 + | [] FAILED = 3 + + + /// Either a legacy onion format or a modern tlv format + [] + type ListforwardsForwardsStyle = + | [] LEGACY = 0 + | [] TLV = 1 + + + [] + [] + type ListforwardsForwards = { + [)>] + [] + InChannel: ShortChannelId + [)>] + [] + InMsat: int64 + // Path `ListForwards.forwards[].status` + [] + [)>] + Status: ListforwardsForwardsStatus + [] + ReceivedTime: int64 + [)>] + [] + [] + OutChannel: ShortChannelId option + [] + [] + PaymentHash: string option + [] + [] + Style: ListforwardsForwardsStyle option + [)>] + [] + [] + FeeMsat: int64 option + [)>] + [] + [] + OutMsat: int64 option + } + + [] + [] + type ListforwardsResponse = { + [] + Forwards: ListforwardsForwards [] + } + + /// status of the payment + [] + type ListpaysPaysStatus = + | [] PENDING = 0 + | [] FAILED = 1 + | [] COMPLETE = 2 + + + [] + [] + type ListpaysPays = { + [] + PaymentHash: string + // Path `ListPays.pays[].status` + [] + [)>] + Status: ListpaysPaysStatus + [)>] + [] + [] + Destination: PubKey option + [] + CreatedAt: uint64 + [] + [] + Label: string option + [] + [] + Bolt11: string option + [] + [] + Description: string option + [] + [] + Bolt12: string option + [)>] + [] + [] + AmountMsat: int64 option + [)>] + [] + [] + AmountSentMsat: int64 option + [] + [] + Erroronion: string option + } + + [] + [] + type ListpaysResponse = { + [] + Pays: ListpaysPays [] + } + + [] + [] + type PingResponse = { + [] + Totlen: uint16 + } + + [] + [] + type SignmessageResponse = { + [] + Signature: string + [] + Recid: string + [] + Zbase: string + } + + + + +[] +type Request = + | Getinfo of Requests.GetinfoRequest + | ListPeers of Requests.ListpeersRequest + | ListFunds of Requests.ListfundsRequest + | SendPay of Requests.SendpayRequest + | ListChannels of Requests.ListchannelsRequest + | AddGossip of Requests.AddgossipRequest + | AutoCleanInvoice of Requests.AutocleaninvoiceRequest + | CheckMessage of Requests.CheckmessageRequest + | Close of Requests.CloseRequest + | ConnectPeer of Requests.ConnectRequest + | CreateInvoice of Requests.CreateinvoiceRequest + | Datastore of Requests.DatastoreRequest + | CreateOnion of Requests.CreateonionRequest + | DelDatastore of Requests.DeldatastoreRequest + | DelExpiredInvoice of Requests.DelexpiredinvoiceRequest + | DelInvoice of Requests.DelinvoiceRequest + | Invoice of Requests.InvoiceRequest + | ListDatastore of Requests.ListdatastoreRequest + | ListInvoices of Requests.ListinvoicesRequest + | SendOnion of Requests.SendonionRequest + | ListSendPays of Requests.ListsendpaysRequest + | ListTransactions of Requests.ListtransactionsRequest + | Pay of Requests.PayRequest + | ListNodes of Requests.ListnodesRequest + | WaitAnyInvoice of Requests.WaitanyinvoiceRequest + | WaitInvoice of Requests.WaitinvoiceRequest + | WaitSendPay of Requests.WaitsendpayRequest + | NewAddr of Requests.NewaddrRequest + | Withdraw of Requests.WithdrawRequest + | KeySend of Requests.KeysendRequest + | FundPsbt of Requests.FundpsbtRequest + | SendPsbt of Requests.SendpsbtRequest + | SignPsbt of Requests.SignpsbtRequest + | UtxoPsbt of Requests.UtxopsbtRequest + | TxDiscard of Requests.TxdiscardRequest + | TxPrepare of Requests.TxprepareRequest + | TxSend of Requests.TxsendRequest + | Disconnect of Requests.DisconnectRequest + | Feerates of Requests.FeeratesRequest + | GetRoute of Requests.GetrouteRequest + | ListForwards of Requests.ListforwardsRequest + | ListPays of Requests.ListpaysRequest + | Ping of Requests.PingRequest + | SignMessage of Requests.SignmessageRequest + with + member this.MethodName = + match this with + | Getinfo _ -> "getinfo" + | ListPeers _ -> "listpeers" + | ListFunds _ -> "listfunds" + | SendPay _ -> "sendpay" + | ListChannels _ -> "listchannels" + | AddGossip _ -> "addgossip" + | AutoCleanInvoice _ -> "autocleaninvoice" + | CheckMessage _ -> "checkmessage" + | Close _ -> "close" + | ConnectPeer _ -> "connectpeer" + | CreateInvoice _ -> "createinvoice" + | Datastore _ -> "datastore" + | CreateOnion _ -> "createonion" + | DelDatastore _ -> "deldatastore" + | DelExpiredInvoice _ -> "delexpiredinvoice" + | DelInvoice _ -> "delinvoice" + | Invoice _ -> "invoice" + | ListDatastore _ -> "listdatastore" + | ListInvoices _ -> "listinvoices" + | SendOnion _ -> "sendonion" + | ListSendPays _ -> "listsendpays" + | ListTransactions _ -> "listtransactions" + | Pay _ -> "pay" + | ListNodes _ -> "listnodes" + | WaitAnyInvoice _ -> "waitanyinvoice" + | WaitInvoice _ -> "waitinvoice" + | WaitSendPay _ -> "waitsendpay" + | NewAddr _ -> "newaddr" + | Withdraw _ -> "withdraw" + | KeySend _ -> "keysend" + | FundPsbt _ -> "fundpsbt" + | SendPsbt _ -> "sendpsbt" + | SignPsbt _ -> "signpsbt" + | UtxoPsbt _ -> "utxopsbt" + | TxDiscard _ -> "txdiscard" + | TxPrepare _ -> "txprepare" + | TxSend _ -> "txsend" + | Disconnect _ -> "disconnect" + | Feerates _ -> "feerates" + | GetRoute _ -> "getroute" + | ListForwards _ -> "listforwards" + | ListPays _ -> "listpays" + | Ping _ -> "ping" + | SignMessage _ -> "signmessage" + member this.Data = + match this with + | Getinfo x -> x |> box + | ListPeers x -> x |> box + | ListFunds x -> x |> box + | SendPay x -> x |> box + | ListChannels x -> x |> box + | AddGossip x -> x |> box + | AutoCleanInvoice x -> x |> box + | CheckMessage x -> x |> box + | Close x -> x |> box + | ConnectPeer x -> x |> box + | CreateInvoice x -> x |> box + | Datastore x -> x |> box + | CreateOnion x -> x |> box + | DelDatastore x -> x |> box + | DelExpiredInvoice x -> x |> box + | DelInvoice x -> x |> box + | Invoice x -> x |> box + | ListDatastore x -> x |> box + | ListInvoices x -> x |> box + | SendOnion x -> x |> box + | ListSendPays x -> x |> box + | ListTransactions x -> x |> box + | Pay x -> x |> box + | ListNodes x -> x |> box + | WaitAnyInvoice x -> x |> box + | WaitInvoice x -> x |> box + | WaitSendPay x -> x |> box + | NewAddr x -> x |> box + | Withdraw x -> x |> box + | KeySend x -> x |> box + | FundPsbt x -> x |> box + | SendPsbt x -> x |> box + | SignPsbt x -> x |> box + | UtxoPsbt x -> x |> box + | TxDiscard x -> x |> box + | TxPrepare x -> x |> box + | TxSend x -> x |> box + | Disconnect x -> x |> box + | Feerates x -> x |> box + | GetRoute x -> x |> box + | ListForwards x -> x |> box + | ListPays x -> x |> box + | Ping x -> x |> box + | SignMessage x -> x |> box + + +[] +type Response = + | Getinfo of Responses.GetinfoResponse + | ListPeers of Responses.ListpeersResponse + | ListFunds of Responses.ListfundsResponse + | SendPay of Responses.SendpayResponse + | ListChannels of Responses.ListchannelsResponse + | AddGossip of Responses.AddgossipResponse + | AutoCleanInvoice of Responses.AutocleaninvoiceResponse + | CheckMessage of Responses.CheckmessageResponse + | Close of Responses.CloseResponse + | ConnectPeer of Responses.ConnectResponse + | CreateInvoice of Responses.CreateinvoiceResponse + | Datastore of Responses.DatastoreResponse + | CreateOnion of Responses.CreateonionResponse + | DelDatastore of Responses.DeldatastoreResponse + | DelExpiredInvoice of Responses.DelexpiredinvoiceResponse + | DelInvoice of Responses.DelinvoiceResponse + | Invoice of Responses.InvoiceResponse + | ListDatastore of Responses.ListdatastoreResponse + | ListInvoices of Responses.ListinvoicesResponse + | SendOnion of Responses.SendonionResponse + | ListSendPays of Responses.ListsendpaysResponse + | ListTransactions of Responses.ListtransactionsResponse + | Pay of Responses.PayResponse + | ListNodes of Responses.ListnodesResponse + | WaitAnyInvoice of Responses.WaitanyinvoiceResponse + | WaitInvoice of Responses.WaitinvoiceResponse + | WaitSendPay of Responses.WaitsendpayResponse + | NewAddr of Responses.NewaddrResponse + | Withdraw of Responses.WithdrawResponse + | KeySend of Responses.KeysendResponse + | FundPsbt of Responses.FundpsbtResponse + | SendPsbt of Responses.SendpsbtResponse + | SignPsbt of Responses.SignpsbtResponse + | UtxoPsbt of Responses.UtxopsbtResponse + | TxDiscard of Responses.TxdiscardResponse + | TxPrepare of Responses.TxprepareResponse + | TxSend of Responses.TxsendResponse + | Disconnect of Responses.DisconnectResponse + | Feerates of Responses.FeeratesResponse + | GetRoute of Responses.GetrouteResponse + | ListForwards of Responses.ListforwardsResponse + | ListPays of Responses.ListpaysResponse + | Ping of Responses.PingResponse + | SignMessage of Responses.SignmessageResponse +