btc-lsp (empty) → 0.1.0.0
raw patch · 95 files changed
+20437/−0 lines, 95 filesdep +GenericPrettydep +QuickCheckdep +SHAsetup-changed
Dependencies added: GenericPretty, QuickCheck, SHA, aeson, async, base, base16-bytestring, base64-bytestring, binary, btc-lsp, bytestring, case-insensitive, casing, chronos, classy-prelude-yesod, containers, cryptonite, envparse, errors, esqueleto, extra, fast-logger, file-embed, format-numbers, generic-pretty-instances, hjsmin, hspec, http-client-tls, http2, http2-client, http2-client-grpc, http2-grpc-proto-lens, http2-grpc-types, iso8601-time, katip, lnd-client, memory, microlens, monad-logger, network-bitcoin, persistent, persistent-migration, persistent-postgresql, pretty, proto-lens, proto-lens-runtime, qrcode-core, qrcode-juicypixels, resource-pool, scientific, secp256k1-haskell, shakespeare, stm, template-haskell, text, time, transformers, unbounded-delays, universum, unliftio, uuid, vector, wai, wai-extra, warp, warp-grpc, warp-tls, witch, yaml, yesod, yesod-auth, yesod-core, yesod-form, yesod-static
Files
- ChangeLog.md +3/−0
- LICENSE +30/−0
- README.md +287/−0
- Setup.hs +2/−0
- app/Main.hs +6/−0
- btc-lsp.cabal +1008/−0
- integration/Integration.hs +19/−0
- integration/IntegrationSpec.hs +104/−0
- src/BtcLsp/Class/Env.hs +119/−0
- src/BtcLsp/Class/Storage.hs +16/−0
- src/BtcLsp/Data/AppM.hs +109/−0
- src/BtcLsp/Data/Env.hs +276/−0
- src/BtcLsp/Data/Kind.hs +68/−0
- src/BtcLsp/Data/Orphan.hs +136/−0
- src/BtcLsp/Data/Smart.hs +99/−0
- src/BtcLsp/Data/Type.hs +879/−0
- src/BtcLsp/Grpc/Client/HighLevel.hs +149/−0
- src/BtcLsp/Grpc/Client/LowLevel.hs +197/−0
- src/BtcLsp/Grpc/Combinator.hs +266/−0
- src/BtcLsp/Grpc/Data.hs +115/−0
- src/BtcLsp/Grpc/Orphan.hs +133/−0
- src/BtcLsp/Grpc/Server/HighLevel.hs +168/−0
- src/BtcLsp/Grpc/Server/LowLevel.hs +154/−0
- src/BtcLsp/Grpc/Sig.hs +88/−0
- src/BtcLsp/Import.hs +19/−0
- src/BtcLsp/Import/External.hs +155/−0
- src/BtcLsp/Import/Psql.hs +88/−0
- src/BtcLsp/Import/Witch.hs +139/−0
- src/BtcLsp/Math/OnChain.hs +146/−0
- src/BtcLsp/Math/Swap.hs +112/−0
- src/BtcLsp/Psbt/PsbtOpener.hs +174/−0
- src/BtcLsp/Psbt/Utils.hs +185/−0
- src/BtcLsp/Storage/Migration.hs +74/−0
- src/BtcLsp/Storage/Model.hs +74/−0
- src/BtcLsp/Storage/Model/Block.hs +124/−0
- src/BtcLsp/Storage/Model/LnChan.hs +339/−0
- src/BtcLsp/Storage/Model/SwapIntoLn.hs +409/−0
- src/BtcLsp/Storage/Model/SwapUtxo.hs +249/−0
- src/BtcLsp/Storage/Model/User.hs +57/−0
- src/BtcLsp/Storage/Util.hs +78/−0
- src/BtcLsp/Text.hs +51/−0
- src/BtcLsp/Thread/BlockScanner.hs +406/−0
- src/BtcLsp/Thread/Expirer.hs +41/−0
- src/BtcLsp/Thread/LnChanOpener.hs +91/−0
- src/BtcLsp/Thread/LnChanWatcher.hs +127/−0
- src/BtcLsp/Thread/Main.hs +137/−0
- src/BtcLsp/Thread/Refunder.hs +205/−0
- src/BtcLsp/Thread/Server.hs +212/−0
- src/BtcLsp/Time.hs +71/−0
- src/BtcLsp/Yesod/Application.hs +175/−0
- src/BtcLsp/Yesod/Data/BootstrapColor.hs +22/−0
- src/BtcLsp/Yesod/Data/Colored.hs +19/−0
- src/BtcLsp/Yesod/Data/Language.hs +37/−0
- src/BtcLsp/Yesod/Data/Widget.hs +128/−0
- src/BtcLsp/Yesod/Foundation.hs +414/−0
- src/BtcLsp/Yesod/Handler/About.hs +67/−0
- src/BtcLsp/Yesod/Handler/Common.hs +27/−0
- src/BtcLsp/Yesod/Handler/Home.hs +23/−0
- src/BtcLsp/Yesod/Handler/Language.hs +14/−0
- src/BtcLsp/Yesod/Handler/OpenChan.hs +31/−0
- src/BtcLsp/Yesod/Handler/SwapIntoLnCreate.hs +152/−0
- src/BtcLsp/Yesod/Handler/SwapIntoLnSelect.hs +313/−0
- src/BtcLsp/Yesod/Handler/SwapUpdates.hs +52/−0
- src/BtcLsp/Yesod/Import.hs +8/−0
- src/BtcLsp/Yesod/Import/NoFoundation.hs +50/−0
- src/BtcLsp/Yesod/Settings.hs +151/−0
- src/BtcLsp/Yesod/Settings/StaticFiles.hs +40/−0
- src/BtcLsp/Yesod/TH.hs +21/−0
- src/Proto/BtcLsp.hs +69/−0
- src/Proto/BtcLsp/Data/HighLevel.hs +3247/−0
- src/Proto/BtcLsp/Data/HighLevel_Fields.hs +155/−0
- src/Proto/BtcLsp/Data/LowLevel.hs +729/−0
- src/Proto/BtcLsp/Data/LowLevel_Fields.hs +46/−0
- src/Proto/BtcLsp/Method/GetCfg.hs +1475/−0
- src/Proto/BtcLsp/Method/GetCfg_Fields.hs +194/−0
- src/Proto/BtcLsp/Method/SwapFromLn.hs +1187/−0
- src/Proto/BtcLsp/Method/SwapFromLn_Fields.hs +143/−0
- src/Proto/BtcLsp/Method/SwapIntoLn.hs +1305/−0
- src/Proto/BtcLsp/Method/SwapIntoLn_Fields.hs +150/−0
- src/Proto/BtcLsp_Fields.hs +32/−0
- test/BakSpec.hs +67/−0
- test/BlockScannerSpec.hs +124/−0
- test/LnChanWatcherSpec.hs +160/−0
- test/Main.hs +19/−0
- test/MathSpec.hs +90/−0
- test/PsbtOpenerSpec.hs +111/−0
- test/RefunderSpec.hs +220/−0
- test/ReorgSpec.hs +70/−0
- test/ServerSpec.hs +158/−0
- test/SmartSpec.hs +51/−0
- test/Spec.hs +2/−0
- test/TestAppM.hs +558/−0
- test/TestHelpers.hs +106/−0
- test/TestOrphan.hs +18/−0
- test/TypeSpec.hs +13/−0
@@ -0,0 +1,3 @@+# Changelog for lsp++## Unreleased changes
@@ -0,0 +1,30 @@+Copyright Yolo name here (c) 2020++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Yolo name here nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,287 @@+# btc-lsp++Bitcoin Lightning Service Provider. Development environment is packed into nix-shell.++## Auth++Every `btc-lsp` gRPC request/response does have `ctx` (context) field in payload which contains credentials:++- First is `nonce`. The nonce is used for security reasons and is used to guard against replay attacks. The server will reject any request that comes with an incorrect nonce. The only requirement for the nonce is that it needs to be strictly increasing. Nonce generation is often achieved by using the current UNIX timestamp.+- Second is `ln_pub_key`. This is lightning node network identity public key in DER format. This key is used to verify request/response signature from headers/trailers.++Also, every request/response does have a signature which is:++- Signed with LN identity key (key locator family is 6 and index is 0).+- Signed over binary request payload in exact gRPC/http2 wire [format](https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md) (1 byte of compression flag + 4 bytes of payload length in big endian format + payload bytes).+- Single hashed (double_hash parameter is False).+- Not compact (compact_sig parameter is False).+- Using DER binary format.+- Base64-encoded according official http2 [spec](https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md).+- Located in `sig-bin` gRPC header/trailer.++## Haskell/Nix++Spawn shell:++```sh+# If you have Nix installed (a bit faster)+./nix/hm-shell-native.sh++# If you have Docker installed (works on Mac)+./nix/hm-shell-docker.sh+```++Work with Haskell sources in shell:++```sh+vi .+```++Run tests with hot code reloading:++```sh+./nix/ns-ghcid-test.sh+```++Run app with hot code reloading:++```sh+./nix/ns-ghcid-main.sh+```++## Release++Releases are automated by CI. To create new release, bump the version inside `VERSION` file. Then push all changes into github and merge into `master` branch. Then run:++```sh+../nix/hm-release.sh+```++The script will push new tag which will trigger new github release and package.++## Kubernetes++Some tools are required to be installed directly on host machine. They can be installed using nix-env:++```sh+./nix/nix-install-tools.sh+```++If nix is not available, install tools in any other way you like:++```+expect-5.45.4+jq-1.6+kubectl-1.23.5+minikube-1.25.2+wget-1.21.3+helm-3.8.2+```++### Regtest setup++1. Setup minikube cluster and deploy k8s resources:++```sh+./nix/mk-deploy-regtest.sh+```++2. Forward services to host network:++```sh+./nix/k8s-forward.sh+```++### Service/config upgrade++1. Set k8s context to upgrade++```sh+kubectl config use-context <ctx-name>+```++2. Upgrade services/configs++```sh+./nix/k8s-upgrade.sh <net> <mode> <services>+```++Example++```sh+./nix/k8s-upgrade.sh --regtest --prebuilt lsp bitcoind+```++## Deploy testnet (DigitalOcean)++1. Install doctl++If you have used nix-env doctl will already be installed, otherwise install it manually.++```+doctl-1.71.1+```++2. Configure doctl++Follow the guide below to configure `doctl`.++https://docs.digitalocean.com/reference/doctl/how-to/install/++3. Setup Managed Kubernetes, Managed Postgres, DNS records, TLS certificates and deploy k8s resources:++```sh+./nix/do-deploy-testnet.sh+```++## Destroy testnet (DigitalOcean)++```sh+./nix/do-destroy-testnet.sh+```++## Deploy testnet (AWS)++1. Install aws cli, eksctl and helm:++If you have used nix-env everything will be already installed, otherwise install manually.++```+aws-cli-2.5.4+eksctl-0.93.0+helm-3.8.2+```++2. Create IAM user with `AdministratorAccess` in AWS Console++3. Configure aws cli `access_key_id`, `secret_access_key`, `region`++```sh+aws configure+```++5. Setup EKS, RDS, Route53, Request certs from ACM and deploy k8s resources:++```sh+./nix/aws-deploy-testnet.sh+```++## Destroy testnet (AWS)++```sh+./nix/aws-destroy-testnet.sh+```++## Troubleshoot++1. Get list of running pods:++```sh+kubectl get po+```++2. Get info about pod:++```sh+kubectl describe pod <pod-name>+```++3. Get detailed info about current cluster state (regtest only):++```sh+minikube dashboard --profile=btc-lsp+```++4. Lnd after restart is locked. Usually Lsp unlocks it automatically, but if for some reason it's locked (for example Lsp is not running) then you can unlock it with:++```sh+./nix/k8s-lazy-init-unlock.sh+```++5. Delete all failed Pods:++```sh+kubectl delete pod --all-namespaces --field-selector 'status.phase=Failed'+```++6. Connect to existing cluster on DigitalOcean:++Get cluster ID++```sh+doctl k cluster get lsp-testnet+```++Add context to kube config++```sh+doctl kubernetes cluster kubeconfig save <cluster-id>+```++7. Connect to existing eks cluster on AWS:++```sh+aws eks update-kubeconfig --name lsp-testnet+```++8. Manage k8s contexts:++Display list of contexts++```sh+kubectl config get-contexts+```++Display the current context++```sh+kubectl config current-context+```++Set current context to btc-lsp++```sh+kubectl config use-context btc-lsp+```++9. List k8s nodes:++```sh+kubectl get nodes -o wide+```++10. Get current storage class:++```sh+kubectl get storageclass+```++## Seed++Secure lnd seed generation procedure for the mainnet:++1. Go to a private place without cameras and witnesses.++2. Create USB stick with minimal [nixos](https://nixos.org) image (cli only).++3. Boot from USB stick to nixos installer and connect to the internet.++4. Load nix-shell using the command:++```sh+nix-shell --pure -p '(import (fetchTarball { url = "https://github.com/coingaming/src/tarball/ef7ed491e5102063763538bc4cb2e86bc8021973"; sha256 = "1ml6jrz605jx7pmzd38d1490n8cbjv8yaclpqy57j7lqp1raaa7w"; } + "/nix/project.nix")).nixBitcoin.lndinit'+```++5. DISCONNECT FROM THE INTERNET.++6. Generate the seed using the command:++```sh+lndinit gen-seed+```++7. Copy the seed to non-digital durable media, for example steel plate.++8. Turn off the computer and erase the USB stick.++9. Keep the seed media safe.
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
@@ -0,0 +1,6 @@+module Main+ ( main,+ )+where++import BtcLsp.Thread.Main (main)
@@ -0,0 +1,1008 @@+cabal-version: 1.12++-- This file has been generated from package.yaml by hpack version 0.34.7.+--+-- see: https://github.com/sol/hpack++name: btc-lsp+version: 0.1.0.0+synopsis: Lightning service provider+description: You can find documentation at <https://hackage.haskell.org/package/btc-lsp>+category: Lightning, Bitcoin, Finance, Network, Payments+homepage: https://github.com/coingaming/src+bug-reports: https://github.com/coingaming/src/issues+author: 21it <21it@tuta.io>, Mikhail Prushinskiy <mprushinsky@gmail.com>, Artem Markov <drownbes@gmail.com>+maintainer: 21it <21it@tuta.io>, Mikhail Prushinskiy <mprushinsky@gmail.com>, Artem Markov <drownbes@gmail.com>+copyright: 2022 Yolo <hello@coingaming.io>+license: BSD3+license-file: LICENSE+build-type: Simple+extra-source-files:+ README.md+ ChangeLog.md++source-repository head+ type: git+ location: https://github.com/coingaming/src++flag ghcid+ manual: True+ default: False++library+ exposed-modules:+ BtcLsp.Class.Env+ BtcLsp.Class.Storage+ BtcLsp.Data.AppM+ BtcLsp.Data.Env+ BtcLsp.Data.Kind+ BtcLsp.Data.Orphan+ BtcLsp.Data.Smart+ BtcLsp.Data.Type+ BtcLsp.Grpc.Client.HighLevel+ BtcLsp.Grpc.Client.LowLevel+ BtcLsp.Grpc.Combinator+ BtcLsp.Grpc.Data+ BtcLsp.Grpc.Orphan+ BtcLsp.Grpc.Server.HighLevel+ BtcLsp.Grpc.Server.LowLevel+ BtcLsp.Grpc.Sig+ BtcLsp.Import+ BtcLsp.Import.External+ BtcLsp.Import.Psql+ BtcLsp.Import.Witch+ BtcLsp.Math.OnChain+ BtcLsp.Math.Swap+ BtcLsp.Psbt.PsbtOpener+ BtcLsp.Psbt.Utils+ BtcLsp.Storage.Migration+ BtcLsp.Storage.Model+ BtcLsp.Storage.Model.Block+ BtcLsp.Storage.Model.LnChan+ BtcLsp.Storage.Model.SwapIntoLn+ BtcLsp.Storage.Model.SwapUtxo+ BtcLsp.Storage.Model.User+ BtcLsp.Storage.Util+ BtcLsp.Text+ BtcLsp.Thread.BlockScanner+ BtcLsp.Thread.Expirer+ BtcLsp.Thread.LnChanOpener+ BtcLsp.Thread.LnChanWatcher+ BtcLsp.Thread.Main+ BtcLsp.Thread.Refunder+ BtcLsp.Thread.Server+ BtcLsp.Time+ BtcLsp.Yesod.Application+ BtcLsp.Yesod.Data.BootstrapColor+ BtcLsp.Yesod.Data.Colored+ BtcLsp.Yesod.Data.Language+ BtcLsp.Yesod.Data.Widget+ BtcLsp.Yesod.Foundation+ BtcLsp.Yesod.Handler.About+ BtcLsp.Yesod.Handler.Common+ BtcLsp.Yesod.Handler.Home+ BtcLsp.Yesod.Handler.Language+ BtcLsp.Yesod.Handler.OpenChan+ BtcLsp.Yesod.Handler.SwapIntoLnCreate+ BtcLsp.Yesod.Handler.SwapIntoLnSelect+ BtcLsp.Yesod.Handler.SwapUpdates+ BtcLsp.Yesod.Import+ BtcLsp.Yesod.Import.NoFoundation+ BtcLsp.Yesod.Settings+ BtcLsp.Yesod.Settings.StaticFiles+ BtcLsp.Yesod.TH+ Proto.BtcLsp+ Proto.BtcLsp.Data.HighLevel+ Proto.BtcLsp.Data.HighLevel_Fields+ Proto.BtcLsp.Data.LowLevel+ Proto.BtcLsp.Data.LowLevel_Fields+ Proto.BtcLsp.Method.GetCfg+ Proto.BtcLsp.Method.GetCfg_Fields+ Proto.BtcLsp.Method.SwapFromLn+ Proto.BtcLsp.Method.SwapFromLn_Fields+ Proto.BtcLsp.Method.SwapIntoLn+ Proto.BtcLsp.Method.SwapIntoLn_Fields+ Proto.BtcLsp_Fields+ other-modules:+ Paths_btc_lsp+ hs-source-dirs:+ src+ default-extensions:+ NoImplicitPrelude+ MultiParamTypeClasses+ LambdaCase+ OverloadedStrings+ ScopedTypeVariables+ DeriveGeneric+ GeneralizedNewtypeDeriving+ TupleSections+ DataKinds+ DerivingStrategies+ KindSignatures+ FlexibleContexts+ FlexibleInstances+ StrictData+ TypeFamilies+ TypeOperators+ StandaloneDeriving+ DerivingVia+ ExistentialQuantification+ InstanceSigs+ ghc-options: -Weverything -Wno-missing-exported-signatures -Wno-missing-import-lists -Wno-missed-specialisations -Wno-all-missed-specialisations -Wno-unsafe -Wno-safe -Wno-missing-local-signatures -Wno-missing-export-lists -fwarn-tabs -O2+ build-depends:+ GenericPretty+ , SHA+ , aeson >=1.4 && <1.6+ , async+ , base >=4.7 && <5+ , base16-bytestring+ , base64-bytestring >=1.2.1+ , binary+ , bytestring+ , case-insensitive+ , casing+ , chronos+ , classy-prelude-yesod ==1.5.*+ , containers+ , cryptonite+ , envparse+ , errors+ , esqueleto >=3.5.3+ , extra+ , fast-logger >=2.2 && <3.1+ , file-embed+ , format-numbers+ , generic-pretty-instances+ , hjsmin >=0.1 && <0.3+ , http-client-tls ==0.3.*+ , http2+ , http2-client+ , http2-client-grpc+ , http2-grpc-proto-lens+ , http2-grpc-types+ , iso8601-time+ , katip+ , lnd-client+ , memory+ , microlens+ , monad-logger ==0.3.*+ , network-bitcoin+ , persistent >=2.13.2.1+ , persistent-migration+ , persistent-postgresql >=2.13.2.1+ , pretty+ , proto-lens+ , proto-lens-runtime+ , qrcode-core+ , qrcode-juicypixels+ , resource-pool+ , scientific+ , secp256k1-haskell+ , shakespeare ==2.0.*+ , stm+ , template-haskell+ , text+ , time+ , transformers+ , unbounded-delays+ , universum+ , unliftio+ , uuid+ , vector+ , wai+ , wai-extra ==3.1.*+ , warp >=3.0 && <3.4+ , warp-grpc+ , warp-tls+ , witch+ , yaml ==0.11.*+ , yesod ==1.6.*+ , yesod-auth ==1.6.*+ , yesod-core ==1.6.*+ , yesod-form ==1.6.*+ , yesod-static ==1.6.*+ if impl(ghc >= 8.10.7)+ ghc-options: -Wno-missing-safe-haskell-mode -Wno-prepositive-qualified-module -fenable-th-splice-warnings -fprint-potential-instances+ default-language: Haskell2010++executable btc-lsp-exe+ main-is: Main.hs+ other-modules:+ Paths_btc_lsp+ hs-source-dirs:+ app+ default-extensions:+ NoImplicitPrelude+ MultiParamTypeClasses+ LambdaCase+ OverloadedStrings+ ScopedTypeVariables+ DeriveGeneric+ GeneralizedNewtypeDeriving+ TupleSections+ DataKinds+ DerivingStrategies+ KindSignatures+ FlexibleContexts+ FlexibleInstances+ StrictData+ TypeFamilies+ TypeOperators+ StandaloneDeriving+ DerivingVia+ ExistentialQuantification+ InstanceSigs+ ghc-options: -Weverything -Wno-missing-exported-signatures -Wno-missing-import-lists -Wno-missed-specialisations -Wno-all-missed-specialisations -Wno-unsafe -Wno-safe -Wno-missing-local-signatures -Wno-missing-export-lists -O2 -optc-O3 -funfolding-use-threshold=16 -threaded -rtsopts -with-rtsopts=-N -optl-fuse-ld=gold+ ld-options: -fuse-ld=gold+ build-depends:+ base+ if impl(ghc >= 8.10.7)+ ghc-options: -Wno-missing-safe-haskell-mode -Wno-prepositive-qualified-module -fenable-th-splice-warnings -fprint-potential-instances+ if flag(ghcid)+ other-modules:+ BtcLsp.Class.Env+ BtcLsp.Class.Storage+ BtcLsp.Data.AppM+ BtcLsp.Data.Env+ BtcLsp.Data.Kind+ BtcLsp.Data.Orphan+ BtcLsp.Data.Smart+ BtcLsp.Data.Type+ BtcLsp.Grpc.Client.HighLevel+ BtcLsp.Grpc.Client.LowLevel+ BtcLsp.Grpc.Combinator+ BtcLsp.Grpc.Data+ BtcLsp.Grpc.Orphan+ BtcLsp.Grpc.Server.HighLevel+ BtcLsp.Grpc.Server.LowLevel+ BtcLsp.Grpc.Sig+ BtcLsp.Import+ BtcLsp.Import.External+ BtcLsp.Import.Psql+ BtcLsp.Import.Witch+ BtcLsp.Math.OnChain+ BtcLsp.Math.Swap+ BtcLsp.Psbt.PsbtOpener+ BtcLsp.Psbt.Utils+ BtcLsp.Storage.Migration+ BtcLsp.Storage.Model+ BtcLsp.Storage.Model.Block+ BtcLsp.Storage.Model.LnChan+ BtcLsp.Storage.Model.SwapIntoLn+ BtcLsp.Storage.Model.SwapUtxo+ BtcLsp.Storage.Model.User+ BtcLsp.Storage.Util+ BtcLsp.Text+ BtcLsp.Thread.BlockScanner+ BtcLsp.Thread.Expirer+ BtcLsp.Thread.LnChanOpener+ BtcLsp.Thread.LnChanWatcher+ BtcLsp.Thread.Main+ BtcLsp.Thread.Refunder+ BtcLsp.Thread.Server+ BtcLsp.Time+ BtcLsp.Yesod.Application+ BtcLsp.Yesod.Data.BootstrapColor+ BtcLsp.Yesod.Data.Colored+ BtcLsp.Yesod.Data.Language+ BtcLsp.Yesod.Data.Widget+ BtcLsp.Yesod.Foundation+ BtcLsp.Yesod.Handler.About+ BtcLsp.Yesod.Handler.Common+ BtcLsp.Yesod.Handler.Home+ BtcLsp.Yesod.Handler.Language+ BtcLsp.Yesod.Handler.OpenChan+ BtcLsp.Yesod.Handler.SwapIntoLnCreate+ BtcLsp.Yesod.Handler.SwapIntoLnSelect+ BtcLsp.Yesod.Handler.SwapUpdates+ BtcLsp.Yesod.Import+ BtcLsp.Yesod.Import.NoFoundation+ BtcLsp.Yesod.Settings+ BtcLsp.Yesod.Settings.StaticFiles+ BtcLsp.Yesod.TH+ Proto.BtcLsp+ Proto.BtcLsp.Data.HighLevel+ Proto.BtcLsp.Data.HighLevel_Fields+ Proto.BtcLsp.Data.LowLevel+ Proto.BtcLsp.Data.LowLevel_Fields+ Proto.BtcLsp.Method.GetCfg+ Proto.BtcLsp.Method.GetCfg_Fields+ Proto.BtcLsp.Method.SwapFromLn+ Proto.BtcLsp.Method.SwapFromLn_Fields+ Proto.BtcLsp.Method.SwapIntoLn+ Proto.BtcLsp.Method.SwapIntoLn_Fields+ Proto.BtcLsp_Fields+ hs-source-dirs:+ src+ ghc-options: -Wno-unused-packages+ build-depends:+ GenericPretty+ , SHA+ , aeson >=1.4 && <1.6+ , async+ , base >=4.7 && <5+ , base16-bytestring+ , base64-bytestring >=1.2.1+ , binary+ , bytestring+ , case-insensitive+ , casing+ , chronos+ , classy-prelude-yesod ==1.5.*+ , containers+ , cryptonite+ , envparse+ , errors+ , esqueleto >=3.5.3+ , extra+ , fast-logger >=2.2 && <3.1+ , file-embed+ , format-numbers+ , generic-pretty-instances+ , hjsmin >=0.1 && <0.3+ , http-client-tls ==0.3.*+ , http2+ , http2-client+ , http2-client-grpc+ , http2-grpc-proto-lens+ , http2-grpc-types+ , iso8601-time+ , katip+ , lnd-client+ , memory+ , microlens+ , monad-logger ==0.3.*+ , network-bitcoin+ , persistent >=2.13.2.1+ , persistent-migration+ , persistent-postgresql >=2.13.2.1+ , pretty+ , proto-lens+ , proto-lens-runtime+ , qrcode-core+ , qrcode-juicypixels+ , resource-pool+ , scientific+ , secp256k1-haskell+ , shakespeare ==2.0.*+ , stm+ , template-haskell+ , text+ , time+ , transformers+ , unbounded-delays+ , universum+ , unliftio+ , uuid+ , vector+ , wai+ , wai-extra ==3.1.*+ , warp >=3.0 && <3.4+ , warp-grpc+ , warp-tls+ , witch+ , yaml ==0.11.*+ , yesod ==1.6.*+ , yesod-auth ==1.6.*+ , yesod-core ==1.6.*+ , yesod-form ==1.6.*+ , yesod-static ==1.6.*+ else+ build-depends:+ btc-lsp+ default-language: Haskell2010++executable btc-lsp-integration+ main-is: Integration.hs+ other-modules:+ IntegrationSpec+ BakSpec+ BlockScannerSpec+ LnChanWatcherSpec+ Main+ MathSpec+ PsbtOpenerSpec+ RefunderSpec+ ReorgSpec+ ServerSpec+ SmartSpec+ Spec+ TestAppM+ TestHelpers+ TestOrphan+ TypeSpec+ Paths_btc_lsp+ hs-source-dirs:+ integration+ test+ default-extensions:+ NoImplicitPrelude+ MultiParamTypeClasses+ LambdaCase+ OverloadedStrings+ ScopedTypeVariables+ DeriveGeneric+ GeneralizedNewtypeDeriving+ TupleSections+ DataKinds+ DerivingStrategies+ KindSignatures+ FlexibleContexts+ FlexibleInstances+ StrictData+ TypeFamilies+ TypeOperators+ StandaloneDeriving+ DerivingVia+ ExistentialQuantification+ InstanceSigs+ ghc-options: -Weverything -Wno-missing-exported-signatures -Wno-missing-import-lists -Wno-missed-specialisations -Wno-all-missed-specialisations -Wno-unsafe -Wno-safe -Wno-missing-local-signatures -Wno-missing-export-lists -O2 -optc-O3 -funfolding-use-threshold=16 -threaded -rtsopts -with-rtsopts=-N -main-is Integration -optl-fuse-ld=gold+ ld-options: -fuse-ld=gold+ build-depends:+ QuickCheck+ , aeson+ , base+ , bytestring+ , envparse+ , hspec+ , lnd-client+ , network-bitcoin+ , proto-lens+ , unliftio+ , vector+ , witch+ if impl(ghc >= 8.10.7)+ ghc-options: -Wno-missing-safe-haskell-mode -Wno-prepositive-qualified-module -fenable-th-splice-warnings -fprint-potential-instances+ if flag(ghcid)+ other-modules:+ BtcLsp.Class.Env+ BtcLsp.Class.Storage+ BtcLsp.Data.AppM+ BtcLsp.Data.Env+ BtcLsp.Data.Kind+ BtcLsp.Data.Orphan+ BtcLsp.Data.Smart+ BtcLsp.Data.Type+ BtcLsp.Grpc.Client.HighLevel+ BtcLsp.Grpc.Client.LowLevel+ BtcLsp.Grpc.Combinator+ BtcLsp.Grpc.Data+ BtcLsp.Grpc.Orphan+ BtcLsp.Grpc.Server.HighLevel+ BtcLsp.Grpc.Server.LowLevel+ BtcLsp.Grpc.Sig+ BtcLsp.Import+ BtcLsp.Import.External+ BtcLsp.Import.Psql+ BtcLsp.Import.Witch+ BtcLsp.Math.OnChain+ BtcLsp.Math.Swap+ BtcLsp.Psbt.PsbtOpener+ BtcLsp.Psbt.Utils+ BtcLsp.Storage.Migration+ BtcLsp.Storage.Model+ BtcLsp.Storage.Model.Block+ BtcLsp.Storage.Model.LnChan+ BtcLsp.Storage.Model.SwapIntoLn+ BtcLsp.Storage.Model.SwapUtxo+ BtcLsp.Storage.Model.User+ BtcLsp.Storage.Util+ BtcLsp.Text+ BtcLsp.Thread.BlockScanner+ BtcLsp.Thread.Expirer+ BtcLsp.Thread.LnChanOpener+ BtcLsp.Thread.LnChanWatcher+ BtcLsp.Thread.Main+ BtcLsp.Thread.Refunder+ BtcLsp.Thread.Server+ BtcLsp.Time+ BtcLsp.Yesod.Application+ BtcLsp.Yesod.Data.BootstrapColor+ BtcLsp.Yesod.Data.Colored+ BtcLsp.Yesod.Data.Language+ BtcLsp.Yesod.Data.Widget+ BtcLsp.Yesod.Foundation+ BtcLsp.Yesod.Handler.About+ BtcLsp.Yesod.Handler.Common+ BtcLsp.Yesod.Handler.Home+ BtcLsp.Yesod.Handler.Language+ BtcLsp.Yesod.Handler.OpenChan+ BtcLsp.Yesod.Handler.SwapIntoLnCreate+ BtcLsp.Yesod.Handler.SwapIntoLnSelect+ BtcLsp.Yesod.Handler.SwapUpdates+ BtcLsp.Yesod.Import+ BtcLsp.Yesod.Import.NoFoundation+ BtcLsp.Yesod.Settings+ BtcLsp.Yesod.Settings.StaticFiles+ BtcLsp.Yesod.TH+ Proto.BtcLsp+ Proto.BtcLsp.Data.HighLevel+ Proto.BtcLsp.Data.HighLevel_Fields+ Proto.BtcLsp.Data.LowLevel+ Proto.BtcLsp.Data.LowLevel_Fields+ Proto.BtcLsp.Method.GetCfg+ Proto.BtcLsp.Method.GetCfg_Fields+ Proto.BtcLsp.Method.SwapFromLn+ Proto.BtcLsp.Method.SwapFromLn_Fields+ Proto.BtcLsp.Method.SwapIntoLn+ Proto.BtcLsp.Method.SwapIntoLn_Fields+ Proto.BtcLsp_Fields+ hs-source-dirs:+ src+ ghc-options: -Wno-unused-packages+ build-depends:+ GenericPretty+ , SHA+ , aeson >=1.4 && <1.6+ , async+ , base >=4.7 && <5+ , base16-bytestring+ , base64-bytestring >=1.2.1+ , binary+ , bytestring+ , case-insensitive+ , casing+ , chronos+ , classy-prelude-yesod ==1.5.*+ , containers+ , cryptonite+ , envparse+ , errors+ , esqueleto >=3.5.3+ , extra+ , fast-logger >=2.2 && <3.1+ , file-embed+ , format-numbers+ , generic-pretty-instances+ , hjsmin >=0.1 && <0.3+ , http-client-tls ==0.3.*+ , http2+ , http2-client+ , http2-client-grpc+ , http2-grpc-proto-lens+ , http2-grpc-types+ , iso8601-time+ , katip+ , lnd-client+ , memory+ , microlens+ , monad-logger ==0.3.*+ , network-bitcoin+ , persistent >=2.13.2.1+ , persistent-migration+ , persistent-postgresql >=2.13.2.1+ , pretty+ , proto-lens+ , proto-lens-runtime+ , qrcode-core+ , qrcode-juicypixels+ , resource-pool+ , scientific+ , secp256k1-haskell+ , shakespeare ==2.0.*+ , stm+ , template-haskell+ , text+ , time+ , transformers+ , unbounded-delays+ , universum+ , unliftio+ , uuid+ , vector+ , wai+ , wai-extra ==3.1.*+ , warp >=3.0 && <3.4+ , warp-grpc+ , warp-tls+ , witch+ , yaml ==0.11.*+ , yesod ==1.6.*+ , yesod-auth ==1.6.*+ , yesod-core ==1.6.*+ , yesod-form ==1.6.*+ , yesod-static ==1.6.*+ else+ build-depends:+ btc-lsp+ default-language: Haskell2010++executable btc-lsp-prof+ main-is: Main.hs+ other-modules:+ Paths_btc_lsp+ hs-source-dirs:+ app+ default-extensions:+ NoImplicitPrelude+ MultiParamTypeClasses+ LambdaCase+ OverloadedStrings+ ScopedTypeVariables+ DeriveGeneric+ GeneralizedNewtypeDeriving+ TupleSections+ DataKinds+ DerivingStrategies+ KindSignatures+ FlexibleContexts+ FlexibleInstances+ StrictData+ TypeFamilies+ TypeOperators+ StandaloneDeriving+ DerivingVia+ ExistentialQuantification+ InstanceSigs+ ghc-options: -Weverything -Wno-missing-exported-signatures -Wno-missing-import-lists -Wno-missed-specialisations -Wno-all-missed-specialisations -Wno-unsafe -Wno-safe -Wno-missing-local-signatures -Wno-missing-export-lists -O2 -optc-O3 -funfolding-use-threshold=16 -threaded -fprof-auto "-with-rtsopts=-N -s -p -h -xt" -fexternal-interpreter -optl-fuse-ld=gold+ ld-options: -fuse-ld=gold+ build-depends:+ base+ if impl(ghc >= 8.10.7)+ ghc-options: -Wno-missing-safe-haskell-mode -Wno-prepositive-qualified-module -fenable-th-splice-warnings -fprint-potential-instances+ if flag(ghcid)+ other-modules:+ BtcLsp.Class.Env+ BtcLsp.Class.Storage+ BtcLsp.Data.AppM+ BtcLsp.Data.Env+ BtcLsp.Data.Kind+ BtcLsp.Data.Orphan+ BtcLsp.Data.Smart+ BtcLsp.Data.Type+ BtcLsp.Grpc.Client.HighLevel+ BtcLsp.Grpc.Client.LowLevel+ BtcLsp.Grpc.Combinator+ BtcLsp.Grpc.Data+ BtcLsp.Grpc.Orphan+ BtcLsp.Grpc.Server.HighLevel+ BtcLsp.Grpc.Server.LowLevel+ BtcLsp.Grpc.Sig+ BtcLsp.Import+ BtcLsp.Import.External+ BtcLsp.Import.Psql+ BtcLsp.Import.Witch+ BtcLsp.Math.OnChain+ BtcLsp.Math.Swap+ BtcLsp.Psbt.PsbtOpener+ BtcLsp.Psbt.Utils+ BtcLsp.Storage.Migration+ BtcLsp.Storage.Model+ BtcLsp.Storage.Model.Block+ BtcLsp.Storage.Model.LnChan+ BtcLsp.Storage.Model.SwapIntoLn+ BtcLsp.Storage.Model.SwapUtxo+ BtcLsp.Storage.Model.User+ BtcLsp.Storage.Util+ BtcLsp.Text+ BtcLsp.Thread.BlockScanner+ BtcLsp.Thread.Expirer+ BtcLsp.Thread.LnChanOpener+ BtcLsp.Thread.LnChanWatcher+ BtcLsp.Thread.Main+ BtcLsp.Thread.Refunder+ BtcLsp.Thread.Server+ BtcLsp.Time+ BtcLsp.Yesod.Application+ BtcLsp.Yesod.Data.BootstrapColor+ BtcLsp.Yesod.Data.Colored+ BtcLsp.Yesod.Data.Language+ BtcLsp.Yesod.Data.Widget+ BtcLsp.Yesod.Foundation+ BtcLsp.Yesod.Handler.About+ BtcLsp.Yesod.Handler.Common+ BtcLsp.Yesod.Handler.Home+ BtcLsp.Yesod.Handler.Language+ BtcLsp.Yesod.Handler.OpenChan+ BtcLsp.Yesod.Handler.SwapIntoLnCreate+ BtcLsp.Yesod.Handler.SwapIntoLnSelect+ BtcLsp.Yesod.Handler.SwapUpdates+ BtcLsp.Yesod.Import+ BtcLsp.Yesod.Import.NoFoundation+ BtcLsp.Yesod.Settings+ BtcLsp.Yesod.Settings.StaticFiles+ BtcLsp.Yesod.TH+ Proto.BtcLsp+ Proto.BtcLsp.Data.HighLevel+ Proto.BtcLsp.Data.HighLevel_Fields+ Proto.BtcLsp.Data.LowLevel+ Proto.BtcLsp.Data.LowLevel_Fields+ Proto.BtcLsp.Method.GetCfg+ Proto.BtcLsp.Method.GetCfg_Fields+ Proto.BtcLsp.Method.SwapFromLn+ Proto.BtcLsp.Method.SwapFromLn_Fields+ Proto.BtcLsp.Method.SwapIntoLn+ Proto.BtcLsp.Method.SwapIntoLn_Fields+ Proto.BtcLsp_Fields+ hs-source-dirs:+ src+ ghc-options: -Wno-unused-packages+ build-depends:+ GenericPretty+ , SHA+ , aeson >=1.4 && <1.6+ , async+ , base >=4.7 && <5+ , base16-bytestring+ , base64-bytestring >=1.2.1+ , binary+ , bytestring+ , case-insensitive+ , casing+ , chronos+ , classy-prelude-yesod ==1.5.*+ , containers+ , cryptonite+ , envparse+ , errors+ , esqueleto >=3.5.3+ , extra+ , fast-logger >=2.2 && <3.1+ , file-embed+ , format-numbers+ , generic-pretty-instances+ , hjsmin >=0.1 && <0.3+ , http-client-tls ==0.3.*+ , http2+ , http2-client+ , http2-client-grpc+ , http2-grpc-proto-lens+ , http2-grpc-types+ , iso8601-time+ , katip+ , lnd-client+ , memory+ , microlens+ , monad-logger ==0.3.*+ , network-bitcoin+ , persistent >=2.13.2.1+ , persistent-migration+ , persistent-postgresql >=2.13.2.1+ , pretty+ , proto-lens+ , proto-lens-runtime+ , qrcode-core+ , qrcode-juicypixels+ , resource-pool+ , scientific+ , secp256k1-haskell+ , shakespeare ==2.0.*+ , stm+ , template-haskell+ , text+ , time+ , transformers+ , unbounded-delays+ , universum+ , unliftio+ , uuid+ , vector+ , wai+ , wai-extra ==3.1.*+ , warp >=3.0 && <3.4+ , warp-grpc+ , warp-tls+ , witch+ , yaml ==0.11.*+ , yesod ==1.6.*+ , yesod-auth ==1.6.*+ , yesod-core ==1.6.*+ , yesod-form ==1.6.*+ , yesod-static ==1.6.*+ else+ build-depends:+ btc-lsp+ default-language: Haskell2010++test-suite btc-lsp-test+ type: exitcode-stdio-1.0+ main-is: Main.hs+ other-modules:+ BakSpec+ BlockScannerSpec+ LnChanWatcherSpec+ MathSpec+ PsbtOpenerSpec+ RefunderSpec+ ReorgSpec+ ServerSpec+ SmartSpec+ Spec+ TestAppM+ TestHelpers+ TestOrphan+ TypeSpec+ Paths_btc_lsp+ hs-source-dirs:+ test+ default-extensions:+ NoImplicitPrelude+ MultiParamTypeClasses+ LambdaCase+ OverloadedStrings+ ScopedTypeVariables+ DeriveGeneric+ GeneralizedNewtypeDeriving+ TupleSections+ DataKinds+ DerivingStrategies+ KindSignatures+ FlexibleContexts+ FlexibleInstances+ StrictData+ TypeFamilies+ TypeOperators+ StandaloneDeriving+ DerivingVia+ ExistentialQuantification+ InstanceSigs+ ghc-options: -Weverything -Wno-missing-exported-signatures -Wno-missing-import-lists -Wno-missed-specialisations -Wno-all-missed-specialisations -Wno-unsafe -Wno-safe -Wno-missing-local-signatures -Wno-missing-export-lists -O2 -optc-O3 -funfolding-use-threshold=16 -threaded -rtsopts -with-rtsopts=-N -optl-fuse-ld=gold+ ld-options: -fuse-ld=gold+ build-depends:+ QuickCheck+ , aeson+ , base+ , bytestring+ , envparse+ , hspec+ , lnd-client+ , network-bitcoin+ , proto-lens+ , unliftio+ , vector+ , witch+ if impl(ghc >= 8.10.7)+ ghc-options: -Wno-missing-safe-haskell-mode -Wno-prepositive-qualified-module -fenable-th-splice-warnings -fprint-potential-instances+ if flag(ghcid)+ other-modules:+ BtcLsp.Class.Env+ BtcLsp.Class.Storage+ BtcLsp.Data.AppM+ BtcLsp.Data.Env+ BtcLsp.Data.Kind+ BtcLsp.Data.Orphan+ BtcLsp.Data.Smart+ BtcLsp.Data.Type+ BtcLsp.Grpc.Client.HighLevel+ BtcLsp.Grpc.Client.LowLevel+ BtcLsp.Grpc.Combinator+ BtcLsp.Grpc.Data+ BtcLsp.Grpc.Orphan+ BtcLsp.Grpc.Server.HighLevel+ BtcLsp.Grpc.Server.LowLevel+ BtcLsp.Grpc.Sig+ BtcLsp.Import+ BtcLsp.Import.External+ BtcLsp.Import.Psql+ BtcLsp.Import.Witch+ BtcLsp.Math.OnChain+ BtcLsp.Math.Swap+ BtcLsp.Psbt.PsbtOpener+ BtcLsp.Psbt.Utils+ BtcLsp.Storage.Migration+ BtcLsp.Storage.Model+ BtcLsp.Storage.Model.Block+ BtcLsp.Storage.Model.LnChan+ BtcLsp.Storage.Model.SwapIntoLn+ BtcLsp.Storage.Model.SwapUtxo+ BtcLsp.Storage.Model.User+ BtcLsp.Storage.Util+ BtcLsp.Text+ BtcLsp.Thread.BlockScanner+ BtcLsp.Thread.Expirer+ BtcLsp.Thread.LnChanOpener+ BtcLsp.Thread.LnChanWatcher+ BtcLsp.Thread.Main+ BtcLsp.Thread.Refunder+ BtcLsp.Thread.Server+ BtcLsp.Time+ BtcLsp.Yesod.Application+ BtcLsp.Yesod.Data.BootstrapColor+ BtcLsp.Yesod.Data.Colored+ BtcLsp.Yesod.Data.Language+ BtcLsp.Yesod.Data.Widget+ BtcLsp.Yesod.Foundation+ BtcLsp.Yesod.Handler.About+ BtcLsp.Yesod.Handler.Common+ BtcLsp.Yesod.Handler.Home+ BtcLsp.Yesod.Handler.Language+ BtcLsp.Yesod.Handler.OpenChan+ BtcLsp.Yesod.Handler.SwapIntoLnCreate+ BtcLsp.Yesod.Handler.SwapIntoLnSelect+ BtcLsp.Yesod.Handler.SwapUpdates+ BtcLsp.Yesod.Import+ BtcLsp.Yesod.Import.NoFoundation+ BtcLsp.Yesod.Settings+ BtcLsp.Yesod.Settings.StaticFiles+ BtcLsp.Yesod.TH+ Proto.BtcLsp+ Proto.BtcLsp.Data.HighLevel+ Proto.BtcLsp.Data.HighLevel_Fields+ Proto.BtcLsp.Data.LowLevel+ Proto.BtcLsp.Data.LowLevel_Fields+ Proto.BtcLsp.Method.GetCfg+ Proto.BtcLsp.Method.GetCfg_Fields+ Proto.BtcLsp.Method.SwapFromLn+ Proto.BtcLsp.Method.SwapFromLn_Fields+ Proto.BtcLsp.Method.SwapIntoLn+ Proto.BtcLsp.Method.SwapIntoLn_Fields+ Proto.BtcLsp_Fields+ hs-source-dirs:+ src+ ghc-options: -Wno-unused-packages+ build-depends:+ GenericPretty+ , SHA+ , aeson >=1.4 && <1.6+ , async+ , base >=4.7 && <5+ , base16-bytestring+ , base64-bytestring >=1.2.1+ , binary+ , bytestring+ , case-insensitive+ , casing+ , chronos+ , classy-prelude-yesod ==1.5.*+ , containers+ , cryptonite+ , envparse+ , errors+ , esqueleto >=3.5.3+ , extra+ , fast-logger >=2.2 && <3.1+ , file-embed+ , format-numbers+ , generic-pretty-instances+ , hjsmin >=0.1 && <0.3+ , http-client-tls ==0.3.*+ , http2+ , http2-client+ , http2-client-grpc+ , http2-grpc-proto-lens+ , http2-grpc-types+ , iso8601-time+ , katip+ , lnd-client+ , memory+ , microlens+ , monad-logger ==0.3.*+ , network-bitcoin+ , persistent >=2.13.2.1+ , persistent-migration+ , persistent-postgresql >=2.13.2.1+ , pretty+ , proto-lens+ , proto-lens-runtime+ , qrcode-core+ , qrcode-juicypixels+ , resource-pool+ , scientific+ , secp256k1-haskell+ , shakespeare ==2.0.*+ , stm+ , template-haskell+ , text+ , time+ , transformers+ , unbounded-delays+ , universum+ , unliftio+ , uuid+ , vector+ , wai+ , wai-extra ==3.1.*+ , warp >=3.0 && <3.4+ , warp-grpc+ , warp-tls+ , witch+ , yaml ==0.11.*+ , yesod ==1.6.*+ , yesod-auth ==1.6.*+ , yesod-core ==1.6.*+ , yesod-form ==1.6.*+ , yesod-static ==1.6.*+ else+ build-depends:+ btc-lsp+ default-language: Haskell2010
@@ -0,0 +1,19 @@+module Integration+ ( main,+ )+where++import BtcLsp.Import+import IntegrationSpec+import Test.Hspec.Formatters+import Test.Hspec.Runner+import TestAppM (mainTestSetup)++main :: IO ()+main = do+ mainTestSetup+ hspecWith+ defaultConfig+ { configFormatter = Just progress+ }+ spec
@@ -0,0 +1,104 @@+{-# LANGUAGE TypeApplications #-}++module IntegrationSpec+ ( spec,+ )+where++import qualified BtcLsp.Grpc.Client.HighLevel as Client+import BtcLsp.Grpc.Client.LowLevel+import BtcLsp.Grpc.Orphan ()+import BtcLsp.Import hiding (setGrpcCtx, setGrpcCtxT)+import qualified BtcLsp.Thread.Main as Main+import qualified LndClient.Data.ListChannels as ListChannels+import qualified LndClient.Data.NewAddress as Lnd+import qualified LndClient.Data.SendCoins as Lnd+import LndClient.LndTest (mine)+import qualified LndClient.LndTest as LndTest+import qualified LndClient.RPC.Silent as Lnd+import qualified Proto.BtcLsp.Data.LowLevel_Fields as SwapIntoLn+import qualified Proto.BtcLsp.Method.SwapIntoLn_Fields as SwapIntoLn+import Test.Hspec+import TestAppM+import TestOrphan ()++spec :: Spec+spec = do+ itEnv @'LndLsp "Server SwapIntoLn" $ do+ -- Let app spawn+ Main.waitForSync+ sleep300ms+ gcEnv <- getGCEnv+ res0 <- runExceptT $ do+ refundAddr <-+ from+ <$> withLndTestT+ LndAlice+ Lnd.newAddress+ ( $+ Lnd.NewAddressRequest+ { Lnd.addrType = Lnd.WITNESS_PUBKEY_HASH,+ Lnd.account = Nothing+ }+ )+ Client.swapIntoLnT+ gcEnv+ { gcEnvCompressMode = Compressed+ }+ =<< setGrpcCtxT+ LndAlice+ ( defMessage+ & SwapIntoLn.refundOnChainAddress+ .~ from @(OnChainAddress 'Refund) refundAddr+ )+ liftIO $+ res0+ `shouldSatisfy` ( \case+ Left {} ->+ False+ Right msg ->+ isJust $+ msg ^. SwapIntoLn.maybe'success+ )++ res1 <- runExceptT $ do+ resp <- except res0+ let fundAddr =+ resp+ ^. ( SwapIntoLn.success+ . SwapIntoLn.fundOnChainAddress+ . SwapIntoLn.val+ . SwapIntoLn.val+ )+ void $+ withLndTestT+ LndAlice+ Lnd.sendCoins+ ( \h ->+ h (Lnd.SendCoinsRequest fundAddr (MSat 200000000))+ )+ lift $+ LndTest.lazyConnectNodes (Proxy :: Proxy TestOwner)+ lift $ mine 10 LndLsp+ sleep10s+ lift Main.waitForSync+ lift $ mine 10 LndLsp+ sleep10s+ alicePub <- getPubKeyT LndAlice+ withLndT+ Lnd.listChannels+ ( $+ ListChannels.ListChannelsRequest+ { ListChannels.activeOnly = True,+ ListChannels.inactiveOnly = False,+ ListChannels.publicOnly = False,+ ListChannels.privateOnly = False,+ ListChannels.peer = Just alicePub+ }+ )+ liftIO $+ res1+ `shouldSatisfy` ( \case+ Right [_] -> True+ _ -> False+ )
@@ -0,0 +1,119 @@+{-# LANGUAGE TypeApplications #-}++module BtcLsp.Class.Env+ ( Env (..),+ )+where++import BtcLsp.Class.Storage+import BtcLsp.Data.Kind+import BtcLsp.Data.Type+import BtcLsp.Grpc.Combinator+import BtcLsp.Grpc.Orphan ()+import BtcLsp.Grpc.Server.LowLevel+import BtcLsp.Import.External+import Data.ProtoLens.Field+import qualified LndClient as Lnd+import qualified LndClient.Data.GetInfo as Lnd+import qualified LndClient.Data.WalletBalance as Lnd+import qualified LndClient.RPC.Katip as Lnd+import qualified Network.Bitcoin as Btc+import qualified Proto.BtcLsp.Data.HighLevel as Proto+import qualified Proto.BtcLsp.Data.HighLevel_Fields as Proto++class+ ( MonadUnliftIO m,+ KatipContext m,+ Storage m+ ) =>+ Env m+ where+ getGsEnv :: m GSEnv+ getSwapIntoLnMinAmt :: m (Money 'Usr 'OnChain 'Fund)+ getMsatPerByte :: m (Maybe MSat)+ getLspPubKeyVar :: m (MVar Lnd.NodePubKey)+ getLndP2PSocketAddress :: m SocketAddress+ getLndNodeUri :: m NodeUri+ getLspPubKey :: m Lnd.NodePubKey+ getLspLndEnv :: m Lnd.LndEnv+ getYesodLog :: m YesodLog+ getLndNodeUri =+ NodeUri <$> getLspPubKey <*> getLndP2PSocketAddress+ getLspPubKey = do+ var <- getLspPubKeyVar+ mPubKey <- tryReadMVar var+ case mPubKey of+ Just pubKey ->+ pure pubKey+ Nothing -> do+ eRes <- withLnd Lnd.getInfo id+ case eRes of+ Left e ->+ --+ -- NOTE : there is fatal failure here,+ -- because lnd-lsp is meaningless without+ -- operational lnd.+ --+ error $+ "Fatal Lnd failure, can not get NodePubKey: "+ <> inspectPlain e+ Right res -> do+ let pubKey = Lnd.identityPubkey res+ void $ tryPutMVar var pubKey+ pure pubKey+ setGrpcCtx ::+ ( HasField msg "ctx" Proto.Ctx+ ) =>+ msg ->+ m msg+ setGrpcCtx message = do+ nonce <- newNonce+ pubKey <- getLspPubKey+ pure $+ message+ & field @"ctx"+ .~ ( defMessage+ & Proto.nonce+ .~ from @Nonce @Proto.Nonce nonce+ & Proto.lnPubKey+ .~ from @Lnd.NodePubKey @Proto.LnPubKey pubKey+ )+ setGrpcCtxT ::+ ( HasField msg "ctx" Proto.Ctx+ ) =>+ msg ->+ ExceptT Failure m msg+ setGrpcCtxT =+ lift . setGrpcCtx+ withLnd ::+ (Lnd.LndEnv -> a) ->+ (a -> m (Either Lnd.LndError b)) ->+ m (Either Failure b)+ withLndT ::+ (Lnd.LndEnv -> a) ->+ (a -> m (Either Lnd.LndError b)) ->+ ExceptT Failure m b+ withLndT method =+ ExceptT . withLnd method+ withLndServerT ::+ ( GrpcRes res failure specific+ ) =>+ (Lnd.LndEnv -> a) ->+ (a -> m (Either Lnd.LndError b)) ->+ ExceptT res m b+ withLndServerT method =+ withExceptT (const $ newInternalFailure FailureRedacted)+ . withLndT method+ withBtc ::+ (Btc.Client -> a) ->+ (a -> IO b) ->+ m (Either Failure b)+ withBtcT ::+ (Btc.Client -> a) ->+ (a -> IO b) ->+ ExceptT Failure m b+ withBtcT method =+ ExceptT . withBtc method+ monitorTotalExtOutgoingLiquidity :: Liquidity 'Outgoing -> m ()+ monitorTotalExtIncomingLiquidity :: Liquidity 'Incoming -> m ()+ monitorTotalOnChainLiquidity :: Lnd.WalletBalance -> m ()
@@ -0,0 +1,16 @@+module BtcLsp.Class.Storage+ ( Storage (..),+ HasTable (..),+ )+where++import BtcLsp.Data.Kind+import BtcLsp.Import.External+import qualified BtcLsp.Import.Psql as Psql++class MonadUnliftIO m => Storage m where+ runSql :: ReaderT Psql.SqlBackend m a -> m a+ getSqlPool :: m (Pool Psql.SqlBackend)++class HasTable a where+ getTable :: Psql.Key a -> Table
@@ -0,0 +1,109 @@+{-# LANGUAGE DeriveFunctor #-}+{-# LANGUAGE TemplateHaskell #-}++module BtcLsp.Data.AppM+ ( runApp,+ AppM (..),+ )+where++import BtcLsp.Data.Env as Env (Env (..))+import BtcLsp.Import as I+import qualified BtcLsp.Import.Psql as Psql+import qualified LndClient.Data.WalletBalance as Lnd+import qualified UnliftIO.Exception as UnIO++newtype AppM m a = AppM+ { unAppM :: ReaderT Env.Env m a+ }+ deriving stock (Functor)+ deriving newtype+ ( Applicative,+ Monad,+ MonadIO,+ MonadReader Env.Env,+ MonadUnliftIO+ )++runApp :: Env.Env -> AppM m a -> m a+runApp env app = runReaderT (unAppM app) env++instance (MonadIO m) => Katip (AppM m) where+ getLogEnv = asks envKatipLE+ localLogEnv f (AppM m) =+ AppM (local (\s -> s {envKatipLE = f (envKatipLE s)}) m)++instance (MonadIO m) => KatipContext (AppM m) where+ getKatipContext = asks envKatipCTX+ localKatipContext f (AppM m) =+ AppM (local (\s -> s {envKatipCTX = f (envKatipCTX s)}) m)+ getKatipNamespace = asks envKatipNS+ localKatipNamespace f (AppM m) =+ AppM (local (\s -> s {envKatipNS = f (envKatipNS s)}) m)++instance (MonadUnliftIO m) => I.Env (AppM m) where+ getGsEnv =+ asks Env.envGrpcServer+ getSwapIntoLnMinAmt =+ asks Env.envSwapIntoLnMinAmt+ getMsatPerByte =+ asks Env.envMsatPerByte+ getLspPubKeyVar =+ asks Env.envLndPubKey+ getLspLndEnv =+ asks Env.envLnd+ getYesodLog =+ asks Env.envYesodLog+ getLndP2PSocketAddress = do+ host <- asks Env.envLndP2PHost+ port <- asks Env.envLndP2PPort+ pure+ SocketAddress+ { socketAddressHost = host,+ socketAddressPort = port+ }+ withLnd method args = do+ lnd <- asks Env.envLnd+ first (const $ FailureInt FailureRedacted) <$> args (method lnd)+ withBtc method args = do+ env <- asks Env.envBtc+ liftIO $ first exHandler <$> UnIO.tryAny (args $ method env)+ where+ exHandler :: (Exception e) => e -> Failure+ exHandler =+ FailureInt . FailurePrivate . pack . displayException+ monitorTotalExtOutgoingLiquidity amt = do+ lim <- asks Env.envMinTotalExtOutgoingLiquidity+ when (amt < lim) $+ $(logTM) CriticalS . logStr $+ "Not enough outgoing liquidity to the external "+ <> "lightning network, got "+ <> inspect amt+ <> " but minimum is "+ <> inspect lim+ <> "."+ monitorTotalExtIncomingLiquidity amt = do+ lim <- asks Env.envMinTotalExtIncomingLiquidity+ when (amt < lim) $+ $(logTM) CriticalS . logStr $+ "Not enough incoming liquidity from the external "+ <> "lightning network, got "+ <> inspect amt+ <> " but minimum is "+ <> inspect lim+ <> "."+ monitorTotalOnChainLiquidity wal = do+ lim <- asks Env.envMinTotalOnChainLiquidity+ when (Lnd.totalBalance wal < lim) $+ $(logTM) CriticalS . logStr $+ "Not enough onchain liquidity, got "+ <> inspect wal+ <> " but minimum is "+ <> inspect lim+ <> "."++instance (MonadUnliftIO m) => Storage (AppM m) where+ getSqlPool = asks envSQLPool+ runSql query = do+ pool <- asks envSQLPool+ Psql.runSqlPool query pool
@@ -0,0 +1,276 @@+{-# LANGUAGE TemplateHaskell #-}++module BtcLsp.Data.Env+ ( Env (..),+ RawConfig (..),+ BitcoindEnv (..),+ readRawConfig,+ readGCEnv,+ withEnv,+ parseFromJSON,+ )+where++import BtcLsp.Data.Kind+import BtcLsp.Data.Type+import BtcLsp.Grpc.Client.LowLevel+import BtcLsp.Grpc.Server.LowLevel+import qualified BtcLsp.Grpc.Sig as Sig+import BtcLsp.Import.External+import qualified BtcLsp.Import.Psql as Psql+import qualified BtcLsp.Math.Swap as Math+import Control.Monad.Logger (runNoLoggingT)+import Data.Aeson (withObject, (.:))+import qualified Data.Aeson as A (decode)+import qualified Data.ByteString as BS+import Data.ByteString.Lazy.Char8 as C8L (pack)+import qualified Env as E+ ( Error (..),+ Mod,+ Var,+ auto,+ def,+ header,+ help,+ keep,+ nonempty,+ parse,+ str,+ var,+ )+import qualified LndClient as Lnd+import qualified LndClient.Data.SignMessage as Lnd+import qualified LndClient.RPC.Katip as Lnd+import qualified Network.Bitcoin as Btc++data Env = Env+ { -- | General+ envSQLPool :: Pool Psql.SqlBackend,+ envMinTotalExtOutgoingLiquidity :: Liquidity 'Outgoing,+ envMinTotalExtIncomingLiquidity :: Liquidity 'Incoming,+ envMinTotalOnChainLiquidity :: MSat,+ -- | Logging+ envKatipNS :: Namespace,+ envKatipCTX :: LogContexts,+ envKatipLE :: LogEnv,+ envYesodLog :: YesodLog,+ -- | Lnd+ envLnd :: Lnd.LndEnv,+ envLndP2PHost :: HostName,+ envLndP2PPort :: PortNumber,+ envSwapIntoLnMinAmt :: Money 'Usr 'OnChain 'Fund,+ envMsatPerByte :: Maybe MSat,+ envLndPubKey :: MVar Lnd.NodePubKey,+ -- | Grpc+ envGrpcServer :: GSEnv,+ -- | Bitcoind+ envBtc :: Btc.Client+ }++data RawConfig = RawConfig+ { -- | General+ rawConfigLibpqConnStr :: Psql.ConnectionString,+ rawConfigMinTotalExtOutgoingLiquidity :: Liquidity 'Outgoing,+ rawConfigMinTotalExtIncomingLiquidity :: Liquidity 'Incoming,+ rawConfigMinTotalOnChainLiquidity :: MSat,+ -- | Logging+ rawConfigLogEnv :: Text,+ rawConfigLogFormat :: LogFormat,+ rawConfigLogVerbosity :: Verbosity,+ rawConfigLogSeverity :: Severity,+ rawConfigLogSecrets :: SecretVision,+ rawConfigLogYesod :: YesodLog,+ -- | Lnd+ rawConfigLndEnv :: Lnd.LndEnv,+ rawConfigLndP2PHost :: HostName,+ rawConfigLndP2PPort :: PortNumber,+ rawConfigMinChanCap :: Money 'Chan 'Ln 'Fund,+ rawConfigMsatPerByte :: Maybe MSat,+ -- | Grpc+ rawConfigGrpcServerEnv :: GSEnv,+ -- | Bitcoind+ rawConfigBtcEnv :: BitcoindEnv+ }++data BitcoindEnv = BitcoindEnv+ { bitcoindEnvHost :: Text,+ bitcoindEnvUsername :: Text,+ bitcoindEnvPassword :: Text+ }+ deriving stock (Generic)++instance FromJSON BitcoindEnv where+ parseJSON =+ withObject+ "BitcoindEnv"+ ( \x ->+ BitcoindEnv+ <$> x .: "host"+ <*> x .: "username"+ <*> x .: "password"+ )++parseFromJSON :: (FromJSON a) => String -> Either E.Error a+parseFromJSON =+ maybe+ (Left $ E.UnreadError "parseFromJSON failed")+ Right+ . A.decode+ . C8L.pack++readRawConfig :: IO RawConfig+readRawConfig =+ E.parse (E.header "BtcLsp") $+ RawConfig+ -- General+ <$> E.var (E.str <=< E.nonempty) "LSP_LIBPQ_CONN_STR" opts+ <*> E.var (E.auto <=< E.nonempty) "LSP_MIN_TOTAL_EXT_OUTGOING_LIQUIDITY_MSAT" (opts <> E.def 0)+ <*> E.var (E.auto <=< E.nonempty) "LSP_MIN_TOTAL_EXT_INCOMING_LIQUIDITY_MSAT" (opts <> E.def 0)+ <*> E.var (E.auto <=< E.nonempty) "LSP_MIN_TOTAL_ON_CHAIN_LIQUIDITY_MSAT" (opts <> E.def 0)+ -- Logging+ <*> E.var (E.str <=< E.nonempty) "LSP_LOG_ENV" opts+ <*> E.var (E.auto <=< E.nonempty) "LSP_LOG_FORMAT" opts+ <*> E.var (E.auto <=< E.nonempty) "LSP_LOG_VERBOSITY" opts+ <*> E.var (E.auto <=< E.nonempty) "LSP_LOG_SEVERITY" opts+ <*> E.var (E.auto <=< E.nonempty) "LSP_LOG_SECRET" (opts <> E.def SecretHidden)+ <*> E.var (E.auto <=< E.nonempty) "LSP_LOG_YESOD" (opts <> E.def YesodLogNoMain)+ -- Lnd+ <*> E.var (parseFromJSON <=< E.nonempty) "LSP_LND_ENV" opts+ <*> E.var (E.str <=< E.nonempty) "LSP_LND_P2P_HOST" opts+ <*> E.var (E.auto <=< E.nonempty) "LSP_LND_P2P_PORT" opts+ <*> E.var (E.auto <=< E.nonempty) "LSP_MIN_CHAN_CAP_MSAT" opts+ <*> optional (E.var (E.auto <=< E.nonempty) "LSP_MSAT_PER_BYTE" opts)+ -- Grpc+ <*> E.var (parseFromJSON <=< E.nonempty) "LSP_GRPC_SERVER_ENV" opts+ -- Bitcoind+ <*> E.var (parseFromJSON <=< E.nonempty) "LSP_BITCOIND_ENV" opts++readGCEnv :: IO GCEnv+readGCEnv =+ E.parse (E.header "GCEnv") $+ E.var (parseFromJSON <=< E.nonempty) "LSP_GRPC_CLIENT_ENV" opts++opts :: E.Mod E.Var a+opts =+ E.keep <> E.help ""++withEnv ::+ forall m a.+ ( MonadUnliftIO m+ ) =>+ RawConfig ->+ (Env -> KatipContextT m a) ->+ m a+withEnv rc this = do+ pubKeyVar <- newEmptyMVar+ handleScribe <-+ liftIO $+ mkHandleScribeWithFormatter+ ( case rawConfigLogFormat rc of+ Bracket -> bracketFormat+ JSON -> jsonFormat+ )+ ColorIfTerminal+ stdout+ (permitItem $ rawConfigLogSeverity rc)+ (rawConfigLogVerbosity rc)+ let newLogEnv =+ liftIO $+ registerScribe+ "stdout"+ handleScribe+ defaultScribeSettings+ =<< initLogEnv+ "BtcLsp"+ ( Environment $ rawConfigLogEnv rc+ )+ let newSqlPool :: m (Pool Psql.SqlBackend) =+ liftIO . runNoLoggingT $+ Psql.createPostgresqlPool (rawConfigLibpqConnStr rc) 10+ let katipCtx = mempty :: LogContexts+ let katipNs = mempty :: Namespace+ let lnd = rawConfigLndEnv rc+ bracket newLogEnv rmLogEnv $ \le ->+ bracket newSqlPool rmSqlPool $ \pool -> do+ let rBtc = rawConfigBtcEnv rc+ btc <-+ liftIO $+ Btc.getClient+ (from $ bitcoindEnvHost rBtc)+ (from $ bitcoindEnvUsername rBtc)+ (from $ bitcoindEnvPassword rBtc)+ runKatipContextT le katipCtx katipNs+ . withUnliftIO+ $ \(UnliftIO run) ->+ run . this $+ Env+ { -- General+ envSQLPool = pool,+ envMinTotalExtOutgoingLiquidity =+ rawConfigMinTotalExtOutgoingLiquidity rc,+ envMinTotalExtIncomingLiquidity =+ rawConfigMinTotalExtIncomingLiquidity rc,+ envMinTotalOnChainLiquidity =+ rawConfigMinTotalOnChainLiquidity rc,+ -- Logging+ envKatipLE = le,+ envKatipCTX = katipCtx,+ envKatipNS = katipNs,+ envYesodLog = rawConfigLogYesod rc,+ -- Lnd+ envLnd = lnd,+ envLndP2PHost = rawConfigLndP2PHost rc,+ envLndP2PPort = rawConfigLndP2PPort rc,+ envSwapIntoLnMinAmt =+ Math.newSwapIntoLnMinAmt $+ rawConfigMinChanCap rc,+ envMsatPerByte = rawConfigMsatPerByte rc,+ envLndPubKey = pubKeyVar,+ -- Grpc+ envGrpcServer =+ (rawConfigGrpcServerEnv rc)+ { gsEnvSigner = run . signT lnd,+ gsEnvLogger = run . $(logTM) DebugS . logStr+ },+ envBtc = btc+ }+ where+ rmLogEnv :: LogEnv -> m ()+ rmLogEnv = void . liftIO . closeScribes+ rmSqlPool :: Pool Psql.SqlBackend -> m ()+ rmSqlPool = liftIO . destroyAllResources+ signT ::+ Lnd.LndEnv ->+ Sig.MsgToSign ->+ KatipContextT m (Maybe Sig.LndSig)+ signT lnd msg = do+ eSig <-+ Lnd.signMessage lnd $+ Lnd.SignMessageRequest+ { Lnd.message = Sig.unMsgToSign msg,+ Lnd.keyLoc =+ Lnd.KeyLocator+ { Lnd.keyFamily = 6,+ Lnd.keyIndex = 0+ },+ Lnd.doubleHash = False,+ Lnd.compactSig = False+ }+ case eSig of+ Left e -> do+ $(logTM) ErrorS . logStr $+ "Server ==> signing procedure failed "+ <> inspect e+ pure Nothing+ Right sig0 -> do+ let sig = coerce sig0+ $(logTM) DebugS . logStr $+ "Server ==> signing procedure succeeded for msg of "+ <> inspect (BS.length $ Sig.unMsgToSign msg)+ <> " bytes "+ <> inspect msg+ <> " got signature of "+ <> inspect (BS.length sig)+ <> " bytes "+ <> inspect sig+ pure . Just $ Sig.LndSig sig
@@ -0,0 +1,68 @@+module BtcLsp.Data.Kind+ ( Direction (..),+ MoneyRelation (..),+ BitcoinLayer (..),+ Owner (..),+ Table (..),+ )+where++import BtcLsp.Import.External++data Direction+ = Outgoing+ | Incoming+ deriving stock+ ( Eq,+ Ord,+ Show,+ Generic+ )++data MoneyRelation+ = Fund+ | Refund+ | Gain+ | Loss+ deriving stock+ ( Eq,+ Ord,+ Show,+ Generic+ )++data BitcoinLayer+ = OnChain+ | Ln+ deriving stock+ ( Eq,+ Ord,+ Show,+ Generic+ )++data Owner+ = Lsp+ | Usr+ | Chan+ deriving stock+ ( Eq,+ Ord,+ Show,+ Generic+ )++data Table+ = UserTable+ | SwapIntoLnTable+ | SwapUtxoTable+ | BlockTable+ | LnChanTable+ deriving stock+ ( Eq,+ Ord,+ Show,+ Generic,+ Enum,+ Bounded+ )
@@ -0,0 +1,136 @@+{-# LANGUAGE TypeApplications #-}+{-# OPTIONS_GHC -Wno-orphans #-}++module BtcLsp.Data.Orphan () where++import BtcLsp.Import.External+import qualified BtcLsp.Import.Psql as Psql+import qualified BtcLsp.Text as T+import qualified Data.Time.ISO8601 as Time+import qualified LndClient as Lnd+import qualified Network.Bitcoin.BlockChain as Btc+import qualified Network.Bitcoin.RawTransaction as Btc+import qualified Network.Bitcoin.Types as Btc+import qualified Text.PrettyPrint as PP+import qualified Universum+import qualified Witch++deriving stock instance Generic Btc.TxnOutputType++deriving stock instance Generic Btc.ScriptSig++deriving stock instance Generic Btc.ScriptPubKey++deriving stock instance Generic Btc.TxIn++deriving stock instance Generic Btc.TxOut++deriving stock instance Generic Btc.BlockVerbose++deriving stock instance Generic Btc.DecodedRawTransaction++deriving stock instance Generic Btc.BlockChainInfo++deriving stock instance Generic Btc.TransactionID++instance Out Btc.TransactionID++instance Out Btc.TxnOutputType++instance Out Btc.ScriptSig++instance Out Btc.ScriptPubKey++instance Out Btc.TxIn++instance Out Btc.TxOut++instance Out Btc.BlockVerbose++instance Out Btc.DecodedRawTransaction++instance Out Btc.BlockChainInfo++instance From Text Lnd.PaymentRequest++instance From Lnd.PaymentRequest Text++instance From Word64 MSat++instance From MSat Word64++instance From Word64 Lnd.Seconds++instance From Lnd.Seconds Word64++deriving stock instance Generic Btc.Block++deriving newtype instance PathPiece Lnd.PaymentRequest++instance Out Btc.Block++instance Out Natural where+ docPrec x =+ docPrec x . into @Integer+ doc =+ docPrec 0++instance Out PortNumber where+ docPrec x =+ docPrec x . toInteger+ doc =+ docPrec 0++instance+ (Psql.ToBackendKey Psql.SqlBackend a) =>+ TryFrom (Psql.Key a) Natural+ where+ tryFrom =+ tryFrom `composeTryLhs` Psql.fromSqlKey++instance+ (Psql.ToBackendKey Psql.SqlBackend a) =>+ TryFrom Natural (Psql.Key a)+ where+ tryFrom =+ Psql.toSqlKey `composeTryRhs` tryFrom++instance Out SomeException where+ docPrec _ =+ PP.text . Universum.show+ doc =+ docPrec 0++instance From Word32 (Vout 'Funding)++instance From ByteString (TxId 'Funding)++instance TryFrom Integer (Vout 'Funding) where+ tryFrom =+ from @Word32+ `composeTryRhs` tryFrom++instance PathPiece UTCTime where+ fromPathPiece :: Text -> Maybe UTCTime+ fromPathPiece =+ Time.parseISO8601+ . unpack+ toPathPiece :: UTCTime -> Text+ toPathPiece =+ pack+ . Time.formatISO8601++instance ToMessage MSat where+ toMessage =+ T.displayRational 1+ . (/ 1000)+ . via @Integer+ . into @Word64++instance Out (Ratio Natural) where+ docPrec x =+ docPrec x . into @Rational+ doc =+ docPrec 0++instance Out (Psql.BackendKey Psql.SqlBackend)
@@ -0,0 +1,99 @@+{-# LANGUAGE TemplateHaskell #-}++module BtcLsp.Data.Smart+ ( OnChainAddress,+ unsafeNewOnChainAddress,+ unOnChainAddress,+ newOnChainAddress,+ newOnChainAddressT,+ )+where++import BtcLsp.Class.Env+import BtcLsp.Data.Kind+import BtcLsp.Data.Type+import BtcLsp.Grpc.Orphan+import BtcLsp.Import.External+import qualified BtcLsp.Import.Psql as Psql+import qualified Data.Text as T+import qualified LndClient.Data.NewAddress as Lnd+import qualified Network.Bitcoin.Wallet as Btc+import qualified Proto.BtcLsp.Data.HighLevel as Proto+import qualified Proto.BtcLsp.Data.LowLevel as Proto+import qualified Witch++newtype OnChainAddress (mrel :: MoneyRelation) = OnChainAddress+ { unOnChainAddress0 :: Text+ }+ deriving newtype+ ( Eq,+ Ord,+ Show,+ Read,+ PathPiece,+ Psql.PersistField,+ Psql.PersistFieldSql+ )+ deriving stock+ ( Generic+ )++instance Out (OnChainAddress mrel)++instance From (OnChainAddress mrel) Text++instance From Lnd.NewAddressResponse (OnChainAddress 'Fund)++instance From Lnd.NewAddressResponse (OnChainAddress 'Gain)++instance From (OnChainAddress mrel) Proto.OnChainAddress where+ from = intoProto++instance From (OnChainAddress 'Refund) Proto.RefundOnChainAddress where+ from = intoProto++instance From (OnChainAddress 'Fund) Proto.FundOnChainAddress where+ from = intoProto++unsafeNewOnChainAddress :: Text -> OnChainAddress mrel+unsafeNewOnChainAddress = OnChainAddress++unOnChainAddress :: OnChainAddress mrel -> Text+unOnChainAddress = unOnChainAddress0++newOnChainAddress ::+ ( Env m+ ) =>+ UnsafeOnChainAddress mrel ->+ m (Either Failure (OnChainAddress mrel))+newOnChainAddress unsafeAddr = do+ eRes <- withBtc Btc.getAddrInfo ($ txtAddr)+ case eRes of+ Left e@(FailureInt (FailurePrivate txt)) ->+ if ("Not a valid Bech32 or Base58 encoding" `T.isInfixOf` txt)+ || ("Invalid checksum" `T.isInfixOf` txt)+ then pure . Left $ FailureInp FailureNonValidAddr+ else do+ $(logTM) WarningS . logStr $+ "newOnChainAddress unexpected private failure " <> inspect e+ pure $ Left e+ Left e -> do+ $(logTM) WarningS . logStr $+ "newOnChainAddress unexpected failure " <> inspect e+ pure $+ Left e+ Right res ->+ pure $+ if Btc.isWitness res+ then Right $ OnChainAddress txtAddr+ else Left $ FailureInp FailureNonSegwitAddr+ where+ txtAddr = from unsafeAddr++newOnChainAddressT ::+ ( Env m+ ) =>+ UnsafeOnChainAddress mrel ->+ ExceptT Failure m (OnChainAddress mrel)+newOnChainAddressT =+ ExceptT . newOnChainAddress
@@ -0,0 +1,879 @@+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TypeApplications #-}++module BtcLsp.Data.Type+ ( Nonce,+ newNonce,+ LnInvoice (..),+ LnInvoiceStatus (..),+ LnChanStatus (..),+ Liquidity (..),+ Money (..),+ FeeRate (..),+ UnsafeOnChainAddress (..),+ Seconds (..),+ LogFormat (..),+ YesodLog (..),+ MicroSeconds (..),+ SwapStatus (..),+ swapStatusChain,+ swapStatusLn,+ swapStatusFinal,+ Failure (..),+ FailureInternal (..),+ FailureInput (..),+ tryFailureE,+ tryFailureT,+ tryFromE,+ tryFromT,+ SocketAddress (..),+ BlkHash (..),+ BlkHeight (..),+ BlkStatus (..),+ SwapUtxoStatus (..),+ Privacy (..),+ NodePubKeyHex (..),+ NodeUri (..),+ NodeUriHex (..),+ UtxoLockId (..),+ RHashHex (..),+ Uuid,+ unUuid,+ newUuid,+ Vbyte (..),+ RowQty (..),+ PsbtUtxo (..),+ SwapHash (..),+ )+where++import BtcLsp.Data.Kind+import BtcLsp.Data.Orphan ()+import BtcLsp.Import.External+import qualified BtcLsp.Import.Psql as Psql+import qualified BtcLsp.Text as T+import qualified Data.ByteString.Base16 as B16+import qualified Data.Text as T+import qualified Data.Text.Encoding as TE+import qualified Data.Time.Clock as Clock+import Data.Time.Clock.POSIX (posixSecondsToUTCTime)+import qualified Data.UUID as UUID+import qualified Data.UUID.V4 as UUID+import qualified LndClient as Lnd+import qualified LndClient.Data.OutPoint as OP+import qualified Network.Bitcoin.BlockChain as Btc+import Text.Julius (ToJavascript)+import qualified Universum+import qualified Witch+import Yesod.Core++newtype Nonce+ = Nonce Word64+ deriving newtype+ ( Eq,+ Ord,+ Show,+ Read,+ Psql.PersistField,+ Psql.PersistFieldSql+ )+ deriving stock+ ( Generic+ )++instance Out Nonce++instance From Nonce Word64++instance From Word64 Nonce++newNonce :: (MonadIO m) => m Nonce+newNonce =+ liftIO $+ Nonce+ . utcTimeToMicros+ <$> Clock.getCurrentTime++utcTimeToMicros :: UTCTime -> Word64+utcTimeToMicros x =+ fromInteger $+ diffTimeToPicoseconds+ ( fromRational+ . toRational+ $ diffUTCTime x epoch+ )+ `div` 1000000++epoch :: UTCTime+epoch =+ posixSecondsToUTCTime 0++data LogFormat+ = Bracket+ | JSON+ deriving stock+ ( Read+ )++data YesodLog+ = YesodLogAll+ | YesodLogNoMain+ | YesodLogNothing+ deriving stock+ ( Eq,+ Ord,+ Show,+ Read,+ Generic+ )++instance FromJSON YesodLog++newtype Seconds+ = Seconds Word64+ deriving newtype+ ( Eq,+ Ord,+ Show,+ Num+ )+ deriving stock+ ( Generic+ )++instance Out Seconds++newtype MicroSeconds+ = MicroSeconds Integer+ deriving newtype+ ( Eq,+ Ord,+ Show,+ Num+ )+ deriving stock+ ( Generic+ )++instance Out MicroSeconds++newtype LnInvoice (mrel :: MoneyRelation)+ = LnInvoice Lnd.PaymentRequest+ deriving newtype+ ( Eq,+ Show,+ Psql.PersistField,+ Psql.PersistFieldSql,+ PathPiece+ )+ deriving stock+ ( Generic+ )++instance Out (LnInvoice mrel)++instance From Lnd.PaymentRequest (LnInvoice mrel)++instance From (LnInvoice mrel) Lnd.PaymentRequest++instance From Text (LnInvoice mrel) where+ from =+ via @Lnd.PaymentRequest++instance From (LnInvoice mrel) Text where+ from =+ via @Lnd.PaymentRequest++newtype SwapHash = SwapHash Text+ deriving newtype+ ( Eq,+ Show,+ Read,+ PathPiece,+ ToJavascript,+ ToJSON+ )+ deriving stock+ ( Generic+ )++instance Out SwapHash++instance ToTypedContent (Maybe SwapHash) where+ toTypedContent = toTypedContent . toJSON++instance ToContent (Maybe SwapHash) where+ toContent = toContent . toJSON++data LnInvoiceStatus+ = LnInvoiceStatusNew+ | LnInvoiceStatusLocked+ | LnInvoiceStatusSettled+ | LnInvoiceStatusCancelled+ | LnInvoiceStatusExpired+ deriving stock+ ( Generic,+ Show,+ Read,+ Eq+ )++instance Out LnInvoiceStatus++data LnChanStatus+ = LnChanStatusPendingOpen+ | LnChanStatusOpened+ | LnChanStatusActive+ | LnChanStatusFullyResolved+ | LnChanStatusInactive+ | LnChanStatusPendingClose+ | LnChanStatusClosed+ deriving stock+ ( Generic,+ Show,+ Read,+ Eq,+ Ord+ )++instance Out LnChanStatus++newtype Liquidity (dir :: Direction) = Liquidity+ { unLiquidity :: MSat+ }+ deriving newtype+ ( Eq,+ Ord,+ Show,+ Read,+ Num+ )+ deriving stock+ ( Generic+ )++instance Out (Liquidity dir)++newtype+ Money+ (owner :: Owner)+ (btcl :: BitcoinLayer)+ (mrel :: MoneyRelation) = Money+ { unMoney :: MSat+ }+ deriving newtype+ ( Eq,+ Ord,+ Show,+ Read,+ Num,+ Psql.PersistField,+ Psql.PersistFieldSql+ )+ deriving stock+ ( Generic+ )++instance Out (Money owner btcl mrel)++instance From MSat (Money owner btcl mrel)++instance From (Money owner btcl mrel) MSat++instance From Word64 (Money owner btcl mrel) where+ from =+ via @MSat++instance From (Money owner btcl mrel) Word64 where+ from =+ via @MSat++instance TryFrom Natural (Money owner btcl mrel) where+ tryFrom =+ from @Word64 `composeTryRhs` tryFrom++instance From (Money owner btcl mrel) Natural where+ from =+ via @Word64++instance TryFrom (Ratio Natural) (Money owner btcl mrel) where+ tryFrom =+ tryFrom @Natural+ `composeTry` tryFrom++instance From (Money owner btcl mrel) (Ratio Natural) where+ from =+ via @Natural++instance TryFrom Rational (Money owner btcl mrel) where+ tryFrom =+ tryFrom @(Ratio Natural)+ `composeTry` tryFrom++instance From (Money owner btcl mrel) Rational where+ from =+ via @(Ratio Natural)++instance ToMessage (Money owner btcl mrel) where+ toMessage =+ T.displayRational 1+ . (/ 1000)+ . from++newtype FeeRate+ = FeeRate (Ratio Word64)+ deriving newtype+ ( Eq,+ Ord,+ Show+ )+ deriving stock+ ( Generic+ )++instance From (Ratio Word64) FeeRate++instance From FeeRate (Ratio Word64)++instance From FeeRate (Ratio Natural) where+ from =+ via @(Ratio Word64)++instance TryFrom Rational FeeRate where+ tryFrom =+ from @(Ratio Word64)+ `composeTryRhs` tryFrom++instance From FeeRate Rational where+ from =+ via @(Ratio Word64)++instance ToMessage FeeRate where+ toMessage =+ (<> "%")+ . T.displayRational 1+ . (* 100)+ . from++newtype UnsafeOnChainAddress (mrel :: MoneyRelation)+ = UnsafeOnChainAddress Text+ deriving newtype+ ( Eq,+ Ord,+ Show,+ Read,+ PathPiece,+ Psql.PersistField,+ Psql.PersistFieldSql+ )+ deriving stock+ ( Generic+ )++instance Out (UnsafeOnChainAddress mrel)++instance From Text (UnsafeOnChainAddress mrel)++instance From (UnsafeOnChainAddress mrel) Text++data SwapStatus+ = -- | Waiting on-chain funding trx with+ -- given amt from user with+ -- some confirmations.+ SwapWaitingFundChain+ | -- | Swap has been funded on-chain,+ -- need to open LN channel now.+ SwapWaitingPeer+ | -- | Waiting channel opening trx+ -- to be mined with some confirmations.+ SwapWaitingChan+ | -- | Final statuses+ SwapSucceeded+ | SwapExpired+ deriving stock+ ( Eq,+ Ord,+ Show,+ Read,+ Generic,+ Enum,+ Bounded+ )++instance Out SwapStatus++swapStatusChain :: [SwapStatus]+swapStatusChain =+ [ SwapWaitingFundChain,+ SwapWaitingPeer+ ]++swapStatusLn :: [SwapStatus]+swapStatusLn =+ [ SwapWaitingChan+ ]++swapStatusFinal :: [SwapStatus]+swapStatusFinal =+ [ SwapSucceeded,+ SwapExpired+ ]++instance PathPiece SwapStatus where+ fromPathPiece :: Text -> Maybe SwapStatus+ fromPathPiece =+ readMaybe+ . unpack+ . T.toTitle+ toPathPiece :: SwapStatus -> Text+ toPathPiece =+ T.toLower+ . Universum.show++data Failure+ = FailureInp FailureInput+ | FailureInt FailureInternal+ deriving stock+ ( Eq,+ Show,+ Generic+ )++instance Out Failure++data FailureInput+ = FailureNonce+ | FailureNonSegwitAddr+ | FailureNonValidAddr+ deriving stock+ ( Eq,+ Show,+ Generic+ )++instance Out FailureInput++data FailureInternal+ = FailureGrpcServer Text+ | FailureGrpcClient Text+ | FailureMath Text+ | FailurePrivate Text+ | FailureRedacted+ deriving stock+ ( Eq,+ Show,+ Generic+ )++instance Out FailureInternal++tryFailureE ::+ forall source target.+ ( Show source,+ Typeable source,+ Typeable target+ ) =>+ Text ->+ Either (TryFromException source target) target ->+ Either Failure target+tryFailureE label =+ first $+ FailureInt+ . FailureMath+ . (label <>)+ . (" " <>)+ . Universum.show++tryFailureT ::+ forall source target m.+ ( Show source,+ Typeable source,+ Typeable target,+ Monad m+ ) =>+ Text ->+ Either (TryFromException source target) target ->+ ExceptT Failure m target+tryFailureT label =+ except . tryFailureE label++tryFromE ::+ forall source target.+ ( Show source,+ Typeable source,+ Typeable target,+ TryFrom source target,+ 'False ~ (source == target)+ ) =>+ Text ->+ source ->+ Either Failure target+tryFromE label =+ tryFailureE label . tryFrom++tryFromT ::+ forall source target m.+ ( Show source,+ Typeable source,+ Typeable target,+ TryFrom source target,+ Monad m,+ 'False ~ (source == target)+ ) =>+ Text ->+ source ->+ ExceptT Failure m target+tryFromT label =+ except . tryFromE label++data SocketAddress = SocketAddress+ { socketAddressHost :: HostName,+ socketAddressPort :: PortNumber+ }+ deriving stock+ ( Eq,+ Ord,+ Show,+ Generic+ )++instance Out SocketAddress++newtype BlkHash+ = BlkHash Btc.BlockHash+ deriving stock (Eq, Ord, Show, Generic)+ deriving newtype (Psql.PersistField, Psql.PersistFieldSql)++instance Out BlkHash++instance From Btc.BlockHash BlkHash++instance From BlkHash Btc.BlockHash++newtype BlkHeight+ = BlkHeight Word64+ deriving stock+ ( Eq,+ Ord,+ Show,+ Generic+ )+ deriving newtype+ ( Num,+ Psql.PersistField,+ Psql.PersistFieldSql+ )++instance Out BlkHeight++instance ToJSON BlkHeight++instance From Word64 BlkHeight++instance From BlkHeight Word64++instance From BlkHeight Natural where+ from =+ via @Word64++instance TryFrom Btc.BlockHeight BlkHeight where+ tryFrom =+ from @Word64+ `composeTryRhs` tryFrom++instance From BlkHeight Btc.BlockHeight where+ from =+ via @Word64++data BlkStatus+ = BlkConfirmed+ | BlkOrphan+ deriving stock+ ( Eq,+ Ord,+ Show,+ Read,+ Generic+ )++instance Out BlkStatus++data SwapUtxoStatus+ = SwapUtxoUnspent+ | SwapUtxoUnspentDust+ | SwapUtxoUnspentChanReserve+ | SwapUtxoSpentChanSwapped+ | SwapUtxoSpentRefund+ | SwapUtxoOrphan+ deriving stock+ ( Eq,+ Ord,+ Show,+ Read,+ Generic+ )++instance Out SwapUtxoStatus++data Privacy+ = Public+ | Private+ deriving stock+ ( Eq,+ Ord,+ Show,+ Read,+ Enum,+ Bounded,+ Generic+ )++instance Out Privacy++newtype NodePubKeyHex+ = NodePubKeyHex Text+ deriving newtype (Eq, Ord, Show, Read, IsString)+ deriving stock (Generic)++instance Out NodePubKeyHex++instance From NodePubKeyHex Text++instance From Text NodePubKeyHex++instance TryFrom NodePubKey NodePubKeyHex where+ tryFrom src =+ from+ `composeTryRhs` ( first+ ( TryFromException src+ . Just+ . toException+ )+ . TE.decodeUtf8'+ . B16.encode+ . coerce+ )+ $ src++newtype UtxoLockId = UtxoLockId ByteString+ deriving newtype (Eq, Ord, Show, Read)+ deriving stock (Generic)++instance Out UtxoLockId++data NodeUri = NodeUri+ { nodeUriPubKey :: NodePubKey,+ nodeUriSocketAddress :: SocketAddress+ }+ deriving stock+ ( Eq,+ Ord,+ Show,+ Generic+ )++instance Out NodeUri++newtype NodeUriHex+ = NodeUriHex Text+ deriving newtype (Eq, Ord, Show, Read, IsString)+ deriving stock (Generic)++instance Out NodeUriHex++instance From NodeUriHex Text++instance From Text NodeUriHex++instance TryFrom NodeUri NodeUriHex where+ tryFrom src =+ bimap+ (withTarget @NodeUriHex . withSource src)+ ( \pubHex ->+ from @Text $+ from pubHex+ <> "@"+ <> from host+ <> ":"+ <> from (showIntegral port)+ )+ $ tryFrom @NodePubKey @NodePubKeyHex $+ nodeUriPubKey src+ where+ sock = nodeUriSocketAddress src+ host = socketAddressHost sock+ port = socketAddressPort sock++newtype RHashHex = RHashHex+ { unRHashHex :: Text+ }+ deriving newtype+ ( Eq,+ Ord,+ Show,+ Read,+ PathPiece+ )+ deriving stock+ ( Generic+ )++instance Out RHashHex++instance From RHashHex Text++instance From Text RHashHex++instance From RHash RHashHex where+ from =+ --+ -- NOTE : decodeUtf8 in general is unsafe+ -- but here we know that it will not fail+ -- because of B16+ --+ RHashHex+ . decodeUtf8+ . B16.encode+ . coerce++instance From RHashHex RHash where+ from =+ --+ -- NOTE : this is not RFC 4648-compliant,+ -- using only for the practical purposes+ --+ RHash+ . B16.decodeLenient+ . encodeUtf8+ . unRHashHex++newtype Uuid (tab :: Table) = Uuid+ { unUuid' :: UUID+ }+ deriving newtype+ ( Eq,+ Ord,+ Show,+ Read+ )+ deriving stock (Generic)++unUuid :: Uuid tab -> UUID+unUuid =+ unUuid'++instance Out (Uuid tab) where+ docPrec x =+ docPrec x+ . UUID.toText+ . unUuid+ doc =+ docPrec 0++newUuid :: (MonadIO m) => m (Uuid tab)+newUuid =+ liftIO $+ Uuid <$> UUID.nextRandom++newtype Vbyte = Vbyte+ { unVbyte :: Ratio Natural+ }+ deriving newtype+ ( Eq,+ Ord,+ Show,+ Num+ )+ deriving stock+ ( Generic+ )++instance Out Vbyte++instance From Vbyte (Ratio Natural)++instance From (Ratio Natural) Vbyte++newtype RowQty = RowQty+ { unRowQty :: Int64+ }+ deriving newtype+ ( Eq,+ Ord,+ Show+ )+ deriving stock+ ( Generic+ )++instance Out RowQty++data PsbtUtxo = PsbtUtxo+ { getOutPoint :: OP.OutPoint,+ getAmt :: MSat,+ getLockId :: Maybe UtxoLockId+ }+ deriving stock (Show, Generic)++instance Out PsbtUtxo++instance From RowQty Int64++instance From Int64 RowQty++instance From Int RowQty where+ from =+ via @Int64++--+-- NOTE : we're taking advantage of+-- PostgreSQL understanding UUID values+--+instance Psql.PersistField (Uuid tab) where+ toPersistValue =+ Psql.PersistLiteral_ Psql.Escaped+ . UUID.toASCIIBytes+ . unUuid+ fromPersistValue = \case+ Psql.PersistLiteral_ Psql.Escaped x ->+ maybe+ ( Left $+ "Failed to deserialize a UUID, got literal: "+ <> inspectPlain x+ )+ ( Right+ . Uuid+ )+ $ UUID.fromASCIIBytes x+ failure ->+ Left $+ "Failed to deserialize a UUID, got: "+ <> inspectPlain failure++instance Psql.PersistFieldSql (Uuid tab) where+ sqlType =+ const $+ Psql.SqlOther "uuid"++instance ToMessage (Uuid tab) where+ toMessage =+ (<> "...")+ . T.take 5+ . UUID.toText+ . unUuid++instance PathPiece (Uuid tab) where+ fromPathPiece =+ (Uuid <$>)+ . UUID.fromText+ toPathPiece =+ UUID.toText+ . unUuid++Psql.derivePersistField "LnInvoiceStatus"+Psql.derivePersistField "LnChanStatus"+Psql.derivePersistField "SwapStatus"+Psql.derivePersistField "BlkStatus"+Psql.derivePersistField "SwapUtxoStatus"+Psql.derivePersistField "Privacy"+Psql.derivePersistField "UtxoLockId"
@@ -0,0 +1,149 @@+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TypeApplications #-}++module BtcLsp.Grpc.Client.HighLevel+ ( swapIntoLn,+ swapIntoLnT,+ getCfg,+ getCfgT,+ )+where++import BtcLsp.Grpc.Client.LowLevel+import BtcLsp.Import+import qualified Data.Binary.Builder as BS+import qualified Data.ByteString as BS+import qualified Data.ByteString.Lazy as BL+import Data.ProtoLens.Field+import Data.ProtoLens.Message+import qualified LndClient.Data.VerifyMessage as Lnd+import qualified LndClient.RPC.Katip as Lnd+import qualified Network.GRPC.HTTP2.Encoding as G+import Network.GRPC.HTTP2.ProtoLens (RPC (..))+import Proto.BtcLsp (Service)+import qualified Proto.BtcLsp.Data.HighLevel as Proto+import qualified Proto.BtcLsp.Data.HighLevel_Fields as Proto+import qualified Proto.BtcLsp.Method.GetCfg as GetCfg+import qualified Proto.BtcLsp.Method.SwapIntoLn as SwapIntoLn++swapIntoLn ::+ ( Env m+ ) =>+ GCEnv ->+ SwapIntoLn.Request ->+ m (Either Failure SwapIntoLn.Response)+swapIntoLn env req = withRunInIO $ \run ->+ first (FailureInt . FailureGrpcClient)+ <$> runUnary+ (RPC :: RPC Service "swapIntoLn")+ env+ ( \res sig compressMode ->+ run $+ verifySig res sig compressMode+ )+ req++swapIntoLnT ::+ ( Env m+ ) =>+ GCEnv ->+ SwapIntoLn.Request ->+ ExceptT Failure m SwapIntoLn.Response+swapIntoLnT env =+ ExceptT . swapIntoLn env++getCfg ::+ ( Env m+ ) =>+ GCEnv ->+ GetCfg.Request ->+ m (Either Failure GetCfg.Response)+getCfg env req = withRunInIO $ \run ->+ first (FailureInt . FailureGrpcClient)+ <$> runUnary+ (RPC :: RPC Service "getCfg")+ env+ ( \res sig compressMode ->+ run $+ verifySig res sig compressMode+ )+ req++getCfgT ::+ ( Env m+ ) =>+ GCEnv ->+ GetCfg.Request ->+ ExceptT Failure m GetCfg.Response+getCfgT env =+ ExceptT . getCfg env++-- | WARNING : this function is unsafe and inefficient+-- but it is used for testing purposes only!+verifySig ::+ ( Env m,+ Message msg,+ HasField msg "ctx" Proto.Ctx+ ) =>+ msg ->+ ByteString ->+ CompressMode ->+ m Bool+verifySig msg sig compressMode = do+ let msgEncoded =+ encodeMessage msg+ let msgChunk =+ case compressMode of+ Compressed -> G._compressionFunction G.gzip msgEncoded+ Uncompressed -> msgEncoded+ let msgWire =+ BS.pack+ [ case compressMode of+ Compressed -> 1+ Uncompressed -> 0+ ]+ <> ( BL.toStrict+ . BS.toLazyByteString+ . BS.putWord32be+ . fromIntegral -- Length is non-neg, it's fine.+ $ BS.length msgChunk+ )+ <> msgChunk+ let pub =+ msg+ ^. field @"ctx"+ . Proto.lnPubKey+ . Proto.val+ res <-+ withLnd+ Lnd.verifyMessage+ ( $+ Lnd.VerifyMessageRequest+ { Lnd.message = msgWire,+ Lnd.signature = sig,+ Lnd.pubkey = pub+ }+ )+ case res of+ Left e -> do+ $(logTM) ErrorS . logStr $+ "Client ==> signature verification failed "+ <> inspect e+ pure False+ Right x ->+ if coerce x+ then pure True+ else do+ $(logTM) ErrorS . logStr $+ "Client ==> signature verification failed "+ <> "for message of "+ <> inspect (BS.length msgWire)+ <> " bytes "+ <> inspect msgWire+ <> " with signature of "+ <> inspect (BS.length sig)+ <> " bytes "+ <> inspect sig+ <> " and pub key "+ <> inspect pub+ pure False
@@ -0,0 +1,197 @@+module BtcLsp.Grpc.Client.LowLevel+ ( runUnary,+ GCEnv (..),+ GCPort (..),+ )+where++import BtcLsp.Grpc.Data+import BtcLsp.Grpc.Orphan ()+import qualified BtcLsp.Grpc.Sig as Sig+import BtcLsp.Import.Witch+import Data.Aeson+ ( FromJSON (..),+ withObject,+ withScientific,+ (.:),+ (.:?),+ )+import qualified Data.Binary.Builder as BS+import qualified Data.ByteString as BS+import qualified Data.ByteString.Base64 as B64+import qualified Data.ByteString.Lazy as BL+import qualified Data.CaseInsensitive as CI+import Data.Coerce (coerce)+import Data.ProtoLens (Message)+import Data.ProtoLens.Encoding (encodeMessage)+import Data.ProtoLens.Service.Types (HasMethod, HasMethodImpl (..))+import Data.Scientific (floatingOrInteger)+import GHC.TypeLits (Symbol)+import Network.GRPC.Client+import Network.GRPC.Client.Helpers+import qualified Network.GRPC.HTTP2.Encoding as G+import qualified Network.GRPC.HTTP2.ProtoLens as ProtoLens+import Network.HTTP2.Client2+import Text.PrettyPrint.GenericPretty+ ( Out,+ )+import Text.PrettyPrint.GenericPretty.Import+ ( inspectPlain,+ )+import Universum++data GCEnv = GCEnv+ { gcEnvHost :: String,+ gcEnvPort :: GCPort,+ gcEnvEncryption :: Maybe Encryption,+ gcEnvSigHeaderName :: SigHeaderName,+ gcEnvCompressMode :: CompressMode,+ gcEnvSigner :: Sig.MsgToSign -> IO (Maybe Sig.LndSig)+ }+ deriving stock+ ( Generic+ )++instance FromJSON GCEnv where+ parseJSON =+ withObject+ "GCEnv"+ ( \x ->+ GCEnv+ <$> x .: "host"+ <*> x .: "port"+ <*> x .:? "encryption"+ <*> x .: "sig_header_name"+ <*> x .: "compress_mode"+ <*> pure (const $ pure Nothing)+ )++newtype GCPort+ = GCPort PortNumber+ deriving newtype+ ( Enum,+ Eq,+ Integral,+ Num,+ Ord,+ Read,+ Real,+ Show+ )++instance FromJSON GCPort where+ parseJSON =+ withScientific "GCPort" $ \x0 ->+ case floatingOrInteger x0 of+ Left (_ :: Double) -> fail "Non-integer"+ Right x -> pure x++runUnary ::+ ( Out res,+ Show res,+ HasMethod s m,+ req ~ MethodInput s m,+ res ~ MethodOutput s m+ ) =>+ ProtoLens.RPC s (m :: Symbol) ->+ GCEnv ->+ (res -> ByteString -> CompressMode -> IO Bool) ->+ req ->+ IO (Either Text res)+runUnary rpc env verifySig req = do+ res <-+ runClientIO $+ bracket+ ( makeClient env req+ . maybe True (== Encrypted)+ $ gcEnvEncryption env+ )+ close+ (\grpc -> rawUnary rpc grpc req)+ case res of+ Right (Right (Right (h, mh, Right x))) ->+ case find (\header -> fst header == sigHeaderName) $ h <> fromMaybe mempty mh of+ Nothing ->+ pure . Left $+ "Client ==> missing server header "+ <> inspectPlain sigHeaderName+ Just (_, b64sig) -> do+ let sigDer = B64.decodeLenient b64sig+ isVerified <-+ verifySig x sigDer $+ gcEnvCompressMode env+ pure $+ if isVerified+ then Right x+ else+ Left $+ "Client ==> server signature verification"+ <> " failed for raw bytes"+ <> " from decoded payload "+ <> inspectPlain x+ <> " with signature "+ <> inspectPlain sigDer+ x ->+ pure . Left $+ "Client ==> server grpc failure "+ <> Universum.show x+ where+ sigHeaderName = CI.mk . from $ gcEnvSigHeaderName env++msgToSignBytes ::+ ( Message msg+ ) =>+ CompressMode ->+ msg ->+ ByteString+msgToSignBytes compressMode msg = header <> body+ where+ rawBody = encodeMessage msg+ body =+ case compressMode of+ Compressed -> G._compressionFunction G.gzip rawBody+ Uncompressed -> rawBody+ header =+ BS.pack+ [ case compressMode of+ Compressed -> 1+ Uncompressed -> 0+ ]+ <> ( BL.toStrict+ . BS.toLazyByteString+ . BS.putWord32be+ . fromIntegral -- Length is non-neg, it's fine.+ $ BS.length body+ )++makeClient ::+ Message req =>+ GCEnv ->+ req ->+ UseTlsOrNot ->+ ClientIO GrpcClient+makeClient env req tlsEnabled = do+ mSignature <- liftIO doSignature+ case mSignature of+ Just signature ->+ setupGrpcClient $+ (grpcClientConfigSimple (gcEnvHost env) (coerce $ gcEnvPort env) tlsEnabled)+ { _grpcClientConfigCompression = compression,+ _grpcClientConfigHeaders =+ [ ( sigHeaderName,+ B64.encode $ Sig.unLndSig signature+ )+ ]+ }+ Nothing -> throwError EarlyEndOfStream+ where+ signer = gcEnvSigner env+ sigHeaderName = from $ gcEnvSigHeaderName env+ compressMode = gcEnvCompressMode env+ doSignature =+ signer . Sig.MsgToSign $+ msgToSignBytes compressMode req+ compression =+ case compressMode of+ Compressed -> gzip+ Uncompressed -> uncompressed
@@ -0,0 +1,266 @@+{-# LANGUAGE AllowAmbiguousTypes #-}+{-# LANGUAGE ConstraintKinds #-}+{-# LANGUAGE DeriveLift #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TypeApplications #-}++module BtcLsp.Grpc.Combinator+ ( fromReqT,+ fromReqE,+ newGenFailure,+ newSpecFailure,+ newInternalFailure,+ throwSpec,+ mkFieldLocation,+ GrpcReq,+ GrpcRes,+ )+where++import BtcLsp.Data.Type+import BtcLsp.Import.External as Ext+import Data.Map as Map+import Data.ProtoLens.Field+import Data.ProtoLens.Message+import Data.Text as T+import Language.Haskell.TH.Syntax as TH+import qualified Proto.BtcLsp.Data.HighLevel as Proto+import qualified Proto.BtcLsp.Data.HighLevel_Fields as Proto+import qualified Universum+import qualified Witch++type GrpcReq req =+ ( HasField req "maybe'ctx" (Maybe Proto.Ctx)+ )++type GrpcRes res failure specific =+ ( HasField res "ctx" Proto.Ctx,+ HasField res "failure" failure,+ HasField failure "generic" [Proto.InputFailure],+ HasField failure "specific" [specific],+ HasField failure "internal" [Proto.InternalFailure],+ Message res,+ Message failure+ )++fromReqT ::+ forall a b res failure specific m.+ ( From a b,+ 'False ~ (a == b),+ GrpcRes res failure specific,+ Monad m+ ) =>+ ReversedFieldLocation ->+ Maybe a ->+ ExceptT res m b+fromReqT loc =+ except+ . fromReqE loc++fromReqE ::+ forall a b res failure specific.+ ( From a b,+ 'False ~ (a == b),+ GrpcRes res failure specific+ ) =>+ ReversedFieldLocation ->+ Maybe a ->+ Either res b+fromReqE loc =+ (from <$>)+ . maybeToRight msg+ where+ msg =+ defMessage+ & field @"failure"+ .~ ( defMessage+ & field @"generic"+ .~ [ defMessage+ & Proto.fieldLocation .~ from loc+ & Proto.kind .~ Proto.REQUIRED+ ]+ )++newGenFailure ::+ forall res failure specific.+ ( GrpcRes res failure specific+ ) =>+ Proto.InputFailureKind ->+ ReversedFieldLocation ->+ res+newGenFailure kind loc =+ defMessage+ & field @"failure"+ .~ ( defMessage+ & field @"generic"+ .~ [ defMessage+ & Proto.fieldLocation .~ from loc+ & Proto.kind .~ kind+ ]+ )++newSpecFailure ::+ forall res failure specific.+ ( GrpcRes res failure specific+ ) =>+ specific ->+ res+newSpecFailure spec =+ defMessage+ & field @"failure"+ .~ ( defMessage+ & field @"specific"+ .~ [ spec+ ]+ )++newInternalFailure ::+ forall res failure specific.+ ( GrpcRes res failure specific+ ) =>+ FailureInternal ->+ res+newInternalFailure hFailure =+ defMessage+ & field @"failure"+ .~ ( defMessage+ & field @"internal"+ .~ [ gFailure+ ]+ )+ where+ gFailure =+ defMessage+ & case hFailure of+ FailureGrpcServer x -> Proto.grpcServer .~ x+ FailureGrpcClient {} -> Proto.redacted .~ True+ FailureMath x -> Proto.math .~ x+ FailurePrivate {} -> Proto.redacted .~ True+ FailureRedacted -> Proto.redacted .~ True++throwSpec ::+ forall a res failure specific m.+ ( GrpcRes res failure specific,+ Monad m+ ) =>+ specific ->+ ExceptT res m a+throwSpec =+ throwE . newSpecFailure++--+-- TH FieldIndex combinators+--++newtype FieldIndex+ = FieldIndex Word32+ deriving newtype+ ( Eq,+ Ord,+ Show+ )+ deriving stock+ ( TH.Lift+ )++newtype ReversedFieldLocation+ = ReversedFieldLocation [FieldIndex]+ deriving newtype+ ( Eq,+ Ord,+ Show,+ Semigroup,+ Monoid+ )+ deriving stock+ ( TH.Lift+ )++instance From ReversedFieldLocation [Proto.FieldIndex] where+ from (ReversedFieldLocation xs) =+ ( \x ->+ defMessage+ & Proto.val .~ coerce x+ )+ <$> Ext.reverse xs++mkFieldLocation ::+ forall a.+ ( Message a+ ) =>+ [String] ->+ Q Exp+mkFieldLocation ns =+ [|+ $(mkPushFieldIndexes @a ns) $+ ReversedFieldLocation []+ |]++mkPushFieldIndexes ::+ forall a.+ ( Message a+ ) =>+ [String] ->+ Q Exp+mkPushFieldIndexes ns = do+ addLoc <- getFieldLocation @a ns+ [|(<>) $(TH.lift addLoc)|]++getFieldLocation ::+ forall a m.+ ( Message a,+ MonadFail m+ ) =>+ [String] ->+ m ReversedFieldLocation+getFieldLocation =+ (ReversedFieldLocation <$>)+ . getFieldLocation0 @a []++getFieldLocation0 ::+ forall a m.+ ( Message a,+ MonadFail m+ ) =>+ [FieldIndex] ->+ [String] ->+ m [FieldIndex]+getFieldLocation0 acc0 [] = pure acc0+getFieldLocation0 acc0 (n : ns) =+ case Ext.find ((\(FieldDescriptor x _ _) -> x == n) . snd) $+ Map.toList (fieldsByTag :: Map Tag (FieldDescriptor a)) of+ Just (_, FieldDescriptor _ _ MapField {}) ->+ fieldFail+ "is MapField (not supported by current TH combinators)"+ Just (_, FieldDescriptor _ _ RepeatedField {})+ | not (Ext.null ns) ->+ fieldFail+ "is RepeatedField and not last field in TH splice"+ Just (it, FieldDescriptor _ ftd _) -> do+ acc <- case tryFrom $ unTag it of+ Right x -> pure $ FieldIndex x : acc0+ Left e ->+ fieldFail $+ "tag overflow "+ <> Universum.show e+ <> " of "+ <> Universum.show it+ case ftd of+ (MessageField {} :: FieldTypeDescriptor nextA) ->+ getFieldLocation0 @nextA acc ns+ ScalarField {} ->+ if Ext.null ns+ then pure acc+ else+ fieldFail $+ "scalar got extra tags "+ <> inspectStr ns+ Nothing ->+ fieldFail "not found"+ where+ msgName =+ T.unpack $+ messageName (Proxy :: Proxy a)+ fieldFail x =+ fail $+ "Field " <> n <> " of " <> msgName <> " " <> x
@@ -0,0 +1,115 @@+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE KindSignatures #-}+{-# LANGUAGE TypeApplications #-}+{-# LANGUAGE NoImplicitPrelude #-}++module BtcLsp.Grpc.Data+ ( GRel (..),+ SigHeaderName,+ TlsCert (..),+ TlsKey (..),+ TlsData (..),+ RawRequestBytes (..),+ Encryption (..),+ )+where++import BtcLsp.Import.Witch+import Data.Aeson (FromJSON (..), withObject, withText, (.:))+import Text.PrettyPrint.GenericPretty (Out)+import Text.PrettyPrint.GenericPretty.Instance ()+import Universum+import qualified Witch++data GRel+ = Client+ | Server++newtype RawRequestBytes+ = RawRequestBytes ByteString+ deriving stock+ ( Eq,+ Ord,+ Generic+ )++instance Out RawRequestBytes++newtype SigHeaderName+ = SigHeaderName Text+ deriving newtype+ ( Eq,+ Ord,+ Show,+ IsString+ )++instance From SigHeaderName Text++instance From Text SigHeaderName++instance From SigHeaderName ByteString where+ from =+ via @Text++instance TryFrom ByteString SigHeaderName where+ tryFrom =+ from @Text+ `composeTryRhs` tryFrom++newtype TlsCert (rel :: GRel)+ = TlsCert Text+ deriving newtype+ ( Eq,+ Ord,+ Show,+ FromJSON+ )++newtype TlsKey (rel :: GRel)+ = TlsKey Text+ deriving newtype+ ( Eq,+ Ord,+ FromJSON+ )++data TlsData (rel :: GRel) = TlsData+ { tlsCert :: TlsCert rel,+ tlsKey :: TlsKey rel+ }+ deriving stock+ ( Eq,+ Ord+ )++instance FromJSON (TlsData (rel :: GRel)) where+ parseJSON =+ withObject+ "TlsData"+ $ \x ->+ TlsData+ <$> x .: "cert"+ <*> x .: "key"++instance FromJSON SigHeaderName where+ parseJSON =+ withText "SigHeaderName" $+ pure . SigHeaderName++data Encryption+ = Encrypted+ | UnEncrypted+ deriving stock+ ( Eq,+ Ord,+ Show,+ Read,+ Enum,+ Bounded,+ Generic+ )++instance Out Encryption++instance FromJSON Encryption
@@ -0,0 +1,133 @@+{-# LANGUAGE TypeApplications #-}+{-# OPTIONS_GHC -Wno-orphans #-}++module BtcLsp.Grpc.Orphan+ ( intoProto,+ fromProto,+ )+where++import BtcLsp.Data.Kind+import BtcLsp.Data.Orphan ()+import BtcLsp.Data.Type+import BtcLsp.Import.External+import Data.ProtoLens.Field+import Data.ProtoLens.Message+import qualified LndClient as Lnd+import qualified Proto.BtcLsp.Data.HighLevel as Proto+import qualified Proto.BtcLsp.Data.HighLevel_Fields as Proto+import qualified Proto.BtcLsp.Data.LowLevel as Proto+import qualified Proto.BtcLsp.Data.LowLevel_Fields as LowLevel+import qualified Witch++fromProto ::+ forall proto through haskell.+ ( HasField proto "val" through,+ From through haskell,+ 'False ~ (through == haskell)+ ) =>+ proto ->+ haskell+fromProto =+ from+ . (^. field @"val")++intoProto ::+ forall proto through haskell.+ ( Message proto,+ HasField proto "val" through,+ From haskell through,+ 'False ~ (haskell == through)+ ) =>+ haskell ->+ proto+intoProto x =+ defMessage+ & field @"val" .~ from x++instance From Proto.Nonce Nonce where+ from = fromProto++instance From Nonce Proto.Nonce where+ from = intoProto++instance From Proto.LnPubKey NodePubKey where+ from =+ coerce . (^. Proto.val)++instance From NodePubKey Proto.LnPubKey where+ from x =+ defMessage+ & Proto.val .~ coerce x++instance From Proto.LnInvoice (LnInvoice mrel) where+ from =+ via @Lnd.PaymentRequest . (^. Proto.val)++instance From (LnInvoice mrel) Proto.LnInvoice where+ from x =+ defMessage+ & Proto.val .~ via @Lnd.PaymentRequest x++instance From Proto.FundLnInvoice (LnInvoice 'Fund) where+ from = fromProto++instance From (LnInvoice 'Fund) Proto.FundLnInvoice where+ from = intoProto++instance From Proto.OnChainAddress (UnsafeOnChainAddress 'Refund) where+ from = fromProto++instance From Proto.RefundOnChainAddress (UnsafeOnChainAddress 'Refund) where+ from = fromProto++instance From Proto.Privacy Privacy where+ from = toEnum . fromEnum++instance From Privacy Proto.Privacy where+ from = toEnum . fromEnum++instance From Proto.Msat MSat where+ from = fromProto++instance From MSat Proto.Msat where+ from = intoProto++instance From Proto.FundMoney MSat where+ from = fromProto++instance From MSat Proto.FundMoney where+ from = intoProto++deriving stock instance Eq CompressMode++deriving stock instance Generic CompressMode++instance FromJSON CompressMode++instance From PortNumber Word32 where+ from = fromIntegral -- Word16 to Word32 is fine.++instance From PortNumber Proto.LnPort where+ from = intoProto++instance From HostName Proto.LnHost where+ from = intoProto++instance From (Money owner btcl mrel) Proto.Msat where+ from = intoProto++instance From (Money 'Usr btcl 'Fund) Proto.LocalBalance where+ from = intoProto++instance From (Money 'Lsp btcl 'Gain) Proto.FeeMoney where+ from = intoProto++instance From FeeRate Proto.Urational where+ from (FeeRate x) =+ defMessage+ & LowLevel.numerator .~ numerator x+ & LowLevel.denominator .~ denominator x++instance From FeeRate Proto.FeeRate where+ from = intoProto
@@ -0,0 +1,168 @@+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TypeApplications #-}++module BtcLsp.Grpc.Server.HighLevel+ ( swapIntoLn,+ swapIntoLnT,+ getCfg,+ )+where++import qualified BtcLsp.Data.Smart as Smart+import BtcLsp.Import+import qualified BtcLsp.Math.Swap as Math+import qualified BtcLsp.Storage.Model.SwapIntoLn as SwapIntoLn+import qualified LndClient as Lnd+import qualified LndClient.Data.NewAddress as Lnd+import qualified LndClient.RPC.Katip as Lnd+import qualified Proto.BtcLsp.Data.HighLevel as Grpc+import qualified Proto.BtcLsp.Data.HighLevel_Fields as Grpc+import qualified Proto.BtcLsp.Method.GetCfg as GetCfg+import qualified Proto.BtcLsp.Method.GetCfg_Fields as GetCfg+import qualified Proto.BtcLsp.Method.SwapIntoLn as SwapIntoLn+import qualified Proto.BtcLsp.Method.SwapIntoLn_Fields as SwapIntoLn++swapIntoLn ::+ ( Env m+ ) =>+ Entity User ->+ SwapIntoLn.Request ->+ m SwapIntoLn.Response+swapIntoLn userEnt req = do+ res <- runExceptT $ do+ privacy <-+ fromReqT+ $( mkFieldLocation+ @SwapIntoLn.Request+ [ "privacy"+ ]+ )+ $ req ^? SwapIntoLn.privacy+ unsafeRefundAddr <-+ fromReqT+ $( mkFieldLocation+ @SwapIntoLn.Request+ [ "refund_on_chain_address"+ ]+ )+ $ req ^. SwapIntoLn.maybe'refundOnChainAddress+ swapIntoLnT+ userEnt+ unsafeRefundAddr+ privacy+ pure $ case res of+ Left e -> e+ Right (Entity _ swap) ->+ defMessage+ & SwapIntoLn.success+ .~ ( defMessage+ & SwapIntoLn.fundOnChainAddress+ .~ from (swapIntoLnFundAddress swap)+ & SwapIntoLn.minFundMoney+ .~ from @MSat+ ( from (swapIntoLnChanCapUser swap)+ + from (swapIntoLnFeeLsp swap)+ )+ )++swapIntoLnT ::+ ( Env m+ ) =>+ Entity User ->+ UnsafeOnChainAddress 'Refund ->+ Privacy ->+ ExceptT SwapIntoLn.Response m (Entity SwapIntoLn)+swapIntoLnT userEnt unsafeRefundAddr chanPrivacy = do+ --+ -- TODO : Do not fail immediately, but collect+ -- all the input failures.+ --+ refundAddr <-+ withExceptT+ ( \case+ FailureInp FailureNonce ->+ newGenFailure+ Grpc.VERIFICATION_FAILED+ $( mkFieldLocation+ @SwapIntoLn.Request+ [ "ctx",+ "nonce"+ ]+ )+ FailureInp FailureNonSegwitAddr ->+ newSpecFailure SwapIntoLn.Response'Failure'REFUND_ON_CHAIN_ADDRESS_IS_NOT_SEGWIT+ FailureInp FailureNonValidAddr ->+ newSpecFailure SwapIntoLn.Response'Failure'REFUND_ON_CHAIN_ADDRESS_IS_NOT_VALID+ FailureInt e ->+ newInternalFailure e+ )+ $ Smart.newOnChainAddressT unsafeRefundAddr+ fundAddr <-+ from+ <$> withLndServerT+ Lnd.newAddress+ ( $+ Lnd.NewAddressRequest+ { Lnd.addrType = Lnd.WITNESS_PUBKEY_HASH,+ Lnd.account = Nothing+ }+ )+ feeAndChangeAddr <-+ withLndServerT+ Lnd.newAddress+ ( $+ Lnd.NewAddressRequest+ { Lnd.addrType = Lnd.WITNESS_PUBKEY_HASH,+ Lnd.account = Nothing+ }+ )+ expAt <-+ getFutureTime+ . Lnd.Seconds+ $ 7 * 24 * 60 * 60+ lift+ . runSql+ . SwapIntoLn.createIgnoreSql+ userEnt+ fundAddr+ (from feeAndChangeAddr)+ refundAddr+ expAt+ $ chanPrivacy++getCfg ::+ ( Env m+ ) =>+ Entity User ->+ GetCfg.Request ->+ m GetCfg.Response+getCfg _ _ = do+ pub <- getLspPubKey+ sa <- getLndP2PSocketAddress+ swapMinAmt <- getSwapIntoLnMinAmt+ pure $+ defMessage+ & GetCfg.success+ .~ ( defMessage+ & GetCfg.lspLnNodes+ .~ [ defMessage+ & Grpc.pubKey+ .~ from pub+ & Grpc.host+ .~ from (socketAddressHost sa)+ & Grpc.port+ .~ from (socketAddressPort sa)+ ]+ & GetCfg.swapIntoLnMinAmt+ .~ from swapMinAmt+ & GetCfg.swapIntoLnMaxAmt+ .~ from Math.swapLnMaxAmt+ & GetCfg.swapFromLnMinAmt+ .~ from swapMinAmt+ & GetCfg.swapFromLnMaxAmt+ .~ from Math.swapLnMaxAmt+ & GetCfg.swapLnFeeRate+ .~ from Math.swapLnFeeRate+ & GetCfg.swapLnMinFee+ .~ from Math.swapLnMinFee+ )
@@ -0,0 +1,154 @@+--+-- NOTE : requestBody is deprecated+-- but we need it.+--+{-# OPTIONS_GHC -Wno-deprecations #-}++module BtcLsp.Grpc.Server.LowLevel+ ( GSEnv (..),+ runServer,+ serverApp,+ )+where++import BtcLsp.Grpc.Data+import qualified BtcLsp.Grpc.Sig as Sig+import BtcLsp.Import.External+import Control.Concurrent (modifyMVar)+import Data.Aeson (withObject, (.:), (.:?))+import qualified Data.ByteString.Base64 as B64+import qualified Data.ByteString.Lazy as BSL+import qualified Data.CaseInsensitive as CI+import qualified Data.Text.Encoding as TE+import Network.GRPC.HTTP2.Encoding (gzip)+import Network.GRPC.Server+import Network.HTTP2.Server hiding (Request)+import Network.Wai+import Network.Wai.Handler.Warp as Warp+import Network.Wai.Handler.WarpTLS (runTLS, tlsSettingsMemory)++data GSEnv = GSEnv+ { gsEnvPort :: Int,+ gsEnvSigVerify :: Bool,+ gsEnvSigHeaderName :: SigHeaderName,+ gsEnvEncryption :: Encryption,+ gsEnvTls :: Maybe (TlsData 'Server),+ gsEnvLogger :: Text -> IO (),+ gsEnvSigner :: Sig.MsgToSign -> IO (Maybe Sig.LndSig)+ }+ deriving stock (Generic)++instance FromJSON GSEnv where+ parseJSON =+ withObject+ "GSEnv"+ ( \x ->+ GSEnv+ <$> x .: "port"+ <*> x .: "sig_verify"+ <*> x .: "sig_header_name"+ <*> x .: "encryption"+ <*> x .:? "tls"+ <*> pure (const $ pure ())+ <*> pure (const $ pure Nothing)+ )++runServer ::+ GSEnv ->+ (GSEnv -> RawRequestBytes -> [ServiceHandler]) ->+ IO ()+runServer env handlers =+ case (gsEnvEncryption env, gsEnvTls env) of+ (Encrypted, Just tls) ->+ runTLS+ ( tlsSettingsMemory+ (TE.encodeUtf8 . coerce $ tlsCert tls)+ (TE.encodeUtf8 . coerce $ tlsKey tls)+ )+ (setPort port defaultSettings)+ (Encrypted, Nothing) ->+ error $+ "Fatal error - can not run LSP gRPC endpoint"+ <> " over TLS unless TlsData is provided!"+ (UnEncrypted, _) ->+ Warp.run port+ $ if gsEnvSigVerify env+ then extractBodyBytesMiddleware env $ serverApp handlers+ else serverApp handlers env (RawRequestBytes mempty)+ where+ port = gsEnvPort env++serverApp ::+ (GSEnv -> RawRequestBytes -> [ServiceHandler]) ->+ GSEnv ->+ RawRequestBytes ->+ Application+serverApp handlers env body req rep = do+ let app = grpcApp [gzip] $ handlers env body+ app req middleware+ where+ sigHeaderName =+ from $ gsEnvSigHeaderName env+ middleware res = do+ modifyHTTP2Data req $ \http2data0 ->+ let http2data = fromMaybe defaultHTTP2Data http2data0+ in Just $+ http2data+ { http2dataTrailers =+ trailersMaker+ mempty+ (http2dataTrailers http2data)+ }+ rep $+ mapResponseHeaders+ (\hs -> ("trailer", sigHeaderName) : hs)+ res+ trailersMaker acc oldMaker Nothing = do+ ts <- oldMaker Nothing+ case ts of+ Trailers ss -> do+ mSig <- gsEnvSigner env $ Sig.MsgToSign acc+ pure $ case mSig of+ Nothing ->+ ts+ Just sig ->+ Trailers $+ ( CI.mk sigHeaderName,+ B64.encode $ Sig.unLndSig sig+ ) :+ ss+ NextTrailersMaker {} ->+ throwIO $+ GRPCStatus+ INTERNAL+ "UNEXPECTED_NEW_TRAILERS_MAKER"+ trailersMaker acc oldMaker (Just bs) = do+ pure+ . NextTrailersMaker+ $ trailersMaker (acc <> bs) oldMaker++extractBodyBytesMiddleware ::+ GSEnv ->+ (GSEnv -> RawRequestBytes -> Application) ->+ Application+extractBodyBytesMiddleware env app req resp = do+ body <- BSL.toStrict <$> strictRequestBody req+ gsEnvLogger env $+ "Server ==> extracted raw request body"+ <> inspect body+ body' <- newMVar body+ app env (RawRequestBytes body) (req' body') resp+ where+ requestBody' mvar =+ modifyMVar+ mvar+ ( \b ->+ pure $+ if b == mempty+ then (mempty, mempty)+ else (mempty, b)+ )+ req' b =+ req+ { requestBody = requestBody' b+ }
@@ -0,0 +1,88 @@+module BtcLsp.Grpc.Sig+ ( MsgToSign (..),+ LndSig (..),+ sigToVerify,+ msgToVerify,+ )+where++import BtcLsp.Data.Type+import BtcLsp.Grpc.Data+import BtcLsp.Import.External+import qualified Crypto.Hash as CH+import qualified Crypto.Secp256k1 as C+import qualified Data.ByteArray as BA+import qualified Data.ByteString as BS+import qualified Data.ByteString.Base64 as B64+import qualified Data.CaseInsensitive as CI+import Network.Wai.Internal (Request (..))++newtype MsgToSign = MsgToSign+ { unMsgToSign :: ByteString+ }+ deriving newtype+ ( Eq,+ Ord,+ Show,+ NFData+ )+ deriving stock+ ( Generic+ )++instance Out MsgToSign++newtype LndSig = LndSig+ { unLndSig :: ByteString+ }+ deriving newtype+ ( Eq,+ Ord,+ Show,+ NFData+ )+ deriving stock+ ( Generic+ )++instance Out LndSig++sigToVerify :: SigHeaderName -> Request -> Either Failure C.Sig+sigToVerify sigHeaderName waiReq = do+ (_, b64sig) <-+ maybeToRight+ ( FailureInt . FailureGrpcServer $+ "Missing "+ <> sigHeaderNameText+ <> " header"+ )+ . find (\x -> fst x == sigHeaderNameCI)+ $ requestHeaders waiReq+ let sigDer =+ B64.decodeLenient b64sig+ maybeToRight+ ( FailureInt . FailureGrpcServer $+ "Signature "+ <> sigHeaderNameText+ <> " import from der payload "+ <> inspectPlain sigDer+ <> " failed"+ )+ $ C.importSig sigDer+ where+ sigHeaderNameText =+ from sigHeaderName+ sigHeaderNameBS =+ from sigHeaderName+ sigHeaderNameCI =+ CI.mk sigHeaderNameBS++msgToVerify :: ByteString -> Maybe C.Msg+msgToVerify =+ C.msg+ . BS.pack+ . BA.unpack+ . hash256+ where+ hash256 :: ByteString -> CH.Digest CH.SHA256+ hash256 = CH.hash
@@ -0,0 +1,19 @@+module BtcLsp.Import+ ( module X,+ )+where++import BtcLsp.Class.Env as X (Env (..))+import BtcLsp.Class.Storage as X (Storage (..))+import BtcLsp.Data.Env as X (readRawConfig, withEnv)+import BtcLsp.Data.Kind as X+import BtcLsp.Data.Orphan as X ()+import BtcLsp.Data.Smart as X+import BtcLsp.Data.Type as X+import BtcLsp.Grpc.Combinator as X+import BtcLsp.Grpc.Orphan as X ()+import BtcLsp.Import.External as X+import BtcLsp.Math.Swap as X (SwapCap (..), newSwapCapM)+import BtcLsp.Storage.Model as X hiding (Key (..))+import BtcLsp.Text as X+import BtcLsp.Time as X
@@ -0,0 +1,155 @@+module BtcLsp.Import.External+ ( module X,+ )+where++import BtcLsp.Import.Witch as X+import Chronos as X (Timespan (..), stopwatch)+import Control.Concurrent.Async as X+ ( Async,+ asyncThreadId,+ cancel,+ linkOnly,+ wait,+ waitAnyCancel,+ waitAnySTM,+ )+import Control.Concurrent.STM as X (atomically)+import Control.Concurrent.STM.TChan as X+ ( TChan,+ dupTChan,+ newBroadcastTChan,+ newBroadcastTChanIO,+ readTChan,+ writeTChan,+ )+import Control.Concurrent.Thread.Delay as X (delay)+import Control.Error.Util as X (failWith, failWithM)+import Control.Monad.Extra as X (eitherM, maybeM)+import Control.Monad.Trans.Except as X+ ( catchE,+ except,+ throwE,+ withExceptT,+ )+import Crypto.Hash as X (Digest, SHA256 (..), hashWith, hashlazy)+import Crypto.Random as X (getRandomBytes)+import Data.Aeson as X+ ( FromJSON (..),+ FromJSONKey (..),+ Options (..),+ ToJSON,+ camelTo2,+ defaultOptions,+ fromJSON,+ genericParseJSON,+ )+import Data.Coerce as X (coerce)+import Data.Containers.ListUtils as X (nubOrd)+import Data.Either.Extra as X (fromEither)+import Data.EitherR as X (flipET, handleE)+import Data.List as X (partition)+import Data.List.Extra as X (notNull)+import Data.Maybe as X (fromJust)+import Data.Pool as X (Pool, destroyAllResources)+import Data.ProtoLens as X (defMessage)+import Data.ProtoLens.Encoding as X (decodeMessage, encodeMessage)+import Data.Ratio as X ((%))+import Data.Text as X (pack, unpack)+import Data.Time.Clock as X+ ( DiffTime,+ UTCTime,+ addUTCTime,+ diffTimeToPicoseconds,+ diffUTCTime,+ secondsToDiffTime,+ )+import Data.Tuple.Extra as X (uncurry3)+import Data.Type.Equality as X (type (==))+import Data.UUID as X (UUID)+import Database.Esqueleto.Legacy as X+ ( Entity (..),+ )+import GHC.Exts as X (IsList)+import Katip as X+ ( ColorStrategy (..),+ Environment (..),+ Katip (..),+ KatipContext (..),+ KatipContextT,+ LogContexts,+ LogEnv,+ LogStr (..),+ Namespace,+ Severity (..),+ Verbosity (..),+ bracketFormat,+ closeScribes,+ defaultScribeSettings,+ initLogEnv,+ jsonFormat,+ katipAddContext,+ logStr,+ logTM,+ mkHandleScribeWithFormatter,+ permitItem,+ registerScribe,+ runKatipContextT,+ sl,+ )+import Katip.Format.Time as X+ ( formatAsLogTime,+ )+import LndClient as X+ ( ChanId (..),+ LndError (..),+ MSat (..),+ NodePubKey (..),+ RHash (..),+ RPreimage (..),+ TxId (..),+ TxKind (..),+ Vout (..),+ )+import LndClient.Util as X+ ( spawnLink,+ txIdHex,+ withSpawnLink,+ )+import Network.GRPC.Client as X (CompressMode (..))+import Network.HTTP2.Client2 as X (HostName, PortNumber)+import Text.Casing as X (camel)+import Text.PrettyPrint.GenericPretty as X (Out (..))+import Text.PrettyPrint.GenericPretty.Import as X+ ( PrettyLog (..),+ SecretVision (..),+ inspect,+ inspectGenPlain,+ inspectPlain,+ inspectStr,+ inspectStrPlain,+ )+import Text.PrettyPrint.GenericPretty.Instance as X ()+import Text.Shakespeare.I18N as X (ToMessage (..))+import Universum as X hiding+ ( atomically,+ bracket,+ finally,+ on,+ print,+ set,+ show,+ state,+ swap,+ )+import UnliftIO as X+ ( MonadUnliftIO (..),+ UnliftIO (..),+ askRunInIO,+ bracket,+ finally,+ race,+ withRunInIO,+ withUnliftIO,+ )+import Yesod.Core as X (PathPiece (..), showIntegral)
@@ -0,0 +1,88 @@+module BtcLsp.Import.Psql+ ( module X,+ )+where++import Database.Esqueleto.Legacy as X+ ( BaseBackend,+ Entity (..),+ FullOuterJoin (..),+ InnerJoin (..),+ Key,+ LeftOuterJoin (..),+ LockingKind (..),+ PersistEntity (..),+ PersistField (..),+ PersistFieldSql (..),+ PersistValue (..),+ RawSql (..),+ RightOuterJoin (..),+ SqlBackend,+ SqlPersistT,+ SqlType (..),+ ToBackendKey,+ Unique,+ asc,+ deleteKey,+ desc,+ from,+ in_,+ isNothing,+ just,+ limit,+ locking,+ max_,+ min_,+ notIn,+ nothing,+ on,+ orderBy,+ rawExecute,+ rawSql,+ runMigration,+ runSqlPool,+ select,+ selectFirst,+ set,+ transactionUndo,+ unValue,+ update,+ updateCount,+ val,+ valList,+ where_,+ (!=.),+ (&&.),+ (+=.),+ (/=.),+ (<.),+ (=.),+ (==.),+ (>.),+ (>=.),+ (?.),+ (^.),+ (||.),+ )+import Database.Esqueleto.PostgreSQL as X+ ( upsertBy,+ )+import Database.Persist as X+ ( LiteralType (..),+ )+import Database.Persist.Class as X+ ( BackendKey,+ )+import Database.Persist.Postgresql as X+ ( ConnectionString,+ copyField,+ createPostgresqlPool,+ upsertManyWhere,+ )+import Database.Persist.Sql as X+ ( fromSqlKey,+ toSqlKey,+ )+import Database.Persist.TH as X+ ( derivePersistField,+ )
@@ -0,0 +1,139 @@+{-# LANGUAGE AllowAmbiguousTypes #-}+{-# LANGUAGE TypeApplications #-}+{-# OPTIONS_GHC -Wno-redundant-constraints #-}+{-# OPTIONS_HADDOCK show-extensions #-}++module BtcLsp.Import.Witch+ ( module X,+ from,+ into,+ via,+ tryFrom,+ tryVia,+ composeTry,+ composeTryRhs,+ composeTryLhs,+ )+where++import Data.Type.Equality (type (==))+import Universum+import Witch as X+ ( From,+ TryFrom,+ TryFromException (..),+ withSource,+ withTarget,+ )+import qualified Witch++from ::+ forall source target.+ ( From source target,+ 'False ~ (source == target)+ ) =>+ source ->+ target+from =+ Witch.from @source @target++into ::+ forall target source.+ ( From source target,+ 'False ~ (source == target)+ ) =>+ source ->+ target+into =+ Witch.into @target @source++via ::+ forall through source target.+ ( From source through,+ From through target,+ 'False ~ (source == through),+ 'False ~ (through == target)+ ) =>+ source ->+ target+via =+ Witch.via @through @source @target++tryFrom ::+ forall source target.+ ( TryFrom source target,+ 'False ~ (source == target)+ ) =>+ source ->+ Either (TryFromException source target) target+tryFrom =+ Witch.tryFrom @source @target++tryVia ::+ forall through source target.+ ( TryFrom source through,+ TryFrom through target,+ 'False ~ (source == through),+ 'False ~ (through == target)+ ) =>+ source ->+ Either (TryFromException source target) target+tryVia =+ tryFrom @through+ `composeTry` tryFrom++composeTry ::+ forall through source target.+ ( 'False ~ (source == through),+ 'False ~ (through == target)+ ) =>+ ( through ->+ Either (TryFromException through target) target+ ) ->+ ( source ->+ Either (TryFromException source through) through+ ) ->+ source ->+ Either (TryFromException source target) target+composeTry =+ Witch.composeTry @through @source @target++composeTryRhs ::+ forall through source target.+ ( 'False ~ (source == through),+ 'False ~ (through == target)+ ) =>+ (through -> target) ->+ ( source ->+ Either+ ( TryFromException source through+ )+ through+ ) ->+ source ->+ Either+ ( TryFromException source target+ )+ target+composeTryRhs =+ Witch.composeTryRhs @through @source @target++composeTryLhs ::+ forall through source target.+ ( 'False ~ (source == through),+ 'False ~ (through == target)+ ) =>+ ( through ->+ Either+ ( TryFromException through target+ )+ target+ ) ->+ (source -> through) ->+ source ->+ Either+ ( TryFromException source target+ )+ target+composeTryLhs =+ Witch.composeTryLhs @through @source @target
@@ -0,0 +1,146 @@+{-# LANGUAGE TypeApplications #-}++module BtcLsp.Math.OnChain+ ( trySatToMsat,+ tryMsatToSat,+ trySatToMsatT,+ tryMsatToSatT,+ trxDustLimit,+ trxHeadSize,+ trxInSize,+ trxOutSize,+ InQty (..),+ OutQty (..),+ SatPerVbyte (..),+ minFeeRate,+ trxEstSize,+ trxEstFee,+ )+where++import BtcLsp.Data.Type+import BtcLsp.Import.External+import qualified Network.Bitcoin as Btc+import qualified Universum++trySatToMsat ::+ Btc.BTC ->+ Either Failure MSat+trySatToMsat =+ first (FailureInt . FailureMath . Universum.show)+ . ( from @Word64+ `composeTryRhs` tryFrom @Integer+ `composeTryLhs` ((* 1000) . from)+ )++tryMsatToSat ::+ MSat ->+ Either Failure Btc.BTC+tryMsatToSat =+ first (FailureInt . FailureMath . Universum.show)+ . ( tryFrom @Rational @Btc.BTC+ `composeTryLhs` ((% 100000000000) . via @Word64)+ )++trySatToMsatT ::+ ( Monad m+ ) =>+ Btc.BTC ->+ ExceptT Failure m MSat+trySatToMsatT =+ except . trySatToMsat++tryMsatToSatT ::+ ( Monad m+ ) =>+ MSat ->+ ExceptT Failure m Btc.BTC+tryMsatToSatT =+ except . tryMsatToSat++trxDustLimit :: MSat+trxDustLimit =+ MSat $ 546 * 1000++--+-- NOTE : estimations are for the P2WPKH only+--++trxHeadSize :: Vbyte+trxHeadSize =+ Vbyte $ 105 % 10++trxInSize :: Vbyte+trxInSize =+ Vbyte 68++trxOutSize :: Vbyte+trxOutSize =+ Vbyte 31++newtype InQty = InQty+ { unInQty :: Natural+ }+ deriving newtype (Eq, Ord, Show, Num)+ deriving stock (Generic)++instance Out InQty++instance From InQty Natural++instance From Natural InQty++newtype OutQty = OutQty+ { unOutQty :: Natural+ }+ deriving newtype (Eq, Ord, Show, Num)+ deriving stock (Generic)++instance Out OutQty++instance From OutQty Natural++instance From Natural OutQty++newtype SatPerVbyte = SatPerVbyte+ { unSatPerVbyte :: Ratio Natural+ }+ deriving newtype (Eq, Ord, Show, Num)+ deriving stock (Generic)++instance Out SatPerVbyte++instance From SatPerVbyte (Ratio Natural)++instance From (Ratio Natural) SatPerVbyte++minFeeRate :: SatPerVbyte+minFeeRate = 1++trxEstSize :: InQty -> OutQty -> Vbyte+trxEstSize inQty outQty =+ trxHeadSize+ + Vbyte (via @Natural inQty) * trxInSize+ --+ -- TODO : LND estimator always requires +1 vout as a change+ -- even if change does not exit. So we should overpay+ -- a bit for non-existent output to use LND PSBTs.+ -- https://github.com/lightningnetwork/lnd/issues/5739+ --+ + Vbyte (via @Natural (outQty + 1)) * trxOutSize+ --+ -- TODO : For some reason LND estimator+ -- requires +1 vbyte overhead.+ --+ + Vbyte 1++trxEstFee ::+ InQty ->+ OutQty ->+ SatPerVbyte ->+ Either (TryFromException Natural MSat) MSat+trxEstFee inQty outQty satPerVbyte =+ (from @Word64 `composeTryRhs` tryFrom)+ . (* 1000)+ . (ceiling :: Ratio Natural -> Natural)+ $ from (trxEstSize inQty outQty) * from satPerVbyte
@@ -0,0 +1,112 @@+{-# LANGUAGE TypeApplications #-}++module BtcLsp.Math.Swap+ ( SwapCap (..),+ swapExpiryLimitInput,+ swapExpiryLimitInternal,+ swapLnMaxAmt,+ swapLnFeeRate,+ swapLnMinFee,+ newSwapCapM,+ newSwapIntoLnMinAmt,+ )+where++import BtcLsp.Class.Env+import BtcLsp.Data.Kind+import BtcLsp.Data.Type+import BtcLsp.Import.External+import qualified LndClient as Lnd++data SwapCap = SwapCap+ { swapCapUsr :: Money 'Usr 'Ln 'Fund,+ swapCapLsp :: Money 'Lsp 'Ln 'Fund,+ swapCapFee :: Money 'Lsp 'OnChain 'Gain+ }+ deriving stock+ ( Eq,+ Ord,+ Show,+ Generic+ )++instance Out SwapCap++swapExpiryLimitInput :: Lnd.Seconds+swapExpiryLimitInput =+ Lnd.Seconds $ (7 * 24 - 1) * 3600++swapExpiryLimitInternal :: Lnd.Seconds+swapExpiryLimitInternal =+ Lnd.Seconds 3600++swapLnMaxAmt :: Money 'Usr btcl 'Fund+swapLnMaxAmt =+ Money $ MSat 10000000000++swapLnFeeRate :: FeeRate+swapLnFeeRate =+ FeeRate 0.004++swapLnMinFee :: Money 'Lsp btcl 'Gain+swapLnMinFee =+ Money $ MSat 2000000++newSwapCapM ::+ ( Env m+ ) =>+ Money 'Usr 'OnChain 'Fund ->+ m (Maybe SwapCap)+newSwapCapM usrAmt = do+ minAmt <- getSwapIntoLnMinAmt+ pure $+ if usrAmt < minAmt+ then Nothing+ else+ Just+ SwapCap+ { swapCapUsr = usrLn,+ swapCapLsp = coerce usrLn,+ swapCapFee = from @Word64 $ ceiling feeRat+ }+ where+ usrFin :: Ratio Word64+ usrFin =+ from usrAmt % 1+ feeRat :: Ratio Word64+ feeRat =+ from @Word64+ . (* 1000)+ . ceiling+ . (/ 1000)+ . max (from swapLnMinFee % 1)+ $ usrFin * from swapLnFeeRate+ usrLn :: Money 'Usr 'Ln 'Fund+ usrLn =+ from @Word64+ . floor+ $ usrFin - feeRat++newSwapIntoLnMinAmt ::+ Money 'Chan 'Ln 'Fund ->+ Money 'Usr 'OnChain 'Fund+newSwapIntoLnMinAmt minCap =+ from @Word64+ . (* 1000)+ . ceiling+ $ usrInitMsat / 1000+ where+ minFee :: Ratio Word64+ minFee =+ from swapLnMinFee % 1+ usrFin :: Ratio Word64+ usrFin =+ from minCap % 2+ usrPerc :: Ratio Word64+ usrPerc =+ usrFin / (1 - from swapLnFeeRate)+ usrInitMsat :: Ratio Word64+ usrInitMsat =+ if usrPerc - usrFin >= minFee+ then usrPerc+ else usrFin + minFee
@@ -0,0 +1,174 @@+{-# LANGUAGE TemplateHaskell #-}++module BtcLsp.Psbt.PsbtOpener+ ( openChannelPsbt,+ OpenChannelPsbtResult (..),+ OpenUpdateEvt (..),+ )+where++import BtcLsp.Import+import qualified BtcLsp.Math.OnChain as Math+import BtcLsp.Psbt.Utils+ ( finalizePsbt,+ fundPsbtReq,+ lockUtxos,+ openChannelReq,+ psbtFinalizeReq,+ psbtVerifyReq,+ releaseUtxosLocks,+ releaseUtxosPsbtLocks,+ shimCancelReq,+ unspendUtxoLookup,+ )+import qualified Data.Map as M+import qualified LndClient as Lnd+import qualified LndClient.Data.ChannelPoint as Lnd+import qualified LndClient.Data.FinalizePsbt as FNP+import qualified LndClient.Data.FundPsbt as FP+import qualified LndClient.Data.ListUnspent as LU+import qualified LndClient.Data.OpenChannel as Lnd+import qualified LndClient.Data.OutPoint as OP+import qualified LndClient.RPC.Katip as Lnd+import qualified UnliftIO.Exception as UE+import qualified UnliftIO.STM as T++sumAmt :: [PsbtUtxo] -> MSat+sumAmt utxos = sum $ getAmt <$> utxos++autoSelectUtxos :: Env m => OnChainAddress 'Fund -> MSat -> ExceptT Failure m FP.FundPsbtResponse+autoSelectUtxos addr amt = withLndT Lnd.fundPsbt ($ req)+ where+ req = fundPsbtReq [] (M.fromList [(unOnChainAddress addr, amt)])++utxoLeaseToPsbtUtxo :: Map OP.OutPoint LU.Utxo -> FP.UtxoLease -> Maybe PsbtUtxo+utxoLeaseToPsbtUtxo l ul = psbtUtxo . LU.amountSat <$> M.lookup op l+ where+ op = FP.outpoint ul+ psbtUtxo amt =+ PsbtUtxo+ { getAmt = amt,+ getLockId = Just . UtxoLockId $ FP.id ul,+ getOutPoint = op+ }++mapLeaseUtxosToPsbtUtxo :: Env m => [FP.UtxoLease] -> ExceptT Failure m [PsbtUtxo]+mapLeaseUtxosToPsbtUtxo lockedUtxos = do+ releaseUtxosLocks lockedUtxos+ l <- unspendUtxoLookup+ newLockedUtxos <- lockUtxos (FP.outpoint <$> lockedUtxos)+ case sequence $ utxoLeaseToPsbtUtxo l <$> newLockedUtxos of+ Just us -> pure us+ Nothing -> do+ $(logTM) DebugS+ . logStr+ $ "Cannot find utxo in utxos:" <> inspect lockedUtxos <> " lookupMap: " <> inspect l+ throwE+ . FailureInt+ $ FailurePrivate "Cannot find utxo in unspent list"++fundChanPsbt ::+ (Env m) =>+ [PsbtUtxo] ->+ OnChainAddress 'Fund ->+ OnChainAddress 'Gain ->+ Money 'Lsp 'OnChain 'Gain ->+ ExceptT Failure m Lnd.Psbt+fundChanPsbt userUtxos chanFundAddr changeAddr lspFee = do+ let userFundingAmt = sumAmt userUtxos - coerce lspFee++ $(logTM) DebugS $+ logStr $+ "UserAmt:"+ <> inspect (sumAmt userUtxos)+ <> " LspFee:"+ <> inspect lspFee++ lspFunded <- autoSelectUtxos (coerce chanFundAddr) userFundingAmt+ lspUtxos <- mapLeaseUtxosToPsbtUtxo $ FP.lockedUtxos lspFunded+ let selectedInputsAmt = sumAmt lspUtxos+ $(logTM) DebugS $ logStr $ "Coins sum by lsp" <> inspect selectedInputsAmt+ let allInputs = getOutPoint <$> (userUtxos <> lspUtxos)+ numInps <-+ tryFromT "Psbt funding inputs length" (length allInputs)+ estFee <-+ tryFailureT "Psbt funding fee estimator" $+ Math.trxEstFee (Math.InQty numInps) (Math.OutQty 2) Math.minFeeRate+ --+ -- TODO: find exact additional cost of open trx+ --+ let fee = estFee + MSat 50000+ $(logTM) DebugS $ logStr $ "Est fee:" <> inspect fee+ let changeAmt = selectedInputsAmt - userFundingAmt + coerce lspFee - fee+ let outputs =+ if changeAmt > Math.trxDustLimit+ then+ [ (unOnChainAddress chanFundAddr, userFundingAmt * 2),+ (unOnChainAddress changeAddr, changeAmt)+ ]+ else+ [ (unOnChainAddress chanFundAddr, userFundingAmt * 2 + changeAmt)+ ]+ let req = fundPsbtReq allInputs (M.fromList outputs)+ releaseUtxosPsbtLocks (userUtxos <> lspUtxos)+ psbt <- withLndT Lnd.fundPsbt ($ req)+ pure $ Lnd.Psbt $ FP.fundedPsbt psbt++data OpenUpdateEvt = LndUpdate Lnd.OpenStatusUpdate | LndSubFail deriving stock (Generic)++instance Out OpenUpdateEvt++data OpenChannelPsbtResult = OpenChannelPsbtResult+ { tchan :: TChan OpenUpdateEvt,+ fundAsync :: Async (Either Failure Lnd.ChannelPoint)+ }++openChannelPsbt ::+ Env m =>+ [PsbtUtxo] ->+ NodePubKey ->+ OnChainAddress 'Gain ->+ Money 'Lsp 'OnChain 'Gain ->+ Privacy ->+ ExceptT Failure m OpenChannelPsbtResult+openChannelPsbt utxos toPubKey changeAddress lspFee private = do+ chan <- lift T.newTChanIO+ pcid <- Lnd.newPendingChanId+ let openChannelRequest =+ openChannelReq pcid toPubKey (coerce (2 * amt)) (coerce amt) private+ let subUpdates u = void . T.atomically . T.writeTChan chan $ LndUpdate u+ res <- lift . UE.tryAny . spawnLink $ do+ r <- withLnd (Lnd.openChannel subUpdates) ($ openChannelRequest)+ whenLeft r $ \e -> do+ $(logTM) ErrorS $ logStr $ "Open channel failed" <> inspect e+ void . T.atomically . T.writeTChan chan $ LndSubFail+ case res of+ Left e -> throwE . FailureInt . FailurePrivate $ inspect e+ Right _ -> do+ fundA <- lift . spawnLink $ runExceptT $ fundStep pcid chan+ pure $ OpenChannelPsbtResult chan fundA+ where+ amt = sumAmt utxos - coerce lspFee+ fundStep pcid chan = do+ upd <- T.atomically $ T.readTChan chan+ $(logTM) DebugS $ logStr $ "Got chan status update" <> inspect upd+ case upd of+ LndUpdate (Lnd.OpenStatusUpdate _ (Just (Lnd.OpenStatusUpdatePsbtFund (Lnd.ReadyForPsbtFunding faddr famt _)))) -> do+ $(logTM) DebugS $ logStr $ "Chan ready for funding at addr:" <> inspect faddr <> " with amt:" <> inspect famt+ psbt' <- fundChanPsbt utxos (unsafeNewOnChainAddress faddr) (coerce changeAddress) lspFee+ void $ withLndT Lnd.fundingStateStep ($ psbtVerifyReq pcid psbt')+ sPsbtResp <- finalizePsbt psbt'+ $(logTM) DebugS $ logStr $ "Used psbt for funding:" <> inspect sPsbtResp+ void $ withLndT Lnd.fundingStateStep ($ psbtFinalizeReq pcid (Lnd.Psbt $ FNP.signedPsbt sPsbtResp))+ fundStep pcid chan+ LndUpdate (Lnd.OpenStatusUpdate _ (Just (Lnd.OpenStatusUpdateChanPending p))) -> do+ $(logTM) DebugS $ logStr $ "Chan is pending... mining..." <> inspect p+ fundStep pcid chan+ LndUpdate (Lnd.OpenStatusUpdate _ (Just (Lnd.OpenStatusUpdateChanOpen (Lnd.ChannelOpenUpdate cp)))) -> do+ $(logTM) DebugS $ logStr $ "Chan is open" <> inspect cp+ pure cp+ LndSubFail -> do+ void $ withLndT Lnd.fundingStateStep ($ shimCancelReq pcid)+ void $ lockUtxos (getOutPoint <$> utxos)+ throwE (FailureInt $ FailurePrivate "Lnd subscription failed. Trying to cancel psbt flow. Its ok if cancel fails")+ _ -> throwE (FailureInt $ FailurePrivate "Unexpected update")
@@ -0,0 +1,185 @@+module BtcLsp.Psbt.Utils+ ( swapUtxoToPsbtUtxo,+ psbtShim,+ fundPsbtReq,+ openChannelReq,+ psbtVerifyReq,+ psbtFinalizeReq,+ finalizePsbt,+ unspendUtxoLookup,+ shimCancelReq,+ releaseUtxosPsbtLocks,+ releaseUtxosLocks,+ newLockId,+ lockUtxo,+ lockUtxos,+ )+where++import BtcLsp.Import+import qualified Data.ByteString.Lazy as L+import qualified Data.Digest.Pure.SHA as SHA+ ( bytestringDigest,+ sha256,+ )+import qualified Data.Map as M+import qualified LndClient as Lnd+import qualified LndClient.Data.FinalizePsbt as FNP+import qualified LndClient.Data.FundPsbt as FP+import qualified LndClient.Data.FundingPsbtFinalize as FPF+import qualified LndClient.Data.FundingPsbtVerify as FSS+import qualified LndClient.Data.FundingShimCancel as FSC+import qualified LndClient.Data.FundingStateStep as FSS+import qualified LndClient.Data.LeaseOutput as LO+import qualified LndClient.Data.ListUnspent as LU+import qualified LndClient.Data.OpenChannel as Lnd+import qualified LndClient.Data.OutPoint as OP+import qualified LndClient.Data.PsbtShim as PS+import qualified LndClient.Data.ReleaseOutput as RO+import qualified LndClient.RPC.Katip as Lnd+import qualified Universum++swapUtxoToPsbtUtxo :: SwapUtxo -> PsbtUtxo+swapUtxoToPsbtUtxo x =+ PsbtUtxo+ ( OP.OutPoint+ (coerce $ swapUtxoTxid x)+ (coerce $ swapUtxoVout x)+ )+ (coerce $ swapUtxoAmount x)+ (swapUtxoLockId x)++psbtShim :: Lnd.PendingChannelId -> PS.PsbtShim+psbtShim pcid =+ PS.PsbtShim+ { PS.pendingChanId = pcid,+ PS.basePsbt = Nothing,+ PS.noPublish = False+ }++fundPsbtReq :: [OP.OutPoint] -> Map Text MSat -> FP.FundPsbtRequest+fundPsbtReq inputs outputs =+ FP.FundPsbtRequest+ { FP.account = "",+ FP.template = FP.TxTemplate inputs outputs,+ FP.minConfs = 0,+ FP.spendUnconfirmed = True,+ FP.fee = FP.SatPerVbyte 1+ }++openChannelReq ::+ Lnd.PendingChannelId ->+ Lnd.NodePubKey ->+ Money 'Lsp 'Ln 'Gain ->+ Money 'Usr 'Ln 'Gain ->+ Privacy ->+ Lnd.OpenChannelRequest+openChannelReq pcid toNode totalFundAmt pushAmt private =+ Lnd.OpenChannelRequest+ { Lnd.nodePubkey = toNode,+ Lnd.localFundingAmount = coerce totalFundAmt,+ Lnd.pushMSat = Just $ coerce pushAmt,+ Lnd.targetConf = Nothing,+ Lnd.mSatPerByte = Nothing,+ Lnd.private = Just $ private == Private,+ Lnd.minHtlcMsat = Nothing,+ Lnd.remoteCsvDelay = Nothing,+ Lnd.minConfs = Nothing,+ Lnd.spendUnconfirmed = Nothing,+ Lnd.closeAddress = Nothing,+ Lnd.fundingShim = Just (psbtShim pcid)+ }++psbtVerifyReq :: Lnd.PendingChannelId -> Lnd.Psbt -> FSS.FundingStateStepRequest+psbtVerifyReq pcid fp =+ FSS.FundingStateStepPsbtVerifyRequest $+ FSS.FundingPsbtVerify+ { FSS.pendingChanId = pcid,+ FSS.fundedPsbt = fp,+ FSS.skipFinalize = False+ }++psbtFinalizeReq :: Lnd.PendingChannelId -> Lnd.Psbt -> FSS.FundingStateStepRequest+psbtFinalizeReq pcid sp =+ FSS.FundingStateStepPsbtFinalizeRequest $+ FPF.FundingPsbtFinalize+ { FPF.signedPsbt = sp,+ FPF.pendingChanId = pcid,+ FPF.finalRawTx = Lnd.RawTx ""+ }++shimCancelReq :: Lnd.PendingChannelId -> FSS.FundingStateStepRequest+shimCancelReq pcid =+ FSS.FundingStateStepShimCancelRequest $+ FSC.FundingShimCancel {FSC.pendingChanId = pcid}++finalizePsbt :: (Env m) => Lnd.Psbt -> ExceptT Failure m FNP.FinalizePsbtResponse+finalizePsbt psbt = withLndT Lnd.finalizePsbt ($ FNP.FinalizePsbtRequest (coerce psbt) "")++unspendUtxoLookup :: (Env m) => ExceptT Failure m (Map OP.OutPoint LU.Utxo)+unspendUtxoLookup = do+ allUtxos <- LU.utxos <$> withLndT Lnd.listUnspent ($ LU.ListUnspentRequest 0 maxBound "")+ pure $ foldr (\u acc -> M.insert (LU.outpoint u) u acc) M.empty allUtxos++releaseUtxosPsbtLocks ::+ ( Env m+ ) =>+ [PsbtUtxo] ->+ ExceptT Failure m ()+releaseUtxosPsbtLocks =+ mapM_+ ( \refUtxo ->+ whenJust+ (getLockId refUtxo)+ ( \lid ->+ void $+ withLndT+ Lnd.releaseOutput+ ( $+ RO.ReleaseOutputRequest+ (coerce lid)+ (Just $ getOutPoint refUtxo)+ )+ )+ )++releaseUtxosLocks ::+ ( Env m+ ) =>+ [FP.UtxoLease] ->+ ExceptT Failure m ()+releaseUtxosLocks =+ mapM_ (\r -> withLndT Lnd.releaseOutput ($ toROR r))+ where+ toROR (FP.UtxoLease id' op _) =+ RO.ReleaseOutputRequest id' (Just op)++newLockId :: OP.OutPoint -> UtxoLockId+newLockId u =+ UtxoLockId+ . L.toStrict+ . SHA.bytestringDigest+ . SHA.sha256+ $ txid <> ":" <> vout+ where+ txid = L.fromStrict . coerce $ OP.txid u+ vout = Universum.show $ OP.outputIndex u++lockUtxo :: (Env m) => OP.OutPoint -> ExceptT Failure m FP.UtxoLease+lockUtxo op = do+ void $+ withLndT+ Lnd.leaseOutput+ ($ LO.LeaseOutputRequest (coerce lockId) (Just op) expS)+ pure+ FP.UtxoLease+ { FP.id = coerce lockId,+ FP.expiration = expS,+ FP.outpoint = op+ }+ where+ expS :: Word64 = 3600 * 24 * 365 * 10+ lockId = newLockId op++lockUtxos :: (Env m) => [OP.OutPoint] -> ExceptT Failure m [FP.UtxoLease]+lockUtxos = mapM lockUtxo
@@ -0,0 +1,74 @@+{-# LANGUAGE TemplateHaskell #-}++module BtcLsp.Storage.Migration+ ( migrateAll,+ )+where++import BtcLsp.Import+import qualified BtcLsp.Import.Psql as Psql+import qualified Database.Persist.Migration as PsqlMig+import qualified Database.Persist.Migration.Postgres as PsqlMig++migrateBefore :: PsqlMig.Migration+migrateBefore =+ [ 1 PsqlMig.~> 2+ PsqlMig.:= [ dropFundInvHashConstraint,+ dropFundInvoice,+ dropFundInvHash,+ dropFundProof+ ]+ ]+ where+ dropFundInvHashConstraint =+ PsqlMig.RawOperation "Drop fund_inv_hash unique constraint" $+ lift . return $+ [PsqlMig.MigrateSql "ALTER TABLE IF EXISTS swap_into_ln DROP CONSTRAINT IF EXISTS unique_swap_into_ln_fund_inv_hash" []]+ dropFundInvoice =+ PsqlMig.RawOperation "Drop fund_invoice" $+ lift . return $+ [PsqlMig.MigrateSql "ALTER TABLE IF EXISTS swap_into_ln DROP COLUMN IF EXISTS fund_invoice" []]+ dropFundInvHash =+ PsqlMig.RawOperation "Drop fund_inv_hash" $+ lift . return $+ [PsqlMig.MigrateSql "ALTER TABLE IF EXISTS swap_into_ln DROP COLUMN IF EXISTS fund_inv_hash" []]+ dropFundProof =+ PsqlMig.RawOperation "Drop fund_proof" $+ lift . return $+ [PsqlMig.MigrateSql "ALTER TABLE IF EXISTS swap_into_ln DROP COLUMN IF EXISTS fund_proof" []]++--+-- TODO : add all needed indexes+--+migrateAfter :: PsqlMig.Migration+migrateAfter =+ [ 0 PsqlMig.~> 1 PsqlMig.:= [lnChanSearchIndexes]+ ]+ where+ lnChanSearchIndexesSql :: Text+ lnChanSearchIndexesSql =+ "CREATE INDEX IF NOT EXISTS "+ <> "ln_chan_status_idx "+ <> "ON ln_chan (status);"+ lnChanSearchIndexes =+ PsqlMig.RawOperation "Create LnChan search indexes" $+ lift . return $+ [PsqlMig.MigrateSql lnChanSearchIndexesSql []]++migrateAll :: (Storage m, KatipContext m) => m ()+migrateAll = do+ $(logTM) InfoS "Running Persistent BEFORE migrations..."+ runM migrateBefore+ $(logTM) InfoS "Running Persistent AUTO migrations..."+ runSql (Psql.runMigration migrateAuto)+ $(logTM) InfoS "Running Persistent AFTER migrations..."+ runM migrateAfter+ $(logTM) InfoS "Persistent database migrated!"+ where+ runM [] = return ()+ runM x = do+ pool <- getSqlPool+ liftIO $+ Psql.runSqlPool+ (PsqlMig.runMigration PsqlMig.defaultSettings x)+ pool
@@ -0,0 +1,74 @@+{-# LANGUAGE EmptyDataDecls #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE GADTs #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE StandaloneDeriving #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE UndecidableInstances #-}+{-# LANGUAGE NoStrictData #-}+{-# OPTIONS_GHC -Wno-missing-export-lists #-}+{-# OPTIONS_GHC -Wno-name-shadowing #-}++module BtcLsp.Storage.Model where++import BtcLsp.Class.Storage+import BtcLsp.Data.Kind+import BtcLsp.Data.Smart+import BtcLsp.Data.Type+import BtcLsp.Import.External+import qualified BtcLsp.Import.Psql as Psql+import Database.Persist.Quasi+import Database.Persist.TH+import qualified LndClient.Data.ChannelBackup as Lnd++-- You can define all of your database entities in the entities file.+-- You can find more information on persistent and how to declare entities+-- at:+-- http://www.yesodweb.com/book/persistent/+share+ [mkPersist sqlSettings, mkMigrate "migrateAuto"]+ $(persistFileWith lowerCaseSettings "config/model")++instance HasTable User where+ getTable = const UserTable++instance HasTable LnChan where+ getTable = const LnChanTable++instance HasTable SwapIntoLn where+ getTable = const SwapIntoLnTable++instance HasTable Block where+ getTable = const BlockTable++deriving stock instance Generic (Psql.Key User)++instance Out (Psql.Key User)++instance Out User++deriving stock instance Generic (Psql.Key SwapIntoLn)++instance Out (Psql.Key SwapIntoLn)++instance Out SwapIntoLn++deriving stock instance Generic (Psql.Key LnChan)++instance Out (Psql.Key LnChan)++instance Out LnChan++deriving stock instance Generic (Psql.Key Block)++instance Out (Psql.Key Block)++instance Out Block++deriving stock instance Generic (Psql.Key SwapUtxo)++instance Out (Psql.Key SwapUtxo)++instance Out SwapUtxo
@@ -0,0 +1,124 @@+module BtcLsp.Storage.Model.Block+ ( createUpdateConfirmedSql,+ getLatestSql,+ getBlockByHeightSql,+ getBlocksHigherSql,+ updateOrphanHigherSql,+ withLockedRowSql,+ )+where++import BtcLsp.Import hiding (Storage (..))+import qualified BtcLsp.Import.Psql as Psql+import qualified BtcLsp.Storage.Util as Util++createUpdateConfirmedSql ::+ ( MonadIO m+ ) =>+ BlkHeight ->+ BlkHash ->+ ReaderT Psql.SqlBackend m (Entity Block)+createUpdateConfirmedSql height hash = do+ ct <- getCurrentTime+ Psql.upsertBy+ (UniqueBlock hash)+ Block+ { blockHeight = height,+ blockHash = hash,+ blockStatus = BlkConfirmed,+ blockInsertedAt = ct,+ blockUpdatedAt = ct+ }+ [ BlockStatus Psql.=. Psql.val BlkConfirmed,+ BlockUpdatedAt Psql.=. Psql.val ct+ ]++getLatestSql ::+ ( MonadIO m+ ) =>+ ReaderT Psql.SqlBackend m (Maybe (Entity Block))+getLatestSql = do+ xs <- Psql.select $+ Psql.from $ \row -> do+ Psql.locking Psql.ForUpdate+ Psql.where_ $+ row Psql.^. BlockStatus+ Psql.==. Psql.val BlkConfirmed+ Psql.orderBy+ [ Psql.desc $+ row Psql.^. BlockHeight+ ]+ Psql.limit 1+ pure row+ pure $+ listToMaybe xs++getBlockByHeightSql ::+ ( MonadIO m+ ) =>+ BlkHeight ->+ ReaderT Psql.SqlBackend m [Entity Block]+getBlockByHeightSql blkHeight = do+ Psql.select $+ Psql.from $ \row -> do+ Psql.locking Psql.ForUpdate+ Psql.where_ $+ ( row Psql.^. BlockHeight+ Psql.==. Psql.val blkHeight+ )+ Psql.&&. ( row Psql.^. BlockStatus+ Psql.==. Psql.val BlkConfirmed+ )+ pure row++getBlocksHigherSql ::+ ( MonadIO m+ ) =>+ BlkHeight ->+ ReaderT Psql.SqlBackend m [Entity Block]+getBlocksHigherSql blkHeight = do+ Psql.select $+ Psql.from $ \row -> do+ Psql.locking Psql.ForUpdate+ Psql.where_ $+ ( row Psql.^. BlockHeight+ Psql.>. Psql.val blkHeight+ )+ Psql.&&. ( row Psql.^. BlockStatus+ Psql.==. Psql.val BlkConfirmed+ )+ pure row++updateOrphanHigherSql ::+ ( MonadIO m+ ) =>+ BlkHeight ->+ ReaderT Psql.SqlBackend m ()+updateOrphanHigherSql height = do+ ct <- getCurrentTime+ Psql.update $ \row -> do+ Psql.set+ row+ [ BlockStatus Psql.=. Psql.val BlkOrphan,+ BlockUpdatedAt Psql.=. Psql.val ct+ ]+ Psql.where_ $+ ( row Psql.^. BlockHeight+ Psql.>. Psql.val height+ )+ Psql.&&. ( row Psql.^. BlockStatus+ Psql.==. Psql.val BlkConfirmed+ )++withLockedRowSql ::+ ( MonadIO m+ ) =>+ BlockId ->+ (BlkStatus -> Bool) ->+ (Block -> ReaderT Psql.SqlBackend m a) ->+ ReaderT Psql.SqlBackend m (Either (Entity Block) a)+withLockedRowSql rowId pre action = do+ rowVal <- Util.lockByRow rowId+ if pre $ blockStatus rowVal+ then Right <$> action rowVal+ else pure . Left $ Entity rowId rowVal
@@ -0,0 +1,339 @@+{-# LANGUAGE TemplateHaskell #-}++module BtcLsp.Storage.Model.LnChan+ ( createUpdateSql,+ getByChannelPointSql,+ persistChannelUpdateSql,+ persistOpenedChannelsSql,+ persistClosedChannelsSql,+ getBySwapIdSql,+ getActiveNonSwapSql,+ )+where++import BtcLsp.Import+import qualified BtcLsp.Import.Psql as Psql+import qualified BtcLsp.Storage.Model.SwapIntoLn as SwapIntoLn+import qualified BtcLsp.Storage.Util as Util+import qualified Data.Set as Set+import qualified LndClient.Data.Channel as Channel+import qualified LndClient.Data.Channel as Lnd+import qualified LndClient.Data.ChannelBackup as Lnd+import qualified LndClient.Data.ChannelPoint as ChannelPoint+import qualified LndClient.Data.ChannelPoint as Lnd+import qualified LndClient.Data.CloseChannel as CloseChannel+import qualified LndClient.Data.CloseChannel as Lnd+import qualified LndClient.Data.SubscribeChannelEvents as Lnd++createUpdateSql ::+ ( MonadIO m+ ) =>+ SwapIntoLnId ->+ TxId 'Funding ->+ Vout 'Funding ->+ ReaderT Psql.SqlBackend m (Entity LnChan)+createUpdateSql swapId txid vout = do+ ct <- getCurrentTime+ Psql.upsertBy+ (UniqueLnChan txid vout)+ LnChan+ { lnChanSwapIntoLnId = Just swapId,+ lnChanFundingTxId = txid,+ lnChanFundingVout = vout,+ lnChanClosingTxId = Nothing,+ lnChanExtId = Nothing,+ lnChanBak = Nothing,+ lnChanStatus = LnChanStatusPendingOpen,+ lnChanInsertedAt = ct,+ lnChanUpdatedAt = ct,+ lnChanTransactedAt = ct,+ lnChanTotalSatoshisReceived = MSat 0,+ lnChanTotalSatoshisSent = MSat 0+ }+ [ LnChanSwapIntoLnId Psql.=. Psql.val (Just swapId),+ LnChanUpdatedAt Psql.=. Psql.val ct+ ]++getByChannelPointSql ::+ ( Storage m+ ) =>+ TxId 'Funding ->+ Vout 'Funding ->+ ReaderT Psql.SqlBackend m (Maybe (Entity LnChan))+getByChannelPointSql txid =+ Util.lockByUnique+ . UniqueLnChan txid++getBySwapIdSql ::+ ( Storage m+ ) =>+ SwapIntoLnId ->+ ReaderT Psql.SqlBackend m [Entity LnChan]+getBySwapIdSql swpId =+ Psql.select $+ Psql.from $ \c -> do+ Psql.where_ (c Psql.^. LnChanSwapIntoLnId Psql.==. Psql.val (Just swpId))+ pure c++getActiveNonSwapSql ::+ ( Storage m+ ) =>+ ReaderT Psql.SqlBackend m [Entity LnChan]+getActiveNonSwapSql =+ Psql.select $+ Psql.from $ \row -> do+ Psql.where_+ ( ( row Psql.^. LnChanStatus+ Psql.==. Psql.val LnChanStatusActive+ )+ Psql.&&. Psql.isNothing+ ( row Psql.^. LnChanSwapIntoLnId+ )+ )+ pure row++lazyUpdateSwapStatus ::+ ( MonadIO m+ ) =>+ Entity LnChan ->+ ReaderT Psql.SqlBackend m ()+lazyUpdateSwapStatus (Entity _ chanVal) = do+ whenJust (lnChanSwapIntoLnId chanVal) $ \swapKey ->+ when (lnChanStatus chanVal == LnChanStatusActive)+ . void+ . SwapIntoLn.withLockedRowSql swapKey (== SwapWaitingChan)+ . const+ $ SwapIntoLn.updateSucceededWithoutInvoiceSql swapKey++upsertChannelSql ::+ ( MonadIO m+ ) =>+ UTCTime ->+ Maybe LnChanStatus ->+ Lnd.Channel ->+ Maybe Lnd.SingleChanBackupBlob ->+ ReaderT Psql.SqlBackend m (Entity LnChan)+upsertChannelSql ct mSS chan mBak =+ maybeM+ (upsert mempty)+ (upsert . getOtherUpdates)+ $ Util.lockByUnique uniq+ where+ upsert otherUpdates = do+ chanEnt <-+ Psql.upsertBy+ uniq+ LnChan+ { lnChanSwapIntoLnId = Nothing,+ lnChanFundingTxId = txid,+ lnChanFundingVout = vout,+ lnChanClosingTxId = Nothing,+ lnChanExtId = extId,+ lnChanBak = mBak,+ lnChanStatus = ss,+ lnChanInsertedAt = ct,+ lnChanUpdatedAt = ct,+ lnChanTransactedAt = ct,+ lnChanTotalSatoshisReceived = rcv,+ lnChanTotalSatoshisSent = sent+ }+ $ [ LnChanExtId+ Psql.=. Psql.val extId,+ LnChanStatus+ Psql.=. Psql.val ss,+ LnChanUpdatedAt+ Psql.=. Psql.val ct+ ]+ <> maybe+ mempty+ (\x -> [LnChanBak Psql.=. Psql.val (Just x)])+ mBak+ <> otherUpdates+ lazyUpdateSwapStatus chanEnt+ pure chanEnt+ getOtherUpdates (Entity _ x) =+ if lnChanTotalSatoshisSent x == sent+ && lnChanTotalSatoshisReceived x == rcv+ then mempty+ else+ [ LnChanTotalSatoshisSent+ Psql.=. Psql.val sent,+ LnChanTotalSatoshisReceived+ Psql.=. Psql.val rcv,+ LnChanTransactedAt+ Psql.=. Psql.val ct+ ]+ ss =+ fromMaybe+ ( if Channel.active chan+ then LnChanStatusActive+ else LnChanStatusInactive+ )+ mSS+ cp = Channel.channelPoint chan+ txid = ChannelPoint.fundingTxId cp+ vout = ChannelPoint.outputIndex cp+ sent = Channel.totalSatoshisSent chan+ rcv = Channel.totalSatoshisReceived chan+ extId = Just $ Channel.chanId chan+ uniq = UniqueLnChan txid vout++upsertChannelPointSql ::+ ( MonadIO m+ ) =>+ UTCTime ->+ LnChanStatus ->+ Lnd.ChannelPoint ->+ ReaderT Psql.SqlBackend m (Entity LnChan)+upsertChannelPointSql ct ss (Lnd.ChannelPoint txid vout) =+ maybeM+ upsert+ (const upsert)+ $ Util.lockByUnique uniq+ where+ uniq = UniqueLnChan txid vout+ upsert = do+ chanEnt <-+ Psql.upsertBy+ uniq+ LnChan+ { lnChanSwapIntoLnId = Nothing,+ lnChanFundingTxId = txid,+ lnChanFundingVout = vout,+ lnChanExtId = Nothing,+ lnChanBak = Nothing,+ lnChanClosingTxId = Nothing,+ lnChanStatus = ss,+ lnChanInsertedAt = ct,+ lnChanUpdatedAt = ct,+ lnChanTransactedAt = ct,+ lnChanTotalSatoshisReceived = MSat 0,+ lnChanTotalSatoshisSent = MSat 0+ }+ [ LnChanStatus+ Psql.=. Psql.val ss,+ LnChanUpdatedAt+ Psql.=. Psql.val ct+ ]+ lazyUpdateSwapStatus chanEnt+ pure chanEnt++closedChannelUpsert ::+ ( MonadIO m+ ) =>+ UTCTime ->+ Lnd.ChannelCloseSummary ->+ ReaderT Psql.SqlBackend m (Entity LnChan)+closedChannelUpsert ct close =+ maybeM+ upsert+ (const upsert)+ $ Util.lockByUnique uniq+ where+ upsert =+ Psql.upsertBy+ uniq+ LnChan+ { lnChanSwapIntoLnId = Nothing,+ lnChanFundingTxId = fundTxId,+ lnChanFundingVout = fundVout,+ lnChanClosingTxId = closeTxId,+ lnChanExtId = extId,+ lnChanBak = Nothing,+ lnChanStatus = ss,+ lnChanInsertedAt = ct,+ lnChanUpdatedAt = ct,+ lnChanTransactedAt = ct,+ lnChanTotalSatoshisReceived = MSat 0,+ lnChanTotalSatoshisSent = MSat 0+ }+ [ LnChanExtId+ Psql.=. Psql.val extId,+ LnChanClosingTxId+ Psql.=. Psql.val closeTxId,+ LnChanStatus+ Psql.=. Psql.val ss,+ LnChanUpdatedAt+ Psql.=. Psql.val ct+ ]+ ss = LnChanStatusClosed+ cp = CloseChannel.chPoint close+ fundTxId = ChannelPoint.fundingTxId cp+ fundVout = ChannelPoint.outputIndex cp+ closeTxId = Just $ CloseChannel.closingTxId close+ extId = Just $ CloseChannel.chanId close+ uniq = UniqueLnChan fundTxId fundVout++persistChannelUpdateSql ::+ ( KatipContext m+ ) =>+ Lnd.ChannelEventUpdate ->+ ReaderT Psql.SqlBackend m (Entity LnChan)+persistChannelUpdateSql (Lnd.ChannelEventUpdate channelEvent _) = do+ $(logTM) DebugS . logStr $ inspect channelEvent+ ct <- getCurrentTime+ case channelEvent of+ Lnd.ChannelEventUpdateChannelOpenChannel chan ->+ upsertChannelSql ct (Just LnChanStatusOpened) chan Nothing+ Lnd.ChannelEventUpdateChannelActiveChannel cp ->+ upsertChannelPointSql ct LnChanStatusActive cp+ Lnd.ChannelEventUpdateChannelInactiveChannel cp ->+ upsertChannelPointSql ct LnChanStatusInactive cp+ Lnd.ChannelEventUpdateChannelClosedChannel close ->+ closedChannelUpsert ct close+ Lnd.ChannelEventUpdateChannelFullyResolved cp ->+ upsertChannelPointSql ct LnChanStatusFullyResolved cp+ Lnd.ChannelEventUpdateChannelPendingOpenChannel+ (Lnd.PendingUpdate txid vout) ->+ upsertChannelPointSql ct LnChanStatusPendingOpen $+ Lnd.ChannelPoint txid vout++persistOpenedChannelsSql ::+ ( MonadIO m+ ) =>+ [(Lnd.Channel, Maybe Lnd.SingleChanBackupBlob)] ->+ ReaderT Psql.SqlBackend m [Entity LnChan]+persistOpenedChannelsSql cs = do+ ct <- getCurrentTime+ forM (sortOn (Channel.channelPoint . fst) cs) $+ uncurry (upsertChannelSql ct Nothing)++getNonClosedSql ::+ ( MonadIO m+ ) =>+ ReaderT Psql.SqlBackend m [Entity LnChan]+getNonClosedSql =+ Psql.select $+ Psql.from $ \row -> do+ Psql.where_+ ( row Psql.^. LnChanStatus+ Psql.!=. Psql.val LnChanStatusClosed+ )+ pure row++persistClosedChannelsSql ::+ ( MonadIO m+ ) =>+ [Lnd.ChannelCloseSummary] ->+ ReaderT Psql.SqlBackend m [Entity LnChan]+persistClosedChannelsSql [] = pure mempty+persistClosedChannelsSql csRaw = do+ ct <- getCurrentTime+ nonClosedList <- getNonClosedSql+ let nonClosedSet =+ fromList $+ ( \(Entity {entityVal = x}) ->+ Lnd.ChannelPoint+ (lnChanFundingTxId x)+ (lnChanFundingVout x)+ )+ <$> nonClosedList+ let csUpd =+ sortOn CloseChannel.chPoint $+ filter+ ( (`Set.member` nonClosedSet)+ . CloseChannel.chPoint+ )+ csRaw+ forM csUpd $+ closedChannelUpsert ct
@@ -0,0 +1,409 @@+{-# LANGUAGE TemplateHaskell #-}++module BtcLsp.Storage.Model.SwapIntoLn+ ( createIgnoreSql,+ updateWaitingPeerSql,+ updateWaitingChanSql,+ updateExpiredSql,+ updateSucceededSql,+ getSwapsWaitingPeerSql,+ getSwapsWaitingChanSql,+ getSwapsAboutToExpirySql,+ updateSucceededWithoutInvoiceSql,+ getByUuidSql,+ getByFundAddressSql,+ withLockedRowSql,+ UtxoInfo (..),+ SwapInfo (..),+ )+where++import BtcLsp.Import hiding (Storage (..))+import qualified BtcLsp.Import.Psql as Psql+import qualified BtcLsp.Math.Swap as Math+import qualified BtcLsp.Storage.Util as Util++createIgnoreSql ::+ ( MonadIO m+ ) =>+ Entity User ->+ OnChainAddress 'Fund ->+ OnChainAddress 'Gain ->+ OnChainAddress 'Refund ->+ UTCTime ->+ Privacy ->+ ReaderT Psql.SqlBackend m (Entity SwapIntoLn)+createIgnoreSql userEnt fundAddr feeAndChangeAddr refundAddr expAt chanPrivacy = do+ ct <- getCurrentTime+ uuid <- newUuid+ --+ -- NOTE : Set initial amount to zero because+ -- we don't know how much user will deposit+ -- into on-chain address.+ --+ Psql.upsertBy+ (UniqueSwapIntoLnFundAddress fundAddr)+ SwapIntoLn+ { swapIntoLnUuid = uuid,+ swapIntoLnUserId = entityKey userEnt,+ swapIntoLnFundAddress = fundAddr,+ swapIntoLnLspFeeAndChangeAddress = feeAndChangeAddr,+ swapIntoLnRefundAddress = refundAddr,+ swapIntoLnChanCapUser = Money 0,+ swapIntoLnChanCapLsp = Money 0,+ swapIntoLnFeeLsp = Money 0,+ swapIntoLnFeeMiner = Money 0,+ swapIntoLnStatus = SwapWaitingFundChain,+ swapIntoLnPrivacy = chanPrivacy,+ swapIntoLnExpiresAt = expAt,+ swapIntoLnInsertedAt = ct,+ swapIntoLnUpdatedAt = ct+ }+ [ SwapIntoLnUpdatedAt+ Psql.=. Psql.val ct+ ]++updateWaitingPeerSql ::+ ( MonadIO m+ ) =>+ SwapIntoLnId ->+ SwapCap ->+ ReaderT Psql.SqlBackend m ()+updateWaitingPeerSql sid cap = do+ ct <- getCurrentTime+ Psql.update $ \row -> do+ Psql.set+ row+ [ SwapIntoLnChanCapUser+ Psql.=. Psql.val (swapCapUsr cap),+ SwapIntoLnChanCapLsp+ Psql.=. Psql.val (swapCapLsp cap),+ SwapIntoLnFeeLsp+ Psql.=. Psql.val (swapCapFee cap),+ SwapIntoLnStatus+ Psql.=. Psql.val SwapWaitingPeer,+ SwapIntoLnUpdatedAt+ Psql.=. Psql.val ct+ ]+ Psql.where_ $+ ( row Psql.^. SwapIntoLnId+ Psql.==. Psql.val sid+ )+ Psql.&&. ( row Psql.^. SwapIntoLnStatus+ `Psql.in_` Psql.valList+ [ SwapWaitingFundChain,+ SwapWaitingPeer+ ]+ )++updateWaitingChanSql ::+ ( MonadIO m+ ) =>+ SwapIntoLnId ->+ ReaderT Psql.SqlBackend m ()+updateWaitingChanSql id0 = do+ ct <- getCurrentTime+ Psql.update $ \row -> do+ Psql.set+ row+ [ SwapIntoLnStatus+ Psql.=. Psql.val SwapWaitingChan,+ SwapIntoLnUpdatedAt+ Psql.=. Psql.val ct+ ]+ Psql.where_ $+ ( row Psql.^. SwapIntoLnId+ Psql.==. Psql.val id0+ )+ Psql.&&. ( row Psql.^. SwapIntoLnStatus+ Psql.==. Psql.val SwapWaitingPeer+ )++updateExpiredSql ::+ ( MonadIO m,+ KatipContext m+ ) =>+ SwapIntoLnId ->+ ReaderT Psql.SqlBackend m ()+updateExpiredSql rowId = do+ ct <- getCurrentTime+ qty <- Psql.updateCount $ \row -> do+ Psql.set+ row+ [ SwapIntoLnStatus+ Psql.=. Psql.val SwapExpired,+ SwapIntoLnUpdatedAt+ Psql.=. Psql.val ct+ ]+ Psql.where_ $+ ( row Psql.^. SwapIntoLnId+ Psql.==. Psql.val rowId+ )+ Psql.&&. ( row Psql.^. SwapIntoLnStatus+ `Psql.in_` Psql.valList+ [ SwapWaitingFundChain,+ SwapWaitingPeer+ ]+ )+ when (qty /= 1)+ . $(logTM) ErrorS+ . logStr+ $ "Wrong expiry update result "+ <> inspect qty+ <> " for the swap "+ <> inspect rowId++updateSucceededWithoutInvoiceSql ::+ ( MonadIO m+ ) =>+ SwapIntoLnId ->+ ReaderT Psql.SqlBackend m ()+updateSucceededWithoutInvoiceSql sid = do+ ct <- getCurrentTime+ Psql.update $ \row -> do+ Psql.set+ row+ [ SwapIntoLnStatus+ Psql.=. Psql.val SwapSucceeded,+ SwapIntoLnUpdatedAt+ Psql.=. Psql.val ct+ ]+ Psql.where_ $+ ( row Psql.^. SwapIntoLnId+ Psql.==. Psql.val sid+ )+ Psql.&&. ( row Psql.^. SwapIntoLnStatus+ Psql.==. Psql.val SwapWaitingChan+ )++updateSucceededSql ::+ ( MonadIO m+ ) =>+ SwapIntoLnId ->+ ReaderT Psql.SqlBackend m ()+updateSucceededSql sid = do+ ct <- getCurrentTime+ Psql.update $ \row -> do+ Psql.set+ row+ [ SwapIntoLnStatus+ Psql.=. Psql.val SwapSucceeded,+ SwapIntoLnUpdatedAt+ Psql.=. Psql.val ct+ ]+ Psql.where_ $+ ( row Psql.^. SwapIntoLnId+ Psql.==. Psql.val sid+ )+ Psql.&&. ( row Psql.^. SwapIntoLnStatus+ Psql.==. Psql.val SwapWaitingChan+ )++getSwapsWaitingPeerSql ::+ ( MonadIO m+ ) =>+ ReaderT+ Psql.SqlBackend+ m+ [ ( Entity SwapIntoLn,+ Entity User+ )+ ]+getSwapsWaitingPeerSql =+ Psql.select $+ Psql.from $ \(swap `Psql.InnerJoin` user) -> do+ Psql.locking Psql.ForUpdate+ Psql.on+ ( swap Psql.^. SwapIntoLnUserId+ Psql.==. user Psql.^. UserId+ )+ Psql.where_+ ( swap Psql.^. SwapIntoLnStatus+ Psql.==. Psql.val SwapWaitingPeer+ )+ --+ -- TODO : some sort of exp backoff in case+ -- where user node is offline for a long time.+ -- Maybe limits, some proper retries etc.+ --+ pure (swap, user)++getSwapsWaitingChanSql ::+ ( MonadIO m+ ) =>+ ReaderT+ Psql.SqlBackend+ m+ [ ( Entity SwapIntoLn,+ Entity User+ )+ ]+getSwapsWaitingChanSql =+ Psql.select $+ Psql.from $ \(swap `Psql.InnerJoin` user) -> do+ Psql.locking Psql.ForUpdate+ Psql.on+ ( swap Psql.^. SwapIntoLnUserId+ Psql.==. user Psql.^. UserId+ )+ Psql.where_+ ( swap Psql.^. SwapIntoLnStatus+ Psql.==. Psql.val SwapWaitingChan+ )+ --+ -- TODO : some sort of exp backoff in case+ -- where user node is offline for a long time.+ -- Maybe limits, some proper retries etc.+ --+ pure (swap, user)++getSwapsAboutToExpirySql ::+ ( MonadIO m+ ) =>+ ReaderT Psql.SqlBackend m [Entity SwapIntoLn]+getSwapsAboutToExpirySql = do+ nearExpTime <- getFutureTime Math.swapExpiryLimitInternal+ Psql.select $+ Psql.from $ \row -> do+ Psql.locking Psql.ForUpdate+ Psql.where_+ ( ( row Psql.^. SwapIntoLnStatus+ `Psql.in_` Psql.valList+ --+ -- TODO : somehow handle corner case+ -- where channel is opening or already+ -- opened and waiting for the swap,+ -- but swap invoice has been expired.+ -- Maybe ask user for the new invoice in+ -- this case? Or maybe we can use keysend+ -- feature?+ --+ [ SwapWaitingFundChain,+ SwapWaitingPeer+ ]+ )+ Psql.&&. ( row Psql.^. SwapIntoLnExpiresAt+ Psql.<. Psql.val nearExpTime+ )+ )+ pure row++data UtxoInfo = UtxoInfo+ { utxoInfoUtxo :: Entity SwapUtxo,+ utxoInfoBlock :: Entity Block+ }+ deriving stock+ ( Eq,+ Show+ )++data SwapInfo = SwapInfo+ { swapInfoSwap :: Entity SwapIntoLn,+ swapInfoUser :: Entity User,+ swapInfoUtxo :: [UtxoInfo],+ swapInfoChan :: [Entity LnChan]+ }+ deriving stock+ ( Eq,+ Show+ )++getByUuidSql ::+ ( MonadIO m+ ) =>+ Uuid 'SwapIntoLnTable ->+ ReaderT Psql.SqlBackend m (Maybe SwapInfo)+getByUuidSql uuid =+ (prettifyGetByUuid <$>) $+ Psql.select $+ Psql.from $+ \( mUtxo+ `Psql.InnerJoin` mBlock+ `Psql.RightOuterJoin` swap+ `Psql.LeftOuterJoin` mChan+ `Psql.InnerJoin` user+ ) -> do+ Psql.on+ ( swap Psql.^. SwapIntoLnUserId+ Psql.==. user Psql.^. UserId+ )+ Psql.on+ ( mChan Psql.?. LnChanSwapIntoLnId+ Psql.==. Psql.just+ ( Psql.just $+ swap Psql.^. SwapIntoLnId+ )+ )+ Psql.on+ ( mUtxo Psql.?. SwapUtxoSwapIntoLnId+ Psql.==. Psql.just (swap Psql.^. SwapIntoLnId)+ )+ Psql.on+ ( mUtxo Psql.?. SwapUtxoBlockId+ Psql.==. mBlock Psql.?. BlockId+ )+ Psql.where_+ ( swap Psql.^. SwapIntoLnUuid+ Psql.==. Psql.val uuid+ )+ pure (mUtxo, mBlock, mChan, swap, user)++prettifyGetByUuid ::+ [ ( Maybe (Entity SwapUtxo),+ Maybe (Entity Block),+ Maybe (Entity LnChan),+ Entity SwapIntoLn,+ Entity User+ )+ ] ->+ Maybe SwapInfo+prettifyGetByUuid = \case+ [] ->+ Nothing+ xs@((_, _, _, swap, user) : _) ->+ Just+ SwapInfo+ { swapInfoSwap = swap,+ swapInfoUser = user,+ swapInfoUtxo =+ ( \(mUtxo, mBlock, _, _, _) ->+ maybe+ mempty+ pure+ $ UtxoInfo+ <$> mUtxo+ <*> mBlock+ )+ =<< xs,+ swapInfoChan =+ nubOrd $+ ( \(_, _, mChan, _, _) ->+ maybe+ mempty+ pure+ mChan+ )+ =<< xs+ }++getByFundAddressSql ::+ ( MonadIO m+ ) =>+ OnChainAddress 'Fund ->+ ReaderT Psql.SqlBackend m (Maybe (Entity SwapIntoLn))+getByFundAddressSql =+ Util.lockByUnique+ . UniqueSwapIntoLnFundAddress++withLockedRowSql ::+ ( MonadIO m+ ) =>+ SwapIntoLnId ->+ (SwapStatus -> Bool) ->+ (SwapIntoLn -> ReaderT Psql.SqlBackend m a) ->+ ReaderT Psql.SqlBackend m (Either (Entity SwapIntoLn) a)+withLockedRowSql rowId pre action = do+ rowVal <- Util.lockByRow rowId+ if pre $ swapIntoLnStatus rowVal+ then Right <$> action rowVal+ else pure . Left $ Entity rowId rowVal
@@ -0,0 +1,249 @@+module BtcLsp.Storage.Model.SwapUtxo+ ( createIgnoreManySql,+ getSpendableUtxosBySwapIdSql,+ updateUnspentChanReserveSql,+ updateSpentChanSwappedSql,+ updateRefundedSql,+ updateOrphanSql,+ getUtxosForRefundSql,+ getUtxosBySwapIdSql,+ updateRefundBlockIdSql,+ revertRefundedSql,+ )+where++import BtcLsp.Import hiding (Storage (..))+import qualified BtcLsp.Import.Psql as Psql++createIgnoreManySql ::+ ( MonadIO m+ ) =>+ [SwapUtxo] ->+ ReaderT Psql.SqlBackend m ()+createIgnoreManySql us =+ Psql.upsertManyWhere+ us+ [Psql.copyField SwapUtxoUpdatedAt]+ mempty+ mempty++getSpendableUtxosBySwapIdSql ::+ ( MonadIO m+ ) =>+ SwapIntoLnId ->+ ReaderT Psql.SqlBackend m [Entity SwapUtxo]+getSpendableUtxosBySwapIdSql swapId = do+ Psql.select $+ Psql.from $ \row -> do+ Psql.locking Psql.ForUpdate+ Psql.where_+ ( ( row Psql.^. SwapUtxoSwapIntoLnId+ Psql.==. Psql.val swapId+ )+ Psql.&&. ( row Psql.^. SwapUtxoStatus+ `Psql.in_` Psql.valList+ [ SwapUtxoUnspent,+ SwapUtxoUnspentChanReserve+ ]+ )+ )+ pure row++updateUnspentChanReserveSql ::+ ( MonadIO m+ ) =>+ [SwapUtxoId] ->+ ReaderT Psql.SqlBackend m RowQty+updateUnspentChanReserveSql ids = do+ ct <- getCurrentTime+ res <- Psql.updateCount $ \row -> do+ Psql.set+ row+ [ SwapUtxoStatus+ Psql.=. Psql.val SwapUtxoUnspentChanReserve,+ SwapUtxoUpdatedAt+ Psql.=. Psql.val ct+ ]+ Psql.where_ $+ ( row Psql.^. SwapUtxoId+ `Psql.in_` Psql.valList ids+ )+ Psql.&&. ( row Psql.^. SwapUtxoStatus+ `Psql.in_` Psql.valList+ [ SwapUtxoUnspent,+ SwapUtxoUnspentChanReserve+ ]+ )+ pure $ from res++updateSpentChanSwappedSql ::+ ( MonadIO m+ ) =>+ SwapIntoLnId ->+ ReaderT Psql.SqlBackend m ()+updateSpentChanSwappedSql id0 = do+ ct <- getCurrentTime+ Psql.update $ \row -> do+ Psql.set+ row+ [ SwapUtxoStatus Psql.=. Psql.val SwapUtxoSpentChanSwapped,+ SwapUtxoUpdatedAt Psql.=. Psql.val ct+ ]+ Psql.where_ $+ ( row Psql.^. SwapUtxoSwapIntoLnId+ Psql.==. Psql.val id0+ )+ Psql.&&. ( row Psql.^. SwapUtxoStatus+ `Psql.in_` Psql.valList+ [ SwapUtxoUnspentChanReserve+ ]+ )++updateRefundedSql ::+ ( MonadIO m+ ) =>+ [SwapUtxoId] ->+ TxId 'Funding ->+ ReaderT Psql.SqlBackend m ()+updateRefundedSql ids rTxId = do+ ct <- getCurrentTime+ Psql.update $ \row -> do+ Psql.set+ row+ [ SwapUtxoStatus Psql.=. Psql.val SwapUtxoSpentRefund,+ SwapUtxoRefundTxId Psql.=. Psql.val (Just rTxId),+ SwapUtxoUpdatedAt Psql.=. Psql.val ct+ ]+ Psql.where_ $+ ( row Psql.^. SwapUtxoId+ `Psql.in_` Psql.valList ids+ )+ Psql.&&. ( row Psql.^. SwapUtxoStatus+ `Psql.in_` Psql.valList+ [ SwapUtxoUnspent,+ SwapUtxoUnspentChanReserve+ ]+ )++getUtxosForRefundSql ::+ ( MonadIO m+ ) =>+ ReaderT+ Psql.SqlBackend+ m+ [(Entity SwapUtxo, Entity SwapIntoLn)]+getUtxosForRefundSql =+ Psql.select $+ Psql.from $ \(swap `Psql.InnerJoin` utxo) -> do+ Psql.locking Psql.ForUpdate+ Psql.on+ ( (swap Psql.^. SwapIntoLnId)+ Psql.==. (utxo Psql.^. SwapUtxoSwapIntoLnId)+ )+ Psql.where_+ ( ( ( swap Psql.^. SwapIntoLnStatus+ Psql.==. Psql.val SwapExpired+ )+ Psql.&&. ( utxo Psql.^. SwapUtxoStatus+ `Psql.in_` Psql.valList+ [ SwapUtxoUnspent,+ SwapUtxoUnspentChanReserve+ ]+ )+ )+ Psql.||. ( ( swap Psql.^. SwapIntoLnStatus+ Psql.==. Psql.val SwapSucceeded+ )+ Psql.&&. ( utxo Psql.^. SwapUtxoStatus+ Psql.==. Psql.val+ SwapUtxoUnspent+ )+ )+ )+ pure (utxo, swap)++getUtxosBySwapIdSql ::+ ( MonadIO m+ ) =>+ SwapIntoLnId ->+ ReaderT Psql.SqlBackend m [Entity SwapUtxo]+getUtxosBySwapIdSql swapId = do+ Psql.select $+ Psql.from $ \row -> do+ Psql.locking Psql.ForUpdate+ Psql.where_+ ( row Psql.^. SwapUtxoSwapIntoLnId+ Psql.==. Psql.val swapId+ )+ pure row++updateRefundBlockIdSql ::+ ( MonadIO m+ ) =>+ BlockId ->+ ReaderT Psql.SqlBackend m ()+updateRefundBlockIdSql blkId = do+ utxos <- Psql.select $+ Psql.from $ \row -> do+ Psql.where_+ ( row Psql.^. SwapUtxoBlockId+ Psql.==. Psql.val blkId+ )+ pure row+ Psql.update $ \row -> do+ Psql.set+ row+ [ SwapUtxoRefundBlockId+ Psql.=. Psql.val (Just blkId)+ ]+ Psql.where_ $+ row Psql.^. SwapUtxoRefundTxId+ `Psql.in_` Psql.valList (Just <$> (swapUtxoTxid . entityVal <$> utxos))+ Psql.&&. ( row Psql.^. SwapUtxoStatus+ Psql.==. Psql.val SwapUtxoSpentRefund+ )++updateOrphanSql ::+ ( MonadIO m+ ) =>+ [BlockId] ->+ ReaderT Psql.SqlBackend m ()+updateOrphanSql ids = do+ ct <- getCurrentTime+ Psql.update $ \row -> do+ Psql.set+ row+ [ SwapUtxoStatus+ Psql.=. Psql.val SwapUtxoOrphan,+ SwapUtxoUpdatedAt+ Psql.=. Psql.val ct+ ]+ Psql.where_ $+ row Psql.^. SwapUtxoBlockId+ `Psql.in_` Psql.valList ids++revertRefundedSql ::+ ( MonadIO m+ ) =>+ [BlockId] ->+ ReaderT Psql.SqlBackend m ()+revertRefundedSql ids = do+ ct <- getCurrentTime+ Psql.update $ \row -> do+ Psql.set+ row+ [ SwapUtxoStatus+ Psql.=. Psql.val SwapUtxoUnspent,+ SwapUtxoRefundTxId+ Psql.=. Psql.val Nothing,+ SwapUtxoRefundBlockId+ Psql.=. Psql.val Nothing,+ SwapUtxoUpdatedAt+ Psql.=. Psql.val ct+ ]+ Psql.where_ $+ row Psql.^. SwapUtxoRefundBlockId+ `Psql.in_` Psql.valList (Just <$> ids)+ Psql.&&. ( row Psql.^. SwapUtxoStatus+ Psql.==. Psql.val SwapUtxoSpentRefund+ )
@@ -0,0 +1,57 @@+{-# LANGUAGE TypeApplications #-}++module BtcLsp.Storage.Model.User+ ( createVerifySql,+ )+where++import BtcLsp.Data.Orphan ()+import BtcLsp.Import hiding (Storage (..))+import qualified BtcLsp.Import.Psql as Psql+import qualified BtcLsp.Storage.Util as Util++--+-- NOTE : We will not create withVerifiedNonce+-- for now to reduce complexity overall.+-- Plus this combinator enables all kinds of+-- possibilities for deadlocks.+--+createVerifySql ::+ ( MonadIO m+ ) =>+ NodePubKey ->+ Nonce ->+ ReaderT Psql.SqlBackend m (Either Failure (Entity User))+createVerifySql pub nonce = do+ ct <- getCurrentTime+ let zeroRow =+ User+ { userNodePubKey = pub,+ userLatestNonce = from @Word64 0,+ userInsertedAt = ct,+ userUpdatedAt = ct+ }+ rowId <-+ entityKey+ <$> Psql.upsertBy+ (UniqueUser pub)+ zeroRow+ [ UserUpdatedAt Psql.=. Psql.val ct+ ]+ existingRow <- Util.lockByRow rowId+ if (existingRow == zeroRow)+ || (userLatestNonce existingRow < nonce)+ then+ Right+ <$> Psql.upsertBy+ (UniqueUser pub)+ zeroRow+ { userLatestNonce = nonce+ }+ [ UserLatestNonce Psql.=. Psql.val nonce,+ UserUpdatedAt Psql.=. Psql.val ct+ ]+ else+ pure+ . Left+ $ FailureInp FailureNonce
@@ -0,0 +1,78 @@+module BtcLsp.Storage.Util+ ( lockByTable,+ lockByRow,+ lockByUnique,+ )+where++import BtcLsp.Class.Storage+import BtcLsp.Data.Kind+import BtcLsp.Import.External+import qualified BtcLsp.Import.Psql as Psql+import qualified Database.Esqueleto.Legacy as Esqueleto+import qualified Universum++-- | This ugly fake type is here just to+-- make Haskell type system compatible+-- with weird Postgres semantics+-- for pg_advisory_xact_lock+data VoidSQL+ = VoidSQL++instance Psql.RawSql VoidSQL where+ rawSqlCols _ _ = (1, [])+ rawSqlColCountReason _ = ""+ rawSqlProcessRow [Psql.PersistNull] = Right VoidSQL+ rawSqlProcessRow _ = Left "Unexpected VoidSQL expr"++lockByTable :: (MonadIO m) => Table -> Psql.SqlPersistT m ()+lockByTable x =+ void+ ( Psql.rawSql+ "SELECT pg_advisory_xact_lock(?)"+ [Psql.PersistInt64 . from $ fromEnum x] ::+ (MonadIO m) => Psql.SqlPersistT m [VoidSQL]+ )++lockByRow ::+ ( MonadIO m,+ HasTable a,+ Psql.ToBackendKey Psql.SqlBackend a+ ) =>+ Psql.Key a ->+ Psql.SqlPersistT m a+lockByRow rowId = do+ void+ ( Psql.rawSql+ "SELECT pg_advisory_xact_lock(?,?)"+ [ Psql.PersistInt64 . from . fromEnum $ getTable rowId,+ Psql.PersistInt64 $ Psql.fromSqlKey rowId+ ] ::+ (MonadIO m) => Psql.SqlPersistT m [VoidSQL]+ )+ maybeM+ (error $ "Impossible missing row " <> Universum.show rowId)+ pure+ . (entityVal <<$>>)+ . (listToMaybe <$>)+ $ Psql.select $+ Psql.from $ \row -> do+ Psql.locking Psql.ForUpdate+ Psql.where_+ ( row Psql.^. Psql.persistIdField+ Psql.==. Psql.val rowId+ )+ pure row++lockByUnique ::+ ( MonadIO m,+ HasTable a,+ Psql.ToBackendKey Psql.SqlBackend a+ ) =>+ Psql.Unique a ->+ Psql.SqlPersistT m (Maybe (Entity a))+lockByUnique =+ maybeM+ (pure Nothing)+ (\(Entity x _) -> Just . Entity x <$> lockByRow x)+ . Esqueleto.getBy
@@ -0,0 +1,51 @@+module BtcLsp.Text+ ( toHex,+ toQr,+ displayRational,+ mkHtmlUuid,+ )+where++import BtcLsp.Import.External+import qualified Codec.QRCode as QR+ ( ErrorLevel (L),+ TextEncoding (Iso8859_1OrUtf8WithoutECI),+ defaultQRCodeOptions,+ encodeAutomatic,+ )+import qualified Codec.QRCode.JuicyPixels as JP+ ( toPngDataUrlT,+ )+import qualified Data.ByteString.Base16 as B16+import qualified Data.Text.Format.Numbers as F+import qualified Data.UUID as UUID+import qualified Data.UUID.V4 as UUID+import qualified Language.Haskell.TH.Syntax as TH++toHex :: ByteString -> Text+toHex =+ decodeUtf8+ . B16.encode++toQr :: Text -> Maybe Text+toQr =+ (toStrict . JP.toPngDataUrlT 4 5 <$>)+ . QR.encodeAutomatic+ (QR.defaultQRCodeOptions QR.L)+ QR.Iso8859_1OrUtf8WithoutECI++displayRational :: Int -> Rational -> Text+displayRational len =+ F.prettyF+ F.PrettyCfg+ { F.pc_decimals = len,+ F.pc_thousandsSep = Just ',',+ F.pc_decimalSep = '.'+ }++mkHtmlUuid :: TH.Q TH.Exp+mkHtmlUuid =+ TH.lift+ . ("uuid-" <>)+ . UUID.toText+ =<< TH.runIO UUID.nextRandom
@@ -0,0 +1,406 @@+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TypeApplications #-}++module BtcLsp.Thread.BlockScanner+ ( apply,+ scan,+ Utxo (..),+ extractRelatedUtxoFromBlock,+ mapVout,+ )+where++import BtcLsp.Data.Orphan ()+import qualified BtcLsp.Data.Smart as Smart+import BtcLsp.Import+import qualified BtcLsp.Import.Psql as Psql+import qualified BtcLsp.Math.OnChain as Math+import BtcLsp.Psbt.Utils (lockUtxo)+import qualified BtcLsp.Storage.Model.Block as Block+import qualified BtcLsp.Storage.Model.SwapIntoLn as SwapIntoLn+import qualified BtcLsp.Storage.Model.SwapUtxo as SwapUtxo+import qualified Data.Vector as V+import LndClient (txIdParser)+import qualified LndClient.Data.FundPsbt as FP+import qualified LndClient.Data.OutPoint as OP+import qualified LndClient.RPC.Katip as Lnd+import qualified Network.Bitcoin as Btc+import qualified Network.Bitcoin.BlockChain as Btc+import qualified Network.Bitcoin.Types as Btc+import qualified Universum++apply :: (Env m) => m ()+apply =+ forever $ do+ eitherM+ ( $(logTM) ErrorS+ . logStr+ . inspect+ )+ maybeFunded+ . runExceptT+ $ monitorOnChainLiquidity >> scan+ sleep300ms++maybeFunded :: (Env m) => [Utxo] -> m ()+maybeFunded [] =+ pure ()+maybeFunded utxos =+ mapM_ maybeFundSwap+ . nubOrd+ $ utxoSwapId <$> utxos++maybeFundSwap :: (Env m) => SwapIntoLnId -> m ()+maybeFundSwap swapId = do+ res <- runSql+ . SwapIntoLn.withLockedRowSql+ swapId+ (`elem` swapStatusChain)+ $ \swapVal -> do+ us <- SwapUtxo.getSpendableUtxosBySwapIdSql swapId+ let amt = sum $ swapUtxoAmount . entityVal <$> us+ mCap <- lift $ newSwapCapM amt+ $(logTM) DebugS . logStr $+ maybe+ ( "Not enough funds for "+ <> inspect swapId+ <> " with amt = "+ <> inspect amt+ )+ ( \cap ->+ "Marking funded "+ <> inspect swapId+ <> " with amt = "+ <> inspect amt+ <> " and cap = "+ <> inspect cap+ )+ mCap+ whenJust mCap $ \swapCap -> do+ qty <-+ SwapUtxo.updateUnspentChanReserveSql $+ entityKey <$> us+ if qty /= from (length us)+ then do+ Psql.transactionUndo+ $(logTM) ErrorS . logStr $+ "Funding update "+ <> inspect swapVal+ <> " failed for UTXOs "+ <> inspect us+ else+ SwapIntoLn.updateWaitingPeerSql+ swapId+ swapCap+ whenLeft res $+ $(logTM) WarningS+ . logStr+ . ("Funding failed due to wrong status " <>)+ . inspect++data Utxo = Utxo+ { utxoAmt :: MSat,+ utxoVout :: Vout 'Funding,+ utxoTxId :: TxId 'Funding,+ utxoSwapId :: SwapIntoLnId,+ utxoLockId :: Maybe UtxoLockId+ }+ deriving stock (Show)++mapVout ::+ ( Env m+ ) =>+ Btc.TransactionID ->+ Btc.TxOut ->+ m (Maybe Utxo)+mapVout txid (Btc.TxOut amt vout (Btc.StandardScriptPubKeyV22 _ _ _ addr)) =+ handleAddr addr amt vout txid+mapVout txid txout@(Btc.TxOut amt vout (Btc.StandardScriptPubKey _ _ _ _ addrsV)) =+ case V.toList addrsV of+ [addr] -> handleAddr addr amt vout txid+ _ -> do+ $(logTM) ErrorS . logStr $+ "Unsupported address vector in txid = "+ <> inspect txid+ <> " and txout = "+ <> Universum.show txout+ pure Nothing+mapVout _ (Btc.TxOut _ _ Btc.NonStandardScriptPubKey {}) =+ pure Nothing++handleAddr ::+ ( Env m+ ) =>+ Btc.Address ->+ Btc.BTC ->+ Integer ->+ Btc.TransactionID ->+ m (Maybe Utxo)+handleAddr addr amt vout txid = do+ mswp <- maybeSwap addr+ case mswp of+ Just swp ->+ newUtxo+ (Math.trySatToMsat amt)+ (tryFrom vout)+ (txIdParser $ Btc.unTransactionID txid)+ swp+ Nothing ->+ pure Nothing++newUtxo ::+ ( Env m+ ) =>+ Either Failure MSat ->+ Either (TryFromException Integer (Vout 'Funding)) (Vout 'Funding) ->+ Either LndError ByteString ->+ Entity SwapIntoLn ->+ m (Maybe Utxo)+newUtxo (Right amt) (Right n) (Right txid) swp =+ pure . Just $+ Utxo amt n (from txid) (entityKey swp) Nothing+newUtxo amt vout txid swp = do+ $(logTM) ErrorS . logStr $+ "TryFrom overflow error amt = "+ <> Universum.show amt+ <> " vout = "+ <> Universum.show vout+ <> " txid = "+ <> inspect txid+ <> " and swap = "+ <> inspect swp+ pure Nothing++extractRelatedUtxoFromBlock ::+ ( Env m+ ) =>+ Btc.BlockVerbose ->+ m [Utxo]+extractRelatedUtxoFromBlock blk =+ foldrM foldTrx [] $+ Btc.vSubTransactions blk+ where+ foldTrx trx acc = do+ utxos <-+ mapM (mapVout $ Btc.decTxId trx)+ . V.toList+ $ Btc.decVout trx+ pure $+ catMaybes utxos <> acc++persistBlockT ::+ ( Storage m,+ Env m+ ) =>+ Btc.BlockVerbose ->+ [Utxo] ->+ ExceptT Failure m ()+persistBlockT blk utxos = do+ height <-+ tryFromT "persistBlockT block height" $+ Btc.vBlkHeight blk+ lift . runSql $ do+ blockId <-+ entityKey+ <$> Block.createUpdateConfirmedSql+ height+ (from $ Btc.vBlockHash blk)+ ct <-+ getCurrentTime+ res <-+ Block.withLockedRowSql blockId (== BlkConfirmed)+ . const+ $ do+ SwapUtxo.createIgnoreManySql $+ newSwapUtxo ct blockId <$> utxos+ SwapUtxo.updateRefundBlockIdSql blockId+ whenLeft res $+ $(logTM) ErrorS+ . logStr+ . ("UTXOs are not persisted for the block " <>)+ . inspect++newSwapUtxo :: UTCTime -> BlockId -> Utxo -> SwapUtxo+newSwapUtxo ct blkId utxo = do+ SwapUtxo+ { swapUtxoSwapIntoLnId = utxoSwapId utxo,+ swapUtxoBlockId = blkId,+ swapUtxoTxid = utxoTxId utxo,+ swapUtxoVout = utxoVout utxo,+ swapUtxoAmount = from amt,+ swapUtxoStatus =+ if amt >= Math.trxDustLimit+ then SwapUtxoUnspent+ else SwapUtxoUnspentDust,+ swapUtxoRefundTxId = Nothing,+ swapUtxoRefundBlockId = Nothing,+ swapUtxoLockId = utxoLockId utxo,+ swapUtxoInsertedAt = ct,+ swapUtxoUpdatedAt = ct+ }+ where+ amt = utxoAmt utxo++scan ::+ ( Env m+ ) =>+ ExceptT Failure m [Utxo]+scan = do+ mBlk <- lift $ runSql Block.getLatestSql+ cHeight <-+ tryFromT "BlockScanner block count"+ =<< withBtcT Btc.getBlockCount id+ case mBlk of+ Nothing -> do+ $(logTM) DebugS . logStr $+ "Found no blocks, scanning height = "+ <> inspect cHeight+ scanOneBlock cHeight+ Just lBlk -> do+ reorgDetected <- detectReorg lBlk+ case reorgDetected of+ Nothing -> do+ let known = from . blockHeight $ entityVal lBlk+ scannerStep [] (1 + known) $ from cHeight+ Just height -> do+ $(logTM) WarningS . logStr $+ "Reorg detected from height = "+ <> inspect height+ bHeight <-+ tryFromT "BlockScanner reorg block height" height+ withExceptT+ ( FailureInt+ . FailurePrivate+ . ("Block scanner failed due to bad status " <>)+ . inspectPlain+ )+ . ExceptT+ . runSql+ . Block.withLockedRowSql+ (entityKey lBlk)+ (== BlkConfirmed)+ . const+ $ do+ blks <- Block.getBlocksHigherSql bHeight+ Block.updateOrphanHigherSql bHeight+ SwapUtxo.revertRefundedSql (entityKey <$> blks)+ SwapUtxo.updateOrphanSql (entityKey <$> blks)+ scannerStep [] (1 + coerce bHeight) $ from cHeight++scannerStep ::+ ( Env m+ ) =>+ [Utxo] ->+ Word64 ->+ Word64 ->+ ExceptT Failure m [Utxo]+scannerStep acc cur end =+ if cur > end+ then pure acc+ else do+ $(logTM) DebugS . logStr $+ "Scanner step cur = "+ <> inspect cur+ <> " end = "+ <> inspect end+ <> " got utxos qty = "+ <> inspect (length acc)+ utxos <- scanOneBlock (BlkHeight cur)+ scannerStep (acc <> utxos) (cur + 1) end++detectReorg ::+ ( Env m+ ) =>+ Entity Block ->+ ExceptT Failure m (Maybe Btc.BlockHeight)+detectReorg blk = do+ cReorgHeight <- checkReorgHeight cHeight+ pure $+ if cReorgHeight == cHeight+ then Nothing+ else Just cReorgHeight+ where+ cHeight =+ from . blockHeight $ entityVal blk++checkReorgHeight ::+ ( Env m+ ) =>+ Btc.BlockHeight ->+ ExceptT Failure m Btc.BlockHeight+checkReorgHeight bHeight = do+ res <- compareHash bHeight+ case res of+ Just True -> pure bHeight+ Just False -> checkReorgHeight (bHeight - 1)+ Nothing -> pure bHeight++compareHash ::+ ( Env m+ ) =>+ Btc.BlockHeight ->+ ExceptT Failure m (Maybe Bool)+compareHash height = do+ w64h <- tryFromT "BlockScanner compareHash" height+ cHash <- withBtcT Btc.getBlockHash ($ height)+ lift+ . ( (== cHash)+ . coerce+ . blockHash+ . entityVal+ <<$>>+ )+ . (listToMaybe <$>)+ . runSql+ . Block.getBlockByHeightSql+ $ BlkHeight w64h++scanOneBlock ::+ ( Env m+ ) =>+ BlkHeight ->+ ExceptT Failure m [Utxo]+scanOneBlock height = do+ hash <- withBtcT Btc.getBlockHash ($ from height)+ blk <- withBtcT Btc.getBlockVerbose ($ hash)+ $(logTM) DebugS . logStr $+ "Got new block with height = "+ <> inspect height+ <> " and hash = "+ <> inspect hash+ utxos <- lift $ extractRelatedUtxoFromBlock blk+ lockedUtxos <- mapM lockUtxo' utxos+ persistBlockT blk lockedUtxos+ pure utxos++--+-- TODO : Verify that it's possible to lock already locked UTXO.+-- It's corner case where UTXO has been locked but storage+-- procedure later failed.+--++utxoToOutPoint :: Utxo -> OP.OutPoint+utxoToOutPoint u = OP.OutPoint (coerce $ utxoTxId u) (coerce $ utxoVout u)++lockUtxo' :: Env m => Utxo -> ExceptT Failure m Utxo+lockUtxo' u = do+ l <- lockUtxo (utxoToOutPoint u)+ pure $ u {utxoLockId = Just $ UtxoLockId $ FP.id l}++maybeSwap ::+ ( Env m+ ) =>+ Btc.Address ->+ m (Maybe (Entity SwapIntoLn))+maybeSwap =+ runSql+ . SwapIntoLn.getByFundAddressSql+ . Smart.unsafeNewOnChainAddress++monitorOnChainLiquidity ::+ ( Env m+ ) =>+ ExceptT Failure m ()+monitorOnChainLiquidity =+ withLndT Lnd.walletBalance id+ >>= lift . monitorTotalOnChainLiquidity
@@ -0,0 +1,41 @@+{-# LANGUAGE TemplateHaskell #-}++module BtcLsp.Thread.Expirer+ ( apply,+ )+where++import BtcLsp.Data.Orphan ()+import BtcLsp.Import+import BtcLsp.Import.Psql as Psql+import qualified BtcLsp.Storage.Model.SwapIntoLn as SwapIntoLn++apply :: (Env m) => m ()+apply =+ forever $ do+ runSql $+ entityKey <<$>> SwapIntoLn.getSwapsAboutToExpirySql+ --+ -- NOTE : We need to always sort id list before working+ -- with the row locks to avoid possible deadlocks.+ --+ >>= mapM_ updateExpiredSwapSql . sort+ sleep300ms++updateExpiredSwapSql ::+ ( KatipContext m+ ) =>+ SwapIntoLnId ->+ ReaderT Psql.SqlBackend m ()+updateExpiredSwapSql rowId = do+ res <-+ SwapIntoLn.withLockedRowSql+ rowId+ (`elem` swapStatusChain)+ . const+ $ SwapIntoLn.updateExpiredSql rowId+ whenLeft res $+ $(logTM) ErrorS+ . logStr+ . ("Expiry update failed for the swap " <>)+ . inspect
@@ -0,0 +1,91 @@+{-# LANGUAGE TemplateHaskell #-}++module BtcLsp.Thread.LnChanOpener+ ( apply,+ )+where++import BtcLsp.Import+import qualified BtcLsp.Import.Psql as Psql+import qualified BtcLsp.Psbt.PsbtOpener as PO+import BtcLsp.Psbt.Utils (swapUtxoToPsbtUtxo)+import qualified BtcLsp.Storage.Model.LnChan as LnChan+import qualified BtcLsp.Storage.Model.SwapIntoLn as SwapIntoLn+import qualified BtcLsp.Storage.Model.SwapUtxo as SwapUtxo+import qualified Data.Set as Set+import qualified LndClient.Data.ChannelPoint as ChannelPoint+import qualified LndClient.Data.Peer as Peer+import qualified LndClient.RPC.Silent as LndSilent++apply :: (Env m) => m ()+apply =+ forever $ do+ ePeerList <-+ withLnd LndSilent.listPeers id+ whenLeft ePeerList $+ $(logTM) ErrorS+ . logStr+ . ("ListPeers procedure failed: " <>)+ . inspect+ let peerSet =+ Set.fromList $+ Peer.pubKey <$> fromRight [] ePeerList+ runSql $ do+ swaps <-+ filter+ ( \x ->+ Set.member+ (userNodePubKey . entityVal $ snd x)+ peerSet+ )+ <$> SwapIntoLn.getSwapsWaitingPeerSql+ mapM_+ (uncurry openChanSql)+ swaps+ sleep300ms++--+-- TODO : Do not open channel in case where+-- there not is enough liquidity to perform swap.+-- Maybe also put some limits into amount of+-- opening chans per user.+--+openChanSql ::+ ( Env m+ ) =>+ Entity SwapIntoLn ->+ Entity User ->+ ReaderT Psql.SqlBackend m ()+openChanSql (Entity swapKey _) userEnt = do+ res <-+ SwapIntoLn.withLockedRowSql swapKey (== SwapWaitingPeer) $+ \swapVal -> do+ utxos <- SwapUtxo.getSpendableUtxosBySwapIdSql swapKey+ cpEither <- lift . runExceptT $ do+ r <-+ PO.openChannelPsbt+ (swapUtxoToPsbtUtxo . entityVal <$> utxos)+ (userNodePubKey $ entityVal userEnt)+ (coerce $ swapIntoLnLspFeeAndChangeAddress swapVal)+ (coerce swapIntoLnFeeLsp swapVal)+ (swapIntoLnPrivacy swapVal)+ liftIO (wait $ PO.fundAsync r) >>= except+ either+ ( $(logTM) ErrorS . logStr+ . ("OpenChan procedure failed: " <>)+ . inspect+ )+ ( \cp ->+ LnChan.createUpdateSql+ swapKey+ (ChannelPoint.fundingTxId cp)+ (ChannelPoint.outputIndex cp)+ >> SwapIntoLn.updateWaitingChanSql swapKey+ >> SwapUtxo.updateSpentChanSwappedSql swapKey+ )+ cpEither+ whenLeft res $+ $(logTM) ErrorS+ . logStr+ . ("Channel opening failed due to wrong status " <>)+ . inspect
@@ -0,0 +1,127 @@+{-# LANGUAGE TemplateHaskell #-}++module BtcLsp.Thread.LnChanWatcher+ ( applyPoll,+ applySub,+ )+where++import BtcLsp.Import+import qualified BtcLsp.Storage.Model.LnChan as LnChan+import qualified Data.Set as Set+import qualified LndClient.Data.Channel as Lnd hiding (outputIndex)+import qualified LndClient.Data.ChannelBackup as Bak+import qualified LndClient.Data.ChannelPoint as Lnd+import LndClient.Data.ClosedChannels (ClosedChannelsRequest (..))+import LndClient.Data.ListChannels+import qualified LndClient.RPC.Silent as LndSilent++syncChannelList :: (Env m) => m ()+syncChannelList = do+ res <-+ runExceptT $ do+ openedChans <-+ withLndT+ LndSilent.listChannels+ ($ ListChannelsRequest False False False False Nothing)+ --+ -- TODO : get list of channels which are opened+ -- according database status, but not in openedChans+ -- list according lnd. Need to check are they closed+ -- and update status.+ --+ openedChansBak <-+ mapM+ ( \ch -> do+ let cp =+ Lnd.channelPoint ch+ let getBakT =+ Just . Bak.chanBackup+ <$> withLndT+ LndSilent.exportChannelBackup+ ($ Lnd.channelPoint ch)+ mCh <-+ lift+ . (entityVal <<$>>)+ . runSql+ . LnChan.getByChannelPointSql (Lnd.fundingTxId cp)+ $ Lnd.outputIndex cp+ mBak <-+ case mCh of+ Nothing -> getBakT+ Just (LnChan {lnChanBak = Nothing}) -> getBakT+ Just {} -> pure Nothing+ pure+ ( ch,+ mBak+ )+ )+ openedChans+ closedChans <-+ withLndT+ LndSilent.closedChannels+ ( $+ ClosedChannelsRequest+ False+ False+ False+ False+ False+ False+ )+ nonSwapSet <- lift . runSql $ do+ void $ LnChan.persistOpenedChannelsSql openedChansBak+ void $ LnChan.persistClosedChannelsSql closedChans+ nonSwapList <- LnChan.getActiveNonSwapSql+ pure . fromList $+ ( \(Entity {entityVal = x}) ->+ Lnd.ChannelPoint+ (lnChanFundingTxId x)+ (lnChanFundingVout x)+ )+ <$> nonSwapList+ let nonSwapChans =+ filter+ ( \x ->+ ( Lnd.channelPoint x+ `Set.member` nonSwapSet+ )+ && not (Lnd.prv x)+ && Lnd.active x+ )+ openedChans+ lift+ . monitorTotalExtOutgoingLiquidity+ . Liquidity+ . sum+ $ Lnd.localBalance <$> nonSwapChans+ lift+ . monitorTotalExtIncomingLiquidity+ . Liquidity+ . sum+ $ Lnd.remoteBalance <$> nonSwapChans+ whenLeft res $+ $(logTM) ErrorS . logStr+ . ("SyncChannelList failure " <>)+ . inspect++applyPoll :: (Env m) => m ()+applyPoll =+ forever $+ syncChannelList+ >> sleep300ms++applySub :: (Env m) => m ()+applySub =+ forever $ do+ lnd <- getLspLndEnv+ withRunInIO $ \run -> do+ void $+ LndSilent.subscribeChannelEvents+ ( void+ . run+ . runSql+ . LnChan.persistChannelUpdateSql+ )+ lnd+ sleep300ms
@@ -0,0 +1,137 @@+{-# LANGUAGE TemplateHaskell #-}++module BtcLsp.Thread.Main+ ( main,+ apply,+ waitForSync,+ )+where++import BtcLsp.Data.AppM (runApp)+import qualified BtcLsp.Data.Env as Env+import BtcLsp.Import+import qualified BtcLsp.Storage.Migration as Storage+import qualified BtcLsp.Thread.BlockScanner as BlockScanner+import qualified BtcLsp.Thread.Expirer as Expirer+import qualified BtcLsp.Thread.LnChanOpener as LnChanOpener+import qualified BtcLsp.Thread.LnChanWatcher as LnChanWatcher+import qualified BtcLsp.Thread.Refunder as Refunder+import qualified BtcLsp.Thread.Server as Server+import qualified BtcLsp.Yesod.Application as Yesod+import Katip+import qualified LndClient.Data.GetInfo as Lnd+import qualified LndClient.RPC.Katip as Lnd+import qualified Network.Bitcoin.BlockChain as Btc++main :: IO ()+main = do+ startupScribe <-+ mkHandleScribe ColorIfTerminal stdout (permitItem InfoS) V2+ let startupLogEnv =+ registerScribe+ "stdout"+ startupScribe+ defaultScribeSettings+ =<< initLogEnv "BtcLsp" "startup"+ cfg <- bracket startupLogEnv closeScribes $ \le ->+ runKatipContextT le (mempty :: LogContexts) mempty $ do+ $(logTM) InfoS "Lsp is starting!"+ $(logTM) InfoS "Reading lsp raw environment..."+ cfg <- liftIO readRawConfig+ let secret title x =+ logStr $+ title+ <> " = "+ <> inspect+ ( SecretLog (Env.rawConfigLogSecrets cfg) x+ )+ let btc = Env.rawConfigBtcEnv cfg+ $(logTM) InfoS $+ secret+ "rawConfigBtcEnv"+ [ ("host" :: Text, Env.bitcoindEnvHost btc),+ ("user", Env.bitcoindEnvUsername btc),+ ("pass", Env.bitcoindEnvPassword btc)+ ]+ $(logTM) InfoS "Creating lsp runtime environment..."+ pure cfg+ withEnv cfg $+ \env -> runApp env apply++apply :: (Env m) => m ()+apply = do+ $(logTM) InfoS "Waiting for bitcoind..."+ waitForBitcoindSync+ $(logTM) InfoS "Waiting for lnd unlock..."+ unlocked <- withLnd Lnd.lazyUnlockWallet id+ if isRight unlocked+ then do+ $(logTM) InfoS "Waiting for lnd sync..."+ waitForLndSync+ $(logTM) InfoS "Running postgres migrations..."+ Storage.migrateAll+ log <- getYesodLog+ pool <- getSqlPool+ $(logTM) InfoS "Spawning lsp threads..."+ xs <-+ mapM+ spawnLink+ [ Server.apply,+ LnChanWatcher.applySub,+ LnChanWatcher.applyPoll,+ LnChanOpener.apply,+ BlockScanner.apply,+ Refunder.apply,+ Expirer.apply,+ withUnliftIO $ Yesod.appMain log pool+ ]+ $(logTM) InfoS "Lsp is running!"+ liftIO+ . void+ $ waitAnyCancel xs+ else+ $(logTM) ErrorS . logStr $+ "Can not unlock wallet, got "+ <> inspect unlocked+ $(logTM) ErrorS "Lsp terminates!"++waitForBitcoindSync :: (Env m) => m ()+waitForBitcoindSync =+ eitherM+ ( \e -> do+ $(logTM) ErrorS . logStr $ inspect e+ waitAndRetry+ )+ ( \x ->+ when (Btc.bciInitialBlockDownload x) $ do+ $(logTM) InfoS . logStr $ "Waiting IBD: " <> inspect x+ waitAndRetry+ )+ $ withBtc Btc.getBlockChainInfo id+ where+ waitAndRetry :: (Env m) => m ()+ waitAndRetry =+ sleep5s >> waitForBitcoindSync++waitForLndSync :: (Env m) => m ()+waitForLndSync =+ eitherM+ ( \e -> do+ $(logTM) ErrorS . logStr $ inspect e+ waitAndRetry+ )+ ( \x ->+ unless (Lnd.syncedToChain x) $ do+ $(logTM) InfoS . logStr $ "Waiting Lnd: " <> inspect x+ waitAndRetry+ )+ $ withLnd Lnd.getInfo id+ where+ waitAndRetry :: (Env m) => m ()+ waitAndRetry =+ sleep5s >> waitForLndSync++waitForSync :: (Env m) => m ()+waitForSync =+ waitForBitcoindSync+ >> waitForLndSync
@@ -0,0 +1,205 @@+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TypeApplications #-}++module BtcLsp.Thread.Refunder+ ( apply,+ SendUtxosResult (..),+ )+where++import BtcLsp.Data.Orphan ()+import BtcLsp.Import+import qualified BtcLsp.Import.Psql as Psql+import qualified BtcLsp.Math.OnChain as Math+import BtcLsp.Psbt.Utils+ ( releaseUtxosLocks,+ releaseUtxosPsbtLocks,+ swapUtxoToPsbtUtxo,+ )+import qualified BtcLsp.Storage.Model.SwapIntoLn as SwapIntoLn+import qualified BtcLsp.Storage.Model.SwapUtxo as SwapUtxo+ ( getUtxosForRefundSql,+ updateRefundedSql,+ )+import Data.List (groupBy)+import qualified Data.Map as M+import LndClient (txIdParser)+import qualified LndClient.Data.FinalizePsbt as FNP+import qualified LndClient.Data.FundPsbt as FP+import qualified LndClient.Data.PublishTransaction as PT+import qualified LndClient.RPC.Katip as Lnd+import qualified Network.Bitcoin as Btc+import qualified Network.Bitcoin.Types as Btc++apply :: (Env m) => m ()+apply =+ forever $ do+ runSql $+ SwapUtxo.getUtxosForRefundSql+ >>= mapM_ processRefundSql+ . groupBy (\a b -> swpId a == swpId b)+ sleep300ms+ where+ swpId = entityKey . snd++data SendUtxosResult = SendUtxosResult+ { getGetDecTrx :: Btc.DecodedRawTransaction,+ getTotalAmt :: MSat,+ getFee :: MSat+ }++newtype TxLabel = TxLabel+ { unTxLabel :: Text+ }+ deriving newtype+ ( Show,+ Eq,+ Ord,+ Semigroup+ )++sendUtxos ::+ ( Env m+ ) =>+ Math.SatPerVbyte ->+ [PsbtUtxo] ->+ OnChainAddress 'Refund ->+ TxLabel ->+ ExceptT Failure m SendUtxosResult+sendUtxos feeRate utxos addr txLabel = do+ inQty <- tryFromT "SendUtxos length" $ length utxos+ estFee <-+ tryFailureT "SendUtxos fee estimator" $+ Math.trxEstFee+ (Math.InQty inQty)+ (Math.OutQty 1)+ feeRate+ let finalOutputAmt = totalInputsAmt - estFee+ when (finalOutputAmt < Math.trxDustLimit) . throwE $+ FailureInt . FailurePrivate $+ "Final output amount "+ <> inspectPlain finalOutputAmt+ <> " = "+ <> inspectPlain totalInputsAmt+ <> " - "+ <> inspectPlain estFee+ <> " is below dust limit "+ <> inspectPlain Math.trxDustLimit+ releaseUtxosPsbtLocks utxos+ estPsbt <-+ withLndT+ Lnd.fundPsbt+ ($ newFundPsbtReq feeRate utxos addr finalOutputAmt)+ releaseUtxosLocks $ FP.lockedUtxos estPsbt+ finPsbt <-+ withLndT+ Lnd.finalizePsbt+ ($ FNP.FinalizePsbtRequest (FP.fundedPsbt estPsbt) mempty)+ decodedTrx <-+ withBtcT+ Btc.decodeRawTransaction+ ($ toHex $ FNP.rawFinalTx finPsbt)+ ptRes <-+ withLndT+ Lnd.publishTransaction+ ( $+ PT.PublishTransactionRequest+ (FNP.rawFinalTx finPsbt)+ $ unTxLabel txLabel+ )+ if null $ PT.publishError ptRes+ then pure $ SendUtxosResult decodedTrx totalInputsAmt estFee+ else throwE . FailureInt $ FailurePrivate "Failed to publish refund transaction"+ where+ totalInputsAmt =+ sum $ getAmt <$> utxos++newFundPsbtReq ::+ Math.SatPerVbyte ->+ [PsbtUtxo] ->+ OnChainAddress 'Refund ->+ MSat ->+ FP.FundPsbtRequest+newFundPsbtReq feeRate utxos' outAddr est = do+ let mtpl =+ FP.TxTemplate+ (getOutPoint <$> utxos')+ (M.fromList [(unOnChainAddress outAddr, est)])+ FP.FundPsbtRequest+ { FP.account = mempty,+ FP.template = mtpl,+ FP.minConfs = 2,+ FP.spendUnconfirmed = False,+ FP.fee =+ FP.SatPerVbyte+ . ceiling+ $ Math.unSatPerVbyte feeRate+ }++processRefundSql ::+ ( Env m+ ) =>+ [(Entity SwapUtxo, Entity SwapIntoLn)] ->+ ReaderT Psql.SqlBackend m ()+processRefundSql [] = pure ()+processRefundSql utxos@(x : _) = do+ res <- SwapIntoLn.withLockedRowSql+ (entityKey $ snd x)+ (`elem` swapStatusFinal)+ . const+ $ do+ $(logTM) DebugS . logStr $+ "Start refunding utxos:"+ <> inspect refUtxos+ <> " to address:"+ <> inspect refAddr+ eitherM+ ( \e -> do+ Psql.transactionUndo+ $(logTM) ErrorS . logStr $+ "Failed to refund utxos:"+ <> inspect refUtxos+ <> " to address:"+ <> inspect refAddr+ <> " with error:"+ <> inspect e+ )+ ( \(SendUtxosResult rtx total fee) -> do+ $(logTM) DebugS . logStr $+ "Successfully refunded utxos: "+ <> inspect refUtxos+ <> " to address:"+ <> inspect refAddr+ <> " on chain rawTx:"+ <> inspect rtx+ <> " amount: "+ <> inspect total+ <> " with fee:"+ <> inspect fee+ case txIdParser+ . Btc.unTransactionID+ $ Btc.decTxId rtx of+ Right rtxid ->+ SwapUtxo.updateRefundedSql+ (entityKey . fst <$> utxos)+ (from rtxid)+ Left e -> do+ Psql.transactionUndo+ $(logTM) ErrorS . logStr $+ "Failed to convert txid:" <> inspect e+ )+ . lift+ . runExceptT+ $ sendUtxos+ Math.minFeeRate+ refUtxos+ (coerce refAddr)+ (TxLabel $ "refund to " <> unOnChainAddress refAddr)+ whenLeft res $+ $(logTM) ErrorS+ . logStr+ . ("No refund due to wrong status " <>)+ . inspect+ where+ refAddr = swapIntoLnRefundAddress $ entityVal $ snd x+ refUtxos = swapUtxoToPsbtUtxo . entityVal . fst <$> utxos
@@ -0,0 +1,212 @@+{-# LANGUAGE ConstraintKinds #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TypeApplications #-}++module BtcLsp.Thread.Server+ ( apply,+ )+where++import BtcLsp.Grpc.Data+import qualified BtcLsp.Grpc.Server.HighLevel as Server+import BtcLsp.Grpc.Server.LowLevel+import qualified BtcLsp.Grpc.Sig as Sig+import BtcLsp.Import+import qualified BtcLsp.Storage.Model.User as User+import qualified Crypto.Secp256k1 as C+import qualified Data.ByteString as BS+import Data.ProtoLens.Field+import Lens.Micro+import Network.GRPC.HTTP2.ProtoLens (RPC (..))+import Network.GRPC.Server+import qualified Network.Wai.Internal as Wai+import Proto.BtcLsp (Service)+import qualified Proto.BtcLsp.Data.HighLevel as Proto+import qualified Proto.BtcLsp.Data.HighLevel_Fields as Proto+import qualified Proto.BtcLsp.Method.SwapFromLn as SwapFromLn+import qualified Proto.BtcLsp.Method.SwapIntoLn as SwapIntoLn+import qualified Universum++apply :: (Env m) => m ()+apply = do+ env <- getGsEnv+ withUnliftIO $ runServer env . handlers++handlers ::+ forall m.+ ( Env m+ ) =>+ UnliftIO m ->+ GSEnv ->+ RawRequestBytes ->+ [ServiceHandler]+handlers run gsEnv body =+ [ unary (RPC :: RPC Service "swapIntoLn") $+ runHandler Server.swapIntoLn,+ unary (RPC :: RPC Service "swapFromLn") $+ runHandler swapFromLn,+ unary (RPC :: RPC Service "getCfg") $+ runHandler Server.getCfg+ ]+ where+ runHandler ::+ ( GrpcReq req,+ GrpcRes res failure specific,+ Out req,+ Out res+ ) =>+ (Entity User -> req -> m res) ->+ Wai.Request ->+ req ->+ IO res+ runHandler =+ withMiddleware run gsEnv body++verifySigE ::+ GSEnv ->+ Wai.Request ->+ NodePubKey ->+ RawRequestBytes ->+ Either Failure ()+verifySigE env waiReq pubNode (RawRequestBytes payload) = do+ pubDer <-+ maybeToRight+ ( FailureInt . FailureGrpcServer $+ "NodePubKey DER import failed from "+ <> inspectPlain pubNode+ )+ . C.importPubKey+ $ coerce pubNode+ sig <-+ Sig.sigToVerify (gsEnvSigHeaderName env) waiReq+ msg <-+ maybeToRight+ ( FailureInt . FailureGrpcServer $+ "Incorrect message from "+ <> inspectPlain payload+ )+ $ Sig.msgToVerify payload+ if C.verifySig pubDer sig msg+ then pure ()+ else+ Left+ . FailureInt+ . FailureGrpcServer+ $ "Signature verification failed with key "+ <> inspectPlain pubDer+ <> " signature "+ <> inspectPlain sig+ <> " message "+ <> inspectPlain payload+ <> " of "+ <> inspectPlain (BS.length payload)+ <> " bytes and message hash "+ <> inspectPlain (C.getMsg msg)++withMiddleware ::+ ( GrpcReq req,+ GrpcRes res failure specific,+ Env m,+ Out req,+ Out res+ ) =>+ UnliftIO m ->+ GSEnv ->+ RawRequestBytes ->+ (Entity User -> req -> m res) ->+ Wai.Request ->+ req ->+ IO res+withMiddleware (UnliftIO run) gsEnv body handler waiReq req =+ run $ do+ userE <- runExceptT $ do+ --+ -- NOTE : Here request type is hardcoded,+ -- because it's impossible to use generic "req"+ -- type with TH. Hardcoding request type is not ideal,+ -- because theoretically other requests could have+ -- other location of context stuff,+ -- but not really in this case.+ --+ nonce <-+ fromReqT+ $( mkFieldLocation+ @SwapIntoLn.Request+ [ "ctx",+ "nonce"+ ]+ )+ $ req+ ^? field @"maybe'ctx"+ . _Just+ . Proto.maybe'nonce+ . _Just+ pub <-+ fromReqT+ $( mkFieldLocation+ @SwapIntoLn.Request+ [ "ctx",+ "ln_pub_key"+ ]+ )+ $ req+ ^? field @"maybe'ctx"+ . _Just+ . Proto.maybe'lnPubKey+ . _Just+ if gsEnvSigVerify gsEnv+ then+ except+ . first+ ( const $+ newGenFailure+ Proto.VERIFICATION_FAILED+ mempty+ )+ $ verifySigE gsEnv waiReq pub body+ else+ $(logTM)+ ErrorS+ "WARNING!!! SIGNATURE VERIFICATION DISABLED!!!"+ withExceptT+ ( const $+ newGenFailure+ Proto.VERIFICATION_FAILED+ $( mkFieldLocation+ @SwapIntoLn.Request+ [ "ctx",+ "nonce"+ ]+ )+ )+ . ExceptT+ . runSql+ $ User.createVerifySql pub nonce+ case userE of+ Right user -> do+ res <- setGrpcCtx =<< handler user req+ $(logTM) DebugS . logStr $ debugMsg res+ pure res+ Left e -> do+ $(logTM) DebugS . logStr $ debugMsg e+ pure e+ where+ debugMsg :: (Out a) => a -> Text+ debugMsg x =+ "Got input "+ <> inspect body+ <> " with Wai request "+ <> Universum.show waiReq+ <> " and decoded "+ <> inspect req+ <> " producing result "+ <> inspect x++swapFromLn ::+ ( Monad m+ ) =>+ Entity User ->+ SwapFromLn.Request ->+ m SwapFromLn.Response+swapFromLn _ _ =+ pure defMessage
@@ -0,0 +1,71 @@+{-# LANGUAGE TypeApplications #-}++module BtcLsp.Time+ ( getCurrentTime,+ getFutureTime,+ getPastTime,+ addSeconds,+ subSeconds,+ swapExpiryLimit,+ sleep300ms,+ sleep1s,+ sleep5s,+ sleep10s,+ )+where++import BtcLsp.Data.Orphan ()+import BtcLsp.Import.External+import qualified Data.Time.Clock as Time+import qualified LndClient as Lnd+import qualified LndClient.Util as Util++getCurrentTime :: (MonadIO m) => m UTCTime+getCurrentTime =+ liftIO Time.getCurrentTime++getFutureTime :: (MonadIO m) => Lnd.Seconds -> m UTCTime+getFutureTime ss =+ addSeconds ss <$> liftIO getCurrentTime++getPastTime :: (MonadIO m) => Lnd.Seconds -> m UTCTime+getPastTime ss =+ subSeconds ss+ <$> liftIO getCurrentTime++addSeconds :: Lnd.Seconds -> UTCTime -> UTCTime+addSeconds =+ addUTCTime+ . fromRational+ . toRational+ . secondsToDiffTime+ . via @Word64++subSeconds :: Lnd.Seconds -> UTCTime -> UTCTime+subSeconds =+ addUTCTime+ . fromRational+ . toRational+ . secondsToDiffTime+ . (* (-1))+ . via @Word64++swapExpiryLimit :: Lnd.Seconds+swapExpiryLimit =+ Lnd.Seconds $ 24 * 60 * 60++sleep300ms :: (MonadIO m) => m ()+sleep300ms =+ Util.sleep $ Util.MicroSecondsDelay 300000++sleep1s :: (MonadIO m) => m ()+sleep1s =+ Util.sleep $ Util.MicroSecondsDelay 1000000++sleep5s :: (MonadIO m) => m ()+sleep5s =+ Util.sleep $ Util.MicroSecondsDelay 5000000++sleep10s :: (MonadIO m) => m ()+sleep10s =+ Util.sleep $ Util.MicroSecondsDelay 10000000
@@ -0,0 +1,175 @@+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE ViewPatterns #-}+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}++module BtcLsp.Yesod.Application+ ( appMain,+ )+where++-- Import all relevant handler modules here.+-- Don't forget to add new modules to your cabal file!++import qualified BtcLsp.Class.Env as Class+import BtcLsp.Yesod.Handler.About+import BtcLsp.Yesod.Handler.Common+import BtcLsp.Yesod.Handler.Home+import BtcLsp.Yesod.Handler.Language+import BtcLsp.Yesod.Handler.OpenChan+import BtcLsp.Yesod.Handler.SwapIntoLnCreate+import BtcLsp.Yesod.Handler.SwapIntoLnSelect+import BtcLsp.Yesod.Handler.SwapUpdates+import BtcLsp.Yesod.Import+import Control.Monad.Logger (liftLoc)+import Language.Haskell.TH.Syntax (qLocation)+import Network.HTTP.Client.TLS (getGlobalManager)+import Network.Wai (Middleware, pathInfo)+import Network.Wai.Handler.Warp+ ( Settings,+ defaultSettings,+ defaultShouldDisplayException,+ runSettings,+ setHost,+ setOnException,+ setPort,+ )+import Network.Wai.Middleware.RequestLogger+ ( Destination (Logger),+ DetailedSettings (..),+ OutputFormat (..),+ destination,+ mkRequestLogger,+ outputFormat,+ )+import System.Log.FastLogger+ ( defaultBufSize,+ newStdoutLoggerSet,+ toLogStr,+ )++-- This line actually creates our YesodDispatch instance. It is the second half+-- of the call to mkYesodData which occurs in Foundation.hs. Please see the+-- comments there for more details.+mkYesodDispatch "App" resourcesApp++-- | This function allocates resources (such as a database connection pool),+-- performs initialization and returns a foundation datatype value. This is also+-- the place to put your migrate statements to have automatic database+-- migrations handled by Yesod.+makeFoundation ::+ ( Class.Env m+ ) =>+ Pool SqlBackend ->+ UnliftIO m ->+ AppSettings ->+ IO App+makeFoundation sqlPool appMRunner appSettings = do+ -- Some basic initializations: HTTP connection manager, logger, and static+ -- subsite.+ appHttpManager <- getGlobalManager+ appLogger <- newStdoutLoggerSet defaultBufSize >>= makeYesodLogger+ appStatic <-+ (if appMutableStatic appSettings then staticDevel else static)+ (appStaticDir appSettings)++ -- We need a log function to create a connection pool. We need a connection+ -- pool to create our foundation. And we need our foundation to get a+ -- logging function. To get out of this loop, we initially create a+ -- temporary foundation without a real connection pool, get a log function+ -- from there, and then create the real foundation.+ let mkFoundation appConnPool = App {..}+ -- The App {..} syntax is an example of record wild cards. For more+ -- information, see:+ -- https://ocharles.org.uk/blog/posts/2014-12-04-record-wildcards.html++ -- Return the foundation+ return $ mkFoundation sqlPool++-- | Convert our foundation to a WAI Application by calling @toWaiAppPlain@ and+-- applying some additional middlewares.+makeApplication :: YesodLog -> App -> IO Application+makeApplication yesodLog foundation = do+ logWare <- makeLogWare yesodLog foundation+ -- Create the WAI application and apply middlewares+ appPlain <- toWaiAppPlain foundation+ return $ logWare $ defaultMiddlewaresNoLogging appPlain++makeLogWare :: YesodLog -> App -> IO Middleware+makeLogWare yesodLog foundation =+ mkRequestLogger+ def+ { outputFormat =+ DetailedWithSettings $+ def+ { useColors = True,+ mFilterRequests = Just $ reqFilter yesodLog+ },+ destination =+ Logger+ . loggerSet+ $ appLogger foundation+ }+ where+ reqFilter YesodLogAll _ =+ const True+ reqFilter YesodLogNothing _ =+ const False+ reqFilter YesodLogNoMain req =+ const $+ case pathInfo req of+ [] -> False+ x : _ ->+ x+ `notElem` [ "static",+ "favicon.ico",+ "robots.txt"+ ]++-- | Warp settings for the given foundation value.+warpSettings :: App -> Settings+warpSettings foundation =+ setPort (appPort $ appSettings foundation) $+ setHost (appHost $ appSettings foundation) $+ setOnException+ ( \_req e ->+ when (defaultShouldDisplayException e) $+ messageLoggerSource+ foundation+ (appLogger foundation)+ $(qLocation >>= liftLoc)+ "yesod"+ LevelError+ (toLogStr $ "Exception from Warp: " ++ show e)+ )+ defaultSettings++-- | The @main@ function for an executable running this site.+appMain ::+ ( Class.Env m+ ) =>+ YesodLog ->+ Pool SqlBackend ->+ UnliftIO m ->+ IO ()+appMain yesodLog sqlPool appMRunner = do+ -- Get the settings from all relevant sources+ settings <-+ loadYamlSettingsArgs+ -- fall back to compile-time values, set to [] to require values at runtime+ [configSettingsYmlValue]+ -- allow environment variables to override+ useEnv++ -- Generate the foundation from the settings+ foundation <- makeFoundation sqlPool appMRunner settings++ -- Generate a WAI Application from the foundation+ app <- makeApplication yesodLog foundation++ -- Run the application with Warp+ runSettings (warpSettings foundation) app
@@ -0,0 +1,22 @@+module BtcLsp.Yesod.Data.BootstrapColor+ ( BootstrapColor (..),+ bsColor2Class,+ )+where++import BtcLsp.Yesod.Import.NoFoundation++data BootstrapColor+ = Success+ | Info+ | Warning+ | Danger+ deriving stock+ ( Show,+ Read,+ Eq+ )++bsColor2Class :: BootstrapColor -> Text+bsColor2Class =+ pack . toLower . show
@@ -0,0 +1,19 @@+{-# LANGUAGE NoImplicitPrelude #-}++module BtcLsp.Yesod.Data.Colored where++import qualified BtcLsp.Storage.Model as Model+import qualified BtcLsp.Storage.Model.SwapIntoLn as SwapIntoLn+import BtcLsp.Yesod.Data.BootstrapColor+import BtcLsp.Yesod.Import++class Colored a where+ color :: a -> Maybe BootstrapColor++instance Colored SwapIntoLn.UtxoInfo where+ color =+ const Nothing++instance Colored (Entity Model.LnChan) where+ color =+ const Nothing
@@ -0,0 +1,37 @@+{-# LANGUAGE TemplateHaskell #-}++module BtcLsp.Yesod.Data.Language where++import BtcLsp.Import.External+import qualified Data.Text as T+import Database.Persist.TH+import qualified Universum++data Code+ = En+ | Ru+ deriving stock+ ( Show,+ Read,+ Eq,+ Enum,+ Bounded+ )++derivePersistField "Code"++codeList :: [Code]+codeList =+ [minBound .. maxBound]++instance PathPiece Code where+ fromPathPiece :: Text -> Maybe Code+ fromPathPiece =+ readMaybe+ . T.unpack+ . T.toTitle+ toPathPiece :: Code -> Text+ toPathPiece =+ T.toLower+ . T.pack+ . Universum.show
@@ -0,0 +1,128 @@+{-# LANGUAGE TemplateHaskell #-}++module BtcLsp.Yesod.Data.Widget where++import BtcLsp.Yesod.Import+import GHC.Exts (IsList (..))+import Yesod.Form.Bootstrap3++newtype HtmlClassAttr+ = HtmlClassAttr [Text]+ deriving newtype+ ( Eq,+ Ord,+ Show,+ Read,+ Semigroup,+ Monoid+ )+ deriving stock+ ( Generic+ )++instance Out HtmlClassAttr++instance IsList HtmlClassAttr where+ type Item HtmlClassAttr = Text+ fromList = coerce+ toList = coerce++--+-- TODO : use bootstrap tabs/panels to provide+-- basic and advanced view options for users.+--+data Layout+ = BasicLayout+ | AdvancedLayout+ deriving stock+ ( Eq,+ Ord,+ Show,+ Read,+ Generic,+ Enum,+ Bounded+ )++instance Out Layout++bfsAutoFocus :: RenderMessage site msg => msg -> FieldSettings site+bfsAutoFocus msg =+ bfsStandard {fsAttrs = ("autofocus", "") : fsAttrs bfsStandard}+ where+ bfsStandard = bfs msg++bfsDisabled :: RenderMessage site msg => msg -> FieldSettings site+bfsDisabled msg =+ bfsStandard {fsAttrs = ("disabled", "") : fsAttrs bfsStandard}+ where+ bfsStandard = bfs msg++fromTextField ::+ forall m a.+ ( Monad m,+ From Text a,+ From a Text,+ 'False ~ (Text == a),+ 'False ~ (a == Text),+ RenderMessage (HandlerSite m) FormMessage+ ) =>+ Field m a+fromTextField =+ Field+ { fieldParse = \f xs ->+ ((from <$>) <$>) <$> fieldParse txtField f xs,+ fieldView = \theId fieldName attrs val isReq ->+ fieldView+ txtField+ theId+ fieldName+ attrs+ (from <$> val)+ isReq,+ fieldEnctype =+ fieldEnctype txtField+ }+ where+ txtField :: Field m Text+ txtField = textField++toText ::+ ( From a Text,+ 'False ~ (Text == a),+ 'False ~ (a == Text)+ ) =>+ a ->+ Text+toText =+ from++newListWidget ::+ [[(AppMessage, AppMessage)]] ->+ Maybe Widget+newListWidget =+ newGenListWidget Nothing $ 1 % 2++newNamedListWidget ::+ AppMessage ->+ [[(AppMessage, AppMessage)]] ->+ Maybe Widget+newNamedListWidget title =+ newGenListWidget (Just title) $ 1 % 3++newGenListWidget ::+ Maybe AppMessage ->+ Rational ->+ [[(AppMessage, AppMessage)]] ->+ Maybe Widget+newGenListWidget _ _ [] =+ Nothing+newGenListWidget mTitle colProp rawRows =+ Just $(widgetFile "named_list")+ where+ idxRows :: [(Natural, [(AppMessage, AppMessage)])]+ idxRows = zip [0 ..] rawRows+ c1 :: Integer+ c1 = round $ 12 * colProp+ c2 :: Integer+ c2 = 12 - c1
@@ -0,0 +1,414 @@+{-# LANGUAGE InstanceSigs #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE RankNTypes #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE ViewPatterns #-}+{-# LANGUAGE NoImplicitPrelude #-}+{-# OPTIONS_GHC -Wno-missing-deriving-strategies #-}+{-# OPTIONS_GHC -Wno-partial-fields #-}++module BtcLsp.Yesod.Foundation where++import qualified BtcLsp.Class.Env as Class+import BtcLsp.Yesod.Data.BootstrapColor+import qualified BtcLsp.Yesod.Data.Language+import BtcLsp.Yesod.Import.NoFoundation+import BtcLsp.Yesod.TH (mkMessageNoFallback)+import Control.Monad.Logger (LogSource)+import qualified Data.CaseInsensitive as CI+import qualified Data.Kind as Kind+import Data.List.NonEmpty (NonEmpty ((:|)))+import qualified Data.Text.Encoding as TE+import Database.Persist.Sql (ConnectionPool, runSqlPool)+import Text.Hamlet (hamletFile)+import Text.Jasmine (minifym)+import Yesod.Auth.Dummy+import qualified Yesod.Auth.Message as Auth+import Yesod.Core.Types (Logger)+import qualified Yesod.Core.Unsafe as Unsafe+import Yesod.Default.Util (addStaticContentExternal)++-- | NOTE : this type aliases are there only because of+-- poor support of advanced Haskell in yesodroutes and i18n+-- files through Yesod TH.+--+-- !!! DO NOT USE DIRECTLY IN SOURCE CODE !!!+type Uuid'SwapIntoLnTable = Uuid 'SwapIntoLnTable++type Money'Lsp'OnChain'Gain = Money 'Lsp 'OnChain 'Gain++type Money'Usr'OnChain'Fund = Money 'Usr 'OnChain 'Fund++-- | The foundation datatype for your application. This can be a good place to+-- keep settings and values requiring initialization before your application+-- starts running, such as database connections. Every handler will have+-- access to the data present here.+data App = forall m.+ (Class.Env m) =>+ App+ { appSettings :: AppSettings,+ -- | Settings for static file serving.+ appStatic :: Static,+ -- | Database connection pool.+ appConnPool :: ~ConnectionPool,+ appHttpManager :: Manager,+ appLogger :: Logger,+ appMRunner :: UnliftIO m+ }++mkMessageNoFallback "App" "messages" $ "en" :| ["ru"]++data MenuItem = MenuItem+ { menuItemLabel :: AppMessage,+ menuItemRoute :: Route App,+ menuItemAccessCallback :: Bool,+ menuItemActiveCallback :: Bool,+ menuItemNoReferrer :: Bool+ }++data MenuTypes+ = NavbarLeft MenuItem+ | NavbarRight MenuItem++-- This is where we define all of the routes in our application. For a full+-- explanation of the syntax, please see:+-- http://www.yesodweb.com/book/routing-and-handlers+--+-- Note that this is really half the story; in Application.hs, mkYesodDispatch+-- generates the rest of the code. Please see the following documentation+-- for an explanation for this split:+-- http://www.yesodweb.com/book/scaffolding-and-the-site-template#scaffolding-and-the-site-template_foundation_and_application_modules+--+-- This function also generates the following type synonyms:+-- type Handler = HandlerFor App+-- type Widget = WidgetFor App ()+mkYesodData "App" $(parseRoutesFile "config/routes.yesodroutes")++-- | A convenient synonym for creating forms.+type Form x = Html -> MForm (HandlerFor App) (FormResult x, Widget)++-- | A convenient synonym for database access functions.+type DB a =+ forall (m :: Kind.Type -> Kind.Type).+ (MonadUnliftIO m) =>+ ReaderT SqlBackend m a++-- Please see the documentation for the Yesod typeclass. There are a number+-- of settings which can be configured by overriding methods here.+instance Yesod App where+ -- Controls the base of generated URLs. For more information on modifying,+ -- see: https://github.com/yesodweb/yesod/wiki/Overriding-approot+ approot :: Approot App+ approot = ApprootRequest $ \app req ->+ case appRoot $ appSettings app of+ Nothing -> getApprootText guessApproot app req+ Just root -> root++ -- Store session data on the client in encrypted cookies,+ -- default session idle timeout is 120 minutes+ makeSessionBackend :: App -> IO (Maybe SessionBackend)+ makeSessionBackend _ =+ Just+ <$> defaultClientSessionBackend+ 120 -- timeout in minutes+ "config/client_session_key.aes"++ -- Yesod Middleware allows you to run code before and after each handler function.+ -- The defaultYesodMiddleware adds the response header "Vary: Accept, Accept-Language" and performs authorization checks.+ -- Some users may also want to add the defaultCsrfMiddleware, which:+ -- a) Sets a cookie with a CSRF token in it.+ -- b) Validates that incoming write requests include that token in either a header or POST parameter.+ -- To add it, chain it together with the defaultMiddleware: yesodMiddleware = defaultYesodMiddleware . defaultCsrfMiddleware+ -- For details, see the CSRF documentation in the Yesod.Core.Handler module of the yesod-core package.+ -- yesodMiddleware ::+ -- ( ToTypedContent res+ -- ) =>+ -- Handler res ->+ -- Handler res+ -- yesodMiddleware =+ -- defaultYesodMiddleware++ defaultLayout :: Widget -> Handler Html+ defaultLayout =+ newLayout Nothing++ -- The page to be redirected to when authentication is required.+ authRoute ::+ App ->+ Maybe (Route App)+ authRoute _ = Just $ AuthR LoginR++ isAuthorized ::+ -- The route the user is visiting.+ Route App ->+ -- Whether or not this is a "write" request.+ Bool ->+ Handler AuthResult+ -- Routes not requiring authentication.+ isAuthorized (AuthR _) _ = return Authorized+ isAuthorized HomeR _ = return Authorized+ isAuthorized FaviconR _ = return Authorized+ isAuthorized RobotsR _ = return Authorized+ isAuthorized (StaticR _) _ = return Authorized+ isAuthorized (LanguageR _) _ = return Authorized+ isAuthorized OpenChanR {} _ = pure Authorized+ isAuthorized SwapIntoLnCreateR {} _ = pure Authorized+ isAuthorized SwapIntoLnSelectR {} _ = pure Authorized+ isAuthorized AboutR _ = pure Authorized+ isAuthorized SwapUpdatesR {} _ = pure Authorized++ -- This function creates static content files in the static folder+ -- and names them based on a hash of their content. This allows+ -- expiration dates to be set far in the future without worry of+ -- users receiving stale content.+ addStaticContent ::+ -- The file extension+ Text ->+ -- The MIME content type+ Text ->+ -- The contents of the file+ LByteString ->+ Handler (Maybe (Either Text (Route App, [(Text, Text)])))+ addStaticContent ext mime content = do+ master <- getYesod+ let staticDir = appStaticDir $ appSettings master+ addStaticContentExternal+ minifym+ genFileName+ staticDir+ (StaticR . flip StaticRoute [])+ ext+ mime+ content+ where+ -- Generate a unique filename based on the content itself+ genFileName lbs = "autogen-" ++ base64md5 lbs++ -- What messages should be logged. The following includes all messages when+ -- in development, and warnings and errors in production.+ shouldLogIO :: App -> LogSource -> LogLevel -> IO Bool+ shouldLogIO app _source level =+ return $+ appShouldLogAll (appSettings app)+ || level == LevelWarn+ || level == LevelError++ makeLogger :: App -> IO Logger+ makeLogger = return . appLogger++-- Define breadcrumbs.+instance YesodBreadcrumbs App where+ -- Takes the route that the user is currently on, and returns a tuple+ -- of the 'Text' that you want the label to display, and a previous+ -- breadcrumb route.+ breadcrumb ::+ -- The route the user is visiting currently.+ Route App ->+ Handler (Text, Maybe (Route App))+ breadcrumb r = do+ render <- getMessageRender+ pure (render $ getMsg r, getParent r)+ where+ getMsg :: Route App -> AppMessage+ getMsg = \case+ StaticR _ -> MsgNothing+ FaviconR -> MsgNothing+ RobotsR -> MsgNothing+ LanguageR {} -> MsgNothing+ AuthR {} -> MsgNothing+ HomeR -> MsgHomeRLinkShort+ OpenChanR -> MsgOpenChanRLinkShort+ SwapIntoLnCreateR -> MsgSwapIntoLnCreateRLinkShort+ SwapIntoLnSelectR x -> MsgSwapIntoLnSelectRLinkShort x+ AboutR -> MsgAboutRLinkShort+ SwapUpdatesR _ _ -> MsgNothing+ getParent :: Route App -> Maybe (Route App)+ getParent = \case+ StaticR {} -> Nothing+ FaviconR -> Nothing+ RobotsR -> Nothing+ LanguageR {} -> Nothing+ HomeR -> Nothing+ AuthR {} -> Just HomeR+ OpenChanR -> Just HomeR+ SwapIntoLnCreateR -> Just HomeR+ SwapIntoLnSelectR {} -> Just SwapIntoLnCreateR+ AboutR -> Just HomeR+ SwapUpdatesR _ _ -> Nothing++-- How to run database actions.+instance YesodPersist App where+ type YesodPersistBackend App = SqlBackend+ runDB :: SqlPersistT Handler a -> Handler a+ runDB action = do+ master <- getYesod+ runSqlPool action $ appConnPool master++instance YesodPersistRunner App where+ getDBRunner :: Handler (DBRunner App, Handler ())+ getDBRunner = defaultGetDBRunner appConnPool++instance YesodAuth App where+ type AuthId App = UserId++ -- Where to send a user after successful login+ loginDest :: App -> Route App+ loginDest _ = HomeR++ -- Where to send a user after logout+ logoutDest :: App -> Route App+ logoutDest _ = HomeR++ -- Override the above two destinations when a Referer: header is present+ redirectToReferer :: App -> Bool+ redirectToReferer _ = True++ authenticate ::+ ( MonadHandler m,+ HandlerSite m ~ App+ ) =>+ Creds App ->+ m (AuthenticationResult App)+ authenticate _ =+ liftHandler $+ pure $ UserError Auth.AuthError++ -- You can add other plugins like Google Email, email or OAuth here+ authPlugins :: App -> [AuthPlugin App]+ authPlugins app =+ extraAuthPlugins+ where+ -- Enable authDummy login if enabled.+ extraAuthPlugins = [authDummy | appAuthDummyLogin $ appSettings app]++-- | Access function to determine if a user is logged in.+isAuthenticated :: Handler AuthResult+isAuthenticated = do+ muid <- maybeAuthId+ return $ case muid of+ Nothing -> Unauthorized "You must login to access this page"+ Just _ -> Authorized++instance YesodAuthPersist App++-- This instance is required to use forms. You can modify renderMessage to+-- achieve customized and internationalized form validation messages.+instance RenderMessage App FormMessage where+ renderMessage :: App -> [Lang] -> FormMessage -> Text+ renderMessage _ _ = defaultFormMessage++-- Useful when writing code that is re-usable outside of the Handler context.+-- An example is background jobs that send email.+-- This can also be useful for writing code that works across multiple Yesod applications.+instance HasHttpManager App where+ getHttpManager :: App -> Manager+ getHttpManager = appHttpManager++unsafeHandler :: App -> Handler a -> IO a+unsafeHandler = Unsafe.fakeHandlerGetLogger appLogger++data PanelConfig = PanelConfig+ { panelConfigColor :: BootstrapColor,+ panelConfigMsgShort :: AppMessage,+ panelConfigMsgLong :: AppMessage+ }++newLayout :: Maybe PanelConfig -> Widget -> Handler Html+newLayout mpcfg widget = do+ master <- getYesod+ mmsg <- getMessage+ mcurrentRoute <- getCurrentRoute++ -- Get the breadcrumbs, as defined in the YesodBreadcrumbs instance.+ (title, parents) <- breadcrumbs++ -- Define the menu items of the header.+ let menuItems =+ [ NavbarLeft $+ MenuItem+ { menuItemLabel = MsgHomeRLinkShort,+ menuItemRoute = HomeR,+ menuItemAccessCallback = True,+ menuItemActiveCallback = mcurrentRoute == Just HomeR,+ menuItemNoReferrer = False+ },+ NavbarLeft $+ MenuItem+ { menuItemLabel = MsgOpenChanRLinkShort,+ menuItemRoute = OpenChanR,+ menuItemAccessCallback = True,+ menuItemActiveCallback = mcurrentRoute == Just OpenChanR,+ menuItemNoReferrer = False+ },+ NavbarLeft $+ MenuItem+ { menuItemLabel = MsgSwapIntoLnCreateRLinkShort,+ menuItemRoute = SwapIntoLnCreateR,+ menuItemAccessCallback = True,+ menuItemActiveCallback =+ maybe+ False+ ( \case+ SwapIntoLnCreateR -> True+ SwapIntoLnSelectR {} -> True+ _ -> False+ )+ mcurrentRoute,+ menuItemNoReferrer = False+ },+ NavbarLeft $+ MenuItem+ { menuItemLabel = MsgAboutRLinkShort,+ menuItemRoute = AboutR,+ menuItemAccessCallback = True,+ menuItemActiveCallback = mcurrentRoute == Just AboutR,+ menuItemNoReferrer = False+ }+ ]++ let navbarLeftMenuItems = [x | NavbarLeft x <- menuItems]+ let navbarRightMenuItems = [x | NavbarRight x <- menuItems]++ let navbarLeftFilteredMenuItems = [x | x <- navbarLeftMenuItems, menuItemAccessCallback x]+ let navbarRightFilteredMenuItems = [x | x <- navbarRightMenuItems, menuItemAccessCallback x]++ -- We break up the default layout into two components:+ -- default-layout is the contents of the body tag, and+ -- default-layout-wrapper is the entire page. Since the final+ -- value passed to hamletToRepHtml cannot be a widget, this allows+ -- you to use normal widget features in default-layout.++ mLang <- lookupSession "_LANG"+ let disclaimerTos = $(widgetFile "disclaimer_tos")+ pc <- widgetToPageContent $ do+ addStylesheet $ StaticR css_bootstrap_css+ addStylesheet $ StaticR css_app_css+ -- generated from @Settings/StaticFiles.hs@+ $(widgetFile "default-layout")++ withUrlRenderer $(hamletFile "templates/default-layout-wrapper.hamlet")++panelLayout ::+ BootstrapColor ->+ AppMessage ->+ AppMessage ->+ Widget ->+ Handler Html+panelLayout color msgShort msgLong =+ newLayout . Just $+ PanelConfig+ { panelConfigColor = color,+ panelConfigMsgShort = msgShort,+ panelConfigMsgLong = msgLong+ }++-- Note: Some functionality previously present in the scaffolding has been+-- moved to documentation in the Wiki. Following are some hopefully helpful+-- links:+--+--+-- https://github.com/yesodweb/yesod/wiki/Sending-email+-- https://github.com/yesodweb/yesod/wiki/Serve-static-files-from-a-separate-domain+-- https://github.com/yesodweb/yesod/wiki/i18n-messages-in-the-scaffolding
@@ -0,0 +1,67 @@+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE NoImplicitPrelude #-}++module BtcLsp.Yesod.Handler.About where++import qualified BtcLsp.Class.Env+import qualified BtcLsp.Math.OnChain as Math+import qualified BtcLsp.Math.Swap as Math+import BtcLsp.Yesod.Data.Widget+import BtcLsp.Yesod.Import++getAboutR :: Handler Html+getAboutR = do+ App {appMRunner = UnliftIO run} <- getYesod+ minAmt <- liftIO $ run getSwapIntoLnMinAmt+ mExamplesWidget <- liftIO . run $ newExamplesWidget minAmt+ defaultLayout $ do+ setTitleI MsgAboutRTitle+ $(widgetFile "about")++newExamplesWidget ::+ ( BtcLsp.Class.Env.Env m+ ) =>+ Money 'Usr 'OnChain 'Fund ->+ m (Maybe Widget)+newExamplesWidget minAmt = do+ caps <-+ mapM+ ( \amt -> do+ mcap <- Math.newSwapCapM amt+ pure $ (amt,) <$> mcap+ )+ [ minAmt,+ minAmt * 5,+ minAmt * 100+ ]+ pure+ . newListWidget+ $ ( \(fundAmt, Math.SwapCap {..}) ->+ [ ( MsgAboutExamplesUserOnChainFunding,+ MsgSatoshi $+ from fundAmt+ ),+ ( MsgAboutExamplesLspSwapFee,+ MsgSatoshi $+ from swapCapFee+ ),+ ( MsgAboutExamplesUserOutgoingCap,+ MsgSatoshi $+ from swapCapUsr+ ),+ ( MsgAboutExamplesUserIncomingCap,+ MsgSatoshi $+ from swapCapLsp+ ),+ ( MsgAboutExamplesTotalChanCap,+ MsgSatoshi $+ from swapCapUsr+ + from swapCapLsp+ )+ ]+ )+ <$> catMaybes caps
@@ -0,0 +1,27 @@+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE NoImplicitPrelude #-}++-- | Common handler functions.+module BtcLsp.Yesod.Handler.Common where++import BtcLsp.Yesod.Import+import Data.FileEmbed (embedFile)++-- These handlers embed files in the executable at compile time to avoid a+-- runtime dependency, and for efficiency.++getFaviconR :: Handler TypedContent+getFaviconR = do+ cacheSeconds $ 60 * 60 * 24 * 30 -- cache for a month+ return $+ TypedContent "image/x-icon" $+ toContent $(embedFile "config/favicon.ico")++getRobotsR :: Handler TypedContent+getRobotsR =+ return $+ TypedContent typePlain $+ toContent $(embedFile "config/robots.txt")
@@ -0,0 +1,23 @@+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE NoImplicitPrelude #-}++module BtcLsp.Yesod.Handler.Home where++import BtcLsp.Yesod.Import++-- This is a handler function for the GET request method on the HomeR+-- resource pattern. All of your resource patterns are defined in+-- config/routes+--+-- The majority of the code you will write in Yesod lives in these handler+-- functions. You can spread them across multiple files if you are so+-- inclined, or create a single monolithic file.+getHomeR :: Handler Html+getHomeR = do+ master <- getYesod+ defaultLayout $ do+ setTitleI MsgHomeRTitle+ $(widgetFile "homepage")
@@ -0,0 +1,14 @@+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE NoImplicitPrelude #-}++module BtcLsp.Yesod.Handler.Language where++import qualified BtcLsp.Yesod.Data.Language as Lang+import BtcLsp.Yesod.Import++getLanguageR :: Lang.Code -> Handler ()+getLanguageR language = do+ setLanguage $ toPathPiece language+ setUltDestReferer+ redirectUltDest HomeR
@@ -0,0 +1,31 @@+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TypeApplications #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE NoImplicitPrelude #-}++module BtcLsp.Yesod.Handler.OpenChan where++import BtcLsp.Class.Env+import BtcLsp.Yesod.Import++getOpenChanR :: Handler Html+getOpenChanR = do+ App {appMRunner = UnliftIO run} <- getYesod+ nodeUri <- liftIO $ run getLndNodeUri+ nodeUriHex <-+ eitherM+ (const badMethod)+ (pure . from @NodeUriHex @Text)+ . pure+ $ tryFrom nodeUri+ qrCodeSrc <-+ maybeM badMethod pure+ . pure+ $ toQr nodeUriHex+ panelLayout Info MsgOpenChanRLinkLong MsgOpenChanInstruction $ do+ setTitleI MsgOpenChanRTitle+ $(widgetFile "open_chan")+ where+ htmlUuid = $(mkHtmlUuid)
@@ -0,0 +1,152 @@+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TypeApplications #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE NoImplicitPrelude #-}++module BtcLsp.Yesod.Handler.SwapIntoLnCreate+ ( getSwapIntoLnCreateR,+ postSwapIntoLnCreateR,+ )+where++import BtcLsp.Data.Kind+import BtcLsp.Data.Type+import BtcLsp.Grpc.Combinator+import qualified BtcLsp.Grpc.Server.HighLevel as Server+import BtcLsp.Storage.Model+import BtcLsp.Storage.Model.User as User+import BtcLsp.Yesod.Data.Widget+import BtcLsp.Yesod.Import+import Lens.Micro+import qualified LndClient.Data.PayReq as Lnd+import qualified LndClient.RPC.Katip as Lnd+import qualified Proto.BtcLsp.Data.HighLevel as Proto+import qualified Proto.BtcLsp.Method.SwapIntoLn as SwapIntoLn+import qualified Proto.BtcLsp.Method.SwapIntoLn_Fields as SwapIntoLn+import Yesod.Form.Bootstrap3++data SwapRequest = SwapRequest+ { swapRequestInvoice :: LnInvoice 'Fund,+ swapRequestRefund :: UnsafeOnChainAddress 'Refund,+ swapRequestPrivacy :: Privacy+ }+ deriving stock+ ( Eq,+ Show,+ Generic+ )++instance Out SwapRequest++getSwapIntoLnCreateR :: Handler Html+getSwapIntoLnCreateR = do+ (formWidget, formEnctype) <-+ generateFormPost $+ renderBootstrap3+ BootstrapBasicForm+ aForm+ renderPage Info formWidget formEnctype++postSwapIntoLnCreateR :: Handler Html+postSwapIntoLnCreateR = do+ ((formResult, formWidget), formEnctype) <-+ runFormPost $+ renderBootstrap3+ BootstrapBasicForm+ aForm+ case formResult of+ FormSuccess req -> do+ let fundInv = swapRequestInvoice req+ App {appMRunner = UnliftIO run} <- getYesod+ eSwap <- liftIO . run . runExceptT $ do+ fundInvLnd <-+ withLndServerT+ Lnd.decodePayReq+ ($ from fundInv)+ userEnt <-+ withExceptT+ ( const $+ newGenFailure+ Proto.VERIFICATION_FAILED+ $( mkFieldLocation+ @SwapIntoLn.Request+ [ "ctx",+ "nonce"+ ]+ )+ )+ . ExceptT+ $ newNonce+ >>= runSql+ . User.createVerifySql+ (Lnd.destination fundInvLnd)+ Server.swapIntoLnT+ userEnt+ (swapRequestRefund req)+ (swapRequestPrivacy req)+ case eSwap of+ Left e -> do+ setMessageI $ explainFailure e+ renderPage Danger formWidget formEnctype+ Right swapEnt ->+ redirect+ . SwapIntoLnSelectR+ . swapIntoLnUuid+ $ entityVal swapEnt+ _ ->+ renderPage Danger formWidget formEnctype++explainFailure :: SwapIntoLn.Response -> AppMessage+explainFailure res =+ maybe+ MsgInputFailure+ ( \case+ SwapIntoLn.Response'Failure'DEFAULT ->+ MsgInputFailure+ SwapIntoLn.Response'Failure'REFUND_ON_CHAIN_ADDRESS_IS_NOT_VALID ->+ MsgSwapIntoLnFailureRefundOnChainAddressIsNotValid+ SwapIntoLn.Response'Failure'REFUND_ON_CHAIN_ADDRESS_IS_NOT_SEGWIT ->+ MsgSwapIntoLnFailureRefundOnChainAddressIsNotSegwit+ SwapIntoLn.Response'Failure'InputFailure'Unrecognized {} ->+ MsgInputFailure+ )+ $ res+ ^? SwapIntoLn.maybe'failure+ . _Just+ . SwapIntoLn.specific+ >>= listToMaybe++renderPage :: BootstrapColor -> Widget -> Enctype -> Handler Html+renderPage color formWidget formEnctype = do+ let formRoute = SwapIntoLnCreateR+ let formMsgSubmit = MsgContinue+ panelLayout+ color+ MsgSwapIntoLnInfoShort+ MsgSwapIntoLnInfoLong+ $ do+ setTitleI MsgSwapIntoLnCreateRTitle+ $(widgetFile "simple_form")++aForm :: AForm Handler SwapRequest+aForm =+ SwapRequest+ <$> areq+ fromTextField+ (bfsAutoFocus MsgSwapIntoLnFundInvoice)+ Nothing+ <*> areq+ fromTextField+ (bfs MsgSwapIntoLnRefundAddress)+ Nothing+ <*> areq+ ( selectField $+ optionsPairs+ [ (MsgChanPublic, Public),+ (MsgChanPrivate, Private)+ ]+ )+ (bfs MsgChannelPrivacy)+ (Just Public)
@@ -0,0 +1,313 @@+{-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TypeApplications #-}++module BtcLsp.Yesod.Handler.SwapIntoLnSelect+ ( getSwapIntoLnSelectR,+ )+where++import BtcLsp.Data.Type+import qualified BtcLsp.Math.Swap as Math+import BtcLsp.Storage.Model+import qualified BtcLsp.Storage.Model.SwapIntoLn as SwapIntoLn+import BtcLsp.Yesod.Data.Widget+import qualified BtcLsp.Yesod.Handler.SwapUpdates as SU+import BtcLsp.Yesod.Import+import qualified Data.UUID as UUID++getSwapIntoLnSelectR :: Uuid 'SwapIntoLnTable -> Handler Html+getSwapIntoLnSelectR uuid = do+ app@App {appMRunner = UnliftIO run} <- getYesod+ nodeUri <- liftIO $ run getLndNodeUri+ nodeUriHex <-+ eitherM+ (const badMethod)+ (pure . from @NodeUriHex @Text)+ . pure+ $ tryFrom nodeUri+ nodeUriQr <-+ maybeM badMethod pure+ . pure+ $ toQr nodeUriHex+ swapHash <- maybeM notFound pure (SU.getSwapUpdate app uuid)+ maybeM+ notFound+ ( \swapInfo@SwapIntoLn.SwapInfo {..} -> do+ minAmt <- liftIO $ run getSwapIntoLnMinAmt+ let SwapIntoLn {..} = entityVal swapInfoSwap+ let (msgShort, msgLong, color) =+ case swapIntoLnStatus of+ SwapWaitingFundChain ->+ ( MsgSwapIntoLnWaitingFundChainShort,+ MsgSwapIntoLnWaitingFundChainLong+ minAmt+ Math.swapLnMaxAmt,+ Info+ )+ SwapWaitingPeer ->+ ( MsgSwapIntoLnFundedShort,+ MsgSwapIntoLnFundedLong,+ Info+ )+ SwapWaitingChan ->+ ( MsgSwapIntoLnWaitingChanShort,+ MsgSwapIntoLnWaitingChanLong,+ Info+ )+ SwapSucceeded ->+ ( MsgSwapIntoLnSucceededShort,+ MsgSwapIntoLnSucceededLong,+ Success+ )+ SwapExpired ->+ ( MsgSwapIntoLnExpiredShort,+ MsgSwapIntoLnExpiredLong,+ Danger+ )+ fundAddrQr <-+ maybeM badMethod pure+ . pure+ . toQr+ $ from swapIntoLnFundAddress+ let mSwapWidget = newSwapWidget swapInfo+ let mUtxoWidget = newUtxoWidget swapInfoUtxo+ let mChanWidget = newChanWidget swapInfoChan+ panelLayout color msgShort msgLong $ do+ setTitleI $ MsgSwapIntoLnSelectRTitle swapIntoLnUuid+ $(widgetFile "swap_updates")+ $(widgetFile "swap_into_ln_select")+ )+ . liftIO+ . run+ . runSql+ $ SwapIntoLn.getByUuidSql uuid+ where+ htmlUuid = $(mkHtmlUuid)++newSwapWidget ::+ SwapIntoLn.SwapInfo ->+ Maybe Widget+newSwapWidget swapInfo =+ newNamedListWidget MsgSwapIntoLnHeaderInfo+ . singleton+ $ [ ( MsgSwapIntoLnTotalOnChainReceived,+ Just+ . MsgSatoshi+ $ totalOnChainAmt (/= SwapUtxoOrphan) swapInfo+ ),+ ( MsgSwapIntoLnTotalOnChainReserved,+ Just+ . MsgSatoshi+ $ totalOnChainAmt+ ( `elem`+ [ SwapUtxoUnspentChanReserve+ ]+ )+ swapInfo+ ),+ ( MsgSwapIntoLnTotalOnChainSwapped,+ Just+ . MsgSatoshi+ $ totalOnChainAmt+ (== SwapUtxoSpentChanSwapped)+ swapInfo+ ),+ ( MsgSwapIntoLnTotalOnChainRefunded,+ Just+ . MsgSatoshi+ $ totalOnChainAmt (== SwapUtxoSpentRefund) swapInfo+ ),+ ( MsgSwapIntoLnTotalOnChainDust,+ Just+ . MsgSatoshi+ $ totalOnChainAmt (== SwapUtxoUnspentDust) swapInfo+ ),+ ( MsgSwapIntoLnFeeLsp,+ Just+ . MsgSatoshi+ $ from swapIntoLnFeeLsp+ ),+ ( MsgSwapIntoLnChanCapUser,+ Just+ . MsgSatoshi+ $ from swapIntoLnChanCapUser+ ),+ ( MsgSwapIntoLnChanCapLsp,+ Just+ . MsgSatoshi+ $ from swapIntoLnChanCapLsp+ ),+ ( MsgSwapIntoLnChanCapTotal,+ Just+ . MsgSatoshi+ $ from swapIntoLnChanCapUser+ + from swapIntoLnChanCapLsp+ ),+ ( MsgChannelPrivacy,+ Just $+ chanPrivacyMsg swapIntoLnPrivacy+ ),+ ( MsgStatus,+ Just $+ swapStatusMsg swapIntoLnStatus+ ),+ ( MsgExpiresAt,+ Just $+ MsgUtcTime swapIntoLnExpiresAt+ ),+ ( MsgSwapIntoLnUuid,+ Just+ . MsgProxy+ . UUID.toText+ . unUuid+ $ swapIntoLnUuid+ ),+ ( MsgSwapIntoLnUserId,+ Just $+ MsgProxy userPub+ ),+ ( MsgSwapIntoLnFundAddress,+ Just+ . MsgProxy+ $ toText swapIntoLnFundAddress+ ),+ ( MsgSwapIntoLnRefundAddress,+ Just+ . MsgProxy+ $ toText swapIntoLnRefundAddress+ ),+ ( MsgInsertedAt,+ Just $+ MsgUtcTime swapIntoLnInsertedAt+ ),+ ( MsgUpdatedAt,+ Just $+ MsgUtcTime swapIntoLnUpdatedAt+ )+ ]+ >>= \case+ (msg, Just txt) -> [(msg, txt)]+ (_, Nothing) -> []+ where+ SwapIntoLn {..} =+ entityVal $+ SwapIntoLn.swapInfoSwap swapInfo+ userPub =+ toHex+ . coerce+ . userNodePubKey+ . entityVal+ $ SwapIntoLn.swapInfoUser swapInfo++totalOnChainAmt ::+ (SwapUtxoStatus -> Bool) ->+ SwapIntoLn.SwapInfo ->+ MSat+totalOnChainAmt only =+ from+ . sum+ . fmap swapUtxoAmount+ . filter (only . swapUtxoStatus)+ . fmap (entityVal . SwapIntoLn.utxoInfoUtxo)+ . SwapIntoLn.swapInfoUtxo++newUtxoWidget :: [SwapIntoLn.UtxoInfo] -> Maybe Widget+newUtxoWidget utxos =+ newNamedListWidget MsgSwapIntoLnHeaderUtxos $+ ( \row ->+ let SwapUtxo {..} =+ entityVal $ SwapIntoLn.utxoInfoUtxo row+ Block {..} =+ entityVal $ SwapIntoLn.utxoInfoBlock row+ in [ ( MsgBlock,+ MsgProxy+ . inspectPlain @Word64+ $ from blockHeight+ ),+ ( MsgAmount,+ MsgSatoshi $+ from swapUtxoAmount+ ),+ ( MsgStatus,+ swapUtxoStatusMsg swapUtxoStatus+ ),+ ( MsgTxId,+ MsgProxy+ . txIdHex+ $ coerce swapUtxoTxid+ ),+ ( MsgVout,+ MsgProxy+ . inspectPlain @Word32+ $ coerce swapUtxoVout+ ),+ ( MsgInsertedAt,+ MsgUtcTime swapUtxoInsertedAt+ ),+ ( MsgUpdatedAt,+ MsgUtcTime swapUtxoUpdatedAt+ )+ ]+ )+ <$> utxos++newChanWidget :: [Entity LnChan] -> Maybe Widget+newChanWidget chans =+ newNamedListWidget MsgSwapIntoLnHeaderChans $+ ( \row ->+ let LnChan {..} = entityVal row+ in [ ( MsgStatus,+ lnChanStatusMsg lnChanStatus+ ),+ ( MsgTxId,+ MsgProxy+ . txIdHex+ $ coerce lnChanFundingTxId+ ),+ ( MsgVout,+ MsgProxy+ . inspectPlain @Word32+ $ coerce lnChanFundingVout+ ),+ ( MsgInsertedAt,+ MsgUtcTime lnChanInsertedAt+ ),+ ( MsgUpdatedAt,+ MsgUtcTime lnChanUpdatedAt+ )+ ]+ )+ <$> chans++swapStatusMsg :: SwapStatus -> AppMessage+swapStatusMsg = \case+ SwapWaitingFundChain -> MsgSwapWaitingFundChain+ SwapWaitingPeer -> MsgSwapWaitingPeer+ SwapWaitingChan -> MsgSwapWaitingChan+ SwapSucceeded -> MsgSwapSucceeded+ SwapExpired -> MsgSwapExpired++chanPrivacyMsg :: Privacy -> AppMessage+chanPrivacyMsg = \case+ Private -> MsgChanPrivate+ Public -> MsgChanPublic++swapUtxoStatusMsg :: SwapUtxoStatus -> AppMessage+swapUtxoStatusMsg = \case+ SwapUtxoUnspent -> MsgSwapUtxoUnspent+ SwapUtxoUnspentDust -> MsgSwapUtxoUnspentDust+ SwapUtxoUnspentChanReserve -> MsgSwapUtxoUnspentChanReserve+ SwapUtxoSpentChanSwapped -> MsgSwapUtxoSpentChanSwapped+ SwapUtxoSpentRefund -> MsgSwapUtxoSpentRefund+ SwapUtxoOrphan -> MsgSwapUtxoOrphan++lnChanStatusMsg :: LnChanStatus -> AppMessage+lnChanStatusMsg = \case+ LnChanStatusPendingOpen -> MsgLnChanStatusPendingOpen+ LnChanStatusOpened -> MsgLnChanStatusOpened+ LnChanStatusActive -> MsgLnChanStatusActive+ LnChanStatusFullyResolved -> MsgLnChanStatusFullyResolved+ LnChanStatusInactive -> MsgLnChanStatusInactive+ LnChanStatusPendingClose -> MsgLnChanStatusPendingClose+ LnChanStatusClosed -> MsgLnChanStatusClosed
@@ -0,0 +1,52 @@+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE NoImplicitPrelude #-}++module BtcLsp.Yesod.Handler.SwapUpdates+ ( getSwapUpdatesR,+ getSwapUpdate,+ )+where++import qualified BtcLsp.Storage.Model.SwapIntoLn as SwapIntoLn+import BtcLsp.Time+import BtcLsp.Yesod.Import+import qualified Data.ByteString.Base64.URL as B64+import Data.ByteString.Char8 as C8+import qualified Data.ByteString.Lazy as L+import qualified Data.Digest.Pure.SHA as SHA+ ( bytestringDigest,+ sha256,+ )+import qualified Universum as U++getSwapUpdatesR :: Uuid 'SwapIntoLnTable -> SwapHash -> Handler (Maybe SwapHash)+getSwapUpdatesR uuid swapHash = do+ app <- getYesod+ getSwapUpdateRec app uuid swapHash 60++getSwapUpdateRec :: MonadHandler m => App -> Uuid 'SwapIntoLnTable -> SwapHash -> Integer -> m (Maybe SwapHash)+getSwapUpdateRec app uuid swapHash counter = do+ currentSwapUpdate <- getSwapUpdate app uuid+ if Just swapHash == currentSwapUpdate && counter > 0+ then do+ sleep5s+ getSwapUpdateRec app uuid swapHash (counter - 1)+ else return currentSwapUpdate++getSwapUpdate :: MonadHandler m => App -> Uuid 'SwapIntoLnTable -> m (Maybe SwapHash)+getSwapUpdate (App {appMRunner = UnliftIO run}) uuid =+ (SwapHash . hashFunc)+ U.<<$>> (liftIO . run . runSql . SwapIntoLn.getByUuidSql) uuid++hashFunc :: SwapIntoLn.SwapInfo -> Text+hashFunc =+ decodeUtf8+ . B64.encode+ . L.toStrict+ . SHA.bytestringDigest+ . SHA.sha256+ . L.fromStrict+ . C8.pack+ . show+ . (\x -> x {SwapIntoLn.swapInfoChan = []})
@@ -0,0 +1,8 @@+module BtcLsp.Yesod.Import+ ( module Import,+ )+where++import BtcLsp.Yesod.Data.BootstrapColor as Import+import BtcLsp.Yesod.Foundation as Import+import BtcLsp.Yesod.Import.NoFoundation as Import
@@ -0,0 +1,50 @@+{-# LANGUAGE CPP #-}++module BtcLsp.Yesod.Import.NoFoundation+ ( module Import,+ )+where++import BtcLsp.Class.Env as Import hiding (Env)+import BtcLsp.Class.Storage as Import+import BtcLsp.Data.Kind as Import+import BtcLsp.Data.Type as Import+import BtcLsp.Import.External as Import+ ( ExceptT (..),+ IsList,+ MSat (..),+ Natural,+ NodePubKey (..),+ Pool,+ RPreimage (..),+ TxId (..),+ Vout (..),+ coerce,+ eitherM,+ formatAsLogTime,+ maybeM,+ runExceptT,+ txIdHex,+ whenJust,+ withExceptT,+ (%),+ )+import BtcLsp.Import.Witch as Import+import BtcLsp.Storage.Model as Import+import BtcLsp.Text as Import+import BtcLsp.Yesod.Settings as Import+import BtcLsp.Yesod.Settings.StaticFiles as Import+import ClassyPrelude.Yesod as Import+import Data.Type.Equality as Import (type (==))+import Text.PrettyPrint.GenericPretty as Import (Out (..))+import Text.PrettyPrint.GenericPretty.Import as Import+ ( inspect,+ inspectGenPlain,+ inspectPlain,+ inspectStr,+ inspectStrPlain,+ )+import Text.PrettyPrint.GenericPretty.Instance as Import ()+import Yesod.Auth as Import+import Yesod.Core.Types as Import (loggerSet)+import Yesod.Default.Config2 as Import
@@ -0,0 +1,151 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE NoImplicitPrelude #-}++-- | Settings are centralized, as much as possible, into this file. This+-- includes database connection settings, static file locations, etc.+-- In addition, you can configure a number of different aspects of Yesod+-- by overriding methods in the Yesod typeclass. That instance is+-- declared in the Foundation.hs file.+module BtcLsp.Yesod.Settings where++import ClassyPrelude.Yesod+import qualified Control.Exception as Exception+import Data.Aeson+ ( Result (..),+ fromJSON,+ withObject,+ (.!=),+ (.:?),+ )+import Data.FileEmbed (embedFile)+import Data.Yaml (decodeEither')+import Language.Haskell.TH.Syntax (Exp, Name, Q)+import Network.Wai.Handler.Warp (HostPreference)+import Yesod.Default.Config2 (applyEnvValue, configSettingsYml)+import Yesod.Default.Util+ ( WidgetFileSettings,+ widgetFileNoReload,+ widgetFileReload,+ )++-- | Runtime settings to configure this application. These settings can be+-- loaded from various sources: defaults, environment variables, config files,+-- theoretically even a database.+data AppSettings = AppSettings+ { -- | Directory from which to serve static files.+ appStaticDir :: String,+ -- | Base for all generated URLs. If @Nothing@, determined+ -- from the request headers.+ appRoot :: Maybe Text,+ -- | Host/interface the server should bind to.+ appHost :: HostPreference,+ -- | Port to listen on+ appPort :: Int,+ -- | Get the IP address from the header when logging. Useful when sitting+ -- behind a reverse proxy.+ appIpFromHeader :: Bool,+ -- | Use detailed request logging system+ appDetailedRequestLogging :: Bool,+ -- | Should all log messages be displayed?+ appShouldLogAll :: Bool,+ -- | Use the reload version of templates+ appReloadTemplates :: Bool,+ -- | Assume that files in the static dir may change after compilation+ appMutableStatic :: Bool,+ -- | Perform no stylesheet/script combining+ appSkipCombining :: Bool,+ -- Example app-specific configuration values.++ -- | Copyright text to appear in the footer of the page+ appCopyright :: Text,+ -- | Google Analytics code+ appAnalytics :: Maybe Text,+ -- | Indicate if auth dummy login should be enabled.+ appAuthDummyLogin :: Bool+ }++instance FromJSON AppSettings where+ parseJSON = withObject "AppSettings" $ \o -> do+ let defaultDev = False+ appStaticDir <- o .: "static-dir"+ appRoot <- o .:? "approot"+ appHost <- fromString <$> o .: "host"+ appPort <- o .: "port"+ appIpFromHeader <- o .: "ip-from-header"++ dev <- o .:? "development" .!= defaultDev++ appDetailedRequestLogging <- o .:? "detailed-logging" .!= dev+ appShouldLogAll <- o .:? "should-log-all" .!= dev+ appReloadTemplates <- o .:? "reload-templates" .!= dev+ appMutableStatic <- o .:? "mutable-static" .!= dev+ appSkipCombining <- o .:? "skip-combining" .!= dev++ appCopyright <- o .: "copyright"+ appAnalytics <- o .:? "analytics"++ appAuthDummyLogin <- o .:? "auth-dummy-login" .!= dev++ return AppSettings {..}++-- | Settings for 'widgetFile', such as which template languages to support and+-- default Hamlet settings.+--+-- For more information on modifying behavior, see:+--+-- https://github.com/yesodweb/yesod/wiki/Overriding-widgetFile+widgetFileSettings :: WidgetFileSettings+widgetFileSettings = def++-- | How static files should be combined.+combineSettings :: CombineSettings+combineSettings = def++-- The rest of this file contains settings which rarely need changing by a+-- user.++widgetFile :: String -> Q Exp+widgetFile =+ ( if appReloadTemplates compileTimeAppSettings+ then widgetFileReload+ else widgetFileNoReload+ )+ widgetFileSettings++-- | Raw bytes at compile time of @config/settings.yml@+configSettingsYmlBS :: ByteString+configSettingsYmlBS = $(embedFile configSettingsYml)++-- | @config/settings.yml@, parsed to a @Value@.+configSettingsYmlValue :: Value+configSettingsYmlValue =+ either Exception.throw id $+ decodeEither' configSettingsYmlBS++-- | A version of @AppSettings@ parsed at compile time from @config/settings.yml@.+compileTimeAppSettings :: AppSettings+compileTimeAppSettings =+ case fromJSON $ applyEnvValue False mempty configSettingsYmlValue of+ Error e -> error e+ Success settings -> settings++-- The following two functions can be used to combine multiple CSS or JS files+-- at compile time to decrease the number of http requests.+-- Sample usage (inside a Widget):+--+-- > $(combineStylesheets 'StaticR [style1_css, style2_css])++combineStylesheets :: Name -> [Route Static] -> Q Exp+combineStylesheets =+ combineStylesheets'+ (appSkipCombining compileTimeAppSettings)+ combineSettings++combineScripts :: Name -> [Route Static] -> Q Exp+combineScripts =+ combineScripts'+ (appSkipCombining compileTimeAppSettings)+ combineSettings
@@ -0,0 +1,40 @@+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE NoImplicitPrelude #-}++module BtcLsp.Yesod.Settings.StaticFiles where++import BtcLsp.Yesod.Settings (appStaticDir, compileTimeAppSettings)+import Yesod.Static (staticFiles)++-- This generates easy references to files in the static directory at compile time,+-- giving you compile-time verification that referenced files exist.+-- Warning: any files added to your static directory during run-time can't be+-- accessed this way. You'll have to use their FilePath or URL to access them.+--+-- For example, to refer to @static/js/script.js@ via an identifier, you'd use:+--+-- js_script_js+--+-- If the identifier is not available, you may use:+--+-- StaticFile ["js", "script.js"] []+staticFiles (appStaticDir compileTimeAppSettings)++-- If you prefer to updating the references by force+-- -- especially when you are devloping like `stack exec -- yesod devel` --+-- you can update references by chaning file stamp.+--+-- On linux or Unix-like system, you can use+-- shell> touch /Path/To/Settings/StaticFiles.hs+--+-- or save without changes on your favorite editor.+-- so yesod devel will re-compile automatically and generate the refereces+-- including new one.+--+-- In this way you can use on your shakespearean template(s)+-- Let's say you have image on "yourStaticDir/img/background-1.jpg"+-- you can use the reference of the file on shakespearean templates like bellow+--+-- /* note: `-' becomes '_' as well */+-- @{StaticR img_background_1_jpg}
@@ -0,0 +1,21 @@+module BtcLsp.Yesod.TH+ ( mkMessageNoFallback,+ )+where++import BtcLsp.Yesod.Import.NoFoundation hiding (forM_)+import Data.Foldable (forM_)+import Data.List.NonEmpty+import Language.Haskell.TH.Syntax++mkMessageNoFallback ::+ -- | base name to use for translation type+ String ->+ -- | subdirectory which contains the translation files+ FilePath ->+ -- | default translation language is first+ NonEmpty Lang ->+ Q [Dec]+mkMessageNoFallback dt folder (lang :| langs) = do+ forM_ langs $ mkMessage dt folder+ mkMessage dt folder lang
@@ -0,0 +1,69 @@+{- This file was auto-generated from btc_lsp.proto by the proto-lens-protoc program. -}+{-# LANGUAGE ScopedTypeVariables, DataKinds, TypeFamilies, UndecidableInstances, GeneralizedNewtypeDeriving, MultiParamTypeClasses, FlexibleContexts, FlexibleInstances, PatternSynonyms, MagicHash, NoImplicitPrelude, BangPatterns, TypeApplications, OverloadedStrings, DerivingStrategies, DeriveGeneric#-}+{-# OPTIONS_GHC -Wno-unused-imports#-}+{-# OPTIONS_GHC -Wno-duplicate-exports#-}+{-# OPTIONS_GHC -Wno-dodgy-exports#-}+module Proto.BtcLsp (+ Service(..)+ ) where+import qualified Data.ProtoLens.Runtime.Control.DeepSeq as Control.DeepSeq+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Prism as Data.ProtoLens.Prism+import qualified Text.PrettyPrint.GenericPretty.Instance+import qualified GHC.Generics+import qualified Text.PrettyPrint.GenericPretty+import qualified Data.ProtoLens.Runtime.Prelude as Prelude+import qualified Data.ProtoLens.Runtime.Data.Int as Data.Int+import qualified Data.ProtoLens.Runtime.Data.Monoid as Data.Monoid+import qualified Data.ProtoLens.Runtime.Data.Word as Data.Word+import qualified Data.ProtoLens.Runtime.Data.ProtoLens as Data.ProtoLens+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Bytes as Data.ProtoLens.Encoding.Bytes+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Growing as Data.ProtoLens.Encoding.Growing+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Parser.Unsafe as Data.ProtoLens.Encoding.Parser.Unsafe+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Wire as Data.ProtoLens.Encoding.Wire+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Field as Data.ProtoLens.Field+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Message.Enum as Data.ProtoLens.Message.Enum+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Service.Types as Data.ProtoLens.Service.Types+import qualified Data.ProtoLens.Runtime.Lens.Family2 as Lens.Family2+import qualified Data.ProtoLens.Runtime.Lens.Family2.Unchecked as Lens.Family2.Unchecked+import qualified Data.ProtoLens.Runtime.Data.Text as Data.Text+import qualified Data.ProtoLens.Runtime.Data.Map as Data.Map+import qualified Data.ProtoLens.Runtime.Data.ByteString as Data.ByteString+import qualified Data.ProtoLens.Runtime.Data.ByteString.Char8 as Data.ByteString.Char8+import qualified Data.ProtoLens.Runtime.Data.Text.Encoding as Data.Text.Encoding+import qualified Data.ProtoLens.Runtime.Data.Vector as Data.Vector+import qualified Data.ProtoLens.Runtime.Data.Vector.Generic as Data.Vector.Generic+import qualified Data.ProtoLens.Runtime.Data.Vector.Unboxed as Data.Vector.Unboxed+import qualified Data.ProtoLens.Runtime.Text.Read as Text.Read+import qualified Proto.BtcLsp.Method.GetCfg+import qualified Proto.BtcLsp.Method.SwapFromLn+import qualified Proto.BtcLsp.Method.SwapIntoLn+data Service = Service {}+instance Data.ProtoLens.Service.Types.Service Service where+ type ServiceName Service = "Service"+ type ServicePackage Service = "BtcLsp"+ type ServiceMethods Service = '["getCfg",+ "swapFromLn",+ "swapIntoLn"]+ packedServiceDescriptor _+ = "\n\+ \\aService\DC2G\n\+ \\ACKGetCfg\DC2\GS.BtcLsp.Method.GetCfg.Request\SUB\RS.BtcLsp.Method.GetCfg.Response\DC2S\n\+ \\n\+ \SwapIntoLn\DC2!.BtcLsp.Method.SwapIntoLn.Request\SUB\".BtcLsp.Method.SwapIntoLn.Response\DC2S\n\+ \\n\+ \SwapFromLn\DC2!.BtcLsp.Method.SwapFromLn.Request\SUB\".BtcLsp.Method.SwapFromLn.Response"+instance Data.ProtoLens.Service.Types.HasMethodImpl Service "getCfg" where+ type MethodName Service "getCfg" = "GetCfg"+ type MethodInput Service "getCfg" = Proto.BtcLsp.Method.GetCfg.Request+ type MethodOutput Service "getCfg" = Proto.BtcLsp.Method.GetCfg.Response+ type MethodStreamingType Service "getCfg" = 'Data.ProtoLens.Service.Types.NonStreaming+instance Data.ProtoLens.Service.Types.HasMethodImpl Service "swapIntoLn" where+ type MethodName Service "swapIntoLn" = "SwapIntoLn"+ type MethodInput Service "swapIntoLn" = Proto.BtcLsp.Method.SwapIntoLn.Request+ type MethodOutput Service "swapIntoLn" = Proto.BtcLsp.Method.SwapIntoLn.Response+ type MethodStreamingType Service "swapIntoLn" = 'Data.ProtoLens.Service.Types.NonStreaming+instance Data.ProtoLens.Service.Types.HasMethodImpl Service "swapFromLn" where+ type MethodName Service "swapFromLn" = "SwapFromLn"+ type MethodInput Service "swapFromLn" = Proto.BtcLsp.Method.SwapFromLn.Request+ type MethodOutput Service "swapFromLn" = Proto.BtcLsp.Method.SwapFromLn.Response+ type MethodStreamingType Service "swapFromLn" = 'Data.ProtoLens.Service.Types.NonStreaming
@@ -0,0 +1,3247 @@+{- This file was auto-generated from btc_lsp/data/high_level.proto by the proto-lens-protoc program. -}+{-# LANGUAGE ScopedTypeVariables, DataKinds, TypeFamilies, UndecidableInstances, GeneralizedNewtypeDeriving, MultiParamTypeClasses, FlexibleContexts, FlexibleInstances, PatternSynonyms, MagicHash, NoImplicitPrelude, BangPatterns, TypeApplications, OverloadedStrings, DerivingStrategies, DeriveGeneric#-}+{-# OPTIONS_GHC -Wno-unused-imports#-}+{-# OPTIONS_GHC -Wno-duplicate-exports#-}+{-# OPTIONS_GHC -Wno-dodgy-exports#-}+module Proto.BtcLsp.Data.HighLevel (+ Ctx(), FeeMoney(), FeeRate(), FieldIndex(), FundLnHodlInvoice(),+ FundLnInvoice(), FundMoney(), FundOnChainAddress(), InputFailure(),+ InputFailureKind(..), InputFailureKind(),+ InputFailureKind'UnrecognizedValue, InternalFailure(),+ InternalFailure'Either(..), _InternalFailure'Redacted,+ _InternalFailure'GrpcServer, _InternalFailure'Math, LnHost(),+ LnPeer(), LnPort(), LnPubKey(), LocalBalance(), Nonce(),+ Privacy(..), Privacy(), Privacy'UnrecognizedValue, RefundMoney(),+ RefundOnChainAddress(), RemoteBalance()+ ) where+import qualified Data.ProtoLens.Runtime.Control.DeepSeq as Control.DeepSeq+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Prism as Data.ProtoLens.Prism+import qualified Text.PrettyPrint.GenericPretty.Instance+import qualified GHC.Generics+import qualified Text.PrettyPrint.GenericPretty+import qualified Data.ProtoLens.Runtime.Prelude as Prelude+import qualified Data.ProtoLens.Runtime.Data.Int as Data.Int+import qualified Data.ProtoLens.Runtime.Data.Monoid as Data.Monoid+import qualified Data.ProtoLens.Runtime.Data.Word as Data.Word+import qualified Data.ProtoLens.Runtime.Data.ProtoLens as Data.ProtoLens+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Bytes as Data.ProtoLens.Encoding.Bytes+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Growing as Data.ProtoLens.Encoding.Growing+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Parser.Unsafe as Data.ProtoLens.Encoding.Parser.Unsafe+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Wire as Data.ProtoLens.Encoding.Wire+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Field as Data.ProtoLens.Field+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Message.Enum as Data.ProtoLens.Message.Enum+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Service.Types as Data.ProtoLens.Service.Types+import qualified Data.ProtoLens.Runtime.Lens.Family2 as Lens.Family2+import qualified Data.ProtoLens.Runtime.Lens.Family2.Unchecked as Lens.Family2.Unchecked+import qualified Data.ProtoLens.Runtime.Data.Text as Data.Text+import qualified Data.ProtoLens.Runtime.Data.Map as Data.Map+import qualified Data.ProtoLens.Runtime.Data.ByteString as Data.ByteString+import qualified Data.ProtoLens.Runtime.Data.ByteString.Char8 as Data.ByteString.Char8+import qualified Data.ProtoLens.Runtime.Data.Text.Encoding as Data.Text.Encoding+import qualified Data.ProtoLens.Runtime.Data.Vector as Data.Vector+import qualified Data.ProtoLens.Runtime.Data.Vector.Generic as Data.Vector.Generic+import qualified Data.ProtoLens.Runtime.Data.Vector.Unboxed as Data.Vector.Unboxed+import qualified Data.ProtoLens.Runtime.Text.Read as Text.Read+import qualified Proto.BtcLsp.Data.LowLevel+{- | Fields :+ + * 'Proto.BtcLsp.Data.HighLevel_Fields.nonce' @:: Lens' Ctx Nonce@+ * 'Proto.BtcLsp.Data.HighLevel_Fields.maybe'nonce' @:: Lens' Ctx (Prelude.Maybe Nonce)@+ * 'Proto.BtcLsp.Data.HighLevel_Fields.lnPubKey' @:: Lens' Ctx LnPubKey@+ * 'Proto.BtcLsp.Data.HighLevel_Fields.maybe'lnPubKey' @:: Lens' Ctx (Prelude.Maybe LnPubKey)@ -}+data Ctx+ = Ctx'_constructor {_Ctx'nonce :: !(Prelude.Maybe Nonce),+ _Ctx'lnPubKey :: !(Prelude.Maybe LnPubKey),+ _Ctx'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show Ctx where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out Ctx+instance Data.ProtoLens.Field.HasField Ctx "nonce" Nonce where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Ctx'nonce (\ x__ y__ -> x__ {_Ctx'nonce = y__}))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage)+instance Data.ProtoLens.Field.HasField Ctx "maybe'nonce" (Prelude.Maybe Nonce) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Ctx'nonce (\ x__ y__ -> x__ {_Ctx'nonce = y__}))+ Prelude.id+instance Data.ProtoLens.Field.HasField Ctx "lnPubKey" LnPubKey where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Ctx'lnPubKey (\ x__ y__ -> x__ {_Ctx'lnPubKey = y__}))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage)+instance Data.ProtoLens.Field.HasField Ctx "maybe'lnPubKey" (Prelude.Maybe LnPubKey) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Ctx'lnPubKey (\ x__ y__ -> x__ {_Ctx'lnPubKey = y__}))+ Prelude.id+instance Data.ProtoLens.Message Ctx where+ messageName _ = Data.Text.pack "BtcLsp.Data.HighLevel.Ctx"+ packedMessageDescriptor _+ = "\n\+ \\ETXCtx\DC22\n\+ \\ENQnonce\CAN\SOH \SOH(\v2\FS.BtcLsp.Data.HighLevel.NonceR\ENQnonce\DC2=\n\+ \\n\+ \ln_pub_key\CAN\STX \SOH(\v2\US.BtcLsp.Data.HighLevel.LnPubKeyR\blnPubKey"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ nonce__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "nonce"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Nonce)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'nonce")) ::+ Data.ProtoLens.FieldDescriptor Ctx+ lnPubKey__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "ln_pub_key"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor LnPubKey)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'lnPubKey")) ::+ Data.ProtoLens.FieldDescriptor Ctx+ in+ Data.Map.fromList+ [(Data.ProtoLens.Tag 1, nonce__field_descriptor),+ (Data.ProtoLens.Tag 2, lnPubKey__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _Ctx'_unknownFields (\ x__ y__ -> x__ {_Ctx'_unknownFields = y__})+ defMessage+ = Ctx'_constructor+ {_Ctx'nonce = Prelude.Nothing, _Ctx'lnPubKey = Prelude.Nothing,+ _Ctx'_unknownFields = []}+ parseMessage+ = let+ loop :: Ctx -> Data.ProtoLens.Encoding.Bytes.Parser Ctx+ loop x+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) x)+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 10+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "nonce"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"nonce") y x)+ 18+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "ln_pub_key"+ loop+ (Lens.Family2.set (Data.ProtoLens.Field.field @"lnPubKey") y x)+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do loop Data.ProtoLens.defMessage) "Ctx"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (case+ Lens.Family2.view (Data.ProtoLens.Field.field @"maybe'nonce") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just _v)+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 10)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ ((Data.Monoid.<>)+ (case+ Lens.Family2.view (Data.ProtoLens.Field.field @"maybe'lnPubKey") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just _v)+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 18)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x)))+instance Control.DeepSeq.NFData Ctx where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_Ctx'_unknownFields x__)+ (Control.DeepSeq.deepseq+ (_Ctx'nonce x__) (Control.DeepSeq.deepseq (_Ctx'lnPubKey x__) ()))+{- | Fields :+ + * 'Proto.BtcLsp.Data.HighLevel_Fields.val' @:: Lens' FeeMoney Proto.BtcLsp.Data.LowLevel.Msat@+ * 'Proto.BtcLsp.Data.HighLevel_Fields.maybe'val' @:: Lens' FeeMoney (Prelude.Maybe Proto.BtcLsp.Data.LowLevel.Msat)@ -}+data FeeMoney+ = FeeMoney'_constructor {_FeeMoney'val :: !(Prelude.Maybe Proto.BtcLsp.Data.LowLevel.Msat),+ _FeeMoney'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show FeeMoney where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out FeeMoney+instance Data.ProtoLens.Field.HasField FeeMoney "val" Proto.BtcLsp.Data.LowLevel.Msat where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _FeeMoney'val (\ x__ y__ -> x__ {_FeeMoney'val = y__}))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage)+instance Data.ProtoLens.Field.HasField FeeMoney "maybe'val" (Prelude.Maybe Proto.BtcLsp.Data.LowLevel.Msat) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _FeeMoney'val (\ x__ y__ -> x__ {_FeeMoney'val = y__}))+ Prelude.id+instance Data.ProtoLens.Message FeeMoney where+ messageName _ = Data.Text.pack "BtcLsp.Data.HighLevel.FeeMoney"+ packedMessageDescriptor _+ = "\n\+ \\bFeeMoney\DC2,\n\+ \\ETXval\CAN\SOH \SOH(\v2\SUB.BtcLsp.Data.LowLevel.MsatR\ETXval"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ val__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "val"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.LowLevel.Msat)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'val")) ::+ Data.ProtoLens.FieldDescriptor FeeMoney+ in+ Data.Map.fromList [(Data.ProtoLens.Tag 1, val__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _FeeMoney'_unknownFields+ (\ x__ y__ -> x__ {_FeeMoney'_unknownFields = y__})+ defMessage+ = FeeMoney'_constructor+ {_FeeMoney'val = Prelude.Nothing, _FeeMoney'_unknownFields = []}+ parseMessage+ = let+ loop :: FeeMoney -> Data.ProtoLens.Encoding.Bytes.Parser FeeMoney+ loop x+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) x)+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 10+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "val"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"val") y x)+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do loop Data.ProtoLens.defMessage) "FeeMoney"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (case+ Lens.Family2.view (Data.ProtoLens.Field.field @"maybe'val") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just _v)+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 10)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x))+instance Control.DeepSeq.NFData FeeMoney where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_FeeMoney'_unknownFields x__)+ (Control.DeepSeq.deepseq (_FeeMoney'val x__) ())+{- | Fields :+ + * 'Proto.BtcLsp.Data.HighLevel_Fields.val' @:: Lens' FeeRate Proto.BtcLsp.Data.LowLevel.Urational@+ * 'Proto.BtcLsp.Data.HighLevel_Fields.maybe'val' @:: Lens' FeeRate (Prelude.Maybe Proto.BtcLsp.Data.LowLevel.Urational)@ -}+data FeeRate+ = FeeRate'_constructor {_FeeRate'val :: !(Prelude.Maybe Proto.BtcLsp.Data.LowLevel.Urational),+ _FeeRate'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show FeeRate where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out FeeRate+instance Data.ProtoLens.Field.HasField FeeRate "val" Proto.BtcLsp.Data.LowLevel.Urational where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _FeeRate'val (\ x__ y__ -> x__ {_FeeRate'val = y__}))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage)+instance Data.ProtoLens.Field.HasField FeeRate "maybe'val" (Prelude.Maybe Proto.BtcLsp.Data.LowLevel.Urational) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _FeeRate'val (\ x__ y__ -> x__ {_FeeRate'val = y__}))+ Prelude.id+instance Data.ProtoLens.Message FeeRate where+ messageName _ = Data.Text.pack "BtcLsp.Data.HighLevel.FeeRate"+ packedMessageDescriptor _+ = "\n\+ \\aFeeRate\DC21\n\+ \\ETXval\CAN\SOH \SOH(\v2\US.BtcLsp.Data.LowLevel.UrationalR\ETXval"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ val__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "val"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.LowLevel.Urational)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'val")) ::+ Data.ProtoLens.FieldDescriptor FeeRate+ in+ Data.Map.fromList [(Data.ProtoLens.Tag 1, val__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _FeeRate'_unknownFields+ (\ x__ y__ -> x__ {_FeeRate'_unknownFields = y__})+ defMessage+ = FeeRate'_constructor+ {_FeeRate'val = Prelude.Nothing, _FeeRate'_unknownFields = []}+ parseMessage+ = let+ loop :: FeeRate -> Data.ProtoLens.Encoding.Bytes.Parser FeeRate+ loop x+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) x)+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 10+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "val"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"val") y x)+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do loop Data.ProtoLens.defMessage) "FeeRate"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (case+ Lens.Family2.view (Data.ProtoLens.Field.field @"maybe'val") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just _v)+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 10)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x))+instance Control.DeepSeq.NFData FeeRate where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_FeeRate'_unknownFields x__)+ (Control.DeepSeq.deepseq (_FeeRate'val x__) ())+{- | Fields :+ + * 'Proto.BtcLsp.Data.HighLevel_Fields.val' @:: Lens' FieldIndex Data.Word.Word32@ -}+data FieldIndex+ = FieldIndex'_constructor {_FieldIndex'val :: !Data.Word.Word32,+ _FieldIndex'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show FieldIndex where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out FieldIndex+instance Data.ProtoLens.Field.HasField FieldIndex "val" Data.Word.Word32 where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _FieldIndex'val (\ x__ y__ -> x__ {_FieldIndex'val = y__}))+ Prelude.id+instance Data.ProtoLens.Message FieldIndex where+ messageName _ = Data.Text.pack "BtcLsp.Data.HighLevel.FieldIndex"+ packedMessageDescriptor _+ = "\n\+ \\n\+ \FieldIndex\DC2\DLE\n\+ \\ETXval\CAN\SOH \SOH(\rR\ETXval"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ val__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "val"+ (Data.ProtoLens.ScalarField Data.ProtoLens.UInt32Field ::+ Data.ProtoLens.FieldTypeDescriptor Data.Word.Word32)+ (Data.ProtoLens.PlainField+ Data.ProtoLens.Optional (Data.ProtoLens.Field.field @"val")) ::+ Data.ProtoLens.FieldDescriptor FieldIndex+ in+ Data.Map.fromList [(Data.ProtoLens.Tag 1, val__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _FieldIndex'_unknownFields+ (\ x__ y__ -> x__ {_FieldIndex'_unknownFields = y__})+ defMessage+ = FieldIndex'_constructor+ {_FieldIndex'val = Data.ProtoLens.fieldDefault,+ _FieldIndex'_unknownFields = []}+ parseMessage+ = let+ loop ::+ FieldIndex -> Data.ProtoLens.Encoding.Bytes.Parser FieldIndex+ loop x+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) x)+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 8 -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (Prelude.fmap+ Prelude.fromIntegral+ Data.ProtoLens.Encoding.Bytes.getVarInt)+ "val"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"val") y x)+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do loop Data.ProtoLens.defMessage) "FieldIndex"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (let _v = Lens.Family2.view (Data.ProtoLens.Field.field @"val") _x+ in+ if (Prelude.==) _v Data.ProtoLens.fieldDefault then+ Data.Monoid.mempty+ else+ (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 8)+ ((Prelude..)+ Data.ProtoLens.Encoding.Bytes.putVarInt Prelude.fromIntegral _v))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x))+instance Control.DeepSeq.NFData FieldIndex where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_FieldIndex'_unknownFields x__)+ (Control.DeepSeq.deepseq (_FieldIndex'val x__) ())+{- | Fields :+ + * 'Proto.BtcLsp.Data.HighLevel_Fields.val' @:: Lens' FundLnHodlInvoice Proto.BtcLsp.Data.LowLevel.LnHodlInvoice@+ * 'Proto.BtcLsp.Data.HighLevel_Fields.maybe'val' @:: Lens' FundLnHodlInvoice (Prelude.Maybe Proto.BtcLsp.Data.LowLevel.LnHodlInvoice)@ -}+data FundLnHodlInvoice+ = FundLnHodlInvoice'_constructor {_FundLnHodlInvoice'val :: !(Prelude.Maybe Proto.BtcLsp.Data.LowLevel.LnHodlInvoice),+ _FundLnHodlInvoice'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show FundLnHodlInvoice where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out FundLnHodlInvoice+instance Data.ProtoLens.Field.HasField FundLnHodlInvoice "val" Proto.BtcLsp.Data.LowLevel.LnHodlInvoice where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _FundLnHodlInvoice'val+ (\ x__ y__ -> x__ {_FundLnHodlInvoice'val = y__}))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage)+instance Data.ProtoLens.Field.HasField FundLnHodlInvoice "maybe'val" (Prelude.Maybe Proto.BtcLsp.Data.LowLevel.LnHodlInvoice) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _FundLnHodlInvoice'val+ (\ x__ y__ -> x__ {_FundLnHodlInvoice'val = y__}))+ Prelude.id+instance Data.ProtoLens.Message FundLnHodlInvoice where+ messageName _+ = Data.Text.pack "BtcLsp.Data.HighLevel.FundLnHodlInvoice"+ packedMessageDescriptor _+ = "\n\+ \\DC1FundLnHodlInvoice\DC25\n\+ \\ETXval\CAN\SOH \SOH(\v2#.BtcLsp.Data.LowLevel.LnHodlInvoiceR\ETXval"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ val__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "val"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.LowLevel.LnHodlInvoice)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'val")) ::+ Data.ProtoLens.FieldDescriptor FundLnHodlInvoice+ in+ Data.Map.fromList [(Data.ProtoLens.Tag 1, val__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _FundLnHodlInvoice'_unknownFields+ (\ x__ y__ -> x__ {_FundLnHodlInvoice'_unknownFields = y__})+ defMessage+ = FundLnHodlInvoice'_constructor+ {_FundLnHodlInvoice'val = Prelude.Nothing,+ _FundLnHodlInvoice'_unknownFields = []}+ parseMessage+ = let+ loop ::+ FundLnHodlInvoice+ -> Data.ProtoLens.Encoding.Bytes.Parser FundLnHodlInvoice+ loop x+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) x)+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 10+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "val"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"val") y x)+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do loop Data.ProtoLens.defMessage) "FundLnHodlInvoice"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (case+ Lens.Family2.view (Data.ProtoLens.Field.field @"maybe'val") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just _v)+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 10)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x))+instance Control.DeepSeq.NFData FundLnHodlInvoice where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_FundLnHodlInvoice'_unknownFields x__)+ (Control.DeepSeq.deepseq (_FundLnHodlInvoice'val x__) ())+{- | Fields :+ + * 'Proto.BtcLsp.Data.HighLevel_Fields.val' @:: Lens' FundLnInvoice Proto.BtcLsp.Data.LowLevel.LnInvoice@+ * 'Proto.BtcLsp.Data.HighLevel_Fields.maybe'val' @:: Lens' FundLnInvoice (Prelude.Maybe Proto.BtcLsp.Data.LowLevel.LnInvoice)@ -}+data FundLnInvoice+ = FundLnInvoice'_constructor {_FundLnInvoice'val :: !(Prelude.Maybe Proto.BtcLsp.Data.LowLevel.LnInvoice),+ _FundLnInvoice'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show FundLnInvoice where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out FundLnInvoice+instance Data.ProtoLens.Field.HasField FundLnInvoice "val" Proto.BtcLsp.Data.LowLevel.LnInvoice where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _FundLnInvoice'val (\ x__ y__ -> x__ {_FundLnInvoice'val = y__}))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage)+instance Data.ProtoLens.Field.HasField FundLnInvoice "maybe'val" (Prelude.Maybe Proto.BtcLsp.Data.LowLevel.LnInvoice) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _FundLnInvoice'val (\ x__ y__ -> x__ {_FundLnInvoice'val = y__}))+ Prelude.id+instance Data.ProtoLens.Message FundLnInvoice where+ messageName _+ = Data.Text.pack "BtcLsp.Data.HighLevel.FundLnInvoice"+ packedMessageDescriptor _+ = "\n\+ \\rFundLnInvoice\DC21\n\+ \\ETXval\CAN\SOH \SOH(\v2\US.BtcLsp.Data.LowLevel.LnInvoiceR\ETXval"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ val__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "val"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.LowLevel.LnInvoice)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'val")) ::+ Data.ProtoLens.FieldDescriptor FundLnInvoice+ in+ Data.Map.fromList [(Data.ProtoLens.Tag 1, val__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _FundLnInvoice'_unknownFields+ (\ x__ y__ -> x__ {_FundLnInvoice'_unknownFields = y__})+ defMessage+ = FundLnInvoice'_constructor+ {_FundLnInvoice'val = Prelude.Nothing,+ _FundLnInvoice'_unknownFields = []}+ parseMessage+ = let+ loop ::+ FundLnInvoice -> Data.ProtoLens.Encoding.Bytes.Parser FundLnInvoice+ loop x+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) x)+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 10+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "val"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"val") y x)+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do loop Data.ProtoLens.defMessage) "FundLnInvoice"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (case+ Lens.Family2.view (Data.ProtoLens.Field.field @"maybe'val") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just _v)+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 10)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x))+instance Control.DeepSeq.NFData FundLnInvoice where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_FundLnInvoice'_unknownFields x__)+ (Control.DeepSeq.deepseq (_FundLnInvoice'val x__) ())+{- | Fields :+ + * 'Proto.BtcLsp.Data.HighLevel_Fields.val' @:: Lens' FundMoney Proto.BtcLsp.Data.LowLevel.Msat@+ * 'Proto.BtcLsp.Data.HighLevel_Fields.maybe'val' @:: Lens' FundMoney (Prelude.Maybe Proto.BtcLsp.Data.LowLevel.Msat)@ -}+data FundMoney+ = FundMoney'_constructor {_FundMoney'val :: !(Prelude.Maybe Proto.BtcLsp.Data.LowLevel.Msat),+ _FundMoney'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show FundMoney where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out FundMoney+instance Data.ProtoLens.Field.HasField FundMoney "val" Proto.BtcLsp.Data.LowLevel.Msat where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _FundMoney'val (\ x__ y__ -> x__ {_FundMoney'val = y__}))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage)+instance Data.ProtoLens.Field.HasField FundMoney "maybe'val" (Prelude.Maybe Proto.BtcLsp.Data.LowLevel.Msat) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _FundMoney'val (\ x__ y__ -> x__ {_FundMoney'val = y__}))+ Prelude.id+instance Data.ProtoLens.Message FundMoney where+ messageName _ = Data.Text.pack "BtcLsp.Data.HighLevel.FundMoney"+ packedMessageDescriptor _+ = "\n\+ \\tFundMoney\DC2,\n\+ \\ETXval\CAN\SOH \SOH(\v2\SUB.BtcLsp.Data.LowLevel.MsatR\ETXval"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ val__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "val"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.LowLevel.Msat)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'val")) ::+ Data.ProtoLens.FieldDescriptor FundMoney+ in+ Data.Map.fromList [(Data.ProtoLens.Tag 1, val__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _FundMoney'_unknownFields+ (\ x__ y__ -> x__ {_FundMoney'_unknownFields = y__})+ defMessage+ = FundMoney'_constructor+ {_FundMoney'val = Prelude.Nothing, _FundMoney'_unknownFields = []}+ parseMessage+ = let+ loop :: FundMoney -> Data.ProtoLens.Encoding.Bytes.Parser FundMoney+ loop x+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) x)+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 10+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "val"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"val") y x)+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do loop Data.ProtoLens.defMessage) "FundMoney"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (case+ Lens.Family2.view (Data.ProtoLens.Field.field @"maybe'val") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just _v)+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 10)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x))+instance Control.DeepSeq.NFData FundMoney where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_FundMoney'_unknownFields x__)+ (Control.DeepSeq.deepseq (_FundMoney'val x__) ())+{- | Fields :+ + * 'Proto.BtcLsp.Data.HighLevel_Fields.val' @:: Lens' FundOnChainAddress Proto.BtcLsp.Data.LowLevel.OnChainAddress@+ * 'Proto.BtcLsp.Data.HighLevel_Fields.maybe'val' @:: Lens' FundOnChainAddress (Prelude.Maybe Proto.BtcLsp.Data.LowLevel.OnChainAddress)@ -}+data FundOnChainAddress+ = FundOnChainAddress'_constructor {_FundOnChainAddress'val :: !(Prelude.Maybe Proto.BtcLsp.Data.LowLevel.OnChainAddress),+ _FundOnChainAddress'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show FundOnChainAddress where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out FundOnChainAddress+instance Data.ProtoLens.Field.HasField FundOnChainAddress "val" Proto.BtcLsp.Data.LowLevel.OnChainAddress where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _FundOnChainAddress'val+ (\ x__ y__ -> x__ {_FundOnChainAddress'val = y__}))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage)+instance Data.ProtoLens.Field.HasField FundOnChainAddress "maybe'val" (Prelude.Maybe Proto.BtcLsp.Data.LowLevel.OnChainAddress) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _FundOnChainAddress'val+ (\ x__ y__ -> x__ {_FundOnChainAddress'val = y__}))+ Prelude.id+instance Data.ProtoLens.Message FundOnChainAddress where+ messageName _+ = Data.Text.pack "BtcLsp.Data.HighLevel.FundOnChainAddress"+ packedMessageDescriptor _+ = "\n\+ \\DC2FundOnChainAddress\DC26\n\+ \\ETXval\CAN\SOH \SOH(\v2$.BtcLsp.Data.LowLevel.OnChainAddressR\ETXval"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ val__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "val"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.LowLevel.OnChainAddress)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'val")) ::+ Data.ProtoLens.FieldDescriptor FundOnChainAddress+ in+ Data.Map.fromList [(Data.ProtoLens.Tag 1, val__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _FundOnChainAddress'_unknownFields+ (\ x__ y__ -> x__ {_FundOnChainAddress'_unknownFields = y__})+ defMessage+ = FundOnChainAddress'_constructor+ {_FundOnChainAddress'val = Prelude.Nothing,+ _FundOnChainAddress'_unknownFields = []}+ parseMessage+ = let+ loop ::+ FundOnChainAddress+ -> Data.ProtoLens.Encoding.Bytes.Parser FundOnChainAddress+ loop x+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) x)+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 10+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "val"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"val") y x)+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do loop Data.ProtoLens.defMessage) "FundOnChainAddress"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (case+ Lens.Family2.view (Data.ProtoLens.Field.field @"maybe'val") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just _v)+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 10)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x))+instance Control.DeepSeq.NFData FundOnChainAddress where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_FundOnChainAddress'_unknownFields x__)+ (Control.DeepSeq.deepseq (_FundOnChainAddress'val x__) ())+{- | Fields :+ + * 'Proto.BtcLsp.Data.HighLevel_Fields.fieldLocation' @:: Lens' InputFailure [FieldIndex]@+ * 'Proto.BtcLsp.Data.HighLevel_Fields.vec'fieldLocation' @:: Lens' InputFailure (Data.Vector.Vector FieldIndex)@+ * 'Proto.BtcLsp.Data.HighLevel_Fields.kind' @:: Lens' InputFailure InputFailureKind@ -}+data InputFailure+ = InputFailure'_constructor {_InputFailure'fieldLocation :: !(Data.Vector.Vector FieldIndex),+ _InputFailure'kind :: !InputFailureKind,+ _InputFailure'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show InputFailure where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out InputFailure+instance Data.ProtoLens.Field.HasField InputFailure "fieldLocation" [FieldIndex] where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _InputFailure'fieldLocation+ (\ x__ y__ -> x__ {_InputFailure'fieldLocation = y__}))+ (Lens.Family2.Unchecked.lens+ Data.Vector.Generic.toList+ (\ _ y__ -> Data.Vector.Generic.fromList y__))+instance Data.ProtoLens.Field.HasField InputFailure "vec'fieldLocation" (Data.Vector.Vector FieldIndex) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _InputFailure'fieldLocation+ (\ x__ y__ -> x__ {_InputFailure'fieldLocation = y__}))+ Prelude.id+instance Data.ProtoLens.Field.HasField InputFailure "kind" InputFailureKind where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _InputFailure'kind (\ x__ y__ -> x__ {_InputFailure'kind = y__}))+ Prelude.id+instance Data.ProtoLens.Message InputFailure where+ messageName _ = Data.Text.pack "BtcLsp.Data.HighLevel.InputFailure"+ packedMessageDescriptor _+ = "\n\+ \\fInputFailure\DC2H\n\+ \\SOfield_location\CAN\SOH \ETX(\v2!.BtcLsp.Data.HighLevel.FieldIndexR\rfieldLocation\DC2;\n\+ \\EOTkind\CAN\STX \SOH(\SO2'.BtcLsp.Data.HighLevel.InputFailureKindR\EOTkind"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ fieldLocation__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "field_location"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor FieldIndex)+ (Data.ProtoLens.RepeatedField+ Data.ProtoLens.Unpacked+ (Data.ProtoLens.Field.field @"fieldLocation")) ::+ Data.ProtoLens.FieldDescriptor InputFailure+ kind__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "kind"+ (Data.ProtoLens.ScalarField Data.ProtoLens.EnumField ::+ Data.ProtoLens.FieldTypeDescriptor InputFailureKind)+ (Data.ProtoLens.PlainField+ Data.ProtoLens.Optional (Data.ProtoLens.Field.field @"kind")) ::+ Data.ProtoLens.FieldDescriptor InputFailure+ in+ Data.Map.fromList+ [(Data.ProtoLens.Tag 1, fieldLocation__field_descriptor),+ (Data.ProtoLens.Tag 2, kind__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _InputFailure'_unknownFields+ (\ x__ y__ -> x__ {_InputFailure'_unknownFields = y__})+ defMessage+ = InputFailure'_constructor+ {_InputFailure'fieldLocation = Data.Vector.Generic.empty,+ _InputFailure'kind = Data.ProtoLens.fieldDefault,+ _InputFailure'_unknownFields = []}+ parseMessage+ = let+ loop ::+ InputFailure+ -> Data.ProtoLens.Encoding.Growing.Growing Data.Vector.Vector Data.ProtoLens.Encoding.Growing.RealWorld FieldIndex+ -> Data.ProtoLens.Encoding.Bytes.Parser InputFailure+ loop x mutable'fieldLocation+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do frozen'fieldLocation <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ (Data.ProtoLens.Encoding.Growing.unsafeFreeze+ mutable'fieldLocation)+ (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t)+ (Lens.Family2.set+ (Data.ProtoLens.Field.field @"vec'fieldLocation")+ frozen'fieldLocation x))+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 10+ -> do !y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len)+ Data.ProtoLens.parseMessage)+ "field_location"+ v <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ (Data.ProtoLens.Encoding.Growing.append+ mutable'fieldLocation y)+ loop x v+ 16+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (Prelude.fmap+ Prelude.toEnum+ (Prelude.fmap+ Prelude.fromIntegral+ Data.ProtoLens.Encoding.Bytes.getVarInt))+ "kind"+ loop+ (Lens.Family2.set (Data.ProtoLens.Field.field @"kind") y x)+ mutable'fieldLocation+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ mutable'fieldLocation+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do mutable'fieldLocation <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ Data.ProtoLens.Encoding.Growing.new+ loop Data.ProtoLens.defMessage mutable'fieldLocation)+ "InputFailure"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.foldMapBuilder+ (\ _v+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 10)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ (Lens.Family2.view+ (Data.ProtoLens.Field.field @"vec'fieldLocation") _x))+ ((Data.Monoid.<>)+ (let _v = Lens.Family2.view (Data.ProtoLens.Field.field @"kind") _x+ in+ if (Prelude.==) _v Data.ProtoLens.fieldDefault then+ Data.Monoid.mempty+ else+ (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 16)+ ((Prelude..)+ ((Prelude..)+ Data.ProtoLens.Encoding.Bytes.putVarInt Prelude.fromIntegral)+ Prelude.fromEnum _v))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x)))+instance Control.DeepSeq.NFData InputFailure where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_InputFailure'_unknownFields x__)+ (Control.DeepSeq.deepseq+ (_InputFailure'fieldLocation x__)+ (Control.DeepSeq.deepseq (_InputFailure'kind x__) ()))+newtype InputFailureKind'UnrecognizedValue+ = InputFailureKind'UnrecognizedValue Data.Int.Int32+ deriving stock (Prelude.Eq,+ Prelude.Ord,+ Prelude.Show,+ GHC.Generics.Generic)+instance Text.PrettyPrint.GenericPretty.Out InputFailureKind'UnrecognizedValue+data InputFailureKind+ = REQUIRED |+ NOT_FOUND |+ PARSING_FAILED |+ VERIFICATION_FAILED |+ InputFailureKind'Unrecognized !InputFailureKind'UnrecognizedValue+ deriving stock (Prelude.Show,+ Prelude.Eq,+ Prelude.Ord,+ GHC.Generics.Generic)+instance Data.ProtoLens.MessageEnum InputFailureKind where+ maybeToEnum 0 = Prelude.Just REQUIRED+ maybeToEnum 1 = Prelude.Just NOT_FOUND+ maybeToEnum 2 = Prelude.Just PARSING_FAILED+ maybeToEnum 3 = Prelude.Just VERIFICATION_FAILED+ maybeToEnum k+ = Prelude.Just+ (InputFailureKind'Unrecognized+ (InputFailureKind'UnrecognizedValue (Prelude.fromIntegral k)))+ showEnum REQUIRED = "REQUIRED"+ showEnum NOT_FOUND = "NOT_FOUND"+ showEnum PARSING_FAILED = "PARSING_FAILED"+ showEnum VERIFICATION_FAILED = "VERIFICATION_FAILED"+ showEnum+ (InputFailureKind'Unrecognized (InputFailureKind'UnrecognizedValue k))+ = Prelude.show k+ readEnum k+ | (Prelude.==) k "REQUIRED" = Prelude.Just REQUIRED+ | (Prelude.==) k "NOT_FOUND" = Prelude.Just NOT_FOUND+ | (Prelude.==) k "PARSING_FAILED" = Prelude.Just PARSING_FAILED+ | (Prelude.==) k "VERIFICATION_FAILED"+ = Prelude.Just VERIFICATION_FAILED+ | Prelude.otherwise+ = (Prelude.>>=) (Text.Read.readMaybe k) Data.ProtoLens.maybeToEnum+instance Prelude.Bounded InputFailureKind where+ minBound = REQUIRED+ maxBound = VERIFICATION_FAILED+instance Prelude.Enum InputFailureKind where+ toEnum k__+ = Prelude.maybe+ (Prelude.error+ ((Prelude.++)+ "toEnum: unknown value for enum InputFailureKind: "+ (Prelude.show k__)))+ Prelude.id (Data.ProtoLens.maybeToEnum k__)+ fromEnum REQUIRED = 0+ fromEnum NOT_FOUND = 1+ fromEnum PARSING_FAILED = 2+ fromEnum VERIFICATION_FAILED = 3+ fromEnum+ (InputFailureKind'Unrecognized (InputFailureKind'UnrecognizedValue k))+ = Prelude.fromIntegral k+ succ VERIFICATION_FAILED+ = Prelude.error+ "InputFailureKind.succ: bad argument VERIFICATION_FAILED. This value would be out of bounds."+ succ REQUIRED = NOT_FOUND+ succ NOT_FOUND = PARSING_FAILED+ succ PARSING_FAILED = VERIFICATION_FAILED+ succ (InputFailureKind'Unrecognized _)+ = Prelude.error+ "InputFailureKind.succ: bad argument: unrecognized value"+ pred REQUIRED+ = Prelude.error+ "InputFailureKind.pred: bad argument REQUIRED. This value would be out of bounds."+ pred NOT_FOUND = REQUIRED+ pred PARSING_FAILED = NOT_FOUND+ pred VERIFICATION_FAILED = PARSING_FAILED+ pred (InputFailureKind'Unrecognized _)+ = Prelude.error+ "InputFailureKind.pred: bad argument: unrecognized value"+ enumFrom = Data.ProtoLens.Message.Enum.messageEnumFrom+ enumFromTo = Data.ProtoLens.Message.Enum.messageEnumFromTo+ enumFromThen = Data.ProtoLens.Message.Enum.messageEnumFromThen+ enumFromThenTo = Data.ProtoLens.Message.Enum.messageEnumFromThenTo+instance Data.ProtoLens.FieldDefault InputFailureKind where+ fieldDefault = REQUIRED+instance Control.DeepSeq.NFData InputFailureKind where+ rnf x__ = Prelude.seq x__ ()+instance Text.PrettyPrint.GenericPretty.Out InputFailureKind+{- | Fields :+ + * 'Proto.BtcLsp.Data.HighLevel_Fields.maybe'either' @:: Lens' InternalFailure (Prelude.Maybe InternalFailure'Either)@+ * 'Proto.BtcLsp.Data.HighLevel_Fields.maybe'redacted' @:: Lens' InternalFailure (Prelude.Maybe Prelude.Bool)@+ * 'Proto.BtcLsp.Data.HighLevel_Fields.redacted' @:: Lens' InternalFailure Prelude.Bool@+ * 'Proto.BtcLsp.Data.HighLevel_Fields.maybe'grpcServer' @:: Lens' InternalFailure (Prelude.Maybe Data.Text.Text)@+ * 'Proto.BtcLsp.Data.HighLevel_Fields.grpcServer' @:: Lens' InternalFailure Data.Text.Text@+ * 'Proto.BtcLsp.Data.HighLevel_Fields.maybe'math' @:: Lens' InternalFailure (Prelude.Maybe Data.Text.Text)@+ * 'Proto.BtcLsp.Data.HighLevel_Fields.math' @:: Lens' InternalFailure Data.Text.Text@ -}+data InternalFailure+ = InternalFailure'_constructor {_InternalFailure'either :: !(Prelude.Maybe InternalFailure'Either),+ _InternalFailure'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show InternalFailure where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out InternalFailure+data InternalFailure'Either+ = InternalFailure'Redacted !Prelude.Bool |+ InternalFailure'GrpcServer !Data.Text.Text |+ InternalFailure'Math !Data.Text.Text+ deriving stock (Prelude.Show,+ Prelude.Eq,+ Prelude.Ord,+ GHC.Generics.Generic)+instance Text.PrettyPrint.GenericPretty.Out InternalFailure'Either+instance Data.ProtoLens.Field.HasField InternalFailure "maybe'either" (Prelude.Maybe InternalFailure'Either) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _InternalFailure'either+ (\ x__ y__ -> x__ {_InternalFailure'either = y__}))+ Prelude.id+instance Data.ProtoLens.Field.HasField InternalFailure "maybe'redacted" (Prelude.Maybe Prelude.Bool) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _InternalFailure'either+ (\ x__ y__ -> x__ {_InternalFailure'either = y__}))+ (Lens.Family2.Unchecked.lens+ (\ x__+ -> case x__ of+ (Prelude.Just (InternalFailure'Redacted x__val))+ -> Prelude.Just x__val+ _otherwise -> Prelude.Nothing)+ (\ _ y__ -> Prelude.fmap InternalFailure'Redacted y__))+instance Data.ProtoLens.Field.HasField InternalFailure "redacted" Prelude.Bool where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _InternalFailure'either+ (\ x__ y__ -> x__ {_InternalFailure'either = y__}))+ ((Prelude..)+ (Lens.Family2.Unchecked.lens+ (\ x__+ -> case x__ of+ (Prelude.Just (InternalFailure'Redacted x__val))+ -> Prelude.Just x__val+ _otherwise -> Prelude.Nothing)+ (\ _ y__ -> Prelude.fmap InternalFailure'Redacted y__))+ (Data.ProtoLens.maybeLens Data.ProtoLens.fieldDefault))+instance Data.ProtoLens.Field.HasField InternalFailure "maybe'grpcServer" (Prelude.Maybe Data.Text.Text) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _InternalFailure'either+ (\ x__ y__ -> x__ {_InternalFailure'either = y__}))+ (Lens.Family2.Unchecked.lens+ (\ x__+ -> case x__ of+ (Prelude.Just (InternalFailure'GrpcServer x__val))+ -> Prelude.Just x__val+ _otherwise -> Prelude.Nothing)+ (\ _ y__ -> Prelude.fmap InternalFailure'GrpcServer y__))+instance Data.ProtoLens.Field.HasField InternalFailure "grpcServer" Data.Text.Text where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _InternalFailure'either+ (\ x__ y__ -> x__ {_InternalFailure'either = y__}))+ ((Prelude..)+ (Lens.Family2.Unchecked.lens+ (\ x__+ -> case x__ of+ (Prelude.Just (InternalFailure'GrpcServer x__val))+ -> Prelude.Just x__val+ _otherwise -> Prelude.Nothing)+ (\ _ y__ -> Prelude.fmap InternalFailure'GrpcServer y__))+ (Data.ProtoLens.maybeLens Data.ProtoLens.fieldDefault))+instance Data.ProtoLens.Field.HasField InternalFailure "maybe'math" (Prelude.Maybe Data.Text.Text) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _InternalFailure'either+ (\ x__ y__ -> x__ {_InternalFailure'either = y__}))+ (Lens.Family2.Unchecked.lens+ (\ x__+ -> case x__ of+ (Prelude.Just (InternalFailure'Math x__val)) -> Prelude.Just x__val+ _otherwise -> Prelude.Nothing)+ (\ _ y__ -> Prelude.fmap InternalFailure'Math y__))+instance Data.ProtoLens.Field.HasField InternalFailure "math" Data.Text.Text where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _InternalFailure'either+ (\ x__ y__ -> x__ {_InternalFailure'either = y__}))+ ((Prelude..)+ (Lens.Family2.Unchecked.lens+ (\ x__+ -> case x__ of+ (Prelude.Just (InternalFailure'Math x__val)) -> Prelude.Just x__val+ _otherwise -> Prelude.Nothing)+ (\ _ y__ -> Prelude.fmap InternalFailure'Math y__))+ (Data.ProtoLens.maybeLens Data.ProtoLens.fieldDefault))+instance Data.ProtoLens.Message InternalFailure where+ messageName _+ = Data.Text.pack "BtcLsp.Data.HighLevel.InternalFailure"+ packedMessageDescriptor _+ = "\n\+ \\SIInternalFailure\DC2\FS\n\+ \\bredacted\CAN\SOH \SOH(\bH\NULR\bredacted\DC2!\n\+ \\vgrpc_server\CAN\STX \SOH(\tH\NULR\n\+ \grpcServer\DC2\DC4\n\+ \\EOTmath\CAN\ETX \SOH(\tH\NULR\EOTmathB\b\n\+ \\ACKeither"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ redacted__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "redacted"+ (Data.ProtoLens.ScalarField Data.ProtoLens.BoolField ::+ Data.ProtoLens.FieldTypeDescriptor Prelude.Bool)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'redacted")) ::+ Data.ProtoLens.FieldDescriptor InternalFailure+ grpcServer__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "grpc_server"+ (Data.ProtoLens.ScalarField Data.ProtoLens.StringField ::+ Data.ProtoLens.FieldTypeDescriptor Data.Text.Text)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'grpcServer")) ::+ Data.ProtoLens.FieldDescriptor InternalFailure+ math__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "math"+ (Data.ProtoLens.ScalarField Data.ProtoLens.StringField ::+ Data.ProtoLens.FieldTypeDescriptor Data.Text.Text)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'math")) ::+ Data.ProtoLens.FieldDescriptor InternalFailure+ in+ Data.Map.fromList+ [(Data.ProtoLens.Tag 1, redacted__field_descriptor),+ (Data.ProtoLens.Tag 2, grpcServer__field_descriptor),+ (Data.ProtoLens.Tag 3, math__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _InternalFailure'_unknownFields+ (\ x__ y__ -> x__ {_InternalFailure'_unknownFields = y__})+ defMessage+ = InternalFailure'_constructor+ {_InternalFailure'either = Prelude.Nothing,+ _InternalFailure'_unknownFields = []}+ parseMessage+ = let+ loop ::+ InternalFailure+ -> Data.ProtoLens.Encoding.Bytes.Parser InternalFailure+ loop x+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) x)+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 8 -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (Prelude.fmap+ ((Prelude./=) 0) Data.ProtoLens.Encoding.Bytes.getVarInt)+ "redacted"+ loop+ (Lens.Family2.set (Data.ProtoLens.Field.field @"redacted") y x)+ 18+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do value <- do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.getBytes+ (Prelude.fromIntegral len)+ Data.ProtoLens.Encoding.Bytes.runEither+ (case Data.Text.Encoding.decodeUtf8' value of+ (Prelude.Left err)+ -> Prelude.Left (Prelude.show err)+ (Prelude.Right r) -> Prelude.Right r))+ "grpc_server"+ loop+ (Lens.Family2.set (Data.ProtoLens.Field.field @"grpcServer") y x)+ 26+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do value <- do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.getBytes+ (Prelude.fromIntegral len)+ Data.ProtoLens.Encoding.Bytes.runEither+ (case Data.Text.Encoding.decodeUtf8' value of+ (Prelude.Left err)+ -> Prelude.Left (Prelude.show err)+ (Prelude.Right r) -> Prelude.Right r))+ "math"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"math") y x)+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do loop Data.ProtoLens.defMessage) "InternalFailure"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (case+ Lens.Family2.view (Data.ProtoLens.Field.field @"maybe'either") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just (InternalFailure'Redacted v))+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 8)+ ((Prelude..)+ Data.ProtoLens.Encoding.Bytes.putVarInt (\ b -> if b then 1 else 0)+ v)+ (Prelude.Just (InternalFailure'GrpcServer v))+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 18)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.Text.Encoding.encodeUtf8 v)+ (Prelude.Just (InternalFailure'Math v))+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 26)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.Text.Encoding.encodeUtf8 v))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x))+instance Control.DeepSeq.NFData InternalFailure where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_InternalFailure'_unknownFields x__)+ (Control.DeepSeq.deepseq (_InternalFailure'either x__) ())+instance Control.DeepSeq.NFData InternalFailure'Either where+ rnf (InternalFailure'Redacted x__) = Control.DeepSeq.rnf x__+ rnf (InternalFailure'GrpcServer x__) = Control.DeepSeq.rnf x__+ rnf (InternalFailure'Math x__) = Control.DeepSeq.rnf x__+_InternalFailure'Redacted ::+ Data.ProtoLens.Prism.Prism' InternalFailure'Either Prelude.Bool+_InternalFailure'Redacted+ = Data.ProtoLens.Prism.prism'+ InternalFailure'Redacted+ (\ p__+ -> case p__ of+ (InternalFailure'Redacted p__val) -> Prelude.Just p__val+ _otherwise -> Prelude.Nothing)+_InternalFailure'GrpcServer ::+ Data.ProtoLens.Prism.Prism' InternalFailure'Either Data.Text.Text+_InternalFailure'GrpcServer+ = Data.ProtoLens.Prism.prism'+ InternalFailure'GrpcServer+ (\ p__+ -> case p__ of+ (InternalFailure'GrpcServer p__val) -> Prelude.Just p__val+ _otherwise -> Prelude.Nothing)+_InternalFailure'Math ::+ Data.ProtoLens.Prism.Prism' InternalFailure'Either Data.Text.Text+_InternalFailure'Math+ = Data.ProtoLens.Prism.prism'+ InternalFailure'Math+ (\ p__+ -> case p__ of+ (InternalFailure'Math p__val) -> Prelude.Just p__val+ _otherwise -> Prelude.Nothing)+{- | Fields :+ + * 'Proto.BtcLsp.Data.HighLevel_Fields.val' @:: Lens' LnHost Data.Text.Text@ -}+data LnHost+ = LnHost'_constructor {_LnHost'val :: !Data.Text.Text,+ _LnHost'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show LnHost where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out LnHost+instance Data.ProtoLens.Field.HasField LnHost "val" Data.Text.Text where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _LnHost'val (\ x__ y__ -> x__ {_LnHost'val = y__}))+ Prelude.id+instance Data.ProtoLens.Message LnHost where+ messageName _ = Data.Text.pack "BtcLsp.Data.HighLevel.LnHost"+ packedMessageDescriptor _+ = "\n\+ \\ACKLnHost\DC2\DLE\n\+ \\ETXval\CAN\SOH \SOH(\tR\ETXval"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ val__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "val"+ (Data.ProtoLens.ScalarField Data.ProtoLens.StringField ::+ Data.ProtoLens.FieldTypeDescriptor Data.Text.Text)+ (Data.ProtoLens.PlainField+ Data.ProtoLens.Optional (Data.ProtoLens.Field.field @"val")) ::+ Data.ProtoLens.FieldDescriptor LnHost+ in+ Data.Map.fromList [(Data.ProtoLens.Tag 1, val__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _LnHost'_unknownFields+ (\ x__ y__ -> x__ {_LnHost'_unknownFields = y__})+ defMessage+ = LnHost'_constructor+ {_LnHost'val = Data.ProtoLens.fieldDefault,+ _LnHost'_unknownFields = []}+ parseMessage+ = let+ loop :: LnHost -> Data.ProtoLens.Encoding.Bytes.Parser LnHost+ loop x+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) x)+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 10+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do value <- do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.getBytes+ (Prelude.fromIntegral len)+ Data.ProtoLens.Encoding.Bytes.runEither+ (case Data.Text.Encoding.decodeUtf8' value of+ (Prelude.Left err)+ -> Prelude.Left (Prelude.show err)+ (Prelude.Right r) -> Prelude.Right r))+ "val"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"val") y x)+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do loop Data.ProtoLens.defMessage) "LnHost"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (let _v = Lens.Family2.view (Data.ProtoLens.Field.field @"val") _x+ in+ if (Prelude.==) _v Data.ProtoLens.fieldDefault then+ Data.Monoid.mempty+ else+ (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 10)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.Text.Encoding.encodeUtf8 _v))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x))+instance Control.DeepSeq.NFData LnHost where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_LnHost'_unknownFields x__)+ (Control.DeepSeq.deepseq (_LnHost'val x__) ())+{- | Fields :+ + * 'Proto.BtcLsp.Data.HighLevel_Fields.pubKey' @:: Lens' LnPeer LnPubKey@+ * 'Proto.BtcLsp.Data.HighLevel_Fields.maybe'pubKey' @:: Lens' LnPeer (Prelude.Maybe LnPubKey)@+ * 'Proto.BtcLsp.Data.HighLevel_Fields.host' @:: Lens' LnPeer LnHost@+ * 'Proto.BtcLsp.Data.HighLevel_Fields.maybe'host' @:: Lens' LnPeer (Prelude.Maybe LnHost)@+ * 'Proto.BtcLsp.Data.HighLevel_Fields.port' @:: Lens' LnPeer LnPort@+ * 'Proto.BtcLsp.Data.HighLevel_Fields.maybe'port' @:: Lens' LnPeer (Prelude.Maybe LnPort)@ -}+data LnPeer+ = LnPeer'_constructor {_LnPeer'pubKey :: !(Prelude.Maybe LnPubKey),+ _LnPeer'host :: !(Prelude.Maybe LnHost),+ _LnPeer'port :: !(Prelude.Maybe LnPort),+ _LnPeer'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show LnPeer where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out LnPeer+instance Data.ProtoLens.Field.HasField LnPeer "pubKey" LnPubKey where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _LnPeer'pubKey (\ x__ y__ -> x__ {_LnPeer'pubKey = y__}))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage)+instance Data.ProtoLens.Field.HasField LnPeer "maybe'pubKey" (Prelude.Maybe LnPubKey) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _LnPeer'pubKey (\ x__ y__ -> x__ {_LnPeer'pubKey = y__}))+ Prelude.id+instance Data.ProtoLens.Field.HasField LnPeer "host" LnHost where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _LnPeer'host (\ x__ y__ -> x__ {_LnPeer'host = y__}))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage)+instance Data.ProtoLens.Field.HasField LnPeer "maybe'host" (Prelude.Maybe LnHost) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _LnPeer'host (\ x__ y__ -> x__ {_LnPeer'host = y__}))+ Prelude.id+instance Data.ProtoLens.Field.HasField LnPeer "port" LnPort where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _LnPeer'port (\ x__ y__ -> x__ {_LnPeer'port = y__}))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage)+instance Data.ProtoLens.Field.HasField LnPeer "maybe'port" (Prelude.Maybe LnPort) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _LnPeer'port (\ x__ y__ -> x__ {_LnPeer'port = y__}))+ Prelude.id+instance Data.ProtoLens.Message LnPeer where+ messageName _ = Data.Text.pack "BtcLsp.Data.HighLevel.LnPeer"+ packedMessageDescriptor _+ = "\n\+ \\ACKLnPeer\DC28\n\+ \\apub_key\CAN\SOH \SOH(\v2\US.BtcLsp.Data.HighLevel.LnPubKeyR\ACKpubKey\DC21\n\+ \\EOThost\CAN\STX \SOH(\v2\GS.BtcLsp.Data.HighLevel.LnHostR\EOThost\DC21\n\+ \\EOTport\CAN\ETX \SOH(\v2\GS.BtcLsp.Data.HighLevel.LnPortR\EOTport"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ pubKey__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "pub_key"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor LnPubKey)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'pubKey")) ::+ Data.ProtoLens.FieldDescriptor LnPeer+ host__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "host"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor LnHost)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'host")) ::+ Data.ProtoLens.FieldDescriptor LnPeer+ port__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "port"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor LnPort)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'port")) ::+ Data.ProtoLens.FieldDescriptor LnPeer+ in+ Data.Map.fromList+ [(Data.ProtoLens.Tag 1, pubKey__field_descriptor),+ (Data.ProtoLens.Tag 2, host__field_descriptor),+ (Data.ProtoLens.Tag 3, port__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _LnPeer'_unknownFields+ (\ x__ y__ -> x__ {_LnPeer'_unknownFields = y__})+ defMessage+ = LnPeer'_constructor+ {_LnPeer'pubKey = Prelude.Nothing, _LnPeer'host = Prelude.Nothing,+ _LnPeer'port = Prelude.Nothing, _LnPeer'_unknownFields = []}+ parseMessage+ = let+ loop :: LnPeer -> Data.ProtoLens.Encoding.Bytes.Parser LnPeer+ loop x+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) x)+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 10+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "pub_key"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"pubKey") y x)+ 18+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "host"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"host") y x)+ 26+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "port"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"port") y x)+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do loop Data.ProtoLens.defMessage) "LnPeer"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (case+ Lens.Family2.view (Data.ProtoLens.Field.field @"maybe'pubKey") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just _v)+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 10)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ ((Data.Monoid.<>)+ (case+ Lens.Family2.view (Data.ProtoLens.Field.field @"maybe'host") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just _v)+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 18)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ ((Data.Monoid.<>)+ (case+ Lens.Family2.view (Data.ProtoLens.Field.field @"maybe'port") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just _v)+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 26)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x))))+instance Control.DeepSeq.NFData LnPeer where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_LnPeer'_unknownFields x__)+ (Control.DeepSeq.deepseq+ (_LnPeer'pubKey x__)+ (Control.DeepSeq.deepseq+ (_LnPeer'host x__)+ (Control.DeepSeq.deepseq (_LnPeer'port x__) ())))+{- | Fields :+ + * 'Proto.BtcLsp.Data.HighLevel_Fields.val' @:: Lens' LnPort Data.Word.Word32@ -}+data LnPort+ = LnPort'_constructor {_LnPort'val :: !Data.Word.Word32,+ _LnPort'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show LnPort where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out LnPort+instance Data.ProtoLens.Field.HasField LnPort "val" Data.Word.Word32 where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _LnPort'val (\ x__ y__ -> x__ {_LnPort'val = y__}))+ Prelude.id+instance Data.ProtoLens.Message LnPort where+ messageName _ = Data.Text.pack "BtcLsp.Data.HighLevel.LnPort"+ packedMessageDescriptor _+ = "\n\+ \\ACKLnPort\DC2\DLE\n\+ \\ETXval\CAN\SOH \SOH(\rR\ETXval"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ val__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "val"+ (Data.ProtoLens.ScalarField Data.ProtoLens.UInt32Field ::+ Data.ProtoLens.FieldTypeDescriptor Data.Word.Word32)+ (Data.ProtoLens.PlainField+ Data.ProtoLens.Optional (Data.ProtoLens.Field.field @"val")) ::+ Data.ProtoLens.FieldDescriptor LnPort+ in+ Data.Map.fromList [(Data.ProtoLens.Tag 1, val__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _LnPort'_unknownFields+ (\ x__ y__ -> x__ {_LnPort'_unknownFields = y__})+ defMessage+ = LnPort'_constructor+ {_LnPort'val = Data.ProtoLens.fieldDefault,+ _LnPort'_unknownFields = []}+ parseMessage+ = let+ loop :: LnPort -> Data.ProtoLens.Encoding.Bytes.Parser LnPort+ loop x+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) x)+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 8 -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (Prelude.fmap+ Prelude.fromIntegral+ Data.ProtoLens.Encoding.Bytes.getVarInt)+ "val"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"val") y x)+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do loop Data.ProtoLens.defMessage) "LnPort"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (let _v = Lens.Family2.view (Data.ProtoLens.Field.field @"val") _x+ in+ if (Prelude.==) _v Data.ProtoLens.fieldDefault then+ Data.Monoid.mempty+ else+ (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 8)+ ((Prelude..)+ Data.ProtoLens.Encoding.Bytes.putVarInt Prelude.fromIntegral _v))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x))+instance Control.DeepSeq.NFData LnPort where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_LnPort'_unknownFields x__)+ (Control.DeepSeq.deepseq (_LnPort'val x__) ())+{- | Fields :+ + * 'Proto.BtcLsp.Data.HighLevel_Fields.val' @:: Lens' LnPubKey Data.ByteString.ByteString@ -}+data LnPubKey+ = LnPubKey'_constructor {_LnPubKey'val :: !Data.ByteString.ByteString,+ _LnPubKey'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show LnPubKey where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out LnPubKey+instance Data.ProtoLens.Field.HasField LnPubKey "val" Data.ByteString.ByteString where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _LnPubKey'val (\ x__ y__ -> x__ {_LnPubKey'val = y__}))+ Prelude.id+instance Data.ProtoLens.Message LnPubKey where+ messageName _ = Data.Text.pack "BtcLsp.Data.HighLevel.LnPubKey"+ packedMessageDescriptor _+ = "\n\+ \\bLnPubKey\DC2\DLE\n\+ \\ETXval\CAN\SOH \SOH(\fR\ETXval"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ val__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "val"+ (Data.ProtoLens.ScalarField Data.ProtoLens.BytesField ::+ Data.ProtoLens.FieldTypeDescriptor Data.ByteString.ByteString)+ (Data.ProtoLens.PlainField+ Data.ProtoLens.Optional (Data.ProtoLens.Field.field @"val")) ::+ Data.ProtoLens.FieldDescriptor LnPubKey+ in+ Data.Map.fromList [(Data.ProtoLens.Tag 1, val__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _LnPubKey'_unknownFields+ (\ x__ y__ -> x__ {_LnPubKey'_unknownFields = y__})+ defMessage+ = LnPubKey'_constructor+ {_LnPubKey'val = Data.ProtoLens.fieldDefault,+ _LnPubKey'_unknownFields = []}+ parseMessage+ = let+ loop :: LnPubKey -> Data.ProtoLens.Encoding.Bytes.Parser LnPubKey+ loop x+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) x)+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 10+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.getBytes+ (Prelude.fromIntegral len))+ "val"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"val") y x)+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do loop Data.ProtoLens.defMessage) "LnPubKey"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (let _v = Lens.Family2.view (Data.ProtoLens.Field.field @"val") _x+ in+ if (Prelude.==) _v Data.ProtoLens.fieldDefault then+ Data.Monoid.mempty+ else+ (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 10)+ ((\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ _v))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x))+instance Control.DeepSeq.NFData LnPubKey where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_LnPubKey'_unknownFields x__)+ (Control.DeepSeq.deepseq (_LnPubKey'val x__) ())+{- | Fields :+ + * 'Proto.BtcLsp.Data.HighLevel_Fields.val' @:: Lens' LocalBalance Proto.BtcLsp.Data.LowLevel.Msat@+ * 'Proto.BtcLsp.Data.HighLevel_Fields.maybe'val' @:: Lens' LocalBalance (Prelude.Maybe Proto.BtcLsp.Data.LowLevel.Msat)@ -}+data LocalBalance+ = LocalBalance'_constructor {_LocalBalance'val :: !(Prelude.Maybe Proto.BtcLsp.Data.LowLevel.Msat),+ _LocalBalance'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show LocalBalance where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out LocalBalance+instance Data.ProtoLens.Field.HasField LocalBalance "val" Proto.BtcLsp.Data.LowLevel.Msat where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _LocalBalance'val (\ x__ y__ -> x__ {_LocalBalance'val = y__}))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage)+instance Data.ProtoLens.Field.HasField LocalBalance "maybe'val" (Prelude.Maybe Proto.BtcLsp.Data.LowLevel.Msat) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _LocalBalance'val (\ x__ y__ -> x__ {_LocalBalance'val = y__}))+ Prelude.id+instance Data.ProtoLens.Message LocalBalance where+ messageName _ = Data.Text.pack "BtcLsp.Data.HighLevel.LocalBalance"+ packedMessageDescriptor _+ = "\n\+ \\fLocalBalance\DC2,\n\+ \\ETXval\CAN\SOH \SOH(\v2\SUB.BtcLsp.Data.LowLevel.MsatR\ETXval"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ val__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "val"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.LowLevel.Msat)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'val")) ::+ Data.ProtoLens.FieldDescriptor LocalBalance+ in+ Data.Map.fromList [(Data.ProtoLens.Tag 1, val__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _LocalBalance'_unknownFields+ (\ x__ y__ -> x__ {_LocalBalance'_unknownFields = y__})+ defMessage+ = LocalBalance'_constructor+ {_LocalBalance'val = Prelude.Nothing,+ _LocalBalance'_unknownFields = []}+ parseMessage+ = let+ loop ::+ LocalBalance -> Data.ProtoLens.Encoding.Bytes.Parser LocalBalance+ loop x+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) x)+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 10+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "val"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"val") y x)+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do loop Data.ProtoLens.defMessage) "LocalBalance"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (case+ Lens.Family2.view (Data.ProtoLens.Field.field @"maybe'val") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just _v)+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 10)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x))+instance Control.DeepSeq.NFData LocalBalance where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_LocalBalance'_unknownFields x__)+ (Control.DeepSeq.deepseq (_LocalBalance'val x__) ())+{- | Fields :+ + * 'Proto.BtcLsp.Data.HighLevel_Fields.val' @:: Lens' Nonce Data.Word.Word64@ -}+data Nonce+ = Nonce'_constructor {_Nonce'val :: !Data.Word.Word64,+ _Nonce'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show Nonce where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out Nonce+instance Data.ProtoLens.Field.HasField Nonce "val" Data.Word.Word64 where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Nonce'val (\ x__ y__ -> x__ {_Nonce'val = y__}))+ Prelude.id+instance Data.ProtoLens.Message Nonce where+ messageName _ = Data.Text.pack "BtcLsp.Data.HighLevel.Nonce"+ packedMessageDescriptor _+ = "\n\+ \\ENQNonce\DC2\DLE\n\+ \\ETXval\CAN\SOH \SOH(\EOTR\ETXval"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ val__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "val"+ (Data.ProtoLens.ScalarField Data.ProtoLens.UInt64Field ::+ Data.ProtoLens.FieldTypeDescriptor Data.Word.Word64)+ (Data.ProtoLens.PlainField+ Data.ProtoLens.Optional (Data.ProtoLens.Field.field @"val")) ::+ Data.ProtoLens.FieldDescriptor Nonce+ in+ Data.Map.fromList [(Data.ProtoLens.Tag 1, val__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _Nonce'_unknownFields+ (\ x__ y__ -> x__ {_Nonce'_unknownFields = y__})+ defMessage+ = Nonce'_constructor+ {_Nonce'val = Data.ProtoLens.fieldDefault,+ _Nonce'_unknownFields = []}+ parseMessage+ = let+ loop :: Nonce -> Data.ProtoLens.Encoding.Bytes.Parser Nonce+ loop x+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) x)+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 8 -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ Data.ProtoLens.Encoding.Bytes.getVarInt "val"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"val") y x)+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do loop Data.ProtoLens.defMessage) "Nonce"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (let _v = Lens.Family2.view (Data.ProtoLens.Field.field @"val") _x+ in+ if (Prelude.==) _v Data.ProtoLens.fieldDefault then+ Data.Monoid.mempty+ else+ (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 8)+ (Data.ProtoLens.Encoding.Bytes.putVarInt _v))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x))+instance Control.DeepSeq.NFData Nonce where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_Nonce'_unknownFields x__)+ (Control.DeepSeq.deepseq (_Nonce'val x__) ())+newtype Privacy'UnrecognizedValue+ = Privacy'UnrecognizedValue Data.Int.Int32+ deriving stock (Prelude.Eq,+ Prelude.Ord,+ Prelude.Show,+ GHC.Generics.Generic)+instance Text.PrettyPrint.GenericPretty.Out Privacy'UnrecognizedValue+data Privacy+ = PUBLIC |+ PRIVATE |+ Privacy'Unrecognized !Privacy'UnrecognizedValue+ deriving stock (Prelude.Show,+ Prelude.Eq,+ Prelude.Ord,+ GHC.Generics.Generic)+instance Data.ProtoLens.MessageEnum Privacy where+ maybeToEnum 0 = Prelude.Just PUBLIC+ maybeToEnum 1 = Prelude.Just PRIVATE+ maybeToEnum k+ = Prelude.Just+ (Privacy'Unrecognized+ (Privacy'UnrecognizedValue (Prelude.fromIntegral k)))+ showEnum PUBLIC = "PUBLIC"+ showEnum PRIVATE = "PRIVATE"+ showEnum (Privacy'Unrecognized (Privacy'UnrecognizedValue k))+ = Prelude.show k+ readEnum k+ | (Prelude.==) k "PUBLIC" = Prelude.Just PUBLIC+ | (Prelude.==) k "PRIVATE" = Prelude.Just PRIVATE+ | Prelude.otherwise+ = (Prelude.>>=) (Text.Read.readMaybe k) Data.ProtoLens.maybeToEnum+instance Prelude.Bounded Privacy where+ minBound = PUBLIC+ maxBound = PRIVATE+instance Prelude.Enum Privacy where+ toEnum k__+ = Prelude.maybe+ (Prelude.error+ ((Prelude.++)+ "toEnum: unknown value for enum Privacy: " (Prelude.show k__)))+ Prelude.id (Data.ProtoLens.maybeToEnum k__)+ fromEnum PUBLIC = 0+ fromEnum PRIVATE = 1+ fromEnum (Privacy'Unrecognized (Privacy'UnrecognizedValue k))+ = Prelude.fromIntegral k+ succ PRIVATE+ = Prelude.error+ "Privacy.succ: bad argument PRIVATE. This value would be out of bounds."+ succ PUBLIC = PRIVATE+ succ (Privacy'Unrecognized _)+ = Prelude.error "Privacy.succ: bad argument: unrecognized value"+ pred PUBLIC+ = Prelude.error+ "Privacy.pred: bad argument PUBLIC. This value would be out of bounds."+ pred PRIVATE = PUBLIC+ pred (Privacy'Unrecognized _)+ = Prelude.error "Privacy.pred: bad argument: unrecognized value"+ enumFrom = Data.ProtoLens.Message.Enum.messageEnumFrom+ enumFromTo = Data.ProtoLens.Message.Enum.messageEnumFromTo+ enumFromThen = Data.ProtoLens.Message.Enum.messageEnumFromThen+ enumFromThenTo = Data.ProtoLens.Message.Enum.messageEnumFromThenTo+instance Data.ProtoLens.FieldDefault Privacy where+ fieldDefault = PUBLIC+instance Control.DeepSeq.NFData Privacy where+ rnf x__ = Prelude.seq x__ ()+instance Text.PrettyPrint.GenericPretty.Out Privacy+{- | Fields :+ + * 'Proto.BtcLsp.Data.HighLevel_Fields.val' @:: Lens' RefundMoney Proto.BtcLsp.Data.LowLevel.Msat@+ * 'Proto.BtcLsp.Data.HighLevel_Fields.maybe'val' @:: Lens' RefundMoney (Prelude.Maybe Proto.BtcLsp.Data.LowLevel.Msat)@ -}+data RefundMoney+ = RefundMoney'_constructor {_RefundMoney'val :: !(Prelude.Maybe Proto.BtcLsp.Data.LowLevel.Msat),+ _RefundMoney'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show RefundMoney where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out RefundMoney+instance Data.ProtoLens.Field.HasField RefundMoney "val" Proto.BtcLsp.Data.LowLevel.Msat where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _RefundMoney'val (\ x__ y__ -> x__ {_RefundMoney'val = y__}))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage)+instance Data.ProtoLens.Field.HasField RefundMoney "maybe'val" (Prelude.Maybe Proto.BtcLsp.Data.LowLevel.Msat) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _RefundMoney'val (\ x__ y__ -> x__ {_RefundMoney'val = y__}))+ Prelude.id+instance Data.ProtoLens.Message RefundMoney where+ messageName _ = Data.Text.pack "BtcLsp.Data.HighLevel.RefundMoney"+ packedMessageDescriptor _+ = "\n\+ \\vRefundMoney\DC2,\n\+ \\ETXval\CAN\SOH \SOH(\v2\SUB.BtcLsp.Data.LowLevel.MsatR\ETXval"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ val__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "val"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.LowLevel.Msat)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'val")) ::+ Data.ProtoLens.FieldDescriptor RefundMoney+ in+ Data.Map.fromList [(Data.ProtoLens.Tag 1, val__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _RefundMoney'_unknownFields+ (\ x__ y__ -> x__ {_RefundMoney'_unknownFields = y__})+ defMessage+ = RefundMoney'_constructor+ {_RefundMoney'val = Prelude.Nothing,+ _RefundMoney'_unknownFields = []}+ parseMessage+ = let+ loop ::+ RefundMoney -> Data.ProtoLens.Encoding.Bytes.Parser RefundMoney+ loop x+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) x)+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 10+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "val"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"val") y x)+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do loop Data.ProtoLens.defMessage) "RefundMoney"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (case+ Lens.Family2.view (Data.ProtoLens.Field.field @"maybe'val") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just _v)+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 10)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x))+instance Control.DeepSeq.NFData RefundMoney where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_RefundMoney'_unknownFields x__)+ (Control.DeepSeq.deepseq (_RefundMoney'val x__) ())+{- | Fields :+ + * 'Proto.BtcLsp.Data.HighLevel_Fields.val' @:: Lens' RefundOnChainAddress Proto.BtcLsp.Data.LowLevel.OnChainAddress@+ * 'Proto.BtcLsp.Data.HighLevel_Fields.maybe'val' @:: Lens' RefundOnChainAddress (Prelude.Maybe Proto.BtcLsp.Data.LowLevel.OnChainAddress)@ -}+data RefundOnChainAddress+ = RefundOnChainAddress'_constructor {_RefundOnChainAddress'val :: !(Prelude.Maybe Proto.BtcLsp.Data.LowLevel.OnChainAddress),+ _RefundOnChainAddress'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show RefundOnChainAddress where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out RefundOnChainAddress+instance Data.ProtoLens.Field.HasField RefundOnChainAddress "val" Proto.BtcLsp.Data.LowLevel.OnChainAddress where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _RefundOnChainAddress'val+ (\ x__ y__ -> x__ {_RefundOnChainAddress'val = y__}))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage)+instance Data.ProtoLens.Field.HasField RefundOnChainAddress "maybe'val" (Prelude.Maybe Proto.BtcLsp.Data.LowLevel.OnChainAddress) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _RefundOnChainAddress'val+ (\ x__ y__ -> x__ {_RefundOnChainAddress'val = y__}))+ Prelude.id+instance Data.ProtoLens.Message RefundOnChainAddress where+ messageName _+ = Data.Text.pack "BtcLsp.Data.HighLevel.RefundOnChainAddress"+ packedMessageDescriptor _+ = "\n\+ \\DC4RefundOnChainAddress\DC26\n\+ \\ETXval\CAN\SOH \SOH(\v2$.BtcLsp.Data.LowLevel.OnChainAddressR\ETXval"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ val__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "val"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.LowLevel.OnChainAddress)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'val")) ::+ Data.ProtoLens.FieldDescriptor RefundOnChainAddress+ in+ Data.Map.fromList [(Data.ProtoLens.Tag 1, val__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _RefundOnChainAddress'_unknownFields+ (\ x__ y__ -> x__ {_RefundOnChainAddress'_unknownFields = y__})+ defMessage+ = RefundOnChainAddress'_constructor+ {_RefundOnChainAddress'val = Prelude.Nothing,+ _RefundOnChainAddress'_unknownFields = []}+ parseMessage+ = let+ loop ::+ RefundOnChainAddress+ -> Data.ProtoLens.Encoding.Bytes.Parser RefundOnChainAddress+ loop x+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) x)+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 10+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "val"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"val") y x)+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do loop Data.ProtoLens.defMessage) "RefundOnChainAddress"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (case+ Lens.Family2.view (Data.ProtoLens.Field.field @"maybe'val") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just _v)+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 10)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x))+instance Control.DeepSeq.NFData RefundOnChainAddress where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_RefundOnChainAddress'_unknownFields x__)+ (Control.DeepSeq.deepseq (_RefundOnChainAddress'val x__) ())+{- | Fields :+ + * 'Proto.BtcLsp.Data.HighLevel_Fields.val' @:: Lens' RemoteBalance Proto.BtcLsp.Data.LowLevel.Msat@+ * 'Proto.BtcLsp.Data.HighLevel_Fields.maybe'val' @:: Lens' RemoteBalance (Prelude.Maybe Proto.BtcLsp.Data.LowLevel.Msat)@ -}+data RemoteBalance+ = RemoteBalance'_constructor {_RemoteBalance'val :: !(Prelude.Maybe Proto.BtcLsp.Data.LowLevel.Msat),+ _RemoteBalance'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show RemoteBalance where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out RemoteBalance+instance Data.ProtoLens.Field.HasField RemoteBalance "val" Proto.BtcLsp.Data.LowLevel.Msat where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _RemoteBalance'val (\ x__ y__ -> x__ {_RemoteBalance'val = y__}))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage)+instance Data.ProtoLens.Field.HasField RemoteBalance "maybe'val" (Prelude.Maybe Proto.BtcLsp.Data.LowLevel.Msat) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _RemoteBalance'val (\ x__ y__ -> x__ {_RemoteBalance'val = y__}))+ Prelude.id+instance Data.ProtoLens.Message RemoteBalance where+ messageName _+ = Data.Text.pack "BtcLsp.Data.HighLevel.RemoteBalance"+ packedMessageDescriptor _+ = "\n\+ \\rRemoteBalance\DC2,\n\+ \\ETXval\CAN\SOH \SOH(\v2\SUB.BtcLsp.Data.LowLevel.MsatR\ETXval"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ val__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "val"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.LowLevel.Msat)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'val")) ::+ Data.ProtoLens.FieldDescriptor RemoteBalance+ in+ Data.Map.fromList [(Data.ProtoLens.Tag 1, val__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _RemoteBalance'_unknownFields+ (\ x__ y__ -> x__ {_RemoteBalance'_unknownFields = y__})+ defMessage+ = RemoteBalance'_constructor+ {_RemoteBalance'val = Prelude.Nothing,+ _RemoteBalance'_unknownFields = []}+ parseMessage+ = let+ loop ::+ RemoteBalance -> Data.ProtoLens.Encoding.Bytes.Parser RemoteBalance+ loop x+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) x)+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 10+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "val"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"val") y x)+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do loop Data.ProtoLens.defMessage) "RemoteBalance"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (case+ Lens.Family2.view (Data.ProtoLens.Field.field @"maybe'val") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just _v)+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 10)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x))+instance Control.DeepSeq.NFData RemoteBalance where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_RemoteBalance'_unknownFields x__)+ (Control.DeepSeq.deepseq (_RemoteBalance'val x__) ())+packedFileDescriptor :: Data.ByteString.ByteString+packedFileDescriptor+ = "\n\+ \\GSbtc_lsp/data/high_level.proto\DC2\NAKBtcLsp.Data.HighLevel\SUB\FSbtc_lsp/data/low_level.proto\"<\n\+ \\aFeeRate\DC21\n\+ \\ETXval\CAN\SOH \SOH(\v2\US.BtcLsp.Data.LowLevel.UrationalR\ETXval\"8\n\+ \\bFeeMoney\DC2,\n\+ \\ETXval\CAN\SOH \SOH(\v2\SUB.BtcLsp.Data.LowLevel.MsatR\ETXval\"9\n\+ \\tFundMoney\DC2,\n\+ \\ETXval\CAN\SOH \SOH(\v2\SUB.BtcLsp.Data.LowLevel.MsatR\ETXval\";\n\+ \\vRefundMoney\DC2,\n\+ \\ETXval\CAN\SOH \SOH(\v2\SUB.BtcLsp.Data.LowLevel.MsatR\ETXval\"<\n\+ \\fLocalBalance\DC2,\n\+ \\ETXval\CAN\SOH \SOH(\v2\SUB.BtcLsp.Data.LowLevel.MsatR\ETXval\"=\n\+ \\rRemoteBalance\DC2,\n\+ \\ETXval\CAN\SOH \SOH(\v2\SUB.BtcLsp.Data.LowLevel.MsatR\ETXval\"B\n\+ \\rFundLnInvoice\DC21\n\+ \\ETXval\CAN\SOH \SOH(\v2\US.BtcLsp.Data.LowLevel.LnInvoiceR\ETXval\"J\n\+ \\DC1FundLnHodlInvoice\DC25\n\+ \\ETXval\CAN\SOH \SOH(\v2#.BtcLsp.Data.LowLevel.LnHodlInvoiceR\ETXval\"L\n\+ \\DC2FundOnChainAddress\DC26\n\+ \\ETXval\CAN\SOH \SOH(\v2$.BtcLsp.Data.LowLevel.OnChainAddressR\ETXval\"N\n\+ \\DC4RefundOnChainAddress\DC26\n\+ \\ETXval\CAN\SOH \SOH(\v2$.BtcLsp.Data.LowLevel.OnChainAddressR\ETXval\"x\n\+ \\ETXCtx\DC22\n\+ \\ENQnonce\CAN\SOH \SOH(\v2\FS.BtcLsp.Data.HighLevel.NonceR\ENQnonce\DC2=\n\+ \\n\+ \ln_pub_key\CAN\STX \SOH(\v2\US.BtcLsp.Data.HighLevel.LnPubKeyR\blnPubKey\"\EM\n\+ \\ENQNonce\DC2\DLE\n\+ \\ETXval\CAN\SOH \SOH(\EOTR\ETXval\"\FS\n\+ \\bLnPubKey\DC2\DLE\n\+ \\ETXval\CAN\SOH \SOH(\fR\ETXval\"\SUB\n\+ \\ACKLnHost\DC2\DLE\n\+ \\ETXval\CAN\SOH \SOH(\tR\ETXval\"\SUB\n\+ \\ACKLnPort\DC2\DLE\n\+ \\ETXval\CAN\SOH \SOH(\rR\ETXval\"\168\SOH\n\+ \\ACKLnPeer\DC28\n\+ \\apub_key\CAN\SOH \SOH(\v2\US.BtcLsp.Data.HighLevel.LnPubKeyR\ACKpubKey\DC21\n\+ \\EOThost\CAN\STX \SOH(\v2\GS.BtcLsp.Data.HighLevel.LnHostR\EOThost\DC21\n\+ \\EOTport\CAN\ETX \SOH(\v2\GS.BtcLsp.Data.HighLevel.LnPortR\EOTport\"\149\SOH\n\+ \\fInputFailure\DC2H\n\+ \\SOfield_location\CAN\SOH \ETX(\v2!.BtcLsp.Data.HighLevel.FieldIndexR\rfieldLocation\DC2;\n\+ \\EOTkind\CAN\STX \SOH(\SO2'.BtcLsp.Data.HighLevel.InputFailureKindR\EOTkind\"\RS\n\+ \\n\+ \FieldIndex\DC2\DLE\n\+ \\ETXval\CAN\SOH \SOH(\rR\ETXval\"r\n\+ \\SIInternalFailure\DC2\FS\n\+ \\bredacted\CAN\SOH \SOH(\bH\NULR\bredacted\DC2!\n\+ \\vgrpc_server\CAN\STX \SOH(\tH\NULR\n\+ \grpcServer\DC2\DC4\n\+ \\EOTmath\CAN\ETX \SOH(\tH\NULR\EOTmathB\b\n\+ \\ACKeither*\\\n\+ \\DLEInputFailureKind\DC2\f\n\+ \\bREQUIRED\DLE\NUL\DC2\r\n\+ \\tNOT_FOUND\DLE\SOH\DC2\DC2\n\+ \\SOPARSING_FAILED\DLE\STX\DC2\ETB\n\+ \\DC3VERIFICATION_FAILED\DLE\ETX*\"\n\+ \\aPrivacy\DC2\n\+ \\n\+ \\ACKPUBLIC\DLE\NUL\DC2\v\n\+ \\aPRIVATE\DLE\SOHJ\165\EM\n\+ \\ACK\DC2\EOT\NUL\NUL\DEL\SOH\n\+ \\b\n\+ \\SOH\f\DC2\ETX\NUL\NUL\DLE\n\+ \P\n\+ \\SOH\STX\DC2\ETX\a\NUL\RS2F\n\+ \ HighLevel types are the only types\n\+ \ used directly in Grpc Methods.\n\+ \\n\+ \\n\+ \\t\n\+ \\STX\ETX\NUL\DC2\ETX\t\NUL&\n\+ \\n\+ \\n\+ \\STX\EOT\NUL\DC2\EOT\v\NUL\r\SOH\n\+ \\n\+ \\n\+ \\ETX\EOT\NUL\SOH\DC2\ETX\v\b\SI\n\+ \\v\n\+ \\EOT\EOT\NUL\STX\NUL\DC2\ETX\f\STX*\n\+ \\f\n\+ \\ENQ\EOT\NUL\STX\NUL\ACK\DC2\ETX\f\STX!\n\+ \\f\n\+ \\ENQ\EOT\NUL\STX\NUL\SOH\DC2\ETX\f\"%\n\+ \\f\n\+ \\ENQ\EOT\NUL\STX\NUL\ETX\DC2\ETX\f()\n\+ \\n\+ \\n\+ \\STX\EOT\SOH\DC2\EOT\SI\NUL\DC1\SOH\n\+ \\n\+ \\n\+ \\ETX\EOT\SOH\SOH\DC2\ETX\SI\b\DLE\n\+ \\v\n\+ \\EOT\EOT\SOH\STX\NUL\DC2\ETX\DLE\STX%\n\+ \\f\n\+ \\ENQ\EOT\SOH\STX\NUL\ACK\DC2\ETX\DLE\STX\FS\n\+ \\f\n\+ \\ENQ\EOT\SOH\STX\NUL\SOH\DC2\ETX\DLE\GS \n\+ \\f\n\+ \\ENQ\EOT\SOH\STX\NUL\ETX\DC2\ETX\DLE#$\n\+ \\n\+ \\n\+ \\STX\EOT\STX\DC2\EOT\DC3\NUL\NAK\SOH\n\+ \\n\+ \\n\+ \\ETX\EOT\STX\SOH\DC2\ETX\DC3\b\DC1\n\+ \\v\n\+ \\EOT\EOT\STX\STX\NUL\DC2\ETX\DC4\STX%\n\+ \\f\n\+ \\ENQ\EOT\STX\STX\NUL\ACK\DC2\ETX\DC4\STX\FS\n\+ \\f\n\+ \\ENQ\EOT\STX\STX\NUL\SOH\DC2\ETX\DC4\GS \n\+ \\f\n\+ \\ENQ\EOT\STX\STX\NUL\ETX\DC2\ETX\DC4#$\n\+ \\n\+ \\n\+ \\STX\EOT\ETX\DC2\EOT\ETB\NUL\EM\SOH\n\+ \\n\+ \\n\+ \\ETX\EOT\ETX\SOH\DC2\ETX\ETB\b\DC3\n\+ \\v\n\+ \\EOT\EOT\ETX\STX\NUL\DC2\ETX\CAN\STX%\n\+ \\f\n\+ \\ENQ\EOT\ETX\STX\NUL\ACK\DC2\ETX\CAN\STX\FS\n\+ \\f\n\+ \\ENQ\EOT\ETX\STX\NUL\SOH\DC2\ETX\CAN\GS \n\+ \\f\n\+ \\ENQ\EOT\ETX\STX\NUL\ETX\DC2\ETX\CAN#$\n\+ \\n\+ \\n\+ \\STX\EOT\EOT\DC2\EOT\ESC\NUL\GS\SOH\n\+ \\n\+ \\n\+ \\ETX\EOT\EOT\SOH\DC2\ETX\ESC\b\DC4\n\+ \\v\n\+ \\EOT\EOT\EOT\STX\NUL\DC2\ETX\FS\STX%\n\+ \\f\n\+ \\ENQ\EOT\EOT\STX\NUL\ACK\DC2\ETX\FS\STX\FS\n\+ \\f\n\+ \\ENQ\EOT\EOT\STX\NUL\SOH\DC2\ETX\FS\GS \n\+ \\f\n\+ \\ENQ\EOT\EOT\STX\NUL\ETX\DC2\ETX\FS#$\n\+ \\n\+ \\n\+ \\STX\EOT\ENQ\DC2\EOT\US\NUL!\SOH\n\+ \\n\+ \\n\+ \\ETX\EOT\ENQ\SOH\DC2\ETX\US\b\NAK\n\+ \\v\n\+ \\EOT\EOT\ENQ\STX\NUL\DC2\ETX \STX%\n\+ \\f\n\+ \\ENQ\EOT\ENQ\STX\NUL\ACK\DC2\ETX \STX\FS\n\+ \\f\n\+ \\ENQ\EOT\ENQ\STX\NUL\SOH\DC2\ETX \GS \n\+ \\f\n\+ \\ENQ\EOT\ENQ\STX\NUL\ETX\DC2\ETX #$\n\+ \\n\+ \\n\+ \\STX\EOT\ACK\DC2\EOT#\NUL%\SOH\n\+ \\n\+ \\n\+ \\ETX\EOT\ACK\SOH\DC2\ETX#\b\NAK\n\+ \\v\n\+ \\EOT\EOT\ACK\STX\NUL\DC2\ETX$\STX*\n\+ \\f\n\+ \\ENQ\EOT\ACK\STX\NUL\ACK\DC2\ETX$\STX!\n\+ \\f\n\+ \\ENQ\EOT\ACK\STX\NUL\SOH\DC2\ETX$\"%\n\+ \\f\n\+ \\ENQ\EOT\ACK\STX\NUL\ETX\DC2\ETX$()\n\+ \\n\+ \\n\+ \\STX\EOT\a\DC2\EOT'\NUL)\SOH\n\+ \\n\+ \\n\+ \\ETX\EOT\a\SOH\DC2\ETX'\b\EM\n\+ \\v\n\+ \\EOT\EOT\a\STX\NUL\DC2\ETX(\STX.\n\+ \\f\n\+ \\ENQ\EOT\a\STX\NUL\ACK\DC2\ETX(\STX%\n\+ \\f\n\+ \\ENQ\EOT\a\STX\NUL\SOH\DC2\ETX(&)\n\+ \\f\n\+ \\ENQ\EOT\a\STX\NUL\ETX\DC2\ETX(,-\n\+ \\n\+ \\n\+ \\STX\EOT\b\DC2\EOT+\NUL-\SOH\n\+ \\n\+ \\n\+ \\ETX\EOT\b\SOH\DC2\ETX+\b\SUB\n\+ \\v\n\+ \\EOT\EOT\b\STX\NUL\DC2\ETX,\STX/\n\+ \\f\n\+ \\ENQ\EOT\b\STX\NUL\ACK\DC2\ETX,\STX&\n\+ \\f\n\+ \\ENQ\EOT\b\STX\NUL\SOH\DC2\ETX,'*\n\+ \\f\n\+ \\ENQ\EOT\b\STX\NUL\ETX\DC2\ETX,-.\n\+ \\n\+ \\n\+ \\STX\EOT\t\DC2\EOT/\NUL1\SOH\n\+ \\n\+ \\n\+ \\ETX\EOT\t\SOH\DC2\ETX/\b\FS\n\+ \\v\n\+ \\EOT\EOT\t\STX\NUL\DC2\ETX0\STX/\n\+ \\f\n\+ \\ENQ\EOT\t\STX\NUL\ACK\DC2\ETX0\STX&\n\+ \\f\n\+ \\ENQ\EOT\t\STX\NUL\SOH\DC2\ETX0'*\n\+ \\f\n\+ \\ENQ\EOT\t\STX\NUL\ETX\DC2\ETX0-.\n\+ \\n\+ \\n\+ \\STX\EOT\n\+ \\DC2\EOT3\NUL6\SOH\n\+ \\n\+ \\n\+ \\ETX\EOT\n\+ \\SOH\DC2\ETX3\b\v\n\+ \\v\n\+ \\EOT\EOT\n\+ \\STX\NUL\DC2\ETX4\STX\DC2\n\+ \\f\n\+ \\ENQ\EOT\n\+ \\STX\NUL\ACK\DC2\ETX4\STX\a\n\+ \\f\n\+ \\ENQ\EOT\n\+ \\STX\NUL\SOH\DC2\ETX4\b\r\n\+ \\f\n\+ \\ENQ\EOT\n\+ \\STX\NUL\ETX\DC2\ETX4\DLE\DC1\n\+ \\v\n\+ \\EOT\EOT\n\+ \\STX\SOH\DC2\ETX5\STX\SUB\n\+ \\f\n\+ \\ENQ\EOT\n\+ \\STX\SOH\ACK\DC2\ETX5\STX\n\+ \\n\+ \\f\n\+ \\ENQ\EOT\n\+ \\STX\SOH\SOH\DC2\ETX5\v\NAK\n\+ \\f\n\+ \\ENQ\EOT\n\+ \\STX\SOH\ETX\DC2\ETX5\CAN\EM\n\+ \\233\STX\n\+ \\STX\EOT\v\DC2\EOTB\NULD\SOH2\220\STX\n\+ \ All requests do require a nonce. The nonce is used\n\+ \ for security reasons and is used to guard against\n\+ \ replay attacks. The server will reject any request\n\+ \ that comes with an incorrect nonce. The only requirement\n\+ \ for the nonce is that it needs to be strictly increasing.\n\+ \ Nonce generation is often achieved by using the\n\+ \ current UNIX timestamp.\n\+ \\n\+ \\n\+ \\n\+ \\n\+ \\ETX\EOT\v\SOH\DC2\ETXB\b\r\n\+ \\v\n\+ \\EOT\EOT\v\STX\NUL\DC2\ETXC\STX\DC1\n\+ \\f\n\+ \\ENQ\EOT\v\STX\NUL\ENQ\DC2\ETXC\STX\b\n\+ \\f\n\+ \\ENQ\EOT\v\STX\NUL\SOH\DC2\ETXC\t\f\n\+ \\f\n\+ \\ENQ\EOT\v\STX\NUL\ETX\DC2\ETXC\SI\DLE\n\+ \\n\+ \\n\+ \\STX\EOT\f\DC2\EOTF\NULH\SOH\n\+ \\n\+ \\n\+ \\ETX\EOT\f\SOH\DC2\ETXF\b\DLE\n\+ \\v\n\+ \\EOT\EOT\f\STX\NUL\DC2\ETXG\STX\DLE\n\+ \\f\n\+ \\ENQ\EOT\f\STX\NUL\ENQ\DC2\ETXG\STX\a\n\+ \\f\n\+ \\ENQ\EOT\f\STX\NUL\SOH\DC2\ETXG\b\v\n\+ \\f\n\+ \\ENQ\EOT\f\STX\NUL\ETX\DC2\ETXG\SO\SI\n\+ \\n\+ \\n\+ \\STX\EOT\r\DC2\EOTJ\NULL\SOH\n\+ \\n\+ \\n\+ \\ETX\EOT\r\SOH\DC2\ETXJ\b\SO\n\+ \\v\n\+ \\EOT\EOT\r\STX\NUL\DC2\ETXK\STX\DC1\n\+ \\f\n\+ \\ENQ\EOT\r\STX\NUL\ENQ\DC2\ETXK\STX\b\n\+ \\f\n\+ \\ENQ\EOT\r\STX\NUL\SOH\DC2\ETXK\t\f\n\+ \\f\n\+ \\ENQ\EOT\r\STX\NUL\ETX\DC2\ETXK\SI\DLE\n\+ \\n\+ \\n\+ \\STX\EOT\SO\DC2\EOTN\NULP\SOH\n\+ \\n\+ \\n\+ \\ETX\EOT\SO\SOH\DC2\ETXN\b\SO\n\+ \\v\n\+ \\EOT\EOT\SO\STX\NUL\DC2\ETXO\STX\DC1\n\+ \\f\n\+ \\ENQ\EOT\SO\STX\NUL\ENQ\DC2\ETXO\STX\b\n\+ \\f\n\+ \\ENQ\EOT\SO\STX\NUL\SOH\DC2\ETXO\t\f\n\+ \\f\n\+ \\ENQ\EOT\SO\STX\NUL\ETX\DC2\ETXO\SI\DLE\n\+ \\n\+ \\n\+ \\STX\EOT\SI\DC2\EOTR\NULV\SOH\n\+ \\n\+ \\n\+ \\ETX\EOT\SI\SOH\DC2\ETXR\b\SO\n\+ \\v\n\+ \\EOT\EOT\SI\STX\NUL\DC2\ETXS\STX\ETB\n\+ \\f\n\+ \\ENQ\EOT\SI\STX\NUL\ACK\DC2\ETXS\STX\n\+ \\n\+ \\f\n\+ \\ENQ\EOT\SI\STX\NUL\SOH\DC2\ETXS\v\DC2\n\+ \\f\n\+ \\ENQ\EOT\SI\STX\NUL\ETX\DC2\ETXS\NAK\SYN\n\+ \\v\n\+ \\EOT\EOT\SI\STX\SOH\DC2\ETXT\STX\DC2\n\+ \\f\n\+ \\ENQ\EOT\SI\STX\SOH\ACK\DC2\ETXT\STX\b\n\+ \\f\n\+ \\ENQ\EOT\SI\STX\SOH\SOH\DC2\ETXT\t\r\n\+ \\f\n\+ \\ENQ\EOT\SI\STX\SOH\ETX\DC2\ETXT\DLE\DC1\n\+ \\v\n\+ \\EOT\EOT\SI\STX\STX\DC2\ETXU\STX\DC2\n\+ \\f\n\+ \\ENQ\EOT\SI\STX\STX\ACK\DC2\ETXU\STX\b\n\+ \\f\n\+ \\ENQ\EOT\SI\STX\STX\SOH\DC2\ETXU\t\r\n\+ \\f\n\+ \\ENQ\EOT\SI\STX\STX\ETX\DC2\ETXU\DLE\DC1\n\+ \\n\+ \\n\+ \\STX\EOT\DLE\DC2\EOTX\NUL[\SOH\n\+ \\n\+ \\n\+ \\ETX\EOT\DLE\SOH\DC2\ETXX\b\DC4\n\+ \\v\n\+ \\EOT\EOT\DLE\STX\NUL\DC2\ETXY\STX)\n\+ \\f\n\+ \\ENQ\EOT\DLE\STX\NUL\EOT\DC2\ETXY\STX\n\+ \\n\+ \\f\n\+ \\ENQ\EOT\DLE\STX\NUL\ACK\DC2\ETXY\v\NAK\n\+ \\f\n\+ \\ENQ\EOT\DLE\STX\NUL\SOH\DC2\ETXY\SYN$\n\+ \\f\n\+ \\ENQ\EOT\DLE\STX\NUL\ETX\DC2\ETXY'(\n\+ \\v\n\+ \\EOT\EOT\DLE\STX\SOH\DC2\ETXZ\STX\FS\n\+ \\f\n\+ \\ENQ\EOT\DLE\STX\SOH\ACK\DC2\ETXZ\STX\DC2\n\+ \\f\n\+ \\ENQ\EOT\DLE\STX\SOH\SOH\DC2\ETXZ\DC3\ETB\n\+ \\f\n\+ \\ENQ\EOT\DLE\STX\SOH\ETX\DC2\ETXZ\SUB\ESC\n\+ \\n\+ \\n\+ \\STX\EOT\DC1\DC2\EOT]\NUL_\SOH\n\+ \\n\+ \\n\+ \\ETX\EOT\DC1\SOH\DC2\ETX]\b\DC2\n\+ \\v\n\+ \\EOT\EOT\DC1\STX\NUL\DC2\ETX^\STX\DC1\n\+ \\f\n\+ \\ENQ\EOT\DC1\STX\NUL\ENQ\DC2\ETX^\STX\b\n\+ \\f\n\+ \\ENQ\EOT\DC1\STX\NUL\SOH\DC2\ETX^\t\f\n\+ \\f\n\+ \\ENQ\EOT\DC1\STX\NUL\ETX\DC2\ETX^\SI\DLE\n\+ \\n\+ \\n\+ \\STX\ENQ\NUL\DC2\EOTa\NULr\SOH\n\+ \\n\+ \\n\+ \\ETX\ENQ\NUL\SOH\DC2\ETXa\ENQ\NAK\n\+ \l\n\+ \\EOT\ENQ\NUL\STX\NUL\DC2\ETXd\STX\SI\SUB_ All proto3 messages are optional, but sometimes\n\+ \ message presence is required by source code.\n\+ \\n\+ \\f\n\+ \\ENQ\ENQ\NUL\STX\NUL\SOH\DC2\ETXd\STX\n\+ \\n\+ \\f\n\+ \\ENQ\ENQ\NUL\STX\NUL\STX\DC2\ETXd\r\SO\n\+ \\182\SOH\n\+ \\EOT\ENQ\NUL\STX\SOH\DC2\ETXh\STX\DLE\SUB\168\SOH Sometimes protobuf term is not data itself, but reference\n\+ \ to some other data, located somewhere else, for example\n\+ \ in database, and this resource might be not found.\n\+ \\n\+ \\f\n\+ \\ENQ\ENQ\NUL\STX\SOH\SOH\DC2\ETXh\STX\v\n\+ \\f\n\+ \\ENQ\ENQ\NUL\STX\SOH\STX\DC2\ETXh\SO\SI\n\+ \\201\SOH\n\+ \\EOT\ENQ\NUL\STX\STX\DC2\ETXm\STX\NAK\SUB\187\SOH Sometimes data is required to be in some\n\+ \ specific format (for example DER binary encoding)\n\+ \ which is not the part of proto3 type system.\n\+ \ This error shows the failure of custom parser.\n\+ \\n\+ \\f\n\+ \\ENQ\ENQ\NUL\STX\STX\SOH\DC2\ETXm\STX\DLE\n\+ \\f\n\+ \\ENQ\ENQ\NUL\STX\STX\STX\DC2\ETXm\DC3\DC4\n\+ \\157\SOH\n\+ \\EOT\ENQ\NUL\STX\ETX\DC2\ETXq\STX\SUB\SUB\143\SOH Even if custom parser succeeded, sometimes data\n\+ \ needs to be verified somehow, for example\n\+ \ signature needs to be cryptographically verified.\n\+ \\n\+ \\f\n\+ \\ENQ\ENQ\NUL\STX\ETX\SOH\DC2\ETXq\STX\NAK\n\+ \\f\n\+ \\ENQ\ENQ\NUL\STX\ETX\STX\DC2\ETXq\CAN\EM\n\+ \\n\+ \\n\+ \\STX\ENQ\SOH\DC2\EOTt\NULw\SOH\n\+ \\n\+ \\n\+ \\ETX\ENQ\SOH\SOH\DC2\ETXt\ENQ\f\n\+ \\v\n\+ \\EOT\ENQ\SOH\STX\NUL\DC2\ETXu\STX\r\n\+ \\f\n\+ \\ENQ\ENQ\SOH\STX\NUL\SOH\DC2\ETXu\STX\b\n\+ \\f\n\+ \\ENQ\ENQ\SOH\STX\NUL\STX\DC2\ETXu\v\f\n\+ \\v\n\+ \\EOT\ENQ\SOH\STX\SOH\DC2\ETXv\STX\SO\n\+ \\f\n\+ \\ENQ\ENQ\SOH\STX\SOH\SOH\DC2\ETXv\STX\t\n\+ \\f\n\+ \\ENQ\ENQ\SOH\STX\SOH\STX\DC2\ETXv\f\r\n\+ \\n\+ \\n\+ \\STX\EOT\DC2\DC2\EOTy\NUL\DEL\SOH\n\+ \\n\+ \\n\+ \\ETX\EOT\DC2\SOH\DC2\ETXy\b\ETB\n\+ \\f\n\+ \\EOT\EOT\DC2\b\NUL\DC2\EOTz\STX~\ETX\n\+ \\f\n\+ \\ENQ\EOT\DC2\b\NUL\SOH\DC2\ETXz\b\SO\n\+ \\v\n\+ \\EOT\EOT\DC2\STX\NUL\DC2\ETX{\EOT\SYN\n\+ \\f\n\+ \\ENQ\EOT\DC2\STX\NUL\ENQ\DC2\ETX{\EOT\b\n\+ \\f\n\+ \\ENQ\EOT\DC2\STX\NUL\SOH\DC2\ETX{\t\DC1\n\+ \\f\n\+ \\ENQ\EOT\DC2\STX\NUL\ETX\DC2\ETX{\DC4\NAK\n\+ \\v\n\+ \\EOT\EOT\DC2\STX\SOH\DC2\ETX|\EOT\ESC\n\+ \\f\n\+ \\ENQ\EOT\DC2\STX\SOH\ENQ\DC2\ETX|\EOT\n\+ \\n\+ \\f\n\+ \\ENQ\EOT\DC2\STX\SOH\SOH\DC2\ETX|\v\SYN\n\+ \\f\n\+ \\ENQ\EOT\DC2\STX\SOH\ETX\DC2\ETX|\EM\SUB\n\+ \\v\n\+ \\EOT\EOT\DC2\STX\STX\DC2\ETX}\EOT\DC4\n\+ \\f\n\+ \\ENQ\EOT\DC2\STX\STX\ENQ\DC2\ETX}\EOT\n\+ \\n\+ \\f\n\+ \\ENQ\EOT\DC2\STX\STX\SOH\DC2\ETX}\v\SI\n\+ \\f\n\+ \\ENQ\EOT\DC2\STX\STX\ETX\DC2\ETX}\DC2\DC3b\ACKproto3"
@@ -0,0 +1,155 @@+{- This file was auto-generated from btc_lsp/data/high_level.proto by the proto-lens-protoc program. -}+{-# LANGUAGE ScopedTypeVariables, DataKinds, TypeFamilies, UndecidableInstances, GeneralizedNewtypeDeriving, MultiParamTypeClasses, FlexibleContexts, FlexibleInstances, PatternSynonyms, MagicHash, NoImplicitPrelude, BangPatterns, TypeApplications, OverloadedStrings, DerivingStrategies, DeriveGeneric#-}+{-# OPTIONS_GHC -Wno-unused-imports#-}+{-# OPTIONS_GHC -Wno-duplicate-exports#-}+{-# OPTIONS_GHC -Wno-dodgy-exports#-}+module Proto.BtcLsp.Data.HighLevel_Fields where+import qualified Data.ProtoLens.Runtime.Prelude as Prelude+import qualified Data.ProtoLens.Runtime.Data.Int as Data.Int+import qualified Data.ProtoLens.Runtime.Data.Monoid as Data.Monoid+import qualified Data.ProtoLens.Runtime.Data.Word as Data.Word+import qualified Data.ProtoLens.Runtime.Data.ProtoLens as Data.ProtoLens+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Bytes as Data.ProtoLens.Encoding.Bytes+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Growing as Data.ProtoLens.Encoding.Growing+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Parser.Unsafe as Data.ProtoLens.Encoding.Parser.Unsafe+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Wire as Data.ProtoLens.Encoding.Wire+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Field as Data.ProtoLens.Field+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Message.Enum as Data.ProtoLens.Message.Enum+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Service.Types as Data.ProtoLens.Service.Types+import qualified Data.ProtoLens.Runtime.Lens.Family2 as Lens.Family2+import qualified Data.ProtoLens.Runtime.Lens.Family2.Unchecked as Lens.Family2.Unchecked+import qualified Data.ProtoLens.Runtime.Data.Text as Data.Text+import qualified Data.ProtoLens.Runtime.Data.Map as Data.Map+import qualified Data.ProtoLens.Runtime.Data.ByteString as Data.ByteString+import qualified Data.ProtoLens.Runtime.Data.ByteString.Char8 as Data.ByteString.Char8+import qualified Data.ProtoLens.Runtime.Data.Text.Encoding as Data.Text.Encoding+import qualified Data.ProtoLens.Runtime.Data.Vector as Data.Vector+import qualified Data.ProtoLens.Runtime.Data.Vector.Generic as Data.Vector.Generic+import qualified Data.ProtoLens.Runtime.Data.Vector.Unboxed as Data.Vector.Unboxed+import qualified Data.ProtoLens.Runtime.Text.Read as Text.Read+import qualified Proto.BtcLsp.Data.LowLevel+fieldLocation ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "fieldLocation" a) =>+ Lens.Family2.LensLike' f s a+fieldLocation = Data.ProtoLens.Field.field @"fieldLocation"+grpcServer ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "grpcServer" a) =>+ Lens.Family2.LensLike' f s a+grpcServer = Data.ProtoLens.Field.field @"grpcServer"+host ::+ forall f s a.+ (Prelude.Functor f, Data.ProtoLens.Field.HasField s "host" a) =>+ Lens.Family2.LensLike' f s a+host = Data.ProtoLens.Field.field @"host"+kind ::+ forall f s a.+ (Prelude.Functor f, Data.ProtoLens.Field.HasField s "kind" a) =>+ Lens.Family2.LensLike' f s a+kind = Data.ProtoLens.Field.field @"kind"+lnPubKey ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "lnPubKey" a) =>+ Lens.Family2.LensLike' f s a+lnPubKey = Data.ProtoLens.Field.field @"lnPubKey"+math ::+ forall f s a.+ (Prelude.Functor f, Data.ProtoLens.Field.HasField s "math" a) =>+ Lens.Family2.LensLike' f s a+math = Data.ProtoLens.Field.field @"math"+maybe'either ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "maybe'either" a) =>+ Lens.Family2.LensLike' f s a+maybe'either = Data.ProtoLens.Field.field @"maybe'either"+maybe'grpcServer ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "maybe'grpcServer" a) =>+ Lens.Family2.LensLike' f s a+maybe'grpcServer = Data.ProtoLens.Field.field @"maybe'grpcServer"+maybe'host ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "maybe'host" a) =>+ Lens.Family2.LensLike' f s a+maybe'host = Data.ProtoLens.Field.field @"maybe'host"+maybe'lnPubKey ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "maybe'lnPubKey" a) =>+ Lens.Family2.LensLike' f s a+maybe'lnPubKey = Data.ProtoLens.Field.field @"maybe'lnPubKey"+maybe'math ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "maybe'math" a) =>+ Lens.Family2.LensLike' f s a+maybe'math = Data.ProtoLens.Field.field @"maybe'math"+maybe'nonce ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "maybe'nonce" a) =>+ Lens.Family2.LensLike' f s a+maybe'nonce = Data.ProtoLens.Field.field @"maybe'nonce"+maybe'port ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "maybe'port" a) =>+ Lens.Family2.LensLike' f s a+maybe'port = Data.ProtoLens.Field.field @"maybe'port"+maybe'pubKey ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "maybe'pubKey" a) =>+ Lens.Family2.LensLike' f s a+maybe'pubKey = Data.ProtoLens.Field.field @"maybe'pubKey"+maybe'redacted ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "maybe'redacted" a) =>+ Lens.Family2.LensLike' f s a+maybe'redacted = Data.ProtoLens.Field.field @"maybe'redacted"+maybe'val ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "maybe'val" a) =>+ Lens.Family2.LensLike' f s a+maybe'val = Data.ProtoLens.Field.field @"maybe'val"+nonce ::+ forall f s a.+ (Prelude.Functor f, Data.ProtoLens.Field.HasField s "nonce" a) =>+ Lens.Family2.LensLike' f s a+nonce = Data.ProtoLens.Field.field @"nonce"+port ::+ forall f s a.+ (Prelude.Functor f, Data.ProtoLens.Field.HasField s "port" a) =>+ Lens.Family2.LensLike' f s a+port = Data.ProtoLens.Field.field @"port"+pubKey ::+ forall f s a.+ (Prelude.Functor f, Data.ProtoLens.Field.HasField s "pubKey" a) =>+ Lens.Family2.LensLike' f s a+pubKey = Data.ProtoLens.Field.field @"pubKey"+redacted ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "redacted" a) =>+ Lens.Family2.LensLike' f s a+redacted = Data.ProtoLens.Field.field @"redacted"+val ::+ forall f s a.+ (Prelude.Functor f, Data.ProtoLens.Field.HasField s "val" a) =>+ Lens.Family2.LensLike' f s a+val = Data.ProtoLens.Field.field @"val"+vec'fieldLocation ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "vec'fieldLocation" a) =>+ Lens.Family2.LensLike' f s a+vec'fieldLocation = Data.ProtoLens.Field.field @"vec'fieldLocation"
@@ -0,0 +1,729 @@+{- This file was auto-generated from btc_lsp/data/low_level.proto by the proto-lens-protoc program. -}+{-# LANGUAGE ScopedTypeVariables, DataKinds, TypeFamilies, UndecidableInstances, GeneralizedNewtypeDeriving, MultiParamTypeClasses, FlexibleContexts, FlexibleInstances, PatternSynonyms, MagicHash, NoImplicitPrelude, BangPatterns, TypeApplications, OverloadedStrings, DerivingStrategies, DeriveGeneric#-}+{-# OPTIONS_GHC -Wno-unused-imports#-}+{-# OPTIONS_GHC -Wno-duplicate-exports#-}+{-# OPTIONS_GHC -Wno-dodgy-exports#-}+module Proto.BtcLsp.Data.LowLevel (+ LnHodlInvoice(), LnInvoice(), Msat(), OnChainAddress(), Urational()+ ) where+import qualified Data.ProtoLens.Runtime.Control.DeepSeq as Control.DeepSeq+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Prism as Data.ProtoLens.Prism+import qualified Text.PrettyPrint.GenericPretty.Instance+import qualified GHC.Generics+import qualified Text.PrettyPrint.GenericPretty+import qualified Data.ProtoLens.Runtime.Prelude as Prelude+import qualified Data.ProtoLens.Runtime.Data.Int as Data.Int+import qualified Data.ProtoLens.Runtime.Data.Monoid as Data.Monoid+import qualified Data.ProtoLens.Runtime.Data.Word as Data.Word+import qualified Data.ProtoLens.Runtime.Data.ProtoLens as Data.ProtoLens+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Bytes as Data.ProtoLens.Encoding.Bytes+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Growing as Data.ProtoLens.Encoding.Growing+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Parser.Unsafe as Data.ProtoLens.Encoding.Parser.Unsafe+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Wire as Data.ProtoLens.Encoding.Wire+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Field as Data.ProtoLens.Field+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Message.Enum as Data.ProtoLens.Message.Enum+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Service.Types as Data.ProtoLens.Service.Types+import qualified Data.ProtoLens.Runtime.Lens.Family2 as Lens.Family2+import qualified Data.ProtoLens.Runtime.Lens.Family2.Unchecked as Lens.Family2.Unchecked+import qualified Data.ProtoLens.Runtime.Data.Text as Data.Text+import qualified Data.ProtoLens.Runtime.Data.Map as Data.Map+import qualified Data.ProtoLens.Runtime.Data.ByteString as Data.ByteString+import qualified Data.ProtoLens.Runtime.Data.ByteString.Char8 as Data.ByteString.Char8+import qualified Data.ProtoLens.Runtime.Data.Text.Encoding as Data.Text.Encoding+import qualified Data.ProtoLens.Runtime.Data.Vector as Data.Vector+import qualified Data.ProtoLens.Runtime.Data.Vector.Generic as Data.Vector.Generic+import qualified Data.ProtoLens.Runtime.Data.Vector.Unboxed as Data.Vector.Unboxed+import qualified Data.ProtoLens.Runtime.Text.Read as Text.Read+{- | Fields :+ + * 'Proto.BtcLsp.Data.LowLevel_Fields.val' @:: Lens' LnHodlInvoice Data.Text.Text@ -}+data LnHodlInvoice+ = LnHodlInvoice'_constructor {_LnHodlInvoice'val :: !Data.Text.Text,+ _LnHodlInvoice'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show LnHodlInvoice where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out LnHodlInvoice+instance Data.ProtoLens.Field.HasField LnHodlInvoice "val" Data.Text.Text where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _LnHodlInvoice'val (\ x__ y__ -> x__ {_LnHodlInvoice'val = y__}))+ Prelude.id+instance Data.ProtoLens.Message LnHodlInvoice where+ messageName _ = Data.Text.pack "BtcLsp.Data.LowLevel.LnHodlInvoice"+ packedMessageDescriptor _+ = "\n\+ \\rLnHodlInvoice\DC2\DLE\n\+ \\ETXval\CAN\SOH \SOH(\tR\ETXval"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ val__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "val"+ (Data.ProtoLens.ScalarField Data.ProtoLens.StringField ::+ Data.ProtoLens.FieldTypeDescriptor Data.Text.Text)+ (Data.ProtoLens.PlainField+ Data.ProtoLens.Optional (Data.ProtoLens.Field.field @"val")) ::+ Data.ProtoLens.FieldDescriptor LnHodlInvoice+ in+ Data.Map.fromList [(Data.ProtoLens.Tag 1, val__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _LnHodlInvoice'_unknownFields+ (\ x__ y__ -> x__ {_LnHodlInvoice'_unknownFields = y__})+ defMessage+ = LnHodlInvoice'_constructor+ {_LnHodlInvoice'val = Data.ProtoLens.fieldDefault,+ _LnHodlInvoice'_unknownFields = []}+ parseMessage+ = let+ loop ::+ LnHodlInvoice -> Data.ProtoLens.Encoding.Bytes.Parser LnHodlInvoice+ loop x+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) x)+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 10+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do value <- do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.getBytes+ (Prelude.fromIntegral len)+ Data.ProtoLens.Encoding.Bytes.runEither+ (case Data.Text.Encoding.decodeUtf8' value of+ (Prelude.Left err)+ -> Prelude.Left (Prelude.show err)+ (Prelude.Right r) -> Prelude.Right r))+ "val"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"val") y x)+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do loop Data.ProtoLens.defMessage) "LnHodlInvoice"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (let _v = Lens.Family2.view (Data.ProtoLens.Field.field @"val") _x+ in+ if (Prelude.==) _v Data.ProtoLens.fieldDefault then+ Data.Monoid.mempty+ else+ (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 10)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.Text.Encoding.encodeUtf8 _v))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x))+instance Control.DeepSeq.NFData LnHodlInvoice where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_LnHodlInvoice'_unknownFields x__)+ (Control.DeepSeq.deepseq (_LnHodlInvoice'val x__) ())+{- | Fields :+ + * 'Proto.BtcLsp.Data.LowLevel_Fields.val' @:: Lens' LnInvoice Data.Text.Text@ -}+data LnInvoice+ = LnInvoice'_constructor {_LnInvoice'val :: !Data.Text.Text,+ _LnInvoice'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show LnInvoice where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out LnInvoice+instance Data.ProtoLens.Field.HasField LnInvoice "val" Data.Text.Text where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _LnInvoice'val (\ x__ y__ -> x__ {_LnInvoice'val = y__}))+ Prelude.id+instance Data.ProtoLens.Message LnInvoice where+ messageName _ = Data.Text.pack "BtcLsp.Data.LowLevel.LnInvoice"+ packedMessageDescriptor _+ = "\n\+ \\tLnInvoice\DC2\DLE\n\+ \\ETXval\CAN\SOH \SOH(\tR\ETXval"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ val__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "val"+ (Data.ProtoLens.ScalarField Data.ProtoLens.StringField ::+ Data.ProtoLens.FieldTypeDescriptor Data.Text.Text)+ (Data.ProtoLens.PlainField+ Data.ProtoLens.Optional (Data.ProtoLens.Field.field @"val")) ::+ Data.ProtoLens.FieldDescriptor LnInvoice+ in+ Data.Map.fromList [(Data.ProtoLens.Tag 1, val__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _LnInvoice'_unknownFields+ (\ x__ y__ -> x__ {_LnInvoice'_unknownFields = y__})+ defMessage+ = LnInvoice'_constructor+ {_LnInvoice'val = Data.ProtoLens.fieldDefault,+ _LnInvoice'_unknownFields = []}+ parseMessage+ = let+ loop :: LnInvoice -> Data.ProtoLens.Encoding.Bytes.Parser LnInvoice+ loop x+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) x)+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 10+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do value <- do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.getBytes+ (Prelude.fromIntegral len)+ Data.ProtoLens.Encoding.Bytes.runEither+ (case Data.Text.Encoding.decodeUtf8' value of+ (Prelude.Left err)+ -> Prelude.Left (Prelude.show err)+ (Prelude.Right r) -> Prelude.Right r))+ "val"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"val") y x)+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do loop Data.ProtoLens.defMessage) "LnInvoice"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (let _v = Lens.Family2.view (Data.ProtoLens.Field.field @"val") _x+ in+ if (Prelude.==) _v Data.ProtoLens.fieldDefault then+ Data.Monoid.mempty+ else+ (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 10)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.Text.Encoding.encodeUtf8 _v))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x))+instance Control.DeepSeq.NFData LnInvoice where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_LnInvoice'_unknownFields x__)+ (Control.DeepSeq.deepseq (_LnInvoice'val x__) ())+{- | Fields :+ + * 'Proto.BtcLsp.Data.LowLevel_Fields.val' @:: Lens' Msat Data.Word.Word64@ -}+data Msat+ = Msat'_constructor {_Msat'val :: !Data.Word.Word64,+ _Msat'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show Msat where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out Msat+instance Data.ProtoLens.Field.HasField Msat "val" Data.Word.Word64 where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Msat'val (\ x__ y__ -> x__ {_Msat'val = y__}))+ Prelude.id+instance Data.ProtoLens.Message Msat where+ messageName _ = Data.Text.pack "BtcLsp.Data.LowLevel.Msat"+ packedMessageDescriptor _+ = "\n\+ \\EOTMsat\DC2\DLE\n\+ \\ETXval\CAN\SOH \SOH(\EOTR\ETXval"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ val__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "val"+ (Data.ProtoLens.ScalarField Data.ProtoLens.UInt64Field ::+ Data.ProtoLens.FieldTypeDescriptor Data.Word.Word64)+ (Data.ProtoLens.PlainField+ Data.ProtoLens.Optional (Data.ProtoLens.Field.field @"val")) ::+ Data.ProtoLens.FieldDescriptor Msat+ in+ Data.Map.fromList [(Data.ProtoLens.Tag 1, val__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _Msat'_unknownFields+ (\ x__ y__ -> x__ {_Msat'_unknownFields = y__})+ defMessage+ = Msat'_constructor+ {_Msat'val = Data.ProtoLens.fieldDefault,+ _Msat'_unknownFields = []}+ parseMessage+ = let+ loop :: Msat -> Data.ProtoLens.Encoding.Bytes.Parser Msat+ loop x+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) x)+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 8 -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ Data.ProtoLens.Encoding.Bytes.getVarInt "val"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"val") y x)+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do loop Data.ProtoLens.defMessage) "Msat"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (let _v = Lens.Family2.view (Data.ProtoLens.Field.field @"val") _x+ in+ if (Prelude.==) _v Data.ProtoLens.fieldDefault then+ Data.Monoid.mempty+ else+ (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 8)+ (Data.ProtoLens.Encoding.Bytes.putVarInt _v))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x))+instance Control.DeepSeq.NFData Msat where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_Msat'_unknownFields x__)+ (Control.DeepSeq.deepseq (_Msat'val x__) ())+{- | Fields :+ + * 'Proto.BtcLsp.Data.LowLevel_Fields.val' @:: Lens' OnChainAddress Data.Text.Text@ -}+data OnChainAddress+ = OnChainAddress'_constructor {_OnChainAddress'val :: !Data.Text.Text,+ _OnChainAddress'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show OnChainAddress where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out OnChainAddress+instance Data.ProtoLens.Field.HasField OnChainAddress "val" Data.Text.Text where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _OnChainAddress'val (\ x__ y__ -> x__ {_OnChainAddress'val = y__}))+ Prelude.id+instance Data.ProtoLens.Message OnChainAddress where+ messageName _+ = Data.Text.pack "BtcLsp.Data.LowLevel.OnChainAddress"+ packedMessageDescriptor _+ = "\n\+ \\SOOnChainAddress\DC2\DLE\n\+ \\ETXval\CAN\SOH \SOH(\tR\ETXval"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ val__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "val"+ (Data.ProtoLens.ScalarField Data.ProtoLens.StringField ::+ Data.ProtoLens.FieldTypeDescriptor Data.Text.Text)+ (Data.ProtoLens.PlainField+ Data.ProtoLens.Optional (Data.ProtoLens.Field.field @"val")) ::+ Data.ProtoLens.FieldDescriptor OnChainAddress+ in+ Data.Map.fromList [(Data.ProtoLens.Tag 1, val__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _OnChainAddress'_unknownFields+ (\ x__ y__ -> x__ {_OnChainAddress'_unknownFields = y__})+ defMessage+ = OnChainAddress'_constructor+ {_OnChainAddress'val = Data.ProtoLens.fieldDefault,+ _OnChainAddress'_unknownFields = []}+ parseMessage+ = let+ loop ::+ OnChainAddress+ -> Data.ProtoLens.Encoding.Bytes.Parser OnChainAddress+ loop x+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) x)+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 10+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do value <- do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.getBytes+ (Prelude.fromIntegral len)+ Data.ProtoLens.Encoding.Bytes.runEither+ (case Data.Text.Encoding.decodeUtf8' value of+ (Prelude.Left err)+ -> Prelude.Left (Prelude.show err)+ (Prelude.Right r) -> Prelude.Right r))+ "val"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"val") y x)+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do loop Data.ProtoLens.defMessage) "OnChainAddress"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (let _v = Lens.Family2.view (Data.ProtoLens.Field.field @"val") _x+ in+ if (Prelude.==) _v Data.ProtoLens.fieldDefault then+ Data.Monoid.mempty+ else+ (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 10)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.Text.Encoding.encodeUtf8 _v))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x))+instance Control.DeepSeq.NFData OnChainAddress where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_OnChainAddress'_unknownFields x__)+ (Control.DeepSeq.deepseq (_OnChainAddress'val x__) ())+{- | Fields :+ + * 'Proto.BtcLsp.Data.LowLevel_Fields.numerator' @:: Lens' Urational Data.Word.Word64@+ * 'Proto.BtcLsp.Data.LowLevel_Fields.denominator' @:: Lens' Urational Data.Word.Word64@ -}+data Urational+ = Urational'_constructor {_Urational'numerator :: !Data.Word.Word64,+ _Urational'denominator :: !Data.Word.Word64,+ _Urational'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show Urational where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out Urational+instance Data.ProtoLens.Field.HasField Urational "numerator" Data.Word.Word64 where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Urational'numerator+ (\ x__ y__ -> x__ {_Urational'numerator = y__}))+ Prelude.id+instance Data.ProtoLens.Field.HasField Urational "denominator" Data.Word.Word64 where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Urational'denominator+ (\ x__ y__ -> x__ {_Urational'denominator = y__}))+ Prelude.id+instance Data.ProtoLens.Message Urational where+ messageName _ = Data.Text.pack "BtcLsp.Data.LowLevel.Urational"+ packedMessageDescriptor _+ = "\n\+ \\tUrational\DC2\FS\n\+ \\tnumerator\CAN\SOH \SOH(\EOTR\tnumerator\DC2 \n\+ \\vdenominator\CAN\STX \SOH(\EOTR\vdenominator"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ numerator__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "numerator"+ (Data.ProtoLens.ScalarField Data.ProtoLens.UInt64Field ::+ Data.ProtoLens.FieldTypeDescriptor Data.Word.Word64)+ (Data.ProtoLens.PlainField+ Data.ProtoLens.Optional+ (Data.ProtoLens.Field.field @"numerator")) ::+ Data.ProtoLens.FieldDescriptor Urational+ denominator__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "denominator"+ (Data.ProtoLens.ScalarField Data.ProtoLens.UInt64Field ::+ Data.ProtoLens.FieldTypeDescriptor Data.Word.Word64)+ (Data.ProtoLens.PlainField+ Data.ProtoLens.Optional+ (Data.ProtoLens.Field.field @"denominator")) ::+ Data.ProtoLens.FieldDescriptor Urational+ in+ Data.Map.fromList+ [(Data.ProtoLens.Tag 1, numerator__field_descriptor),+ (Data.ProtoLens.Tag 2, denominator__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _Urational'_unknownFields+ (\ x__ y__ -> x__ {_Urational'_unknownFields = y__})+ defMessage+ = Urational'_constructor+ {_Urational'numerator = Data.ProtoLens.fieldDefault,+ _Urational'denominator = Data.ProtoLens.fieldDefault,+ _Urational'_unknownFields = []}+ parseMessage+ = let+ loop :: Urational -> Data.ProtoLens.Encoding.Bytes.Parser Urational+ loop x+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) x)+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 8 -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ Data.ProtoLens.Encoding.Bytes.getVarInt "numerator"+ loop+ (Lens.Family2.set (Data.ProtoLens.Field.field @"numerator") y x)+ 16+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ Data.ProtoLens.Encoding.Bytes.getVarInt "denominator"+ loop+ (Lens.Family2.set (Data.ProtoLens.Field.field @"denominator") y x)+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do loop Data.ProtoLens.defMessage) "Urational"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (let+ _v = Lens.Family2.view (Data.ProtoLens.Field.field @"numerator") _x+ in+ if (Prelude.==) _v Data.ProtoLens.fieldDefault then+ Data.Monoid.mempty+ else+ (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 8)+ (Data.ProtoLens.Encoding.Bytes.putVarInt _v))+ ((Data.Monoid.<>)+ (let+ _v+ = Lens.Family2.view (Data.ProtoLens.Field.field @"denominator") _x+ in+ if (Prelude.==) _v Data.ProtoLens.fieldDefault then+ Data.Monoid.mempty+ else+ (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 16)+ (Data.ProtoLens.Encoding.Bytes.putVarInt _v))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x)))+instance Control.DeepSeq.NFData Urational where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_Urational'_unknownFields x__)+ (Control.DeepSeq.deepseq+ (_Urational'numerator x__)+ (Control.DeepSeq.deepseq (_Urational'denominator x__) ()))+packedFileDescriptor :: Data.ByteString.ByteString+packedFileDescriptor+ = "\n\+ \\FSbtc_lsp/data/low_level.proto\DC2\DC4BtcLsp.Data.LowLevel\"K\n\+ \\tUrational\DC2\FS\n\+ \\tnumerator\CAN\SOH \SOH(\EOTR\tnumerator\DC2 \n\+ \\vdenominator\CAN\STX \SOH(\EOTR\vdenominator\"\CAN\n\+ \\EOTMsat\DC2\DLE\n\+ \\ETXval\CAN\SOH \SOH(\EOTR\ETXval\"\GS\n\+ \\tLnInvoice\DC2\DLE\n\+ \\ETXval\CAN\SOH \SOH(\tR\ETXval\"!\n\+ \\rLnHodlInvoice\DC2\DLE\n\+ \\ETXval\CAN\SOH \SOH(\tR\ETXval\"\"\n\+ \\SOOnChainAddress\DC2\DLE\n\+ \\ETXval\CAN\SOH \SOH(\tR\ETXvalJ\206\EOT\n\+ \\ACK\DC2\EOT\NUL\NUL\GS\SOH\n\+ \\b\n\+ \\SOH\f\DC2\ETX\NUL\NUL\DLE\n\+ \x\n\+ \\SOH\STX\DC2\ETX\b\NUL\GS2n\n\+ \ LowLevel types which are used only to\n\+ \ create HighLevel types, and are not used\n\+ \ directly in Grpc Methods.\n\+ \\n\+ \\n\+ \\n\+ \\n\+ \\STX\EOT\NUL\DC2\EOT\n\+ \\NUL\r\SOH\n\+ \\n\+ \\n\+ \\ETX\EOT\NUL\SOH\DC2\ETX\n\+ \\b\DC1\n\+ \\v\n\+ \\EOT\EOT\NUL\STX\NUL\DC2\ETX\v\STX\ETB\n\+ \\f\n\+ \\ENQ\EOT\NUL\STX\NUL\ENQ\DC2\ETX\v\STX\b\n\+ \\f\n\+ \\ENQ\EOT\NUL\STX\NUL\SOH\DC2\ETX\v\t\DC2\n\+ \\f\n\+ \\ENQ\EOT\NUL\STX\NUL\ETX\DC2\ETX\v\NAK\SYN\n\+ \\v\n\+ \\EOT\EOT\NUL\STX\SOH\DC2\ETX\f\STX\EM\n\+ \\f\n\+ \\ENQ\EOT\NUL\STX\SOH\ENQ\DC2\ETX\f\STX\b\n\+ \\f\n\+ \\ENQ\EOT\NUL\STX\SOH\SOH\DC2\ETX\f\t\DC4\n\+ \\f\n\+ \\ENQ\EOT\NUL\STX\SOH\ETX\DC2\ETX\f\ETB\CAN\n\+ \\n\+ \\n\+ \\STX\EOT\SOH\DC2\EOT\SI\NUL\DC1\SOH\n\+ \\n\+ \\n\+ \\ETX\EOT\SOH\SOH\DC2\ETX\SI\b\f\n\+ \\v\n\+ \\EOT\EOT\SOH\STX\NUL\DC2\ETX\DLE\STX\DC1\n\+ \\f\n\+ \\ENQ\EOT\SOH\STX\NUL\ENQ\DC2\ETX\DLE\STX\b\n\+ \\f\n\+ \\ENQ\EOT\SOH\STX\NUL\SOH\DC2\ETX\DLE\t\f\n\+ \\f\n\+ \\ENQ\EOT\SOH\STX\NUL\ETX\DC2\ETX\DLE\SI\DLE\n\+ \\n\+ \\n\+ \\STX\EOT\STX\DC2\EOT\DC3\NUL\NAK\SOH\n\+ \\n\+ \\n\+ \\ETX\EOT\STX\SOH\DC2\ETX\DC3\b\DC1\n\+ \\v\n\+ \\EOT\EOT\STX\STX\NUL\DC2\ETX\DC4\STX\DC1\n\+ \\f\n\+ \\ENQ\EOT\STX\STX\NUL\ENQ\DC2\ETX\DC4\STX\b\n\+ \\f\n\+ \\ENQ\EOT\STX\STX\NUL\SOH\DC2\ETX\DC4\t\f\n\+ \\f\n\+ \\ENQ\EOT\STX\STX\NUL\ETX\DC2\ETX\DC4\SI\DLE\n\+ \\n\+ \\n\+ \\STX\EOT\ETX\DC2\EOT\ETB\NUL\EM\SOH\n\+ \\n\+ \\n\+ \\ETX\EOT\ETX\SOH\DC2\ETX\ETB\b\NAK\n\+ \\v\n\+ \\EOT\EOT\ETX\STX\NUL\DC2\ETX\CAN\STX\DC1\n\+ \\f\n\+ \\ENQ\EOT\ETX\STX\NUL\ENQ\DC2\ETX\CAN\STX\b\n\+ \\f\n\+ \\ENQ\EOT\ETX\STX\NUL\SOH\DC2\ETX\CAN\t\f\n\+ \\f\n\+ \\ENQ\EOT\ETX\STX\NUL\ETX\DC2\ETX\CAN\SI\DLE\n\+ \\n\+ \\n\+ \\STX\EOT\EOT\DC2\EOT\ESC\NUL\GS\SOH\n\+ \\n\+ \\n\+ \\ETX\EOT\EOT\SOH\DC2\ETX\ESC\b\SYN\n\+ \\v\n\+ \\EOT\EOT\EOT\STX\NUL\DC2\ETX\FS\STX\DC1\n\+ \\f\n\+ \\ENQ\EOT\EOT\STX\NUL\ENQ\DC2\ETX\FS\STX\b\n\+ \\f\n\+ \\ENQ\EOT\EOT\STX\NUL\SOH\DC2\ETX\FS\t\f\n\+ \\f\n\+ \\ENQ\EOT\EOT\STX\NUL\ETX\DC2\ETX\FS\SI\DLEb\ACKproto3"
@@ -0,0 +1,46 @@+{- This file was auto-generated from btc_lsp/data/low_level.proto by the proto-lens-protoc program. -}+{-# LANGUAGE ScopedTypeVariables, DataKinds, TypeFamilies, UndecidableInstances, GeneralizedNewtypeDeriving, MultiParamTypeClasses, FlexibleContexts, FlexibleInstances, PatternSynonyms, MagicHash, NoImplicitPrelude, BangPatterns, TypeApplications, OverloadedStrings, DerivingStrategies, DeriveGeneric#-}+{-# OPTIONS_GHC -Wno-unused-imports#-}+{-# OPTIONS_GHC -Wno-duplicate-exports#-}+{-# OPTIONS_GHC -Wno-dodgy-exports#-}+module Proto.BtcLsp.Data.LowLevel_Fields where+import qualified Data.ProtoLens.Runtime.Prelude as Prelude+import qualified Data.ProtoLens.Runtime.Data.Int as Data.Int+import qualified Data.ProtoLens.Runtime.Data.Monoid as Data.Monoid+import qualified Data.ProtoLens.Runtime.Data.Word as Data.Word+import qualified Data.ProtoLens.Runtime.Data.ProtoLens as Data.ProtoLens+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Bytes as Data.ProtoLens.Encoding.Bytes+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Growing as Data.ProtoLens.Encoding.Growing+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Parser.Unsafe as Data.ProtoLens.Encoding.Parser.Unsafe+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Wire as Data.ProtoLens.Encoding.Wire+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Field as Data.ProtoLens.Field+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Message.Enum as Data.ProtoLens.Message.Enum+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Service.Types as Data.ProtoLens.Service.Types+import qualified Data.ProtoLens.Runtime.Lens.Family2 as Lens.Family2+import qualified Data.ProtoLens.Runtime.Lens.Family2.Unchecked as Lens.Family2.Unchecked+import qualified Data.ProtoLens.Runtime.Data.Text as Data.Text+import qualified Data.ProtoLens.Runtime.Data.Map as Data.Map+import qualified Data.ProtoLens.Runtime.Data.ByteString as Data.ByteString+import qualified Data.ProtoLens.Runtime.Data.ByteString.Char8 as Data.ByteString.Char8+import qualified Data.ProtoLens.Runtime.Data.Text.Encoding as Data.Text.Encoding+import qualified Data.ProtoLens.Runtime.Data.Vector as Data.Vector+import qualified Data.ProtoLens.Runtime.Data.Vector.Generic as Data.Vector.Generic+import qualified Data.ProtoLens.Runtime.Data.Vector.Unboxed as Data.Vector.Unboxed+import qualified Data.ProtoLens.Runtime.Text.Read as Text.Read+denominator ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "denominator" a) =>+ Lens.Family2.LensLike' f s a+denominator = Data.ProtoLens.Field.field @"denominator"+numerator ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "numerator" a) =>+ Lens.Family2.LensLike' f s a+numerator = Data.ProtoLens.Field.field @"numerator"+val ::+ forall f s a.+ (Prelude.Functor f, Data.ProtoLens.Field.HasField s "val" a) =>+ Lens.Family2.LensLike' f s a+val = Data.ProtoLens.Field.field @"val"
@@ -0,0 +1,1475 @@+{- This file was auto-generated from btc_lsp/method/get_cfg.proto by the proto-lens-protoc program. -}+{-# LANGUAGE ScopedTypeVariables, DataKinds, TypeFamilies, UndecidableInstances, GeneralizedNewtypeDeriving, MultiParamTypeClasses, FlexibleContexts, FlexibleInstances, PatternSynonyms, MagicHash, NoImplicitPrelude, BangPatterns, TypeApplications, OverloadedStrings, DerivingStrategies, DeriveGeneric#-}+{-# OPTIONS_GHC -Wno-unused-imports#-}+{-# OPTIONS_GHC -Wno-duplicate-exports#-}+{-# OPTIONS_GHC -Wno-dodgy-exports#-}+module Proto.BtcLsp.Method.GetCfg (+ Request(), Response(), Response'Either(..), _Response'Success',+ _Response'Failure', Response'Failure(),+ Response'Failure'InputFailure(..), Response'Failure'InputFailure(),+ Response'Failure'InputFailure'UnrecognizedValue, Response'Success()+ ) where+import qualified Data.ProtoLens.Runtime.Control.DeepSeq as Control.DeepSeq+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Prism as Data.ProtoLens.Prism+import qualified Text.PrettyPrint.GenericPretty.Instance+import qualified GHC.Generics+import qualified Text.PrettyPrint.GenericPretty+import qualified Data.ProtoLens.Runtime.Prelude as Prelude+import qualified Data.ProtoLens.Runtime.Data.Int as Data.Int+import qualified Data.ProtoLens.Runtime.Data.Monoid as Data.Monoid+import qualified Data.ProtoLens.Runtime.Data.Word as Data.Word+import qualified Data.ProtoLens.Runtime.Data.ProtoLens as Data.ProtoLens+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Bytes as Data.ProtoLens.Encoding.Bytes+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Growing as Data.ProtoLens.Encoding.Growing+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Parser.Unsafe as Data.ProtoLens.Encoding.Parser.Unsafe+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Wire as Data.ProtoLens.Encoding.Wire+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Field as Data.ProtoLens.Field+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Message.Enum as Data.ProtoLens.Message.Enum+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Service.Types as Data.ProtoLens.Service.Types+import qualified Data.ProtoLens.Runtime.Lens.Family2 as Lens.Family2+import qualified Data.ProtoLens.Runtime.Lens.Family2.Unchecked as Lens.Family2.Unchecked+import qualified Data.ProtoLens.Runtime.Data.Text as Data.Text+import qualified Data.ProtoLens.Runtime.Data.Map as Data.Map+import qualified Data.ProtoLens.Runtime.Data.ByteString as Data.ByteString+import qualified Data.ProtoLens.Runtime.Data.ByteString.Char8 as Data.ByteString.Char8+import qualified Data.ProtoLens.Runtime.Data.Text.Encoding as Data.Text.Encoding+import qualified Data.ProtoLens.Runtime.Data.Vector as Data.Vector+import qualified Data.ProtoLens.Runtime.Data.Vector.Generic as Data.Vector.Generic+import qualified Data.ProtoLens.Runtime.Data.Vector.Unboxed as Data.Vector.Unboxed+import qualified Data.ProtoLens.Runtime.Text.Read as Text.Read+import qualified Proto.BtcLsp.Data.HighLevel+{- | Fields :+ + * 'Proto.BtcLsp.Method.GetCfg_Fields.ctx' @:: Lens' Request Proto.BtcLsp.Data.HighLevel.Ctx@+ * 'Proto.BtcLsp.Method.GetCfg_Fields.maybe'ctx' @:: Lens' Request (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.Ctx)@ -}+data Request+ = Request'_constructor {_Request'ctx :: !(Prelude.Maybe Proto.BtcLsp.Data.HighLevel.Ctx),+ _Request'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show Request where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out Request+instance Data.ProtoLens.Field.HasField Request "ctx" Proto.BtcLsp.Data.HighLevel.Ctx where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Request'ctx (\ x__ y__ -> x__ {_Request'ctx = y__}))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage)+instance Data.ProtoLens.Field.HasField Request "maybe'ctx" (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.Ctx) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Request'ctx (\ x__ y__ -> x__ {_Request'ctx = y__}))+ Prelude.id+instance Data.ProtoLens.Message Request where+ messageName _ = Data.Text.pack "BtcLsp.Method.GetCfg.Request"+ packedMessageDescriptor _+ = "\n\+ \\aRequest\DC2,\n\+ \\ETXctx\CAN\SOH \SOH(\v2\SUB.BtcLsp.Data.HighLevel.CtxR\ETXctx"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ ctx__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "ctx"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.HighLevel.Ctx)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'ctx")) ::+ Data.ProtoLens.FieldDescriptor Request+ in+ Data.Map.fromList [(Data.ProtoLens.Tag 1, ctx__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _Request'_unknownFields+ (\ x__ y__ -> x__ {_Request'_unknownFields = y__})+ defMessage+ = Request'_constructor+ {_Request'ctx = Prelude.Nothing, _Request'_unknownFields = []}+ parseMessage+ = let+ loop :: Request -> Data.ProtoLens.Encoding.Bytes.Parser Request+ loop x+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) x)+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 10+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "ctx"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"ctx") y x)+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do loop Data.ProtoLens.defMessage) "Request"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (case+ Lens.Family2.view (Data.ProtoLens.Field.field @"maybe'ctx") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just _v)+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 10)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x))+instance Control.DeepSeq.NFData Request where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_Request'_unknownFields x__)+ (Control.DeepSeq.deepseq (_Request'ctx x__) ())+{- | Fields :+ + * 'Proto.BtcLsp.Method.GetCfg_Fields.ctx' @:: Lens' Response Proto.BtcLsp.Data.HighLevel.Ctx@+ * 'Proto.BtcLsp.Method.GetCfg_Fields.maybe'ctx' @:: Lens' Response (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.Ctx)@+ * 'Proto.BtcLsp.Method.GetCfg_Fields.maybe'either' @:: Lens' Response (Prelude.Maybe Response'Either)@+ * 'Proto.BtcLsp.Method.GetCfg_Fields.maybe'success' @:: Lens' Response (Prelude.Maybe Response'Success)@+ * 'Proto.BtcLsp.Method.GetCfg_Fields.success' @:: Lens' Response Response'Success@+ * 'Proto.BtcLsp.Method.GetCfg_Fields.maybe'failure' @:: Lens' Response (Prelude.Maybe Response'Failure)@+ * 'Proto.BtcLsp.Method.GetCfg_Fields.failure' @:: Lens' Response Response'Failure@ -}+data Response+ = Response'_constructor {_Response'ctx :: !(Prelude.Maybe Proto.BtcLsp.Data.HighLevel.Ctx),+ _Response'either :: !(Prelude.Maybe Response'Either),+ _Response'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show Response where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out Response+data Response'Either+ = Response'Success' !Response'Success |+ Response'Failure' !Response'Failure+ deriving stock (Prelude.Show,+ Prelude.Eq,+ Prelude.Ord,+ GHC.Generics.Generic)+instance Text.PrettyPrint.GenericPretty.Out Response'Either+instance Data.ProtoLens.Field.HasField Response "ctx" Proto.BtcLsp.Data.HighLevel.Ctx where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'ctx (\ x__ y__ -> x__ {_Response'ctx = y__}))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage)+instance Data.ProtoLens.Field.HasField Response "maybe'ctx" (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.Ctx) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'ctx (\ x__ y__ -> x__ {_Response'ctx = y__}))+ Prelude.id+instance Data.ProtoLens.Field.HasField Response "maybe'either" (Prelude.Maybe Response'Either) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'either (\ x__ y__ -> x__ {_Response'either = y__}))+ Prelude.id+instance Data.ProtoLens.Field.HasField Response "maybe'success" (Prelude.Maybe Response'Success) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'either (\ x__ y__ -> x__ {_Response'either = y__}))+ (Lens.Family2.Unchecked.lens+ (\ x__+ -> case x__ of+ (Prelude.Just (Response'Success' x__val)) -> Prelude.Just x__val+ _otherwise -> Prelude.Nothing)+ (\ _ y__ -> Prelude.fmap Response'Success' y__))+instance Data.ProtoLens.Field.HasField Response "success" Response'Success where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'either (\ x__ y__ -> x__ {_Response'either = y__}))+ ((Prelude..)+ (Lens.Family2.Unchecked.lens+ (\ x__+ -> case x__ of+ (Prelude.Just (Response'Success' x__val)) -> Prelude.Just x__val+ _otherwise -> Prelude.Nothing)+ (\ _ y__ -> Prelude.fmap Response'Success' y__))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage))+instance Data.ProtoLens.Field.HasField Response "maybe'failure" (Prelude.Maybe Response'Failure) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'either (\ x__ y__ -> x__ {_Response'either = y__}))+ (Lens.Family2.Unchecked.lens+ (\ x__+ -> case x__ of+ (Prelude.Just (Response'Failure' x__val)) -> Prelude.Just x__val+ _otherwise -> Prelude.Nothing)+ (\ _ y__ -> Prelude.fmap Response'Failure' y__))+instance Data.ProtoLens.Field.HasField Response "failure" Response'Failure where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'either (\ x__ y__ -> x__ {_Response'either = y__}))+ ((Prelude..)+ (Lens.Family2.Unchecked.lens+ (\ x__+ -> case x__ of+ (Prelude.Just (Response'Failure' x__val)) -> Prelude.Just x__val+ _otherwise -> Prelude.Nothing)+ (\ _ y__ -> Prelude.fmap Response'Failure' y__))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage))+instance Data.ProtoLens.Message Response where+ messageName _ = Data.Text.pack "BtcLsp.Method.GetCfg.Response"+ packedMessageDescriptor _+ = "\n\+ \\bResponse\DC2,\n\+ \\ETXctx\CAN\SOH \SOH(\v2\SUB.BtcLsp.Data.HighLevel.CtxR\ETXctx\DC2B\n\+ \\asuccess\CAN\STX \SOH(\v2&.BtcLsp.Method.GetCfg.Response.SuccessH\NULR\asuccess\DC2B\n\+ \\afailure\CAN\ETX \SOH(\v2&.BtcLsp.Method.GetCfg.Response.FailureH\NULR\afailure\SUB\175\EOT\n\+ \\aSuccess\DC2?\n\+ \\flsp_ln_nodes\CAN\SOH \ETX(\v2\GS.BtcLsp.Data.HighLevel.LnPeerR\n\+ \lspLnNodes\DC2S\n\+ \\DC4swap_into_ln_min_amt\CAN\STX \SOH(\v2#.BtcLsp.Data.HighLevel.LocalBalanceR\DLEswapIntoLnMinAmt\DC2S\n\+ \\DC4swap_into_ln_max_amt\CAN\ETX \SOH(\v2#.BtcLsp.Data.HighLevel.LocalBalanceR\DLEswapIntoLnMaxAmt\DC2S\n\+ \\DC4swap_from_ln_min_amt\CAN\EOT \SOH(\v2#.BtcLsp.Data.HighLevel.LocalBalanceR\DLEswapFromLnMinAmt\DC2S\n\+ \\DC4swap_from_ln_max_amt\CAN\ENQ \SOH(\v2#.BtcLsp.Data.HighLevel.LocalBalanceR\DLEswapFromLnMaxAmt\DC2G\n\+ \\DLEswap_ln_fee_rate\CAN\ACK \SOH(\v2\RS.BtcLsp.Data.HighLevel.FeeRateR\rswapLnFeeRate\DC2F\n\+ \\SIswap_ln_min_fee\CAN\a \SOH(\v2\US.BtcLsp.Data.HighLevel.FeeMoneyR\fswapLnMinFee\SUB\250\SOH\n\+ \\aFailure\DC2=\n\+ \\ageneric\CAN\SOH \ETX(\v2#.BtcLsp.Data.HighLevel.InputFailureR\ageneric\DC2O\n\+ \\bspecific\CAN\STX \ETX(\SO23.BtcLsp.Method.GetCfg.Response.Failure.InputFailureR\bspecific\DC2B\n\+ \\binternal\CAN\ETX \ETX(\v2&.BtcLsp.Data.HighLevel.InternalFailureR\binternal\"\ESC\n\+ \\fInputFailure\DC2\v\n\+ \\aDEFAULT\DLE\NULB\b\n\+ \\ACKeither"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ ctx__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "ctx"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.HighLevel.Ctx)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'ctx")) ::+ Data.ProtoLens.FieldDescriptor Response+ success__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "success"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Response'Success)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'success")) ::+ Data.ProtoLens.FieldDescriptor Response+ failure__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "failure"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Response'Failure)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'failure")) ::+ Data.ProtoLens.FieldDescriptor Response+ in+ Data.Map.fromList+ [(Data.ProtoLens.Tag 1, ctx__field_descriptor),+ (Data.ProtoLens.Tag 2, success__field_descriptor),+ (Data.ProtoLens.Tag 3, failure__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _Response'_unknownFields+ (\ x__ y__ -> x__ {_Response'_unknownFields = y__})+ defMessage+ = Response'_constructor+ {_Response'ctx = Prelude.Nothing,+ _Response'either = Prelude.Nothing, _Response'_unknownFields = []}+ parseMessage+ = let+ loop :: Response -> Data.ProtoLens.Encoding.Bytes.Parser Response+ loop x+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) x)+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 10+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "ctx"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"ctx") y x)+ 18+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "success"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"success") y x)+ 26+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "failure"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"failure") y x)+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do loop Data.ProtoLens.defMessage) "Response"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (case+ Lens.Family2.view (Data.ProtoLens.Field.field @"maybe'ctx") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just _v)+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 10)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ ((Data.Monoid.<>)+ (case+ Lens.Family2.view (Data.ProtoLens.Field.field @"maybe'either") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just (Response'Success' v))+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 18)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage v)+ (Prelude.Just (Response'Failure' v))+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 26)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage v))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x)))+instance Control.DeepSeq.NFData Response where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_Response'_unknownFields x__)+ (Control.DeepSeq.deepseq+ (_Response'ctx x__)+ (Control.DeepSeq.deepseq (_Response'either x__) ()))+instance Control.DeepSeq.NFData Response'Either where+ rnf (Response'Success' x__) = Control.DeepSeq.rnf x__+ rnf (Response'Failure' x__) = Control.DeepSeq.rnf x__+_Response'Success' ::+ Data.ProtoLens.Prism.Prism' Response'Either Response'Success+_Response'Success'+ = Data.ProtoLens.Prism.prism'+ Response'Success'+ (\ p__+ -> case p__ of+ (Response'Success' p__val) -> Prelude.Just p__val+ _otherwise -> Prelude.Nothing)+_Response'Failure' ::+ Data.ProtoLens.Prism.Prism' Response'Either Response'Failure+_Response'Failure'+ = Data.ProtoLens.Prism.prism'+ Response'Failure'+ (\ p__+ -> case p__ of+ (Response'Failure' p__val) -> Prelude.Just p__val+ _otherwise -> Prelude.Nothing)+{- | Fields :+ + * 'Proto.BtcLsp.Method.GetCfg_Fields.generic' @:: Lens' Response'Failure [Proto.BtcLsp.Data.HighLevel.InputFailure]@+ * 'Proto.BtcLsp.Method.GetCfg_Fields.vec'generic' @:: Lens' Response'Failure (Data.Vector.Vector Proto.BtcLsp.Data.HighLevel.InputFailure)@+ * 'Proto.BtcLsp.Method.GetCfg_Fields.specific' @:: Lens' Response'Failure [Response'Failure'InputFailure]@+ * 'Proto.BtcLsp.Method.GetCfg_Fields.vec'specific' @:: Lens' Response'Failure (Data.Vector.Vector Response'Failure'InputFailure)@+ * 'Proto.BtcLsp.Method.GetCfg_Fields.internal' @:: Lens' Response'Failure [Proto.BtcLsp.Data.HighLevel.InternalFailure]@+ * 'Proto.BtcLsp.Method.GetCfg_Fields.vec'internal' @:: Lens' Response'Failure (Data.Vector.Vector Proto.BtcLsp.Data.HighLevel.InternalFailure)@ -}+data Response'Failure+ = Response'Failure'_constructor {_Response'Failure'generic :: !(Data.Vector.Vector Proto.BtcLsp.Data.HighLevel.InputFailure),+ _Response'Failure'specific :: !(Data.Vector.Vector Response'Failure'InputFailure),+ _Response'Failure'internal :: !(Data.Vector.Vector Proto.BtcLsp.Data.HighLevel.InternalFailure),+ _Response'Failure'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show Response'Failure where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out Response'Failure+instance Data.ProtoLens.Field.HasField Response'Failure "generic" [Proto.BtcLsp.Data.HighLevel.InputFailure] where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Failure'generic+ (\ x__ y__ -> x__ {_Response'Failure'generic = y__}))+ (Lens.Family2.Unchecked.lens+ Data.Vector.Generic.toList+ (\ _ y__ -> Data.Vector.Generic.fromList y__))+instance Data.ProtoLens.Field.HasField Response'Failure "vec'generic" (Data.Vector.Vector Proto.BtcLsp.Data.HighLevel.InputFailure) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Failure'generic+ (\ x__ y__ -> x__ {_Response'Failure'generic = y__}))+ Prelude.id+instance Data.ProtoLens.Field.HasField Response'Failure "specific" [Response'Failure'InputFailure] where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Failure'specific+ (\ x__ y__ -> x__ {_Response'Failure'specific = y__}))+ (Lens.Family2.Unchecked.lens+ Data.Vector.Generic.toList+ (\ _ y__ -> Data.Vector.Generic.fromList y__))+instance Data.ProtoLens.Field.HasField Response'Failure "vec'specific" (Data.Vector.Vector Response'Failure'InputFailure) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Failure'specific+ (\ x__ y__ -> x__ {_Response'Failure'specific = y__}))+ Prelude.id+instance Data.ProtoLens.Field.HasField Response'Failure "internal" [Proto.BtcLsp.Data.HighLevel.InternalFailure] where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Failure'internal+ (\ x__ y__ -> x__ {_Response'Failure'internal = y__}))+ (Lens.Family2.Unchecked.lens+ Data.Vector.Generic.toList+ (\ _ y__ -> Data.Vector.Generic.fromList y__))+instance Data.ProtoLens.Field.HasField Response'Failure "vec'internal" (Data.Vector.Vector Proto.BtcLsp.Data.HighLevel.InternalFailure) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Failure'internal+ (\ x__ y__ -> x__ {_Response'Failure'internal = y__}))+ Prelude.id+instance Data.ProtoLens.Message Response'Failure where+ messageName _+ = Data.Text.pack "BtcLsp.Method.GetCfg.Response.Failure"+ packedMessageDescriptor _+ = "\n\+ \\aFailure\DC2=\n\+ \\ageneric\CAN\SOH \ETX(\v2#.BtcLsp.Data.HighLevel.InputFailureR\ageneric\DC2O\n\+ \\bspecific\CAN\STX \ETX(\SO23.BtcLsp.Method.GetCfg.Response.Failure.InputFailureR\bspecific\DC2B\n\+ \\binternal\CAN\ETX \ETX(\v2&.BtcLsp.Data.HighLevel.InternalFailureR\binternal\"\ESC\n\+ \\fInputFailure\DC2\v\n\+ \\aDEFAULT\DLE\NUL"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ generic__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "generic"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.HighLevel.InputFailure)+ (Data.ProtoLens.RepeatedField+ Data.ProtoLens.Unpacked (Data.ProtoLens.Field.field @"generic")) ::+ Data.ProtoLens.FieldDescriptor Response'Failure+ specific__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "specific"+ (Data.ProtoLens.ScalarField Data.ProtoLens.EnumField ::+ Data.ProtoLens.FieldTypeDescriptor Response'Failure'InputFailure)+ (Data.ProtoLens.RepeatedField+ Data.ProtoLens.Packed (Data.ProtoLens.Field.field @"specific")) ::+ Data.ProtoLens.FieldDescriptor Response'Failure+ internal__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "internal"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.HighLevel.InternalFailure)+ (Data.ProtoLens.RepeatedField+ Data.ProtoLens.Unpacked+ (Data.ProtoLens.Field.field @"internal")) ::+ Data.ProtoLens.FieldDescriptor Response'Failure+ in+ Data.Map.fromList+ [(Data.ProtoLens.Tag 1, generic__field_descriptor),+ (Data.ProtoLens.Tag 2, specific__field_descriptor),+ (Data.ProtoLens.Tag 3, internal__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _Response'Failure'_unknownFields+ (\ x__ y__ -> x__ {_Response'Failure'_unknownFields = y__})+ defMessage+ = Response'Failure'_constructor+ {_Response'Failure'generic = Data.Vector.Generic.empty,+ _Response'Failure'specific = Data.Vector.Generic.empty,+ _Response'Failure'internal = Data.Vector.Generic.empty,+ _Response'Failure'_unknownFields = []}+ parseMessage+ = let+ loop ::+ Response'Failure+ -> Data.ProtoLens.Encoding.Growing.Growing Data.Vector.Vector Data.ProtoLens.Encoding.Growing.RealWorld Proto.BtcLsp.Data.HighLevel.InputFailure+ -> Data.ProtoLens.Encoding.Growing.Growing Data.Vector.Vector Data.ProtoLens.Encoding.Growing.RealWorld Proto.BtcLsp.Data.HighLevel.InternalFailure+ -> Data.ProtoLens.Encoding.Growing.Growing Data.Vector.Vector Data.ProtoLens.Encoding.Growing.RealWorld Response'Failure'InputFailure+ -> Data.ProtoLens.Encoding.Bytes.Parser Response'Failure+ loop x mutable'generic mutable'internal mutable'specific+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do frozen'generic <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ (Data.ProtoLens.Encoding.Growing.unsafeFreeze+ mutable'generic)+ frozen'internal <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ (Data.ProtoLens.Encoding.Growing.unsafeFreeze+ mutable'internal)+ frozen'specific <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ (Data.ProtoLens.Encoding.Growing.unsafeFreeze+ mutable'specific)+ (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t)+ (Lens.Family2.set+ (Data.ProtoLens.Field.field @"vec'generic") frozen'generic+ (Lens.Family2.set+ (Data.ProtoLens.Field.field @"vec'internal") frozen'internal+ (Lens.Family2.set+ (Data.ProtoLens.Field.field @"vec'specific") frozen'specific+ x))))+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 10+ -> do !y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len)+ Data.ProtoLens.parseMessage)+ "generic"+ v <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ (Data.ProtoLens.Encoding.Growing.append mutable'generic y)+ loop x v mutable'internal mutable'specific+ 16+ -> do !y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (Prelude.fmap+ Prelude.toEnum+ (Prelude.fmap+ Prelude.fromIntegral+ Data.ProtoLens.Encoding.Bytes.getVarInt))+ "specific"+ v <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ (Data.ProtoLens.Encoding.Growing.append mutable'specific y)+ loop x mutable'generic mutable'internal v+ 18+ -> do y <- do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len)+ ((let+ ploop qs+ = do packedEnd <- Data.ProtoLens.Encoding.Bytes.atEnd+ if packedEnd then+ Prelude.return qs+ else+ do !q <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (Prelude.fmap+ Prelude.toEnum+ (Prelude.fmap+ Prelude.fromIntegral+ Data.ProtoLens.Encoding.Bytes.getVarInt))+ "specific"+ qs' <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ (Data.ProtoLens.Encoding.Growing.append+ qs q)+ ploop qs'+ in ploop)+ mutable'specific)+ loop x mutable'generic mutable'internal y+ 26+ -> do !y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len)+ Data.ProtoLens.parseMessage)+ "internal"+ v <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ (Data.ProtoLens.Encoding.Growing.append mutable'internal y)+ loop x mutable'generic v mutable'specific+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ mutable'generic mutable'internal mutable'specific+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do mutable'generic <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ Data.ProtoLens.Encoding.Growing.new+ mutable'internal <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ Data.ProtoLens.Encoding.Growing.new+ mutable'specific <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ Data.ProtoLens.Encoding.Growing.new+ loop+ Data.ProtoLens.defMessage mutable'generic mutable'internal+ mutable'specific)+ "Failure"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.foldMapBuilder+ (\ _v+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 10)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ (Lens.Family2.view (Data.ProtoLens.Field.field @"vec'generic") _x))+ ((Data.Monoid.<>)+ (let+ p = Lens.Family2.view+ (Data.ProtoLens.Field.field @"vec'specific") _x+ in+ if Data.Vector.Generic.null p then+ Data.Monoid.mempty+ else+ (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 18)+ ((\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ (Data.ProtoLens.Encoding.Bytes.runBuilder+ (Data.ProtoLens.Encoding.Bytes.foldMapBuilder+ ((Prelude..)+ ((Prelude..)+ Data.ProtoLens.Encoding.Bytes.putVarInt+ Prelude.fromIntegral)+ Prelude.fromEnum)+ p))))+ ((Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.foldMapBuilder+ (\ _v+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 26)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ (Lens.Family2.view+ (Data.ProtoLens.Field.field @"vec'internal") _x))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x))))+instance Control.DeepSeq.NFData Response'Failure where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_Response'Failure'_unknownFields x__)+ (Control.DeepSeq.deepseq+ (_Response'Failure'generic x__)+ (Control.DeepSeq.deepseq+ (_Response'Failure'specific x__)+ (Control.DeepSeq.deepseq (_Response'Failure'internal x__) ())))+newtype Response'Failure'InputFailure'UnrecognizedValue+ = Response'Failure'InputFailure'UnrecognizedValue Data.Int.Int32+ deriving stock (Prelude.Eq,+ Prelude.Ord,+ Prelude.Show,+ GHC.Generics.Generic)+instance Text.PrettyPrint.GenericPretty.Out Response'Failure'InputFailure'UnrecognizedValue+data Response'Failure'InputFailure+ = Response'Failure'DEFAULT |+ Response'Failure'InputFailure'Unrecognized !Response'Failure'InputFailure'UnrecognizedValue+ deriving stock (Prelude.Show,+ Prelude.Eq,+ Prelude.Ord,+ GHC.Generics.Generic)+instance Data.ProtoLens.MessageEnum Response'Failure'InputFailure where+ maybeToEnum 0 = Prelude.Just Response'Failure'DEFAULT+ maybeToEnum k+ = Prelude.Just+ (Response'Failure'InputFailure'Unrecognized+ (Response'Failure'InputFailure'UnrecognizedValue+ (Prelude.fromIntegral k)))+ showEnum Response'Failure'DEFAULT = "DEFAULT"+ showEnum+ (Response'Failure'InputFailure'Unrecognized (Response'Failure'InputFailure'UnrecognizedValue k))+ = Prelude.show k+ readEnum k+ | (Prelude.==) k "DEFAULT" = Prelude.Just Response'Failure'DEFAULT+ | Prelude.otherwise+ = (Prelude.>>=) (Text.Read.readMaybe k) Data.ProtoLens.maybeToEnum+instance Prelude.Bounded Response'Failure'InputFailure where+ minBound = Response'Failure'DEFAULT+ maxBound = Response'Failure'DEFAULT+instance Prelude.Enum Response'Failure'InputFailure where+ toEnum k__+ = Prelude.maybe+ (Prelude.error+ ((Prelude.++)+ "toEnum: unknown value for enum InputFailure: "+ (Prelude.show k__)))+ Prelude.id (Data.ProtoLens.maybeToEnum k__)+ fromEnum Response'Failure'DEFAULT = 0+ fromEnum+ (Response'Failure'InputFailure'Unrecognized (Response'Failure'InputFailure'UnrecognizedValue k))+ = Prelude.fromIntegral k+ succ Response'Failure'DEFAULT+ = Prelude.error+ "Response'Failure'InputFailure.succ: bad argument Response'Failure'DEFAULT. This value would be out of bounds."+ succ (Response'Failure'InputFailure'Unrecognized _)+ = Prelude.error+ "Response'Failure'InputFailure.succ: bad argument: unrecognized value"+ pred Response'Failure'DEFAULT+ = Prelude.error+ "Response'Failure'InputFailure.pred: bad argument Response'Failure'DEFAULT. This value would be out of bounds."+ pred (Response'Failure'InputFailure'Unrecognized _)+ = Prelude.error+ "Response'Failure'InputFailure.pred: bad argument: unrecognized value"+ enumFrom = Data.ProtoLens.Message.Enum.messageEnumFrom+ enumFromTo = Data.ProtoLens.Message.Enum.messageEnumFromTo+ enumFromThen = Data.ProtoLens.Message.Enum.messageEnumFromThen+ enumFromThenTo = Data.ProtoLens.Message.Enum.messageEnumFromThenTo+instance Data.ProtoLens.FieldDefault Response'Failure'InputFailure where+ fieldDefault = Response'Failure'DEFAULT+instance Control.DeepSeq.NFData Response'Failure'InputFailure where+ rnf x__ = Prelude.seq x__ ()+instance Text.PrettyPrint.GenericPretty.Out Response'Failure'InputFailure+{- | Fields :+ + * 'Proto.BtcLsp.Method.GetCfg_Fields.lspLnNodes' @:: Lens' Response'Success [Proto.BtcLsp.Data.HighLevel.LnPeer]@+ * 'Proto.BtcLsp.Method.GetCfg_Fields.vec'lspLnNodes' @:: Lens' Response'Success (Data.Vector.Vector Proto.BtcLsp.Data.HighLevel.LnPeer)@+ * 'Proto.BtcLsp.Method.GetCfg_Fields.swapIntoLnMinAmt' @:: Lens' Response'Success Proto.BtcLsp.Data.HighLevel.LocalBalance@+ * 'Proto.BtcLsp.Method.GetCfg_Fields.maybe'swapIntoLnMinAmt' @:: Lens' Response'Success (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.LocalBalance)@+ * 'Proto.BtcLsp.Method.GetCfg_Fields.swapIntoLnMaxAmt' @:: Lens' Response'Success Proto.BtcLsp.Data.HighLevel.LocalBalance@+ * 'Proto.BtcLsp.Method.GetCfg_Fields.maybe'swapIntoLnMaxAmt' @:: Lens' Response'Success (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.LocalBalance)@+ * 'Proto.BtcLsp.Method.GetCfg_Fields.swapFromLnMinAmt' @:: Lens' Response'Success Proto.BtcLsp.Data.HighLevel.LocalBalance@+ * 'Proto.BtcLsp.Method.GetCfg_Fields.maybe'swapFromLnMinAmt' @:: Lens' Response'Success (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.LocalBalance)@+ * 'Proto.BtcLsp.Method.GetCfg_Fields.swapFromLnMaxAmt' @:: Lens' Response'Success Proto.BtcLsp.Data.HighLevel.LocalBalance@+ * 'Proto.BtcLsp.Method.GetCfg_Fields.maybe'swapFromLnMaxAmt' @:: Lens' Response'Success (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.LocalBalance)@+ * 'Proto.BtcLsp.Method.GetCfg_Fields.swapLnFeeRate' @:: Lens' Response'Success Proto.BtcLsp.Data.HighLevel.FeeRate@+ * 'Proto.BtcLsp.Method.GetCfg_Fields.maybe'swapLnFeeRate' @:: Lens' Response'Success (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.FeeRate)@+ * 'Proto.BtcLsp.Method.GetCfg_Fields.swapLnMinFee' @:: Lens' Response'Success Proto.BtcLsp.Data.HighLevel.FeeMoney@+ * 'Proto.BtcLsp.Method.GetCfg_Fields.maybe'swapLnMinFee' @:: Lens' Response'Success (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.FeeMoney)@ -}+data Response'Success+ = Response'Success'_constructor {_Response'Success'lspLnNodes :: !(Data.Vector.Vector Proto.BtcLsp.Data.HighLevel.LnPeer),+ _Response'Success'swapIntoLnMinAmt :: !(Prelude.Maybe Proto.BtcLsp.Data.HighLevel.LocalBalance),+ _Response'Success'swapIntoLnMaxAmt :: !(Prelude.Maybe Proto.BtcLsp.Data.HighLevel.LocalBalance),+ _Response'Success'swapFromLnMinAmt :: !(Prelude.Maybe Proto.BtcLsp.Data.HighLevel.LocalBalance),+ _Response'Success'swapFromLnMaxAmt :: !(Prelude.Maybe Proto.BtcLsp.Data.HighLevel.LocalBalance),+ _Response'Success'swapLnFeeRate :: !(Prelude.Maybe Proto.BtcLsp.Data.HighLevel.FeeRate),+ _Response'Success'swapLnMinFee :: !(Prelude.Maybe Proto.BtcLsp.Data.HighLevel.FeeMoney),+ _Response'Success'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show Response'Success where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out Response'Success+instance Data.ProtoLens.Field.HasField Response'Success "lspLnNodes" [Proto.BtcLsp.Data.HighLevel.LnPeer] where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Success'lspLnNodes+ (\ x__ y__ -> x__ {_Response'Success'lspLnNodes = y__}))+ (Lens.Family2.Unchecked.lens+ Data.Vector.Generic.toList+ (\ _ y__ -> Data.Vector.Generic.fromList y__))+instance Data.ProtoLens.Field.HasField Response'Success "vec'lspLnNodes" (Data.Vector.Vector Proto.BtcLsp.Data.HighLevel.LnPeer) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Success'lspLnNodes+ (\ x__ y__ -> x__ {_Response'Success'lspLnNodes = y__}))+ Prelude.id+instance Data.ProtoLens.Field.HasField Response'Success "swapIntoLnMinAmt" Proto.BtcLsp.Data.HighLevel.LocalBalance where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Success'swapIntoLnMinAmt+ (\ x__ y__ -> x__ {_Response'Success'swapIntoLnMinAmt = y__}))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage)+instance Data.ProtoLens.Field.HasField Response'Success "maybe'swapIntoLnMinAmt" (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.LocalBalance) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Success'swapIntoLnMinAmt+ (\ x__ y__ -> x__ {_Response'Success'swapIntoLnMinAmt = y__}))+ Prelude.id+instance Data.ProtoLens.Field.HasField Response'Success "swapIntoLnMaxAmt" Proto.BtcLsp.Data.HighLevel.LocalBalance where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Success'swapIntoLnMaxAmt+ (\ x__ y__ -> x__ {_Response'Success'swapIntoLnMaxAmt = y__}))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage)+instance Data.ProtoLens.Field.HasField Response'Success "maybe'swapIntoLnMaxAmt" (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.LocalBalance) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Success'swapIntoLnMaxAmt+ (\ x__ y__ -> x__ {_Response'Success'swapIntoLnMaxAmt = y__}))+ Prelude.id+instance Data.ProtoLens.Field.HasField Response'Success "swapFromLnMinAmt" Proto.BtcLsp.Data.HighLevel.LocalBalance where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Success'swapFromLnMinAmt+ (\ x__ y__ -> x__ {_Response'Success'swapFromLnMinAmt = y__}))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage)+instance Data.ProtoLens.Field.HasField Response'Success "maybe'swapFromLnMinAmt" (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.LocalBalance) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Success'swapFromLnMinAmt+ (\ x__ y__ -> x__ {_Response'Success'swapFromLnMinAmt = y__}))+ Prelude.id+instance Data.ProtoLens.Field.HasField Response'Success "swapFromLnMaxAmt" Proto.BtcLsp.Data.HighLevel.LocalBalance where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Success'swapFromLnMaxAmt+ (\ x__ y__ -> x__ {_Response'Success'swapFromLnMaxAmt = y__}))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage)+instance Data.ProtoLens.Field.HasField Response'Success "maybe'swapFromLnMaxAmt" (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.LocalBalance) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Success'swapFromLnMaxAmt+ (\ x__ y__ -> x__ {_Response'Success'swapFromLnMaxAmt = y__}))+ Prelude.id+instance Data.ProtoLens.Field.HasField Response'Success "swapLnFeeRate" Proto.BtcLsp.Data.HighLevel.FeeRate where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Success'swapLnFeeRate+ (\ x__ y__ -> x__ {_Response'Success'swapLnFeeRate = y__}))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage)+instance Data.ProtoLens.Field.HasField Response'Success "maybe'swapLnFeeRate" (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.FeeRate) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Success'swapLnFeeRate+ (\ x__ y__ -> x__ {_Response'Success'swapLnFeeRate = y__}))+ Prelude.id+instance Data.ProtoLens.Field.HasField Response'Success "swapLnMinFee" Proto.BtcLsp.Data.HighLevel.FeeMoney where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Success'swapLnMinFee+ (\ x__ y__ -> x__ {_Response'Success'swapLnMinFee = y__}))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage)+instance Data.ProtoLens.Field.HasField Response'Success "maybe'swapLnMinFee" (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.FeeMoney) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Success'swapLnMinFee+ (\ x__ y__ -> x__ {_Response'Success'swapLnMinFee = y__}))+ Prelude.id+instance Data.ProtoLens.Message Response'Success where+ messageName _+ = Data.Text.pack "BtcLsp.Method.GetCfg.Response.Success"+ packedMessageDescriptor _+ = "\n\+ \\aSuccess\DC2?\n\+ \\flsp_ln_nodes\CAN\SOH \ETX(\v2\GS.BtcLsp.Data.HighLevel.LnPeerR\n\+ \lspLnNodes\DC2S\n\+ \\DC4swap_into_ln_min_amt\CAN\STX \SOH(\v2#.BtcLsp.Data.HighLevel.LocalBalanceR\DLEswapIntoLnMinAmt\DC2S\n\+ \\DC4swap_into_ln_max_amt\CAN\ETX \SOH(\v2#.BtcLsp.Data.HighLevel.LocalBalanceR\DLEswapIntoLnMaxAmt\DC2S\n\+ \\DC4swap_from_ln_min_amt\CAN\EOT \SOH(\v2#.BtcLsp.Data.HighLevel.LocalBalanceR\DLEswapFromLnMinAmt\DC2S\n\+ \\DC4swap_from_ln_max_amt\CAN\ENQ \SOH(\v2#.BtcLsp.Data.HighLevel.LocalBalanceR\DLEswapFromLnMaxAmt\DC2G\n\+ \\DLEswap_ln_fee_rate\CAN\ACK \SOH(\v2\RS.BtcLsp.Data.HighLevel.FeeRateR\rswapLnFeeRate\DC2F\n\+ \\SIswap_ln_min_fee\CAN\a \SOH(\v2\US.BtcLsp.Data.HighLevel.FeeMoneyR\fswapLnMinFee"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ lspLnNodes__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "lsp_ln_nodes"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.HighLevel.LnPeer)+ (Data.ProtoLens.RepeatedField+ Data.ProtoLens.Unpacked+ (Data.ProtoLens.Field.field @"lspLnNodes")) ::+ Data.ProtoLens.FieldDescriptor Response'Success+ swapIntoLnMinAmt__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "swap_into_ln_min_amt"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.HighLevel.LocalBalance)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'swapIntoLnMinAmt")) ::+ Data.ProtoLens.FieldDescriptor Response'Success+ swapIntoLnMaxAmt__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "swap_into_ln_max_amt"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.HighLevel.LocalBalance)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'swapIntoLnMaxAmt")) ::+ Data.ProtoLens.FieldDescriptor Response'Success+ swapFromLnMinAmt__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "swap_from_ln_min_amt"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.HighLevel.LocalBalance)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'swapFromLnMinAmt")) ::+ Data.ProtoLens.FieldDescriptor Response'Success+ swapFromLnMaxAmt__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "swap_from_ln_max_amt"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.HighLevel.LocalBalance)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'swapFromLnMaxAmt")) ::+ Data.ProtoLens.FieldDescriptor Response'Success+ swapLnFeeRate__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "swap_ln_fee_rate"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.HighLevel.FeeRate)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'swapLnFeeRate")) ::+ Data.ProtoLens.FieldDescriptor Response'Success+ swapLnMinFee__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "swap_ln_min_fee"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.HighLevel.FeeMoney)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'swapLnMinFee")) ::+ Data.ProtoLens.FieldDescriptor Response'Success+ in+ Data.Map.fromList+ [(Data.ProtoLens.Tag 1, lspLnNodes__field_descriptor),+ (Data.ProtoLens.Tag 2, swapIntoLnMinAmt__field_descriptor),+ (Data.ProtoLens.Tag 3, swapIntoLnMaxAmt__field_descriptor),+ (Data.ProtoLens.Tag 4, swapFromLnMinAmt__field_descriptor),+ (Data.ProtoLens.Tag 5, swapFromLnMaxAmt__field_descriptor),+ (Data.ProtoLens.Tag 6, swapLnFeeRate__field_descriptor),+ (Data.ProtoLens.Tag 7, swapLnMinFee__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _Response'Success'_unknownFields+ (\ x__ y__ -> x__ {_Response'Success'_unknownFields = y__})+ defMessage+ = Response'Success'_constructor+ {_Response'Success'lspLnNodes = Data.Vector.Generic.empty,+ _Response'Success'swapIntoLnMinAmt = Prelude.Nothing,+ _Response'Success'swapIntoLnMaxAmt = Prelude.Nothing,+ _Response'Success'swapFromLnMinAmt = Prelude.Nothing,+ _Response'Success'swapFromLnMaxAmt = Prelude.Nothing,+ _Response'Success'swapLnFeeRate = Prelude.Nothing,+ _Response'Success'swapLnMinFee = Prelude.Nothing,+ _Response'Success'_unknownFields = []}+ parseMessage+ = let+ loop ::+ Response'Success+ -> Data.ProtoLens.Encoding.Growing.Growing Data.Vector.Vector Data.ProtoLens.Encoding.Growing.RealWorld Proto.BtcLsp.Data.HighLevel.LnPeer+ -> Data.ProtoLens.Encoding.Bytes.Parser Response'Success+ loop x mutable'lspLnNodes+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do frozen'lspLnNodes <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ (Data.ProtoLens.Encoding.Growing.unsafeFreeze+ mutable'lspLnNodes)+ (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t)+ (Lens.Family2.set+ (Data.ProtoLens.Field.field @"vec'lspLnNodes") frozen'lspLnNodes+ x))+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 10+ -> do !y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len)+ Data.ProtoLens.parseMessage)+ "lsp_ln_nodes"+ v <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ (Data.ProtoLens.Encoding.Growing.append mutable'lspLnNodes y)+ loop x v+ 18+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "swap_into_ln_min_amt"+ loop+ (Lens.Family2.set+ (Data.ProtoLens.Field.field @"swapIntoLnMinAmt") y x)+ mutable'lspLnNodes+ 26+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "swap_into_ln_max_amt"+ loop+ (Lens.Family2.set+ (Data.ProtoLens.Field.field @"swapIntoLnMaxAmt") y x)+ mutable'lspLnNodes+ 34+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "swap_from_ln_min_amt"+ loop+ (Lens.Family2.set+ (Data.ProtoLens.Field.field @"swapFromLnMinAmt") y x)+ mutable'lspLnNodes+ 42+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "swap_from_ln_max_amt"+ loop+ (Lens.Family2.set+ (Data.ProtoLens.Field.field @"swapFromLnMaxAmt") y x)+ mutable'lspLnNodes+ 50+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "swap_ln_fee_rate"+ loop+ (Lens.Family2.set+ (Data.ProtoLens.Field.field @"swapLnFeeRate") y x)+ mutable'lspLnNodes+ 58+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "swap_ln_min_fee"+ loop+ (Lens.Family2.set+ (Data.ProtoLens.Field.field @"swapLnMinFee") y x)+ mutable'lspLnNodes+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ mutable'lspLnNodes+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do mutable'lspLnNodes <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ Data.ProtoLens.Encoding.Growing.new+ loop Data.ProtoLens.defMessage mutable'lspLnNodes)+ "Success"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.foldMapBuilder+ (\ _v+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 10)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ (Lens.Family2.view+ (Data.ProtoLens.Field.field @"vec'lspLnNodes") _x))+ ((Data.Monoid.<>)+ (case+ Lens.Family2.view+ (Data.ProtoLens.Field.field @"maybe'swapIntoLnMinAmt") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just _v)+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 18)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ ((Data.Monoid.<>)+ (case+ Lens.Family2.view+ (Data.ProtoLens.Field.field @"maybe'swapIntoLnMaxAmt") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just _v)+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 26)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ ((Data.Monoid.<>)+ (case+ Lens.Family2.view+ (Data.ProtoLens.Field.field @"maybe'swapFromLnMinAmt") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just _v)+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 34)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ ((Data.Monoid.<>)+ (case+ Lens.Family2.view+ (Data.ProtoLens.Field.field @"maybe'swapFromLnMaxAmt") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just _v)+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 42)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ ((Data.Monoid.<>)+ (case+ Lens.Family2.view+ (Data.ProtoLens.Field.field @"maybe'swapLnFeeRate") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just _v)+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 50)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral+ (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ ((Data.Monoid.<>)+ (case+ Lens.Family2.view+ (Data.ProtoLens.Field.field @"maybe'swapLnMinFee") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just _v)+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 58)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral+ (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x))))))))+instance Control.DeepSeq.NFData Response'Success where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_Response'Success'_unknownFields x__)+ (Control.DeepSeq.deepseq+ (_Response'Success'lspLnNodes x__)+ (Control.DeepSeq.deepseq+ (_Response'Success'swapIntoLnMinAmt x__)+ (Control.DeepSeq.deepseq+ (_Response'Success'swapIntoLnMaxAmt x__)+ (Control.DeepSeq.deepseq+ (_Response'Success'swapFromLnMinAmt x__)+ (Control.DeepSeq.deepseq+ (_Response'Success'swapFromLnMaxAmt x__)+ (Control.DeepSeq.deepseq+ (_Response'Success'swapLnFeeRate x__)+ (Control.DeepSeq.deepseq+ (_Response'Success'swapLnMinFee x__) ())))))))+packedFileDescriptor :: Data.ByteString.ByteString+packedFileDescriptor+ = "\n\+ \\FSbtc_lsp/method/get_cfg.proto\DC2\DC4BtcLsp.Method.GetCfg\SUB\GSbtc_lsp/data/high_level.proto\"7\n\+ \\aRequest\DC2,\n\+ \\ETXctx\CAN\SOH \SOH(\v2\SUB.BtcLsp.Data.HighLevel.CtxR\ETXctx\"\249\a\n\+ \\bResponse\DC2,\n\+ \\ETXctx\CAN\SOH \SOH(\v2\SUB.BtcLsp.Data.HighLevel.CtxR\ETXctx\DC2B\n\+ \\asuccess\CAN\STX \SOH(\v2&.BtcLsp.Method.GetCfg.Response.SuccessH\NULR\asuccess\DC2B\n\+ \\afailure\CAN\ETX \SOH(\v2&.BtcLsp.Method.GetCfg.Response.FailureH\NULR\afailure\SUB\175\EOT\n\+ \\aSuccess\DC2?\n\+ \\flsp_ln_nodes\CAN\SOH \ETX(\v2\GS.BtcLsp.Data.HighLevel.LnPeerR\n\+ \lspLnNodes\DC2S\n\+ \\DC4swap_into_ln_min_amt\CAN\STX \SOH(\v2#.BtcLsp.Data.HighLevel.LocalBalanceR\DLEswapIntoLnMinAmt\DC2S\n\+ \\DC4swap_into_ln_max_amt\CAN\ETX \SOH(\v2#.BtcLsp.Data.HighLevel.LocalBalanceR\DLEswapIntoLnMaxAmt\DC2S\n\+ \\DC4swap_from_ln_min_amt\CAN\EOT \SOH(\v2#.BtcLsp.Data.HighLevel.LocalBalanceR\DLEswapFromLnMinAmt\DC2S\n\+ \\DC4swap_from_ln_max_amt\CAN\ENQ \SOH(\v2#.BtcLsp.Data.HighLevel.LocalBalanceR\DLEswapFromLnMaxAmt\DC2G\n\+ \\DLEswap_ln_fee_rate\CAN\ACK \SOH(\v2\RS.BtcLsp.Data.HighLevel.FeeRateR\rswapLnFeeRate\DC2F\n\+ \\SIswap_ln_min_fee\CAN\a \SOH(\v2\US.BtcLsp.Data.HighLevel.FeeMoneyR\fswapLnMinFee\SUB\250\SOH\n\+ \\aFailure\DC2=\n\+ \\ageneric\CAN\SOH \ETX(\v2#.BtcLsp.Data.HighLevel.InputFailureR\ageneric\DC2O\n\+ \\bspecific\CAN\STX \ETX(\SO23.BtcLsp.Method.GetCfg.Response.Failure.InputFailureR\bspecific\DC2B\n\+ \\binternal\CAN\ETX \ETX(\v2&.BtcLsp.Data.HighLevel.InternalFailureR\binternal\"\ESC\n\+ \\fInputFailure\DC2\v\n\+ \\aDEFAULT\DLE\NULB\b\n\+ \\ACKeitherJ\146\t\n\+ \\ACK\DC2\EOT\NUL\NUL%\SOH\n\+ \\b\n\+ \\SOH\f\DC2\ETX\NUL\NUL\DLE\n\+ \\b\n\+ \\SOH\STX\DC2\ETX\STX\NUL\GS\n\+ \\t\n\+ \\STX\ETX\NUL\DC2\ETX\EOT\NUL'\n\+ \\n\+ \\n\+ \\STX\EOT\NUL\DC2\EOT\ACK\NUL\b\SOH\n\+ \\n\+ \\n\+ \\ETX\EOT\NUL\SOH\DC2\ETX\ACK\b\SI\n\+ \\v\n\+ \\EOT\EOT\NUL\STX\NUL\DC2\ETX\a\STX%\n\+ \\f\n\+ \\ENQ\EOT\NUL\STX\NUL\ACK\DC2\ETX\a\STX\FS\n\+ \\f\n\+ \\ENQ\EOT\NUL\STX\NUL\SOH\DC2\ETX\a\GS \n\+ \\f\n\+ \\ENQ\EOT\NUL\STX\NUL\ETX\DC2\ETX\a#$\n\+ \\n\+ \\n\+ \\STX\EOT\SOH\DC2\EOT\n\+ \\NUL%\SOH\n\+ \\n\+ \\n\+ \\ETX\EOT\SOH\SOH\DC2\ETX\n\+ \\b\DLE\n\+ \\v\n\+ \\EOT\EOT\SOH\STX\NUL\DC2\ETX\v\STX%\n\+ \\f\n\+ \\ENQ\EOT\SOH\STX\NUL\ACK\DC2\ETX\v\STX\FS\n\+ \\f\n\+ \\ENQ\EOT\SOH\STX\NUL\SOH\DC2\ETX\v\GS \n\+ \\f\n\+ \\ENQ\EOT\SOH\STX\NUL\ETX\DC2\ETX\v#$\n\+ \\f\n\+ \\EOT\EOT\SOH\b\NUL\DC2\EOT\r\STX\DLE\ETX\n\+ \\f\n\+ \\ENQ\EOT\SOH\b\NUL\SOH\DC2\ETX\r\b\SO\n\+ \\v\n\+ \\EOT\EOT\SOH\STX\SOH\DC2\ETX\SO\EOT\CAN\n\+ \\f\n\+ \\ENQ\EOT\SOH\STX\SOH\ACK\DC2\ETX\SO\EOT\v\n\+ \\f\n\+ \\ENQ\EOT\SOH\STX\SOH\SOH\DC2\ETX\SO\f\DC3\n\+ \\f\n\+ \\ENQ\EOT\SOH\STX\SOH\ETX\DC2\ETX\SO\SYN\ETB\n\+ \\v\n\+ \\EOT\EOT\SOH\STX\STX\DC2\ETX\SI\EOT\CAN\n\+ \\f\n\+ \\ENQ\EOT\SOH\STX\STX\ACK\DC2\ETX\SI\EOT\v\n\+ \\f\n\+ \\ENQ\EOT\SOH\STX\STX\SOH\DC2\ETX\SI\f\DC3\n\+ \\f\n\+ \\ENQ\EOT\SOH\STX\STX\ETX\DC2\ETX\SI\SYN\ETB\n\+ \\f\n\+ \\EOT\EOT\SOH\ETX\NUL\DC2\EOT\DC2\STX\SUB\ETX\n\+ \\f\n\+ \\ENQ\EOT\SOH\ETX\NUL\SOH\DC2\ETX\DC2\n\+ \\DC1\n\+ \\r\n\+ \\ACK\EOT\SOH\ETX\NUL\STX\NUL\DC2\ETX\DC3\EOT<\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\NUL\STX\NUL\EOT\DC2\ETX\DC3\EOT\f\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\NUL\STX\NUL\ACK\DC2\ETX\DC3\r*\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\NUL\STX\NUL\SOH\DC2\ETX\DC3+7\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\NUL\STX\NUL\ETX\DC2\ETX\DC3:;\n\+ \\r\n\+ \\ACK\EOT\SOH\ETX\NUL\STX\SOH\DC2\ETX\DC4\EOTA\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\NUL\STX\SOH\ACK\DC2\ETX\DC4\EOT'\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\NUL\STX\SOH\SOH\DC2\ETX\DC4(<\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\NUL\STX\SOH\ETX\DC2\ETX\DC4?@\n\+ \\r\n\+ \\ACK\EOT\SOH\ETX\NUL\STX\STX\DC2\ETX\NAK\EOTA\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\NUL\STX\STX\ACK\DC2\ETX\NAK\EOT'\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\NUL\STX\STX\SOH\DC2\ETX\NAK(<\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\NUL\STX\STX\ETX\DC2\ETX\NAK?@\n\+ \\r\n\+ \\ACK\EOT\SOH\ETX\NUL\STX\ETX\DC2\ETX\SYN\EOTA\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\NUL\STX\ETX\ACK\DC2\ETX\SYN\EOT'\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\NUL\STX\ETX\SOH\DC2\ETX\SYN(<\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\NUL\STX\ETX\ETX\DC2\ETX\SYN?@\n\+ \\r\n\+ \\ACK\EOT\SOH\ETX\NUL\STX\EOT\DC2\ETX\ETB\EOTA\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\NUL\STX\EOT\ACK\DC2\ETX\ETB\EOT'\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\NUL\STX\EOT\SOH\DC2\ETX\ETB(<\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\NUL\STX\EOT\ETX\DC2\ETX\ETB?@\n\+ \\r\n\+ \\ACK\EOT\SOH\ETX\NUL\STX\ENQ\DC2\ETX\CAN\EOT8\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\NUL\STX\ENQ\ACK\DC2\ETX\CAN\EOT\"\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\NUL\STX\ENQ\SOH\DC2\ETX\CAN#3\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\NUL\STX\ENQ\ETX\DC2\ETX\CAN67\n\+ \\r\n\+ \\ACK\EOT\SOH\ETX\NUL\STX\ACK\DC2\ETX\EM\EOT8\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\NUL\STX\ACK\ACK\DC2\ETX\EM\EOT#\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\NUL\STX\ACK\SOH\DC2\ETX\EM$3\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\NUL\STX\ACK\ETX\DC2\ETX\EM67\n\+ \\f\n\+ \\EOT\EOT\SOH\ETX\SOH\DC2\EOT\FS\STX$\ETX\n\+ \\f\n\+ \\ENQ\EOT\SOH\ETX\SOH\SOH\DC2\ETX\FS\n\+ \\DC1\n\+ \\r\n\+ \\ACK\EOT\SOH\ETX\SOH\STX\NUL\DC2\ETX\GS\EOT=\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\NUL\EOT\DC2\ETX\GS\EOT\f\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\NUL\ACK\DC2\ETX\GS\r0\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\NUL\SOH\DC2\ETX\GS18\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\NUL\ETX\DC2\ETX\GS;<\n\+ \\r\n\+ \\ACK\EOT\SOH\ETX\SOH\STX\SOH\DC2\ETX\RS\EOT'\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\SOH\EOT\DC2\ETX\RS\EOT\f\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\SOH\ACK\DC2\ETX\RS\r\EM\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\SOH\SOH\DC2\ETX\RS\SUB\"\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\SOH\ETX\DC2\ETX\RS%&\n\+ \\r\n\+ \\ACK\EOT\SOH\ETX\SOH\STX\STX\DC2\ETX\US\EOTA\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\STX\EOT\DC2\ETX\US\EOT\f\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\STX\ACK\DC2\ETX\US\r3\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\STX\SOH\DC2\ETX\US4<\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\STX\ETX\DC2\ETX\US?@\n\+ \\SO\n\+ \\ACK\EOT\SOH\ETX\SOH\EOT\NUL\DC2\EOT!\EOT#\ENQ\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\EOT\NUL\SOH\DC2\ETX!\t\NAK\n\+ \\SI\n\+ \\b\EOT\SOH\ETX\SOH\EOT\NUL\STX\NUL\DC2\ETX\"\ACK\DC2\n\+ \\DLE\n\+ \\t\EOT\SOH\ETX\SOH\EOT\NUL\STX\NUL\SOH\DC2\ETX\"\ACK\r\n\+ \\DLE\n\+ \\t\EOT\SOH\ETX\SOH\EOT\NUL\STX\NUL\STX\DC2\ETX\"\DLE\DC1b\ACKproto3"
@@ -0,0 +1,194 @@+{- This file was auto-generated from btc_lsp/method/get_cfg.proto by the proto-lens-protoc program. -}+{-# LANGUAGE ScopedTypeVariables, DataKinds, TypeFamilies, UndecidableInstances, GeneralizedNewtypeDeriving, MultiParamTypeClasses, FlexibleContexts, FlexibleInstances, PatternSynonyms, MagicHash, NoImplicitPrelude, BangPatterns, TypeApplications, OverloadedStrings, DerivingStrategies, DeriveGeneric#-}+{-# OPTIONS_GHC -Wno-unused-imports#-}+{-# OPTIONS_GHC -Wno-duplicate-exports#-}+{-# OPTIONS_GHC -Wno-dodgy-exports#-}+module Proto.BtcLsp.Method.GetCfg_Fields where+import qualified Data.ProtoLens.Runtime.Prelude as Prelude+import qualified Data.ProtoLens.Runtime.Data.Int as Data.Int+import qualified Data.ProtoLens.Runtime.Data.Monoid as Data.Monoid+import qualified Data.ProtoLens.Runtime.Data.Word as Data.Word+import qualified Data.ProtoLens.Runtime.Data.ProtoLens as Data.ProtoLens+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Bytes as Data.ProtoLens.Encoding.Bytes+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Growing as Data.ProtoLens.Encoding.Growing+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Parser.Unsafe as Data.ProtoLens.Encoding.Parser.Unsafe+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Wire as Data.ProtoLens.Encoding.Wire+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Field as Data.ProtoLens.Field+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Message.Enum as Data.ProtoLens.Message.Enum+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Service.Types as Data.ProtoLens.Service.Types+import qualified Data.ProtoLens.Runtime.Lens.Family2 as Lens.Family2+import qualified Data.ProtoLens.Runtime.Lens.Family2.Unchecked as Lens.Family2.Unchecked+import qualified Data.ProtoLens.Runtime.Data.Text as Data.Text+import qualified Data.ProtoLens.Runtime.Data.Map as Data.Map+import qualified Data.ProtoLens.Runtime.Data.ByteString as Data.ByteString+import qualified Data.ProtoLens.Runtime.Data.ByteString.Char8 as Data.ByteString.Char8+import qualified Data.ProtoLens.Runtime.Data.Text.Encoding as Data.Text.Encoding+import qualified Data.ProtoLens.Runtime.Data.Vector as Data.Vector+import qualified Data.ProtoLens.Runtime.Data.Vector.Generic as Data.Vector.Generic+import qualified Data.ProtoLens.Runtime.Data.Vector.Unboxed as Data.Vector.Unboxed+import qualified Data.ProtoLens.Runtime.Text.Read as Text.Read+import qualified Proto.BtcLsp.Data.HighLevel+ctx ::+ forall f s a.+ (Prelude.Functor f, Data.ProtoLens.Field.HasField s "ctx" a) =>+ Lens.Family2.LensLike' f s a+ctx = Data.ProtoLens.Field.field @"ctx"+failure ::+ forall f s a.+ (Prelude.Functor f, Data.ProtoLens.Field.HasField s "failure" a) =>+ Lens.Family2.LensLike' f s a+failure = Data.ProtoLens.Field.field @"failure"+generic ::+ forall f s a.+ (Prelude.Functor f, Data.ProtoLens.Field.HasField s "generic" a) =>+ Lens.Family2.LensLike' f s a+generic = Data.ProtoLens.Field.field @"generic"+internal ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "internal" a) =>+ Lens.Family2.LensLike' f s a+internal = Data.ProtoLens.Field.field @"internal"+lspLnNodes ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "lspLnNodes" a) =>+ Lens.Family2.LensLike' f s a+lspLnNodes = Data.ProtoLens.Field.field @"lspLnNodes"+maybe'ctx ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "maybe'ctx" a) =>+ Lens.Family2.LensLike' f s a+maybe'ctx = Data.ProtoLens.Field.field @"maybe'ctx"+maybe'either ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "maybe'either" a) =>+ Lens.Family2.LensLike' f s a+maybe'either = Data.ProtoLens.Field.field @"maybe'either"+maybe'failure ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "maybe'failure" a) =>+ Lens.Family2.LensLike' f s a+maybe'failure = Data.ProtoLens.Field.field @"maybe'failure"+maybe'success ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "maybe'success" a) =>+ Lens.Family2.LensLike' f s a+maybe'success = Data.ProtoLens.Field.field @"maybe'success"+maybe'swapFromLnMaxAmt ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "maybe'swapFromLnMaxAmt" a) =>+ Lens.Family2.LensLike' f s a+maybe'swapFromLnMaxAmt+ = Data.ProtoLens.Field.field @"maybe'swapFromLnMaxAmt"+maybe'swapFromLnMinAmt ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "maybe'swapFromLnMinAmt" a) =>+ Lens.Family2.LensLike' f s a+maybe'swapFromLnMinAmt+ = Data.ProtoLens.Field.field @"maybe'swapFromLnMinAmt"+maybe'swapIntoLnMaxAmt ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "maybe'swapIntoLnMaxAmt" a) =>+ Lens.Family2.LensLike' f s a+maybe'swapIntoLnMaxAmt+ = Data.ProtoLens.Field.field @"maybe'swapIntoLnMaxAmt"+maybe'swapIntoLnMinAmt ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "maybe'swapIntoLnMinAmt" a) =>+ Lens.Family2.LensLike' f s a+maybe'swapIntoLnMinAmt+ = Data.ProtoLens.Field.field @"maybe'swapIntoLnMinAmt"+maybe'swapLnFeeRate ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "maybe'swapLnFeeRate" a) =>+ Lens.Family2.LensLike' f s a+maybe'swapLnFeeRate+ = Data.ProtoLens.Field.field @"maybe'swapLnFeeRate"+maybe'swapLnMinFee ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "maybe'swapLnMinFee" a) =>+ Lens.Family2.LensLike' f s a+maybe'swapLnMinFee+ = Data.ProtoLens.Field.field @"maybe'swapLnMinFee"+specific ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "specific" a) =>+ Lens.Family2.LensLike' f s a+specific = Data.ProtoLens.Field.field @"specific"+success ::+ forall f s a.+ (Prelude.Functor f, Data.ProtoLens.Field.HasField s "success" a) =>+ Lens.Family2.LensLike' f s a+success = Data.ProtoLens.Field.field @"success"+swapFromLnMaxAmt ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "swapFromLnMaxAmt" a) =>+ Lens.Family2.LensLike' f s a+swapFromLnMaxAmt = Data.ProtoLens.Field.field @"swapFromLnMaxAmt"+swapFromLnMinAmt ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "swapFromLnMinAmt" a) =>+ Lens.Family2.LensLike' f s a+swapFromLnMinAmt = Data.ProtoLens.Field.field @"swapFromLnMinAmt"+swapIntoLnMaxAmt ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "swapIntoLnMaxAmt" a) =>+ Lens.Family2.LensLike' f s a+swapIntoLnMaxAmt = Data.ProtoLens.Field.field @"swapIntoLnMaxAmt"+swapIntoLnMinAmt ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "swapIntoLnMinAmt" a) =>+ Lens.Family2.LensLike' f s a+swapIntoLnMinAmt = Data.ProtoLens.Field.field @"swapIntoLnMinAmt"+swapLnFeeRate ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "swapLnFeeRate" a) =>+ Lens.Family2.LensLike' f s a+swapLnFeeRate = Data.ProtoLens.Field.field @"swapLnFeeRate"+swapLnMinFee ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "swapLnMinFee" a) =>+ Lens.Family2.LensLike' f s a+swapLnMinFee = Data.ProtoLens.Field.field @"swapLnMinFee"+vec'generic ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "vec'generic" a) =>+ Lens.Family2.LensLike' f s a+vec'generic = Data.ProtoLens.Field.field @"vec'generic"+vec'internal ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "vec'internal" a) =>+ Lens.Family2.LensLike' f s a+vec'internal = Data.ProtoLens.Field.field @"vec'internal"+vec'lspLnNodes ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "vec'lspLnNodes" a) =>+ Lens.Family2.LensLike' f s a+vec'lspLnNodes = Data.ProtoLens.Field.field @"vec'lspLnNodes"+vec'specific ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "vec'specific" a) =>+ Lens.Family2.LensLike' f s a+vec'specific = Data.ProtoLens.Field.field @"vec'specific"
@@ -0,0 +1,1187 @@+{- This file was auto-generated from btc_lsp/method/swap_from_ln.proto by the proto-lens-protoc program. -}+{-# LANGUAGE ScopedTypeVariables, DataKinds, TypeFamilies, UndecidableInstances, GeneralizedNewtypeDeriving, MultiParamTypeClasses, FlexibleContexts, FlexibleInstances, PatternSynonyms, MagicHash, NoImplicitPrelude, BangPatterns, TypeApplications, OverloadedStrings, DerivingStrategies, DeriveGeneric#-}+{-# OPTIONS_GHC -Wno-unused-imports#-}+{-# OPTIONS_GHC -Wno-duplicate-exports#-}+{-# OPTIONS_GHC -Wno-dodgy-exports#-}+module Proto.BtcLsp.Method.SwapFromLn (+ Request(), Response(), Response'Either(..), _Response'Success',+ _Response'Failure', Response'Failure(),+ Response'Failure'InputFailure(..), Response'Failure'InputFailure(),+ Response'Failure'InputFailure'UnrecognizedValue, Response'Success()+ ) where+import qualified Data.ProtoLens.Runtime.Control.DeepSeq as Control.DeepSeq+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Prism as Data.ProtoLens.Prism+import qualified Text.PrettyPrint.GenericPretty.Instance+import qualified GHC.Generics+import qualified Text.PrettyPrint.GenericPretty+import qualified Data.ProtoLens.Runtime.Prelude as Prelude+import qualified Data.ProtoLens.Runtime.Data.Int as Data.Int+import qualified Data.ProtoLens.Runtime.Data.Monoid as Data.Monoid+import qualified Data.ProtoLens.Runtime.Data.Word as Data.Word+import qualified Data.ProtoLens.Runtime.Data.ProtoLens as Data.ProtoLens+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Bytes as Data.ProtoLens.Encoding.Bytes+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Growing as Data.ProtoLens.Encoding.Growing+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Parser.Unsafe as Data.ProtoLens.Encoding.Parser.Unsafe+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Wire as Data.ProtoLens.Encoding.Wire+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Field as Data.ProtoLens.Field+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Message.Enum as Data.ProtoLens.Message.Enum+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Service.Types as Data.ProtoLens.Service.Types+import qualified Data.ProtoLens.Runtime.Lens.Family2 as Lens.Family2+import qualified Data.ProtoLens.Runtime.Lens.Family2.Unchecked as Lens.Family2.Unchecked+import qualified Data.ProtoLens.Runtime.Data.Text as Data.Text+import qualified Data.ProtoLens.Runtime.Data.Map as Data.Map+import qualified Data.ProtoLens.Runtime.Data.ByteString as Data.ByteString+import qualified Data.ProtoLens.Runtime.Data.ByteString.Char8 as Data.ByteString.Char8+import qualified Data.ProtoLens.Runtime.Data.Text.Encoding as Data.Text.Encoding+import qualified Data.ProtoLens.Runtime.Data.Vector as Data.Vector+import qualified Data.ProtoLens.Runtime.Data.Vector.Generic as Data.Vector.Generic+import qualified Data.ProtoLens.Runtime.Data.Vector.Unboxed as Data.Vector.Unboxed+import qualified Data.ProtoLens.Runtime.Text.Read as Text.Read+import qualified Proto.BtcLsp.Data.HighLevel+{- | Fields :+ + * 'Proto.BtcLsp.Method.SwapFromLn_Fields.ctx' @:: Lens' Request Proto.BtcLsp.Data.HighLevel.Ctx@+ * 'Proto.BtcLsp.Method.SwapFromLn_Fields.maybe'ctx' @:: Lens' Request (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.Ctx)@+ * 'Proto.BtcLsp.Method.SwapFromLn_Fields.fundMoney' @:: Lens' Request Proto.BtcLsp.Data.HighLevel.FundMoney@+ * 'Proto.BtcLsp.Method.SwapFromLn_Fields.maybe'fundMoney' @:: Lens' Request (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.FundMoney)@+ * 'Proto.BtcLsp.Method.SwapFromLn_Fields.fundOnChainAddress' @:: Lens' Request Proto.BtcLsp.Data.HighLevel.FundOnChainAddress@+ * 'Proto.BtcLsp.Method.SwapFromLn_Fields.maybe'fundOnChainAddress' @:: Lens' Request (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.FundOnChainAddress)@ -}+data Request+ = Request'_constructor {_Request'ctx :: !(Prelude.Maybe Proto.BtcLsp.Data.HighLevel.Ctx),+ _Request'fundMoney :: !(Prelude.Maybe Proto.BtcLsp.Data.HighLevel.FundMoney),+ _Request'fundOnChainAddress :: !(Prelude.Maybe Proto.BtcLsp.Data.HighLevel.FundOnChainAddress),+ _Request'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show Request where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out Request+instance Data.ProtoLens.Field.HasField Request "ctx" Proto.BtcLsp.Data.HighLevel.Ctx where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Request'ctx (\ x__ y__ -> x__ {_Request'ctx = y__}))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage)+instance Data.ProtoLens.Field.HasField Request "maybe'ctx" (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.Ctx) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Request'ctx (\ x__ y__ -> x__ {_Request'ctx = y__}))+ Prelude.id+instance Data.ProtoLens.Field.HasField Request "fundMoney" Proto.BtcLsp.Data.HighLevel.FundMoney where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Request'fundMoney (\ x__ y__ -> x__ {_Request'fundMoney = y__}))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage)+instance Data.ProtoLens.Field.HasField Request "maybe'fundMoney" (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.FundMoney) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Request'fundMoney (\ x__ y__ -> x__ {_Request'fundMoney = y__}))+ Prelude.id+instance Data.ProtoLens.Field.HasField Request "fundOnChainAddress" Proto.BtcLsp.Data.HighLevel.FundOnChainAddress where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Request'fundOnChainAddress+ (\ x__ y__ -> x__ {_Request'fundOnChainAddress = y__}))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage)+instance Data.ProtoLens.Field.HasField Request "maybe'fundOnChainAddress" (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.FundOnChainAddress) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Request'fundOnChainAddress+ (\ x__ y__ -> x__ {_Request'fundOnChainAddress = y__}))+ Prelude.id+instance Data.ProtoLens.Message Request where+ messageName _ = Data.Text.pack "BtcLsp.Method.SwapFromLn.Request"+ packedMessageDescriptor _+ = "\n\+ \\aRequest\DC2,\n\+ \\ETXctx\CAN\SOH \SOH(\v2\SUB.BtcLsp.Data.HighLevel.CtxR\ETXctx\DC2?\n\+ \\n\+ \fund_money\CAN\STX \SOH(\v2 .BtcLsp.Data.HighLevel.FundMoneyR\tfundMoney\DC2\\\n\+ \\NAKfund_on_chain_address\CAN\ETX \SOH(\v2).BtcLsp.Data.HighLevel.FundOnChainAddressR\DC2fundOnChainAddress"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ ctx__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "ctx"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.HighLevel.Ctx)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'ctx")) ::+ Data.ProtoLens.FieldDescriptor Request+ fundMoney__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "fund_money"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.HighLevel.FundMoney)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'fundMoney")) ::+ Data.ProtoLens.FieldDescriptor Request+ fundOnChainAddress__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "fund_on_chain_address"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.HighLevel.FundOnChainAddress)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'fundOnChainAddress")) ::+ Data.ProtoLens.FieldDescriptor Request+ in+ Data.Map.fromList+ [(Data.ProtoLens.Tag 1, ctx__field_descriptor),+ (Data.ProtoLens.Tag 2, fundMoney__field_descriptor),+ (Data.ProtoLens.Tag 3, fundOnChainAddress__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _Request'_unknownFields+ (\ x__ y__ -> x__ {_Request'_unknownFields = y__})+ defMessage+ = Request'_constructor+ {_Request'ctx = Prelude.Nothing,+ _Request'fundMoney = Prelude.Nothing,+ _Request'fundOnChainAddress = Prelude.Nothing,+ _Request'_unknownFields = []}+ parseMessage+ = let+ loop :: Request -> Data.ProtoLens.Encoding.Bytes.Parser Request+ loop x+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) x)+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 10+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "ctx"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"ctx") y x)+ 18+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "fund_money"+ loop+ (Lens.Family2.set (Data.ProtoLens.Field.field @"fundMoney") y x)+ 26+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "fund_on_chain_address"+ loop+ (Lens.Family2.set+ (Data.ProtoLens.Field.field @"fundOnChainAddress") y x)+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do loop Data.ProtoLens.defMessage) "Request"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (case+ Lens.Family2.view (Data.ProtoLens.Field.field @"maybe'ctx") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just _v)+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 10)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ ((Data.Monoid.<>)+ (case+ Lens.Family2.view+ (Data.ProtoLens.Field.field @"maybe'fundMoney") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just _v)+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 18)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ ((Data.Monoid.<>)+ (case+ Lens.Family2.view+ (Data.ProtoLens.Field.field @"maybe'fundOnChainAddress") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just _v)+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 26)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x))))+instance Control.DeepSeq.NFData Request where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_Request'_unknownFields x__)+ (Control.DeepSeq.deepseq+ (_Request'ctx x__)+ (Control.DeepSeq.deepseq+ (_Request'fundMoney x__)+ (Control.DeepSeq.deepseq (_Request'fundOnChainAddress x__) ())))+{- | Fields :+ + * 'Proto.BtcLsp.Method.SwapFromLn_Fields.ctx' @:: Lens' Response Proto.BtcLsp.Data.HighLevel.Ctx@+ * 'Proto.BtcLsp.Method.SwapFromLn_Fields.maybe'ctx' @:: Lens' Response (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.Ctx)@+ * 'Proto.BtcLsp.Method.SwapFromLn_Fields.maybe'either' @:: Lens' Response (Prelude.Maybe Response'Either)@+ * 'Proto.BtcLsp.Method.SwapFromLn_Fields.maybe'success' @:: Lens' Response (Prelude.Maybe Response'Success)@+ * 'Proto.BtcLsp.Method.SwapFromLn_Fields.success' @:: Lens' Response Response'Success@+ * 'Proto.BtcLsp.Method.SwapFromLn_Fields.maybe'failure' @:: Lens' Response (Prelude.Maybe Response'Failure)@+ * 'Proto.BtcLsp.Method.SwapFromLn_Fields.failure' @:: Lens' Response Response'Failure@ -}+data Response+ = Response'_constructor {_Response'ctx :: !(Prelude.Maybe Proto.BtcLsp.Data.HighLevel.Ctx),+ _Response'either :: !(Prelude.Maybe Response'Either),+ _Response'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show Response where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out Response+data Response'Either+ = Response'Success' !Response'Success |+ Response'Failure' !Response'Failure+ deriving stock (Prelude.Show,+ Prelude.Eq,+ Prelude.Ord,+ GHC.Generics.Generic)+instance Text.PrettyPrint.GenericPretty.Out Response'Either+instance Data.ProtoLens.Field.HasField Response "ctx" Proto.BtcLsp.Data.HighLevel.Ctx where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'ctx (\ x__ y__ -> x__ {_Response'ctx = y__}))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage)+instance Data.ProtoLens.Field.HasField Response "maybe'ctx" (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.Ctx) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'ctx (\ x__ y__ -> x__ {_Response'ctx = y__}))+ Prelude.id+instance Data.ProtoLens.Field.HasField Response "maybe'either" (Prelude.Maybe Response'Either) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'either (\ x__ y__ -> x__ {_Response'either = y__}))+ Prelude.id+instance Data.ProtoLens.Field.HasField Response "maybe'success" (Prelude.Maybe Response'Success) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'either (\ x__ y__ -> x__ {_Response'either = y__}))+ (Lens.Family2.Unchecked.lens+ (\ x__+ -> case x__ of+ (Prelude.Just (Response'Success' x__val)) -> Prelude.Just x__val+ _otherwise -> Prelude.Nothing)+ (\ _ y__ -> Prelude.fmap Response'Success' y__))+instance Data.ProtoLens.Field.HasField Response "success" Response'Success where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'either (\ x__ y__ -> x__ {_Response'either = y__}))+ ((Prelude..)+ (Lens.Family2.Unchecked.lens+ (\ x__+ -> case x__ of+ (Prelude.Just (Response'Success' x__val)) -> Prelude.Just x__val+ _otherwise -> Prelude.Nothing)+ (\ _ y__ -> Prelude.fmap Response'Success' y__))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage))+instance Data.ProtoLens.Field.HasField Response "maybe'failure" (Prelude.Maybe Response'Failure) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'either (\ x__ y__ -> x__ {_Response'either = y__}))+ (Lens.Family2.Unchecked.lens+ (\ x__+ -> case x__ of+ (Prelude.Just (Response'Failure' x__val)) -> Prelude.Just x__val+ _otherwise -> Prelude.Nothing)+ (\ _ y__ -> Prelude.fmap Response'Failure' y__))+instance Data.ProtoLens.Field.HasField Response "failure" Response'Failure where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'either (\ x__ y__ -> x__ {_Response'either = y__}))+ ((Prelude..)+ (Lens.Family2.Unchecked.lens+ (\ x__+ -> case x__ of+ (Prelude.Just (Response'Failure' x__val)) -> Prelude.Just x__val+ _otherwise -> Prelude.Nothing)+ (\ _ y__ -> Prelude.fmap Response'Failure' y__))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage))+instance Data.ProtoLens.Message Response where+ messageName _ = Data.Text.pack "BtcLsp.Method.SwapFromLn.Response"+ packedMessageDescriptor _+ = "\n\+ \\bResponse\DC2,\n\+ \\ETXctx\CAN\SOH \SOH(\v2\SUB.BtcLsp.Data.HighLevel.CtxR\ETXctx\DC2F\n\+ \\asuccess\CAN\STX \SOH(\v2*.BtcLsp.Method.SwapFromLn.Response.SuccessH\NULR\asuccess\DC2F\n\+ \\afailure\CAN\ETX \SOH(\v2*.BtcLsp.Method.SwapFromLn.Response.FailureH\NULR\afailure\SUBd\n\+ \\aSuccess\DC2Y\n\+ \\DC4fund_ln_hodl_invoice\CAN\SOH \SOH(\v2(.BtcLsp.Data.HighLevel.FundLnHodlInvoiceR\DC1fundLnHodlInvoice\SUB\254\SOH\n\+ \\aFailure\DC2=\n\+ \\ageneric\CAN\SOH \ETX(\v2#.BtcLsp.Data.HighLevel.InputFailureR\ageneric\DC2S\n\+ \\bspecific\CAN\STX \ETX(\SO27.BtcLsp.Method.SwapFromLn.Response.Failure.InputFailureR\bspecific\DC2B\n\+ \\binternal\CAN\ETX \ETX(\v2&.BtcLsp.Data.HighLevel.InternalFailureR\binternal\"\ESC\n\+ \\fInputFailure\DC2\v\n\+ \\aDEFAULT\DLE\NULB\b\n\+ \\ACKeither"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ ctx__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "ctx"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.HighLevel.Ctx)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'ctx")) ::+ Data.ProtoLens.FieldDescriptor Response+ success__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "success"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Response'Success)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'success")) ::+ Data.ProtoLens.FieldDescriptor Response+ failure__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "failure"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Response'Failure)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'failure")) ::+ Data.ProtoLens.FieldDescriptor Response+ in+ Data.Map.fromList+ [(Data.ProtoLens.Tag 1, ctx__field_descriptor),+ (Data.ProtoLens.Tag 2, success__field_descriptor),+ (Data.ProtoLens.Tag 3, failure__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _Response'_unknownFields+ (\ x__ y__ -> x__ {_Response'_unknownFields = y__})+ defMessage+ = Response'_constructor+ {_Response'ctx = Prelude.Nothing,+ _Response'either = Prelude.Nothing, _Response'_unknownFields = []}+ parseMessage+ = let+ loop :: Response -> Data.ProtoLens.Encoding.Bytes.Parser Response+ loop x+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) x)+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 10+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "ctx"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"ctx") y x)+ 18+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "success"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"success") y x)+ 26+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "failure"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"failure") y x)+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do loop Data.ProtoLens.defMessage) "Response"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (case+ Lens.Family2.view (Data.ProtoLens.Field.field @"maybe'ctx") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just _v)+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 10)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ ((Data.Monoid.<>)+ (case+ Lens.Family2.view (Data.ProtoLens.Field.field @"maybe'either") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just (Response'Success' v))+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 18)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage v)+ (Prelude.Just (Response'Failure' v))+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 26)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage v))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x)))+instance Control.DeepSeq.NFData Response where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_Response'_unknownFields x__)+ (Control.DeepSeq.deepseq+ (_Response'ctx x__)+ (Control.DeepSeq.deepseq (_Response'either x__) ()))+instance Control.DeepSeq.NFData Response'Either where+ rnf (Response'Success' x__) = Control.DeepSeq.rnf x__+ rnf (Response'Failure' x__) = Control.DeepSeq.rnf x__+_Response'Success' ::+ Data.ProtoLens.Prism.Prism' Response'Either Response'Success+_Response'Success'+ = Data.ProtoLens.Prism.prism'+ Response'Success'+ (\ p__+ -> case p__ of+ (Response'Success' p__val) -> Prelude.Just p__val+ _otherwise -> Prelude.Nothing)+_Response'Failure' ::+ Data.ProtoLens.Prism.Prism' Response'Either Response'Failure+_Response'Failure'+ = Data.ProtoLens.Prism.prism'+ Response'Failure'+ (\ p__+ -> case p__ of+ (Response'Failure' p__val) -> Prelude.Just p__val+ _otherwise -> Prelude.Nothing)+{- | Fields :+ + * 'Proto.BtcLsp.Method.SwapFromLn_Fields.generic' @:: Lens' Response'Failure [Proto.BtcLsp.Data.HighLevel.InputFailure]@+ * 'Proto.BtcLsp.Method.SwapFromLn_Fields.vec'generic' @:: Lens' Response'Failure (Data.Vector.Vector Proto.BtcLsp.Data.HighLevel.InputFailure)@+ * 'Proto.BtcLsp.Method.SwapFromLn_Fields.specific' @:: Lens' Response'Failure [Response'Failure'InputFailure]@+ * 'Proto.BtcLsp.Method.SwapFromLn_Fields.vec'specific' @:: Lens' Response'Failure (Data.Vector.Vector Response'Failure'InputFailure)@+ * 'Proto.BtcLsp.Method.SwapFromLn_Fields.internal' @:: Lens' Response'Failure [Proto.BtcLsp.Data.HighLevel.InternalFailure]@+ * 'Proto.BtcLsp.Method.SwapFromLn_Fields.vec'internal' @:: Lens' Response'Failure (Data.Vector.Vector Proto.BtcLsp.Data.HighLevel.InternalFailure)@ -}+data Response'Failure+ = Response'Failure'_constructor {_Response'Failure'generic :: !(Data.Vector.Vector Proto.BtcLsp.Data.HighLevel.InputFailure),+ _Response'Failure'specific :: !(Data.Vector.Vector Response'Failure'InputFailure),+ _Response'Failure'internal :: !(Data.Vector.Vector Proto.BtcLsp.Data.HighLevel.InternalFailure),+ _Response'Failure'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show Response'Failure where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out Response'Failure+instance Data.ProtoLens.Field.HasField Response'Failure "generic" [Proto.BtcLsp.Data.HighLevel.InputFailure] where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Failure'generic+ (\ x__ y__ -> x__ {_Response'Failure'generic = y__}))+ (Lens.Family2.Unchecked.lens+ Data.Vector.Generic.toList+ (\ _ y__ -> Data.Vector.Generic.fromList y__))+instance Data.ProtoLens.Field.HasField Response'Failure "vec'generic" (Data.Vector.Vector Proto.BtcLsp.Data.HighLevel.InputFailure) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Failure'generic+ (\ x__ y__ -> x__ {_Response'Failure'generic = y__}))+ Prelude.id+instance Data.ProtoLens.Field.HasField Response'Failure "specific" [Response'Failure'InputFailure] where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Failure'specific+ (\ x__ y__ -> x__ {_Response'Failure'specific = y__}))+ (Lens.Family2.Unchecked.lens+ Data.Vector.Generic.toList+ (\ _ y__ -> Data.Vector.Generic.fromList y__))+instance Data.ProtoLens.Field.HasField Response'Failure "vec'specific" (Data.Vector.Vector Response'Failure'InputFailure) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Failure'specific+ (\ x__ y__ -> x__ {_Response'Failure'specific = y__}))+ Prelude.id+instance Data.ProtoLens.Field.HasField Response'Failure "internal" [Proto.BtcLsp.Data.HighLevel.InternalFailure] where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Failure'internal+ (\ x__ y__ -> x__ {_Response'Failure'internal = y__}))+ (Lens.Family2.Unchecked.lens+ Data.Vector.Generic.toList+ (\ _ y__ -> Data.Vector.Generic.fromList y__))+instance Data.ProtoLens.Field.HasField Response'Failure "vec'internal" (Data.Vector.Vector Proto.BtcLsp.Data.HighLevel.InternalFailure) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Failure'internal+ (\ x__ y__ -> x__ {_Response'Failure'internal = y__}))+ Prelude.id+instance Data.ProtoLens.Message Response'Failure where+ messageName _+ = Data.Text.pack "BtcLsp.Method.SwapFromLn.Response.Failure"+ packedMessageDescriptor _+ = "\n\+ \\aFailure\DC2=\n\+ \\ageneric\CAN\SOH \ETX(\v2#.BtcLsp.Data.HighLevel.InputFailureR\ageneric\DC2S\n\+ \\bspecific\CAN\STX \ETX(\SO27.BtcLsp.Method.SwapFromLn.Response.Failure.InputFailureR\bspecific\DC2B\n\+ \\binternal\CAN\ETX \ETX(\v2&.BtcLsp.Data.HighLevel.InternalFailureR\binternal\"\ESC\n\+ \\fInputFailure\DC2\v\n\+ \\aDEFAULT\DLE\NUL"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ generic__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "generic"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.HighLevel.InputFailure)+ (Data.ProtoLens.RepeatedField+ Data.ProtoLens.Unpacked (Data.ProtoLens.Field.field @"generic")) ::+ Data.ProtoLens.FieldDescriptor Response'Failure+ specific__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "specific"+ (Data.ProtoLens.ScalarField Data.ProtoLens.EnumField ::+ Data.ProtoLens.FieldTypeDescriptor Response'Failure'InputFailure)+ (Data.ProtoLens.RepeatedField+ Data.ProtoLens.Packed (Data.ProtoLens.Field.field @"specific")) ::+ Data.ProtoLens.FieldDescriptor Response'Failure+ internal__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "internal"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.HighLevel.InternalFailure)+ (Data.ProtoLens.RepeatedField+ Data.ProtoLens.Unpacked+ (Data.ProtoLens.Field.field @"internal")) ::+ Data.ProtoLens.FieldDescriptor Response'Failure+ in+ Data.Map.fromList+ [(Data.ProtoLens.Tag 1, generic__field_descriptor),+ (Data.ProtoLens.Tag 2, specific__field_descriptor),+ (Data.ProtoLens.Tag 3, internal__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _Response'Failure'_unknownFields+ (\ x__ y__ -> x__ {_Response'Failure'_unknownFields = y__})+ defMessage+ = Response'Failure'_constructor+ {_Response'Failure'generic = Data.Vector.Generic.empty,+ _Response'Failure'specific = Data.Vector.Generic.empty,+ _Response'Failure'internal = Data.Vector.Generic.empty,+ _Response'Failure'_unknownFields = []}+ parseMessage+ = let+ loop ::+ Response'Failure+ -> Data.ProtoLens.Encoding.Growing.Growing Data.Vector.Vector Data.ProtoLens.Encoding.Growing.RealWorld Proto.BtcLsp.Data.HighLevel.InputFailure+ -> Data.ProtoLens.Encoding.Growing.Growing Data.Vector.Vector Data.ProtoLens.Encoding.Growing.RealWorld Proto.BtcLsp.Data.HighLevel.InternalFailure+ -> Data.ProtoLens.Encoding.Growing.Growing Data.Vector.Vector Data.ProtoLens.Encoding.Growing.RealWorld Response'Failure'InputFailure+ -> Data.ProtoLens.Encoding.Bytes.Parser Response'Failure+ loop x mutable'generic mutable'internal mutable'specific+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do frozen'generic <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ (Data.ProtoLens.Encoding.Growing.unsafeFreeze+ mutable'generic)+ frozen'internal <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ (Data.ProtoLens.Encoding.Growing.unsafeFreeze+ mutable'internal)+ frozen'specific <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ (Data.ProtoLens.Encoding.Growing.unsafeFreeze+ mutable'specific)+ (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t)+ (Lens.Family2.set+ (Data.ProtoLens.Field.field @"vec'generic") frozen'generic+ (Lens.Family2.set+ (Data.ProtoLens.Field.field @"vec'internal") frozen'internal+ (Lens.Family2.set+ (Data.ProtoLens.Field.field @"vec'specific") frozen'specific+ x))))+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 10+ -> do !y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len)+ Data.ProtoLens.parseMessage)+ "generic"+ v <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ (Data.ProtoLens.Encoding.Growing.append mutable'generic y)+ loop x v mutable'internal mutable'specific+ 16+ -> do !y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (Prelude.fmap+ Prelude.toEnum+ (Prelude.fmap+ Prelude.fromIntegral+ Data.ProtoLens.Encoding.Bytes.getVarInt))+ "specific"+ v <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ (Data.ProtoLens.Encoding.Growing.append mutable'specific y)+ loop x mutable'generic mutable'internal v+ 18+ -> do y <- do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len)+ ((let+ ploop qs+ = do packedEnd <- Data.ProtoLens.Encoding.Bytes.atEnd+ if packedEnd then+ Prelude.return qs+ else+ do !q <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (Prelude.fmap+ Prelude.toEnum+ (Prelude.fmap+ Prelude.fromIntegral+ Data.ProtoLens.Encoding.Bytes.getVarInt))+ "specific"+ qs' <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ (Data.ProtoLens.Encoding.Growing.append+ qs q)+ ploop qs'+ in ploop)+ mutable'specific)+ loop x mutable'generic mutable'internal y+ 26+ -> do !y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len)+ Data.ProtoLens.parseMessage)+ "internal"+ v <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ (Data.ProtoLens.Encoding.Growing.append mutable'internal y)+ loop x mutable'generic v mutable'specific+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ mutable'generic mutable'internal mutable'specific+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do mutable'generic <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ Data.ProtoLens.Encoding.Growing.new+ mutable'internal <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ Data.ProtoLens.Encoding.Growing.new+ mutable'specific <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ Data.ProtoLens.Encoding.Growing.new+ loop+ Data.ProtoLens.defMessage mutable'generic mutable'internal+ mutable'specific)+ "Failure"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.foldMapBuilder+ (\ _v+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 10)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ (Lens.Family2.view (Data.ProtoLens.Field.field @"vec'generic") _x))+ ((Data.Monoid.<>)+ (let+ p = Lens.Family2.view+ (Data.ProtoLens.Field.field @"vec'specific") _x+ in+ if Data.Vector.Generic.null p then+ Data.Monoid.mempty+ else+ (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 18)+ ((\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ (Data.ProtoLens.Encoding.Bytes.runBuilder+ (Data.ProtoLens.Encoding.Bytes.foldMapBuilder+ ((Prelude..)+ ((Prelude..)+ Data.ProtoLens.Encoding.Bytes.putVarInt+ Prelude.fromIntegral)+ Prelude.fromEnum)+ p))))+ ((Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.foldMapBuilder+ (\ _v+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 26)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ (Lens.Family2.view+ (Data.ProtoLens.Field.field @"vec'internal") _x))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x))))+instance Control.DeepSeq.NFData Response'Failure where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_Response'Failure'_unknownFields x__)+ (Control.DeepSeq.deepseq+ (_Response'Failure'generic x__)+ (Control.DeepSeq.deepseq+ (_Response'Failure'specific x__)+ (Control.DeepSeq.deepseq (_Response'Failure'internal x__) ())))+newtype Response'Failure'InputFailure'UnrecognizedValue+ = Response'Failure'InputFailure'UnrecognizedValue Data.Int.Int32+ deriving stock (Prelude.Eq,+ Prelude.Ord,+ Prelude.Show,+ GHC.Generics.Generic)+instance Text.PrettyPrint.GenericPretty.Out Response'Failure'InputFailure'UnrecognizedValue+data Response'Failure'InputFailure+ = Response'Failure'DEFAULT |+ Response'Failure'InputFailure'Unrecognized !Response'Failure'InputFailure'UnrecognizedValue+ deriving stock (Prelude.Show,+ Prelude.Eq,+ Prelude.Ord,+ GHC.Generics.Generic)+instance Data.ProtoLens.MessageEnum Response'Failure'InputFailure where+ maybeToEnum 0 = Prelude.Just Response'Failure'DEFAULT+ maybeToEnum k+ = Prelude.Just+ (Response'Failure'InputFailure'Unrecognized+ (Response'Failure'InputFailure'UnrecognizedValue+ (Prelude.fromIntegral k)))+ showEnum Response'Failure'DEFAULT = "DEFAULT"+ showEnum+ (Response'Failure'InputFailure'Unrecognized (Response'Failure'InputFailure'UnrecognizedValue k))+ = Prelude.show k+ readEnum k+ | (Prelude.==) k "DEFAULT" = Prelude.Just Response'Failure'DEFAULT+ | Prelude.otherwise+ = (Prelude.>>=) (Text.Read.readMaybe k) Data.ProtoLens.maybeToEnum+instance Prelude.Bounded Response'Failure'InputFailure where+ minBound = Response'Failure'DEFAULT+ maxBound = Response'Failure'DEFAULT+instance Prelude.Enum Response'Failure'InputFailure where+ toEnum k__+ = Prelude.maybe+ (Prelude.error+ ((Prelude.++)+ "toEnum: unknown value for enum InputFailure: "+ (Prelude.show k__)))+ Prelude.id (Data.ProtoLens.maybeToEnum k__)+ fromEnum Response'Failure'DEFAULT = 0+ fromEnum+ (Response'Failure'InputFailure'Unrecognized (Response'Failure'InputFailure'UnrecognizedValue k))+ = Prelude.fromIntegral k+ succ Response'Failure'DEFAULT+ = Prelude.error+ "Response'Failure'InputFailure.succ: bad argument Response'Failure'DEFAULT. This value would be out of bounds."+ succ (Response'Failure'InputFailure'Unrecognized _)+ = Prelude.error+ "Response'Failure'InputFailure.succ: bad argument: unrecognized value"+ pred Response'Failure'DEFAULT+ = Prelude.error+ "Response'Failure'InputFailure.pred: bad argument Response'Failure'DEFAULT. This value would be out of bounds."+ pred (Response'Failure'InputFailure'Unrecognized _)+ = Prelude.error+ "Response'Failure'InputFailure.pred: bad argument: unrecognized value"+ enumFrom = Data.ProtoLens.Message.Enum.messageEnumFrom+ enumFromTo = Data.ProtoLens.Message.Enum.messageEnumFromTo+ enumFromThen = Data.ProtoLens.Message.Enum.messageEnumFromThen+ enumFromThenTo = Data.ProtoLens.Message.Enum.messageEnumFromThenTo+instance Data.ProtoLens.FieldDefault Response'Failure'InputFailure where+ fieldDefault = Response'Failure'DEFAULT+instance Control.DeepSeq.NFData Response'Failure'InputFailure where+ rnf x__ = Prelude.seq x__ ()+instance Text.PrettyPrint.GenericPretty.Out Response'Failure'InputFailure+{- | Fields :+ + * 'Proto.BtcLsp.Method.SwapFromLn_Fields.fundLnHodlInvoice' @:: Lens' Response'Success Proto.BtcLsp.Data.HighLevel.FundLnHodlInvoice@+ * 'Proto.BtcLsp.Method.SwapFromLn_Fields.maybe'fundLnHodlInvoice' @:: Lens' Response'Success (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.FundLnHodlInvoice)@ -}+data Response'Success+ = Response'Success'_constructor {_Response'Success'fundLnHodlInvoice :: !(Prelude.Maybe Proto.BtcLsp.Data.HighLevel.FundLnHodlInvoice),+ _Response'Success'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show Response'Success where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out Response'Success+instance Data.ProtoLens.Field.HasField Response'Success "fundLnHodlInvoice" Proto.BtcLsp.Data.HighLevel.FundLnHodlInvoice where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Success'fundLnHodlInvoice+ (\ x__ y__ -> x__ {_Response'Success'fundLnHodlInvoice = y__}))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage)+instance Data.ProtoLens.Field.HasField Response'Success "maybe'fundLnHodlInvoice" (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.FundLnHodlInvoice) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Success'fundLnHodlInvoice+ (\ x__ y__ -> x__ {_Response'Success'fundLnHodlInvoice = y__}))+ Prelude.id+instance Data.ProtoLens.Message Response'Success where+ messageName _+ = Data.Text.pack "BtcLsp.Method.SwapFromLn.Response.Success"+ packedMessageDescriptor _+ = "\n\+ \\aSuccess\DC2Y\n\+ \\DC4fund_ln_hodl_invoice\CAN\SOH \SOH(\v2(.BtcLsp.Data.HighLevel.FundLnHodlInvoiceR\DC1fundLnHodlInvoice"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ fundLnHodlInvoice__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "fund_ln_hodl_invoice"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.HighLevel.FundLnHodlInvoice)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'fundLnHodlInvoice")) ::+ Data.ProtoLens.FieldDescriptor Response'Success+ in+ Data.Map.fromList+ [(Data.ProtoLens.Tag 1, fundLnHodlInvoice__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _Response'Success'_unknownFields+ (\ x__ y__ -> x__ {_Response'Success'_unknownFields = y__})+ defMessage+ = Response'Success'_constructor+ {_Response'Success'fundLnHodlInvoice = Prelude.Nothing,+ _Response'Success'_unknownFields = []}+ parseMessage+ = let+ loop ::+ Response'Success+ -> Data.ProtoLens.Encoding.Bytes.Parser Response'Success+ loop x+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) x)+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 10+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "fund_ln_hodl_invoice"+ loop+ (Lens.Family2.set+ (Data.ProtoLens.Field.field @"fundLnHodlInvoice") y x)+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do loop Data.ProtoLens.defMessage) "Success"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (case+ Lens.Family2.view+ (Data.ProtoLens.Field.field @"maybe'fundLnHodlInvoice") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just _v)+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 10)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x))+instance Control.DeepSeq.NFData Response'Success where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_Response'Success'_unknownFields x__)+ (Control.DeepSeq.deepseq+ (_Response'Success'fundLnHodlInvoice x__) ())+packedFileDescriptor :: Data.ByteString.ByteString+packedFileDescriptor+ = "\n\+ \!btc_lsp/method/swap_from_ln.proto\DC2\CANBtcLsp.Method.SwapFromLn\SUB\GSbtc_lsp/data/high_level.proto\"\214\SOH\n\+ \\aRequest\DC2,\n\+ \\ETXctx\CAN\SOH \SOH(\v2\SUB.BtcLsp.Data.HighLevel.CtxR\ETXctx\DC2?\n\+ \\n\+ \fund_money\CAN\STX \SOH(\v2 .BtcLsp.Data.HighLevel.FundMoneyR\tfundMoney\DC2\\\n\+ \\NAKfund_on_chain_address\CAN\ETX \SOH(\v2).BtcLsp.Data.HighLevel.FundOnChainAddressR\DC2fundOnChainAddress\"\185\EOT\n\+ \\bResponse\DC2,\n\+ \\ETXctx\CAN\SOH \SOH(\v2\SUB.BtcLsp.Data.HighLevel.CtxR\ETXctx\DC2F\n\+ \\asuccess\CAN\STX \SOH(\v2*.BtcLsp.Method.SwapFromLn.Response.SuccessH\NULR\asuccess\DC2F\n\+ \\afailure\CAN\ETX \SOH(\v2*.BtcLsp.Method.SwapFromLn.Response.FailureH\NULR\afailure\SUBd\n\+ \\aSuccess\DC2Y\n\+ \\DC4fund_ln_hodl_invoice\CAN\SOH \SOH(\v2(.BtcLsp.Data.HighLevel.FundLnHodlInvoiceR\DC1fundLnHodlInvoice\SUB\254\SOH\n\+ \\aFailure\DC2=\n\+ \\ageneric\CAN\SOH \ETX(\v2#.BtcLsp.Data.HighLevel.InputFailureR\ageneric\DC2S\n\+ \\bspecific\CAN\STX \ETX(\SO27.BtcLsp.Method.SwapFromLn.Response.Failure.InputFailureR\bspecific\DC2B\n\+ \\binternal\CAN\ETX \ETX(\v2&.BtcLsp.Data.HighLevel.InternalFailureR\binternal\"\ESC\n\+ \\fInputFailure\DC2\v\n\+ \\aDEFAULT\DLE\NULB\b\n\+ \\ACKeitherJ\246\ACK\n\+ \\ACK\DC2\EOT\NUL\NUL!\SOH\n\+ \\b\n\+ \\SOH\f\DC2\ETX\NUL\NUL\DLE\n\+ \\b\n\+ \\SOH\STX\DC2\ETX\STX\NUL!\n\+ \\t\n\+ \\STX\ETX\NUL\DC2\ETX\EOT\NUL'\n\+ \\n\+ \\n\+ \\STX\EOT\NUL\DC2\EOT\ACK\NUL\n\+ \\SOH\n\+ \\n\+ \\n\+ \\ETX\EOT\NUL\SOH\DC2\ETX\ACK\b\SI\n\+ \\v\n\+ \\EOT\EOT\NUL\STX\NUL\DC2\ETX\a\STX%\n\+ \\f\n\+ \\ENQ\EOT\NUL\STX\NUL\ACK\DC2\ETX\a\STX\FS\n\+ \\f\n\+ \\ENQ\EOT\NUL\STX\NUL\SOH\DC2\ETX\a\GS \n\+ \\f\n\+ \\ENQ\EOT\NUL\STX\NUL\ETX\DC2\ETX\a#$\n\+ \\v\n\+ \\EOT\EOT\NUL\STX\SOH\DC2\ETX\b\STX2\n\+ \\f\n\+ \\ENQ\EOT\NUL\STX\SOH\ACK\DC2\ETX\b\STX\"\n\+ \\f\n\+ \\ENQ\EOT\NUL\STX\SOH\SOH\DC2\ETX\b#-\n\+ \\f\n\+ \\ENQ\EOT\NUL\STX\SOH\ETX\DC2\ETX\b01\n\+ \\v\n\+ \\EOT\EOT\NUL\STX\STX\DC2\ETX\t\STXF\n\+ \\f\n\+ \\ENQ\EOT\NUL\STX\STX\ACK\DC2\ETX\t\STX+\n\+ \\f\n\+ \\ENQ\EOT\NUL\STX\STX\SOH\DC2\ETX\t,A\n\+ \\f\n\+ \\ENQ\EOT\NUL\STX\STX\ETX\DC2\ETX\tDE\n\+ \\n\+ \\n\+ \\STX\EOT\SOH\DC2\EOT\f\NUL!\SOH\n\+ \\n\+ \\n\+ \\ETX\EOT\SOH\SOH\DC2\ETX\f\b\DLE\n\+ \\v\n\+ \\EOT\EOT\SOH\STX\NUL\DC2\ETX\r\STX%\n\+ \\f\n\+ \\ENQ\EOT\SOH\STX\NUL\ACK\DC2\ETX\r\STX\FS\n\+ \\f\n\+ \\ENQ\EOT\SOH\STX\NUL\SOH\DC2\ETX\r\GS \n\+ \\f\n\+ \\ENQ\EOT\SOH\STX\NUL\ETX\DC2\ETX\r#$\n\+ \\f\n\+ \\EOT\EOT\SOH\b\NUL\DC2\EOT\SI\STX\DC2\ETX\n\+ \\f\n\+ \\ENQ\EOT\SOH\b\NUL\SOH\DC2\ETX\SI\b\SO\n\+ \\v\n\+ \\EOT\EOT\SOH\STX\SOH\DC2\ETX\DLE\EOT\CAN\n\+ \\f\n\+ \\ENQ\EOT\SOH\STX\SOH\ACK\DC2\ETX\DLE\EOT\v\n\+ \\f\n\+ \\ENQ\EOT\SOH\STX\SOH\SOH\DC2\ETX\DLE\f\DC3\n\+ \\f\n\+ \\ENQ\EOT\SOH\STX\SOH\ETX\DC2\ETX\DLE\SYN\ETB\n\+ \\v\n\+ \\EOT\EOT\SOH\STX\STX\DC2\ETX\DC1\EOT\CAN\n\+ \\f\n\+ \\ENQ\EOT\SOH\STX\STX\ACK\DC2\ETX\DC1\EOT\v\n\+ \\f\n\+ \\ENQ\EOT\SOH\STX\STX\SOH\DC2\ETX\DC1\f\DC3\n\+ \\f\n\+ \\ENQ\EOT\SOH\STX\STX\ETX\DC2\ETX\DC1\SYN\ETB\n\+ \\f\n\+ \\EOT\EOT\SOH\ETX\NUL\DC2\EOT\DC4\STX\SYN\ETX\n\+ \\f\n\+ \\ENQ\EOT\SOH\ETX\NUL\SOH\DC2\ETX\DC4\n\+ \\DC1\n\+ \\r\n\+ \\ACK\EOT\SOH\ETX\NUL\STX\NUL\DC2\ETX\NAK\EOTF\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\NUL\STX\NUL\ACK\DC2\ETX\NAK\EOT,\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\NUL\STX\NUL\SOH\DC2\ETX\NAK-A\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\NUL\STX\NUL\ETX\DC2\ETX\NAKDE\n\+ \\f\n\+ \\EOT\EOT\SOH\ETX\SOH\DC2\EOT\CAN\STX \ETX\n\+ \\f\n\+ \\ENQ\EOT\SOH\ETX\SOH\SOH\DC2\ETX\CAN\n\+ \\DC1\n\+ \\r\n\+ \\ACK\EOT\SOH\ETX\SOH\STX\NUL\DC2\ETX\EM\EOT=\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\NUL\EOT\DC2\ETX\EM\EOT\f\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\NUL\ACK\DC2\ETX\EM\r0\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\NUL\SOH\DC2\ETX\EM18\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\NUL\ETX\DC2\ETX\EM;<\n\+ \\r\n\+ \\ACK\EOT\SOH\ETX\SOH\STX\SOH\DC2\ETX\SUB\EOT'\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\SOH\EOT\DC2\ETX\SUB\EOT\f\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\SOH\ACK\DC2\ETX\SUB\r\EM\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\SOH\SOH\DC2\ETX\SUB\SUB\"\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\SOH\ETX\DC2\ETX\SUB%&\n\+ \\r\n\+ \\ACK\EOT\SOH\ETX\SOH\STX\STX\DC2\ETX\ESC\EOTA\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\STX\EOT\DC2\ETX\ESC\EOT\f\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\STX\ACK\DC2\ETX\ESC\r3\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\STX\SOH\DC2\ETX\ESC4<\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\STX\ETX\DC2\ETX\ESC?@\n\+ \\SO\n\+ \\ACK\EOT\SOH\ETX\SOH\EOT\NUL\DC2\EOT\GS\EOT\US\ENQ\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\EOT\NUL\SOH\DC2\ETX\GS\t\NAK\n\+ \\SI\n\+ \\b\EOT\SOH\ETX\SOH\EOT\NUL\STX\NUL\DC2\ETX\RS\ACK\DC2\n\+ \\DLE\n\+ \\t\EOT\SOH\ETX\SOH\EOT\NUL\STX\NUL\SOH\DC2\ETX\RS\ACK\r\n\+ \\DLE\n\+ \\t\EOT\SOH\ETX\SOH\EOT\NUL\STX\NUL\STX\DC2\ETX\RS\DLE\DC1b\ACKproto3"
@@ -0,0 +1,143 @@+{- This file was auto-generated from btc_lsp/method/swap_from_ln.proto by the proto-lens-protoc program. -}+{-# LANGUAGE ScopedTypeVariables, DataKinds, TypeFamilies, UndecidableInstances, GeneralizedNewtypeDeriving, MultiParamTypeClasses, FlexibleContexts, FlexibleInstances, PatternSynonyms, MagicHash, NoImplicitPrelude, BangPatterns, TypeApplications, OverloadedStrings, DerivingStrategies, DeriveGeneric#-}+{-# OPTIONS_GHC -Wno-unused-imports#-}+{-# OPTIONS_GHC -Wno-duplicate-exports#-}+{-# OPTIONS_GHC -Wno-dodgy-exports#-}+module Proto.BtcLsp.Method.SwapFromLn_Fields where+import qualified Data.ProtoLens.Runtime.Prelude as Prelude+import qualified Data.ProtoLens.Runtime.Data.Int as Data.Int+import qualified Data.ProtoLens.Runtime.Data.Monoid as Data.Monoid+import qualified Data.ProtoLens.Runtime.Data.Word as Data.Word+import qualified Data.ProtoLens.Runtime.Data.ProtoLens as Data.ProtoLens+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Bytes as Data.ProtoLens.Encoding.Bytes+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Growing as Data.ProtoLens.Encoding.Growing+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Parser.Unsafe as Data.ProtoLens.Encoding.Parser.Unsafe+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Wire as Data.ProtoLens.Encoding.Wire+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Field as Data.ProtoLens.Field+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Message.Enum as Data.ProtoLens.Message.Enum+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Service.Types as Data.ProtoLens.Service.Types+import qualified Data.ProtoLens.Runtime.Lens.Family2 as Lens.Family2+import qualified Data.ProtoLens.Runtime.Lens.Family2.Unchecked as Lens.Family2.Unchecked+import qualified Data.ProtoLens.Runtime.Data.Text as Data.Text+import qualified Data.ProtoLens.Runtime.Data.Map as Data.Map+import qualified Data.ProtoLens.Runtime.Data.ByteString as Data.ByteString+import qualified Data.ProtoLens.Runtime.Data.ByteString.Char8 as Data.ByteString.Char8+import qualified Data.ProtoLens.Runtime.Data.Text.Encoding as Data.Text.Encoding+import qualified Data.ProtoLens.Runtime.Data.Vector as Data.Vector+import qualified Data.ProtoLens.Runtime.Data.Vector.Generic as Data.Vector.Generic+import qualified Data.ProtoLens.Runtime.Data.Vector.Unboxed as Data.Vector.Unboxed+import qualified Data.ProtoLens.Runtime.Text.Read as Text.Read+import qualified Proto.BtcLsp.Data.HighLevel+ctx ::+ forall f s a.+ (Prelude.Functor f, Data.ProtoLens.Field.HasField s "ctx" a) =>+ Lens.Family2.LensLike' f s a+ctx = Data.ProtoLens.Field.field @"ctx"+failure ::+ forall f s a.+ (Prelude.Functor f, Data.ProtoLens.Field.HasField s "failure" a) =>+ Lens.Family2.LensLike' f s a+failure = Data.ProtoLens.Field.field @"failure"+fundLnHodlInvoice ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "fundLnHodlInvoice" a) =>+ Lens.Family2.LensLike' f s a+fundLnHodlInvoice = Data.ProtoLens.Field.field @"fundLnHodlInvoice"+fundMoney ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "fundMoney" a) =>+ Lens.Family2.LensLike' f s a+fundMoney = Data.ProtoLens.Field.field @"fundMoney"+fundOnChainAddress ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "fundOnChainAddress" a) =>+ Lens.Family2.LensLike' f s a+fundOnChainAddress+ = Data.ProtoLens.Field.field @"fundOnChainAddress"+generic ::+ forall f s a.+ (Prelude.Functor f, Data.ProtoLens.Field.HasField s "generic" a) =>+ Lens.Family2.LensLike' f s a+generic = Data.ProtoLens.Field.field @"generic"+internal ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "internal" a) =>+ Lens.Family2.LensLike' f s a+internal = Data.ProtoLens.Field.field @"internal"+maybe'ctx ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "maybe'ctx" a) =>+ Lens.Family2.LensLike' f s a+maybe'ctx = Data.ProtoLens.Field.field @"maybe'ctx"+maybe'either ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "maybe'either" a) =>+ Lens.Family2.LensLike' f s a+maybe'either = Data.ProtoLens.Field.field @"maybe'either"+maybe'failure ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "maybe'failure" a) =>+ Lens.Family2.LensLike' f s a+maybe'failure = Data.ProtoLens.Field.field @"maybe'failure"+maybe'fundLnHodlInvoice ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "maybe'fundLnHodlInvoice" a) =>+ Lens.Family2.LensLike' f s a+maybe'fundLnHodlInvoice+ = Data.ProtoLens.Field.field @"maybe'fundLnHodlInvoice"+maybe'fundMoney ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "maybe'fundMoney" a) =>+ Lens.Family2.LensLike' f s a+maybe'fundMoney = Data.ProtoLens.Field.field @"maybe'fundMoney"+maybe'fundOnChainAddress ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "maybe'fundOnChainAddress" a) =>+ Lens.Family2.LensLike' f s a+maybe'fundOnChainAddress+ = Data.ProtoLens.Field.field @"maybe'fundOnChainAddress"+maybe'success ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "maybe'success" a) =>+ Lens.Family2.LensLike' f s a+maybe'success = Data.ProtoLens.Field.field @"maybe'success"+specific ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "specific" a) =>+ Lens.Family2.LensLike' f s a+specific = Data.ProtoLens.Field.field @"specific"+success ::+ forall f s a.+ (Prelude.Functor f, Data.ProtoLens.Field.HasField s "success" a) =>+ Lens.Family2.LensLike' f s a+success = Data.ProtoLens.Field.field @"success"+vec'generic ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "vec'generic" a) =>+ Lens.Family2.LensLike' f s a+vec'generic = Data.ProtoLens.Field.field @"vec'generic"+vec'internal ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "vec'internal" a) =>+ Lens.Family2.LensLike' f s a+vec'internal = Data.ProtoLens.Field.field @"vec'internal"+vec'specific ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "vec'specific" a) =>+ Lens.Family2.LensLike' f s a+vec'specific = Data.ProtoLens.Field.field @"vec'specific"
@@ -0,0 +1,1305 @@+{- This file was auto-generated from btc_lsp/method/swap_into_ln.proto by the proto-lens-protoc program. -}+{-# LANGUAGE ScopedTypeVariables, DataKinds, TypeFamilies, UndecidableInstances, GeneralizedNewtypeDeriving, MultiParamTypeClasses, FlexibleContexts, FlexibleInstances, PatternSynonyms, MagicHash, NoImplicitPrelude, BangPatterns, TypeApplications, OverloadedStrings, DerivingStrategies, DeriveGeneric#-}+{-# OPTIONS_GHC -Wno-unused-imports#-}+{-# OPTIONS_GHC -Wno-duplicate-exports#-}+{-# OPTIONS_GHC -Wno-dodgy-exports#-}+module Proto.BtcLsp.Method.SwapIntoLn (+ Request(), Response(), Response'Either(..), _Response'Success',+ _Response'Failure', Response'Failure(),+ Response'Failure'InputFailure(..), Response'Failure'InputFailure(),+ Response'Failure'InputFailure'UnrecognizedValue, Response'Success()+ ) where+import qualified Data.ProtoLens.Runtime.Control.DeepSeq as Control.DeepSeq+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Prism as Data.ProtoLens.Prism+import qualified Text.PrettyPrint.GenericPretty.Instance+import qualified GHC.Generics+import qualified Text.PrettyPrint.GenericPretty+import qualified Data.ProtoLens.Runtime.Prelude as Prelude+import qualified Data.ProtoLens.Runtime.Data.Int as Data.Int+import qualified Data.ProtoLens.Runtime.Data.Monoid as Data.Monoid+import qualified Data.ProtoLens.Runtime.Data.Word as Data.Word+import qualified Data.ProtoLens.Runtime.Data.ProtoLens as Data.ProtoLens+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Bytes as Data.ProtoLens.Encoding.Bytes+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Growing as Data.ProtoLens.Encoding.Growing+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Parser.Unsafe as Data.ProtoLens.Encoding.Parser.Unsafe+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Wire as Data.ProtoLens.Encoding.Wire+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Field as Data.ProtoLens.Field+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Message.Enum as Data.ProtoLens.Message.Enum+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Service.Types as Data.ProtoLens.Service.Types+import qualified Data.ProtoLens.Runtime.Lens.Family2 as Lens.Family2+import qualified Data.ProtoLens.Runtime.Lens.Family2.Unchecked as Lens.Family2.Unchecked+import qualified Data.ProtoLens.Runtime.Data.Text as Data.Text+import qualified Data.ProtoLens.Runtime.Data.Map as Data.Map+import qualified Data.ProtoLens.Runtime.Data.ByteString as Data.ByteString+import qualified Data.ProtoLens.Runtime.Data.ByteString.Char8 as Data.ByteString.Char8+import qualified Data.ProtoLens.Runtime.Data.Text.Encoding as Data.Text.Encoding+import qualified Data.ProtoLens.Runtime.Data.Vector as Data.Vector+import qualified Data.ProtoLens.Runtime.Data.Vector.Generic as Data.Vector.Generic+import qualified Data.ProtoLens.Runtime.Data.Vector.Unboxed as Data.Vector.Unboxed+import qualified Data.ProtoLens.Runtime.Text.Read as Text.Read+import qualified Proto.BtcLsp.Data.HighLevel+{- | Fields :+ + * 'Proto.BtcLsp.Method.SwapIntoLn_Fields.ctx' @:: Lens' Request Proto.BtcLsp.Data.HighLevel.Ctx@+ * 'Proto.BtcLsp.Method.SwapIntoLn_Fields.maybe'ctx' @:: Lens' Request (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.Ctx)@+ * 'Proto.BtcLsp.Method.SwapIntoLn_Fields.refundOnChainAddress' @:: Lens' Request Proto.BtcLsp.Data.HighLevel.RefundOnChainAddress@+ * 'Proto.BtcLsp.Method.SwapIntoLn_Fields.maybe'refundOnChainAddress' @:: Lens' Request (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.RefundOnChainAddress)@+ * 'Proto.BtcLsp.Method.SwapIntoLn_Fields.privacy' @:: Lens' Request Proto.BtcLsp.Data.HighLevel.Privacy@ -}+data Request+ = Request'_constructor {_Request'ctx :: !(Prelude.Maybe Proto.BtcLsp.Data.HighLevel.Ctx),+ _Request'refundOnChainAddress :: !(Prelude.Maybe Proto.BtcLsp.Data.HighLevel.RefundOnChainAddress),+ _Request'privacy :: !Proto.BtcLsp.Data.HighLevel.Privacy,+ _Request'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show Request where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out Request+instance Data.ProtoLens.Field.HasField Request "ctx" Proto.BtcLsp.Data.HighLevel.Ctx where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Request'ctx (\ x__ y__ -> x__ {_Request'ctx = y__}))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage)+instance Data.ProtoLens.Field.HasField Request "maybe'ctx" (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.Ctx) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Request'ctx (\ x__ y__ -> x__ {_Request'ctx = y__}))+ Prelude.id+instance Data.ProtoLens.Field.HasField Request "refundOnChainAddress" Proto.BtcLsp.Data.HighLevel.RefundOnChainAddress where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Request'refundOnChainAddress+ (\ x__ y__ -> x__ {_Request'refundOnChainAddress = y__}))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage)+instance Data.ProtoLens.Field.HasField Request "maybe'refundOnChainAddress" (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.RefundOnChainAddress) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Request'refundOnChainAddress+ (\ x__ y__ -> x__ {_Request'refundOnChainAddress = y__}))+ Prelude.id+instance Data.ProtoLens.Field.HasField Request "privacy" Proto.BtcLsp.Data.HighLevel.Privacy where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Request'privacy (\ x__ y__ -> x__ {_Request'privacy = y__}))+ Prelude.id+instance Data.ProtoLens.Message Request where+ messageName _ = Data.Text.pack "BtcLsp.Method.SwapIntoLn.Request"+ packedMessageDescriptor _+ = "\n\+ \\aRequest\DC2,\n\+ \\ETXctx\CAN\SOH \SOH(\v2\SUB.BtcLsp.Data.HighLevel.CtxR\ETXctx\DC2b\n\+ \\ETBrefund_on_chain_address\CAN\ETX \SOH(\v2+.BtcLsp.Data.HighLevel.RefundOnChainAddressR\DC4refundOnChainAddress\DC28\n\+ \\aprivacy\CAN\EOT \SOH(\SO2\RS.BtcLsp.Data.HighLevel.PrivacyR\aprivacy"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ ctx__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "ctx"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.HighLevel.Ctx)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'ctx")) ::+ Data.ProtoLens.FieldDescriptor Request+ refundOnChainAddress__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "refund_on_chain_address"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.HighLevel.RefundOnChainAddress)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'refundOnChainAddress")) ::+ Data.ProtoLens.FieldDescriptor Request+ privacy__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "privacy"+ (Data.ProtoLens.ScalarField Data.ProtoLens.EnumField ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.HighLevel.Privacy)+ (Data.ProtoLens.PlainField+ Data.ProtoLens.Optional (Data.ProtoLens.Field.field @"privacy")) ::+ Data.ProtoLens.FieldDescriptor Request+ in+ Data.Map.fromList+ [(Data.ProtoLens.Tag 1, ctx__field_descriptor),+ (Data.ProtoLens.Tag 3, refundOnChainAddress__field_descriptor),+ (Data.ProtoLens.Tag 4, privacy__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _Request'_unknownFields+ (\ x__ y__ -> x__ {_Request'_unknownFields = y__})+ defMessage+ = Request'_constructor+ {_Request'ctx = Prelude.Nothing,+ _Request'refundOnChainAddress = Prelude.Nothing,+ _Request'privacy = Data.ProtoLens.fieldDefault,+ _Request'_unknownFields = []}+ parseMessage+ = let+ loop :: Request -> Data.ProtoLens.Encoding.Bytes.Parser Request+ loop x+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) x)+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 10+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "ctx"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"ctx") y x)+ 26+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "refund_on_chain_address"+ loop+ (Lens.Family2.set+ (Data.ProtoLens.Field.field @"refundOnChainAddress") y x)+ 32+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (Prelude.fmap+ Prelude.toEnum+ (Prelude.fmap+ Prelude.fromIntegral+ Data.ProtoLens.Encoding.Bytes.getVarInt))+ "privacy"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"privacy") y x)+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do loop Data.ProtoLens.defMessage) "Request"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (case+ Lens.Family2.view (Data.ProtoLens.Field.field @"maybe'ctx") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just _v)+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 10)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ ((Data.Monoid.<>)+ (case+ Lens.Family2.view+ (Data.ProtoLens.Field.field @"maybe'refundOnChainAddress") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just _v)+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 26)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ ((Data.Monoid.<>)+ (let+ _v = Lens.Family2.view (Data.ProtoLens.Field.field @"privacy") _x+ in+ if (Prelude.==) _v Data.ProtoLens.fieldDefault then+ Data.Monoid.mempty+ else+ (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 32)+ ((Prelude..)+ ((Prelude..)+ Data.ProtoLens.Encoding.Bytes.putVarInt Prelude.fromIntegral)+ Prelude.fromEnum _v))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x))))+instance Control.DeepSeq.NFData Request where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_Request'_unknownFields x__)+ (Control.DeepSeq.deepseq+ (_Request'ctx x__)+ (Control.DeepSeq.deepseq+ (_Request'refundOnChainAddress x__)+ (Control.DeepSeq.deepseq (_Request'privacy x__) ())))+{- | Fields :+ + * 'Proto.BtcLsp.Method.SwapIntoLn_Fields.ctx' @:: Lens' Response Proto.BtcLsp.Data.HighLevel.Ctx@+ * 'Proto.BtcLsp.Method.SwapIntoLn_Fields.maybe'ctx' @:: Lens' Response (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.Ctx)@+ * 'Proto.BtcLsp.Method.SwapIntoLn_Fields.maybe'either' @:: Lens' Response (Prelude.Maybe Response'Either)@+ * 'Proto.BtcLsp.Method.SwapIntoLn_Fields.maybe'success' @:: Lens' Response (Prelude.Maybe Response'Success)@+ * 'Proto.BtcLsp.Method.SwapIntoLn_Fields.success' @:: Lens' Response Response'Success@+ * 'Proto.BtcLsp.Method.SwapIntoLn_Fields.maybe'failure' @:: Lens' Response (Prelude.Maybe Response'Failure)@+ * 'Proto.BtcLsp.Method.SwapIntoLn_Fields.failure' @:: Lens' Response Response'Failure@ -}+data Response+ = Response'_constructor {_Response'ctx :: !(Prelude.Maybe Proto.BtcLsp.Data.HighLevel.Ctx),+ _Response'either :: !(Prelude.Maybe Response'Either),+ _Response'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show Response where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out Response+data Response'Either+ = Response'Success' !Response'Success |+ Response'Failure' !Response'Failure+ deriving stock (Prelude.Show,+ Prelude.Eq,+ Prelude.Ord,+ GHC.Generics.Generic)+instance Text.PrettyPrint.GenericPretty.Out Response'Either+instance Data.ProtoLens.Field.HasField Response "ctx" Proto.BtcLsp.Data.HighLevel.Ctx where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'ctx (\ x__ y__ -> x__ {_Response'ctx = y__}))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage)+instance Data.ProtoLens.Field.HasField Response "maybe'ctx" (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.Ctx) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'ctx (\ x__ y__ -> x__ {_Response'ctx = y__}))+ Prelude.id+instance Data.ProtoLens.Field.HasField Response "maybe'either" (Prelude.Maybe Response'Either) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'either (\ x__ y__ -> x__ {_Response'either = y__}))+ Prelude.id+instance Data.ProtoLens.Field.HasField Response "maybe'success" (Prelude.Maybe Response'Success) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'either (\ x__ y__ -> x__ {_Response'either = y__}))+ (Lens.Family2.Unchecked.lens+ (\ x__+ -> case x__ of+ (Prelude.Just (Response'Success' x__val)) -> Prelude.Just x__val+ _otherwise -> Prelude.Nothing)+ (\ _ y__ -> Prelude.fmap Response'Success' y__))+instance Data.ProtoLens.Field.HasField Response "success" Response'Success where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'either (\ x__ y__ -> x__ {_Response'either = y__}))+ ((Prelude..)+ (Lens.Family2.Unchecked.lens+ (\ x__+ -> case x__ of+ (Prelude.Just (Response'Success' x__val)) -> Prelude.Just x__val+ _otherwise -> Prelude.Nothing)+ (\ _ y__ -> Prelude.fmap Response'Success' y__))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage))+instance Data.ProtoLens.Field.HasField Response "maybe'failure" (Prelude.Maybe Response'Failure) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'either (\ x__ y__ -> x__ {_Response'either = y__}))+ (Lens.Family2.Unchecked.lens+ (\ x__+ -> case x__ of+ (Prelude.Just (Response'Failure' x__val)) -> Prelude.Just x__val+ _otherwise -> Prelude.Nothing)+ (\ _ y__ -> Prelude.fmap Response'Failure' y__))+instance Data.ProtoLens.Field.HasField Response "failure" Response'Failure where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'either (\ x__ y__ -> x__ {_Response'either = y__}))+ ((Prelude..)+ (Lens.Family2.Unchecked.lens+ (\ x__+ -> case x__ of+ (Prelude.Just (Response'Failure' x__val)) -> Prelude.Just x__val+ _otherwise -> Prelude.Nothing)+ (\ _ y__ -> Prelude.fmap Response'Failure' y__))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage))+instance Data.ProtoLens.Message Response where+ messageName _ = Data.Text.pack "BtcLsp.Method.SwapIntoLn.Response"+ packedMessageDescriptor _+ = "\n\+ \\bResponse\DC2,\n\+ \\ETXctx\CAN\SOH \SOH(\v2\SUB.BtcLsp.Data.HighLevel.CtxR\ETXctx\DC2F\n\+ \\asuccess\CAN\STX \SOH(\v2*.BtcLsp.Method.SwapIntoLn.Response.SuccessH\NULR\asuccess\DC2F\n\+ \\afailure\CAN\ETX \SOH(\v2*.BtcLsp.Method.SwapIntoLn.Response.FailureH\NULR\afailure\SUB\175\SOH\n\+ \\aSuccess\DC2\\\n\+ \\NAKfund_on_chain_address\CAN\SOH \SOH(\v2).BtcLsp.Data.HighLevel.FundOnChainAddressR\DC2fundOnChainAddress\DC2F\n\+ \\SOmin_fund_money\CAN\STX \SOH(\v2 .BtcLsp.Data.HighLevel.FundMoneyR\fminFundMoney\SUB\211\STX\n\+ \\aFailure\DC2=\n\+ \\ageneric\CAN\SOH \ETX(\v2#.BtcLsp.Data.HighLevel.InputFailureR\ageneric\DC2S\n\+ \\bspecific\CAN\STX \ETX(\SO27.BtcLsp.Method.SwapIntoLn.Response.Failure.InputFailureR\bspecific\DC2B\n\+ \\binternal\CAN\ETX \ETX(\v2&.BtcLsp.Data.HighLevel.InternalFailureR\binternal\"p\n\+ \\fInputFailure\DC2\v\n\+ \\aDEFAULT\DLE\NUL\DC2(\n\+ \$REFUND_ON_CHAIN_ADDRESS_IS_NOT_VALID\DLE\ETX\DC2)\n\+ \%REFUND_ON_CHAIN_ADDRESS_IS_NOT_SEGWIT\DLE\EOTB\b\n\+ \\ACKeither"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ ctx__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "ctx"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.HighLevel.Ctx)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'ctx")) ::+ Data.ProtoLens.FieldDescriptor Response+ success__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "success"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Response'Success)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'success")) ::+ Data.ProtoLens.FieldDescriptor Response+ failure__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "failure"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Response'Failure)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'failure")) ::+ Data.ProtoLens.FieldDescriptor Response+ in+ Data.Map.fromList+ [(Data.ProtoLens.Tag 1, ctx__field_descriptor),+ (Data.ProtoLens.Tag 2, success__field_descriptor),+ (Data.ProtoLens.Tag 3, failure__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _Response'_unknownFields+ (\ x__ y__ -> x__ {_Response'_unknownFields = y__})+ defMessage+ = Response'_constructor+ {_Response'ctx = Prelude.Nothing,+ _Response'either = Prelude.Nothing, _Response'_unknownFields = []}+ parseMessage+ = let+ loop :: Response -> Data.ProtoLens.Encoding.Bytes.Parser Response+ loop x+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) x)+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 10+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "ctx"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"ctx") y x)+ 18+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "success"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"success") y x)+ 26+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "failure"+ loop (Lens.Family2.set (Data.ProtoLens.Field.field @"failure") y x)+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do loop Data.ProtoLens.defMessage) "Response"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (case+ Lens.Family2.view (Data.ProtoLens.Field.field @"maybe'ctx") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just _v)+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 10)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ ((Data.Monoid.<>)+ (case+ Lens.Family2.view (Data.ProtoLens.Field.field @"maybe'either") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just (Response'Success' v))+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 18)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage v)+ (Prelude.Just (Response'Failure' v))+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 26)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage v))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x)))+instance Control.DeepSeq.NFData Response where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_Response'_unknownFields x__)+ (Control.DeepSeq.deepseq+ (_Response'ctx x__)+ (Control.DeepSeq.deepseq (_Response'either x__) ()))+instance Control.DeepSeq.NFData Response'Either where+ rnf (Response'Success' x__) = Control.DeepSeq.rnf x__+ rnf (Response'Failure' x__) = Control.DeepSeq.rnf x__+_Response'Success' ::+ Data.ProtoLens.Prism.Prism' Response'Either Response'Success+_Response'Success'+ = Data.ProtoLens.Prism.prism'+ Response'Success'+ (\ p__+ -> case p__ of+ (Response'Success' p__val) -> Prelude.Just p__val+ _otherwise -> Prelude.Nothing)+_Response'Failure' ::+ Data.ProtoLens.Prism.Prism' Response'Either Response'Failure+_Response'Failure'+ = Data.ProtoLens.Prism.prism'+ Response'Failure'+ (\ p__+ -> case p__ of+ (Response'Failure' p__val) -> Prelude.Just p__val+ _otherwise -> Prelude.Nothing)+{- | Fields :+ + * 'Proto.BtcLsp.Method.SwapIntoLn_Fields.generic' @:: Lens' Response'Failure [Proto.BtcLsp.Data.HighLevel.InputFailure]@+ * 'Proto.BtcLsp.Method.SwapIntoLn_Fields.vec'generic' @:: Lens' Response'Failure (Data.Vector.Vector Proto.BtcLsp.Data.HighLevel.InputFailure)@+ * 'Proto.BtcLsp.Method.SwapIntoLn_Fields.specific' @:: Lens' Response'Failure [Response'Failure'InputFailure]@+ * 'Proto.BtcLsp.Method.SwapIntoLn_Fields.vec'specific' @:: Lens' Response'Failure (Data.Vector.Vector Response'Failure'InputFailure)@+ * 'Proto.BtcLsp.Method.SwapIntoLn_Fields.internal' @:: Lens' Response'Failure [Proto.BtcLsp.Data.HighLevel.InternalFailure]@+ * 'Proto.BtcLsp.Method.SwapIntoLn_Fields.vec'internal' @:: Lens' Response'Failure (Data.Vector.Vector Proto.BtcLsp.Data.HighLevel.InternalFailure)@ -}+data Response'Failure+ = Response'Failure'_constructor {_Response'Failure'generic :: !(Data.Vector.Vector Proto.BtcLsp.Data.HighLevel.InputFailure),+ _Response'Failure'specific :: !(Data.Vector.Vector Response'Failure'InputFailure),+ _Response'Failure'internal :: !(Data.Vector.Vector Proto.BtcLsp.Data.HighLevel.InternalFailure),+ _Response'Failure'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show Response'Failure where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out Response'Failure+instance Data.ProtoLens.Field.HasField Response'Failure "generic" [Proto.BtcLsp.Data.HighLevel.InputFailure] where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Failure'generic+ (\ x__ y__ -> x__ {_Response'Failure'generic = y__}))+ (Lens.Family2.Unchecked.lens+ Data.Vector.Generic.toList+ (\ _ y__ -> Data.Vector.Generic.fromList y__))+instance Data.ProtoLens.Field.HasField Response'Failure "vec'generic" (Data.Vector.Vector Proto.BtcLsp.Data.HighLevel.InputFailure) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Failure'generic+ (\ x__ y__ -> x__ {_Response'Failure'generic = y__}))+ Prelude.id+instance Data.ProtoLens.Field.HasField Response'Failure "specific" [Response'Failure'InputFailure] where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Failure'specific+ (\ x__ y__ -> x__ {_Response'Failure'specific = y__}))+ (Lens.Family2.Unchecked.lens+ Data.Vector.Generic.toList+ (\ _ y__ -> Data.Vector.Generic.fromList y__))+instance Data.ProtoLens.Field.HasField Response'Failure "vec'specific" (Data.Vector.Vector Response'Failure'InputFailure) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Failure'specific+ (\ x__ y__ -> x__ {_Response'Failure'specific = y__}))+ Prelude.id+instance Data.ProtoLens.Field.HasField Response'Failure "internal" [Proto.BtcLsp.Data.HighLevel.InternalFailure] where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Failure'internal+ (\ x__ y__ -> x__ {_Response'Failure'internal = y__}))+ (Lens.Family2.Unchecked.lens+ Data.Vector.Generic.toList+ (\ _ y__ -> Data.Vector.Generic.fromList y__))+instance Data.ProtoLens.Field.HasField Response'Failure "vec'internal" (Data.Vector.Vector Proto.BtcLsp.Data.HighLevel.InternalFailure) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Failure'internal+ (\ x__ y__ -> x__ {_Response'Failure'internal = y__}))+ Prelude.id+instance Data.ProtoLens.Message Response'Failure where+ messageName _+ = Data.Text.pack "BtcLsp.Method.SwapIntoLn.Response.Failure"+ packedMessageDescriptor _+ = "\n\+ \\aFailure\DC2=\n\+ \\ageneric\CAN\SOH \ETX(\v2#.BtcLsp.Data.HighLevel.InputFailureR\ageneric\DC2S\n\+ \\bspecific\CAN\STX \ETX(\SO27.BtcLsp.Method.SwapIntoLn.Response.Failure.InputFailureR\bspecific\DC2B\n\+ \\binternal\CAN\ETX \ETX(\v2&.BtcLsp.Data.HighLevel.InternalFailureR\binternal\"p\n\+ \\fInputFailure\DC2\v\n\+ \\aDEFAULT\DLE\NUL\DC2(\n\+ \$REFUND_ON_CHAIN_ADDRESS_IS_NOT_VALID\DLE\ETX\DC2)\n\+ \%REFUND_ON_CHAIN_ADDRESS_IS_NOT_SEGWIT\DLE\EOT"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ generic__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "generic"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.HighLevel.InputFailure)+ (Data.ProtoLens.RepeatedField+ Data.ProtoLens.Unpacked (Data.ProtoLens.Field.field @"generic")) ::+ Data.ProtoLens.FieldDescriptor Response'Failure+ specific__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "specific"+ (Data.ProtoLens.ScalarField Data.ProtoLens.EnumField ::+ Data.ProtoLens.FieldTypeDescriptor Response'Failure'InputFailure)+ (Data.ProtoLens.RepeatedField+ Data.ProtoLens.Packed (Data.ProtoLens.Field.field @"specific")) ::+ Data.ProtoLens.FieldDescriptor Response'Failure+ internal__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "internal"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.HighLevel.InternalFailure)+ (Data.ProtoLens.RepeatedField+ Data.ProtoLens.Unpacked+ (Data.ProtoLens.Field.field @"internal")) ::+ Data.ProtoLens.FieldDescriptor Response'Failure+ in+ Data.Map.fromList+ [(Data.ProtoLens.Tag 1, generic__field_descriptor),+ (Data.ProtoLens.Tag 2, specific__field_descriptor),+ (Data.ProtoLens.Tag 3, internal__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _Response'Failure'_unknownFields+ (\ x__ y__ -> x__ {_Response'Failure'_unknownFields = y__})+ defMessage+ = Response'Failure'_constructor+ {_Response'Failure'generic = Data.Vector.Generic.empty,+ _Response'Failure'specific = Data.Vector.Generic.empty,+ _Response'Failure'internal = Data.Vector.Generic.empty,+ _Response'Failure'_unknownFields = []}+ parseMessage+ = let+ loop ::+ Response'Failure+ -> Data.ProtoLens.Encoding.Growing.Growing Data.Vector.Vector Data.ProtoLens.Encoding.Growing.RealWorld Proto.BtcLsp.Data.HighLevel.InputFailure+ -> Data.ProtoLens.Encoding.Growing.Growing Data.Vector.Vector Data.ProtoLens.Encoding.Growing.RealWorld Proto.BtcLsp.Data.HighLevel.InternalFailure+ -> Data.ProtoLens.Encoding.Growing.Growing Data.Vector.Vector Data.ProtoLens.Encoding.Growing.RealWorld Response'Failure'InputFailure+ -> Data.ProtoLens.Encoding.Bytes.Parser Response'Failure+ loop x mutable'generic mutable'internal mutable'specific+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do frozen'generic <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ (Data.ProtoLens.Encoding.Growing.unsafeFreeze+ mutable'generic)+ frozen'internal <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ (Data.ProtoLens.Encoding.Growing.unsafeFreeze+ mutable'internal)+ frozen'specific <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ (Data.ProtoLens.Encoding.Growing.unsafeFreeze+ mutable'specific)+ (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t)+ (Lens.Family2.set+ (Data.ProtoLens.Field.field @"vec'generic") frozen'generic+ (Lens.Family2.set+ (Data.ProtoLens.Field.field @"vec'internal") frozen'internal+ (Lens.Family2.set+ (Data.ProtoLens.Field.field @"vec'specific") frozen'specific+ x))))+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 10+ -> do !y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len)+ Data.ProtoLens.parseMessage)+ "generic"+ v <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ (Data.ProtoLens.Encoding.Growing.append mutable'generic y)+ loop x v mutable'internal mutable'specific+ 16+ -> do !y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (Prelude.fmap+ Prelude.toEnum+ (Prelude.fmap+ Prelude.fromIntegral+ Data.ProtoLens.Encoding.Bytes.getVarInt))+ "specific"+ v <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ (Data.ProtoLens.Encoding.Growing.append mutable'specific y)+ loop x mutable'generic mutable'internal v+ 18+ -> do y <- do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len)+ ((let+ ploop qs+ = do packedEnd <- Data.ProtoLens.Encoding.Bytes.atEnd+ if packedEnd then+ Prelude.return qs+ else+ do !q <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (Prelude.fmap+ Prelude.toEnum+ (Prelude.fmap+ Prelude.fromIntegral+ Data.ProtoLens.Encoding.Bytes.getVarInt))+ "specific"+ qs' <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ (Data.ProtoLens.Encoding.Growing.append+ qs q)+ ploop qs'+ in ploop)+ mutable'specific)+ loop x mutable'generic mutable'internal y+ 26+ -> do !y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len)+ Data.ProtoLens.parseMessage)+ "internal"+ v <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ (Data.ProtoLens.Encoding.Growing.append mutable'internal y)+ loop x mutable'generic v mutable'specific+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ mutable'generic mutable'internal mutable'specific+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do mutable'generic <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ Data.ProtoLens.Encoding.Growing.new+ mutable'internal <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ Data.ProtoLens.Encoding.Growing.new+ mutable'specific <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO+ Data.ProtoLens.Encoding.Growing.new+ loop+ Data.ProtoLens.defMessage mutable'generic mutable'internal+ mutable'specific)+ "Failure"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.foldMapBuilder+ (\ _v+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 10)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ (Lens.Family2.view (Data.ProtoLens.Field.field @"vec'generic") _x))+ ((Data.Monoid.<>)+ (let+ p = Lens.Family2.view+ (Data.ProtoLens.Field.field @"vec'specific") _x+ in+ if Data.Vector.Generic.null p then+ Data.Monoid.mempty+ else+ (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 18)+ ((\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ (Data.ProtoLens.Encoding.Bytes.runBuilder+ (Data.ProtoLens.Encoding.Bytes.foldMapBuilder+ ((Prelude..)+ ((Prelude..)+ Data.ProtoLens.Encoding.Bytes.putVarInt+ Prelude.fromIntegral)+ Prelude.fromEnum)+ p))))+ ((Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.foldMapBuilder+ (\ _v+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 26)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ (Lens.Family2.view+ (Data.ProtoLens.Field.field @"vec'internal") _x))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x))))+instance Control.DeepSeq.NFData Response'Failure where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_Response'Failure'_unknownFields x__)+ (Control.DeepSeq.deepseq+ (_Response'Failure'generic x__)+ (Control.DeepSeq.deepseq+ (_Response'Failure'specific x__)+ (Control.DeepSeq.deepseq (_Response'Failure'internal x__) ())))+newtype Response'Failure'InputFailure'UnrecognizedValue+ = Response'Failure'InputFailure'UnrecognizedValue Data.Int.Int32+ deriving stock (Prelude.Eq,+ Prelude.Ord,+ Prelude.Show,+ GHC.Generics.Generic)+instance Text.PrettyPrint.GenericPretty.Out Response'Failure'InputFailure'UnrecognizedValue+data Response'Failure'InputFailure+ = Response'Failure'DEFAULT |+ Response'Failure'REFUND_ON_CHAIN_ADDRESS_IS_NOT_VALID |+ Response'Failure'REFUND_ON_CHAIN_ADDRESS_IS_NOT_SEGWIT |+ Response'Failure'InputFailure'Unrecognized !Response'Failure'InputFailure'UnrecognizedValue+ deriving stock (Prelude.Show,+ Prelude.Eq,+ Prelude.Ord,+ GHC.Generics.Generic)+instance Data.ProtoLens.MessageEnum Response'Failure'InputFailure where+ maybeToEnum 0 = Prelude.Just Response'Failure'DEFAULT+ maybeToEnum 3+ = Prelude.Just+ Response'Failure'REFUND_ON_CHAIN_ADDRESS_IS_NOT_VALID+ maybeToEnum 4+ = Prelude.Just+ Response'Failure'REFUND_ON_CHAIN_ADDRESS_IS_NOT_SEGWIT+ maybeToEnum k+ = Prelude.Just+ (Response'Failure'InputFailure'Unrecognized+ (Response'Failure'InputFailure'UnrecognizedValue+ (Prelude.fromIntegral k)))+ showEnum Response'Failure'DEFAULT = "DEFAULT"+ showEnum Response'Failure'REFUND_ON_CHAIN_ADDRESS_IS_NOT_VALID+ = "REFUND_ON_CHAIN_ADDRESS_IS_NOT_VALID"+ showEnum Response'Failure'REFUND_ON_CHAIN_ADDRESS_IS_NOT_SEGWIT+ = "REFUND_ON_CHAIN_ADDRESS_IS_NOT_SEGWIT"+ showEnum+ (Response'Failure'InputFailure'Unrecognized (Response'Failure'InputFailure'UnrecognizedValue k))+ = Prelude.show k+ readEnum k+ | (Prelude.==) k "DEFAULT" = Prelude.Just Response'Failure'DEFAULT+ | (Prelude.==) k "REFUND_ON_CHAIN_ADDRESS_IS_NOT_VALID"+ = Prelude.Just+ Response'Failure'REFUND_ON_CHAIN_ADDRESS_IS_NOT_VALID+ | (Prelude.==) k "REFUND_ON_CHAIN_ADDRESS_IS_NOT_SEGWIT"+ = Prelude.Just+ Response'Failure'REFUND_ON_CHAIN_ADDRESS_IS_NOT_SEGWIT+ | Prelude.otherwise+ = (Prelude.>>=) (Text.Read.readMaybe k) Data.ProtoLens.maybeToEnum+instance Prelude.Bounded Response'Failure'InputFailure where+ minBound = Response'Failure'DEFAULT+ maxBound = Response'Failure'REFUND_ON_CHAIN_ADDRESS_IS_NOT_SEGWIT+instance Prelude.Enum Response'Failure'InputFailure where+ toEnum k__+ = Prelude.maybe+ (Prelude.error+ ((Prelude.++)+ "toEnum: unknown value for enum InputFailure: "+ (Prelude.show k__)))+ Prelude.id (Data.ProtoLens.maybeToEnum k__)+ fromEnum Response'Failure'DEFAULT = 0+ fromEnum Response'Failure'REFUND_ON_CHAIN_ADDRESS_IS_NOT_VALID = 3+ fromEnum Response'Failure'REFUND_ON_CHAIN_ADDRESS_IS_NOT_SEGWIT = 4+ fromEnum+ (Response'Failure'InputFailure'Unrecognized (Response'Failure'InputFailure'UnrecognizedValue k))+ = Prelude.fromIntegral k+ succ Response'Failure'REFUND_ON_CHAIN_ADDRESS_IS_NOT_SEGWIT+ = Prelude.error+ "Response'Failure'InputFailure.succ: bad argument Response'Failure'REFUND_ON_CHAIN_ADDRESS_IS_NOT_SEGWIT. This value would be out of bounds."+ succ Response'Failure'DEFAULT+ = Response'Failure'REFUND_ON_CHAIN_ADDRESS_IS_NOT_VALID+ succ Response'Failure'REFUND_ON_CHAIN_ADDRESS_IS_NOT_VALID+ = Response'Failure'REFUND_ON_CHAIN_ADDRESS_IS_NOT_SEGWIT+ succ (Response'Failure'InputFailure'Unrecognized _)+ = Prelude.error+ "Response'Failure'InputFailure.succ: bad argument: unrecognized value"+ pred Response'Failure'DEFAULT+ = Prelude.error+ "Response'Failure'InputFailure.pred: bad argument Response'Failure'DEFAULT. This value would be out of bounds."+ pred Response'Failure'REFUND_ON_CHAIN_ADDRESS_IS_NOT_VALID+ = Response'Failure'DEFAULT+ pred Response'Failure'REFUND_ON_CHAIN_ADDRESS_IS_NOT_SEGWIT+ = Response'Failure'REFUND_ON_CHAIN_ADDRESS_IS_NOT_VALID+ pred (Response'Failure'InputFailure'Unrecognized _)+ = Prelude.error+ "Response'Failure'InputFailure.pred: bad argument: unrecognized value"+ enumFrom = Data.ProtoLens.Message.Enum.messageEnumFrom+ enumFromTo = Data.ProtoLens.Message.Enum.messageEnumFromTo+ enumFromThen = Data.ProtoLens.Message.Enum.messageEnumFromThen+ enumFromThenTo = Data.ProtoLens.Message.Enum.messageEnumFromThenTo+instance Data.ProtoLens.FieldDefault Response'Failure'InputFailure where+ fieldDefault = Response'Failure'DEFAULT+instance Control.DeepSeq.NFData Response'Failure'InputFailure where+ rnf x__ = Prelude.seq x__ ()+instance Text.PrettyPrint.GenericPretty.Out Response'Failure'InputFailure+{- | Fields :+ + * 'Proto.BtcLsp.Method.SwapIntoLn_Fields.fundOnChainAddress' @:: Lens' Response'Success Proto.BtcLsp.Data.HighLevel.FundOnChainAddress@+ * 'Proto.BtcLsp.Method.SwapIntoLn_Fields.maybe'fundOnChainAddress' @:: Lens' Response'Success (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.FundOnChainAddress)@+ * 'Proto.BtcLsp.Method.SwapIntoLn_Fields.minFundMoney' @:: Lens' Response'Success Proto.BtcLsp.Data.HighLevel.FundMoney@+ * 'Proto.BtcLsp.Method.SwapIntoLn_Fields.maybe'minFundMoney' @:: Lens' Response'Success (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.FundMoney)@ -}+data Response'Success+ = Response'Success'_constructor {_Response'Success'fundOnChainAddress :: !(Prelude.Maybe Proto.BtcLsp.Data.HighLevel.FundOnChainAddress),+ _Response'Success'minFundMoney :: !(Prelude.Maybe Proto.BtcLsp.Data.HighLevel.FundMoney),+ _Response'Success'_unknownFields :: !Data.ProtoLens.FieldSet}+ deriving stock (Prelude.Eq, Prelude.Ord, GHC.Generics.Generic)+instance Prelude.Show Response'Success where+ showsPrec _ __x __s+ = Prelude.showChar+ '{'+ (Prelude.showString+ (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s))+instance Text.PrettyPrint.GenericPretty.Out Response'Success+instance Data.ProtoLens.Field.HasField Response'Success "fundOnChainAddress" Proto.BtcLsp.Data.HighLevel.FundOnChainAddress where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Success'fundOnChainAddress+ (\ x__ y__ -> x__ {_Response'Success'fundOnChainAddress = y__}))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage)+instance Data.ProtoLens.Field.HasField Response'Success "maybe'fundOnChainAddress" (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.FundOnChainAddress) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Success'fundOnChainAddress+ (\ x__ y__ -> x__ {_Response'Success'fundOnChainAddress = y__}))+ Prelude.id+instance Data.ProtoLens.Field.HasField Response'Success "minFundMoney" Proto.BtcLsp.Data.HighLevel.FundMoney where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Success'minFundMoney+ (\ x__ y__ -> x__ {_Response'Success'minFundMoney = y__}))+ (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage)+instance Data.ProtoLens.Field.HasField Response'Success "maybe'minFundMoney" (Prelude.Maybe Proto.BtcLsp.Data.HighLevel.FundMoney) where+ fieldOf _+ = (Prelude..)+ (Lens.Family2.Unchecked.lens+ _Response'Success'minFundMoney+ (\ x__ y__ -> x__ {_Response'Success'minFundMoney = y__}))+ Prelude.id+instance Data.ProtoLens.Message Response'Success where+ messageName _+ = Data.Text.pack "BtcLsp.Method.SwapIntoLn.Response.Success"+ packedMessageDescriptor _+ = "\n\+ \\aSuccess\DC2\\\n\+ \\NAKfund_on_chain_address\CAN\SOH \SOH(\v2).BtcLsp.Data.HighLevel.FundOnChainAddressR\DC2fundOnChainAddress\DC2F\n\+ \\SOmin_fund_money\CAN\STX \SOH(\v2 .BtcLsp.Data.HighLevel.FundMoneyR\fminFundMoney"+ packedFileDescriptor _ = packedFileDescriptor+ fieldsByTag+ = let+ fundOnChainAddress__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "fund_on_chain_address"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.HighLevel.FundOnChainAddress)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'fundOnChainAddress")) ::+ Data.ProtoLens.FieldDescriptor Response'Success+ minFundMoney__field_descriptor+ = Data.ProtoLens.FieldDescriptor+ "min_fund_money"+ (Data.ProtoLens.MessageField Data.ProtoLens.MessageType ::+ Data.ProtoLens.FieldTypeDescriptor Proto.BtcLsp.Data.HighLevel.FundMoney)+ (Data.ProtoLens.OptionalField+ (Data.ProtoLens.Field.field @"maybe'minFundMoney")) ::+ Data.ProtoLens.FieldDescriptor Response'Success+ in+ Data.Map.fromList+ [(Data.ProtoLens.Tag 1, fundOnChainAddress__field_descriptor),+ (Data.ProtoLens.Tag 2, minFundMoney__field_descriptor)]+ unknownFields+ = Lens.Family2.Unchecked.lens+ _Response'Success'_unknownFields+ (\ x__ y__ -> x__ {_Response'Success'_unknownFields = y__})+ defMessage+ = Response'Success'_constructor+ {_Response'Success'fundOnChainAddress = Prelude.Nothing,+ _Response'Success'minFundMoney = Prelude.Nothing,+ _Response'Success'_unknownFields = []}+ parseMessage+ = let+ loop ::+ Response'Success+ -> Data.ProtoLens.Encoding.Bytes.Parser Response'Success+ loop x+ = do end <- Data.ProtoLens.Encoding.Bytes.atEnd+ if end then+ do (let missing = []+ in+ if Prelude.null missing then+ Prelude.return ()+ else+ Prelude.fail+ ((Prelude.++)+ "Missing required fields: "+ (Prelude.show (missing :: [Prelude.String]))))+ Prelude.return+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) x)+ else+ do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt+ case tag of+ 10+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "fund_on_chain_address"+ loop+ (Lens.Family2.set+ (Data.ProtoLens.Field.field @"fundOnChainAddress") y x)+ 18+ -> do y <- (Data.ProtoLens.Encoding.Bytes.<?>)+ (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt+ Data.ProtoLens.Encoding.Bytes.isolate+ (Prelude.fromIntegral len) Data.ProtoLens.parseMessage)+ "min_fund_money"+ loop+ (Lens.Family2.set+ (Data.ProtoLens.Field.field @"minFundMoney") y x)+ wire+ -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire+ wire+ loop+ (Lens.Family2.over+ Data.ProtoLens.unknownFields (\ !t -> (:) y t) x)+ in+ (Data.ProtoLens.Encoding.Bytes.<?>)+ (do loop Data.ProtoLens.defMessage) "Success"+ buildMessage+ = \ _x+ -> (Data.Monoid.<>)+ (case+ Lens.Family2.view+ (Data.ProtoLens.Field.field @"maybe'fundOnChainAddress") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just _v)+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 10)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ ((Data.Monoid.<>)+ (case+ Lens.Family2.view+ (Data.ProtoLens.Field.field @"maybe'minFundMoney") _x+ of+ Prelude.Nothing -> Data.Monoid.mempty+ (Prelude.Just _v)+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt 18)+ ((Prelude..)+ (\ bs+ -> (Data.Monoid.<>)+ (Data.ProtoLens.Encoding.Bytes.putVarInt+ (Prelude.fromIntegral (Data.ByteString.length bs)))+ (Data.ProtoLens.Encoding.Bytes.putBytes bs))+ Data.ProtoLens.encodeMessage _v))+ (Data.ProtoLens.Encoding.Wire.buildFieldSet+ (Lens.Family2.view Data.ProtoLens.unknownFields _x)))+instance Control.DeepSeq.NFData Response'Success where+ rnf+ = \ x__+ -> Control.DeepSeq.deepseq+ (_Response'Success'_unknownFields x__)+ (Control.DeepSeq.deepseq+ (_Response'Success'fundOnChainAddress x__)+ (Control.DeepSeq.deepseq (_Response'Success'minFundMoney x__) ()))+packedFileDescriptor :: Data.ByteString.ByteString+packedFileDescriptor+ = "\n\+ \!btc_lsp/method/swap_into_ln.proto\DC2\CANBtcLsp.Method.SwapIntoLn\SUB\GSbtc_lsp/data/high_level.proto\"\213\SOH\n\+ \\aRequest\DC2,\n\+ \\ETXctx\CAN\SOH \SOH(\v2\SUB.BtcLsp.Data.HighLevel.CtxR\ETXctx\DC2b\n\+ \\ETBrefund_on_chain_address\CAN\ETX \SOH(\v2+.BtcLsp.Data.HighLevel.RefundOnChainAddressR\DC4refundOnChainAddress\DC28\n\+ \\aprivacy\CAN\EOT \SOH(\SO2\RS.BtcLsp.Data.HighLevel.PrivacyR\aprivacy\"\218\ENQ\n\+ \\bResponse\DC2,\n\+ \\ETXctx\CAN\SOH \SOH(\v2\SUB.BtcLsp.Data.HighLevel.CtxR\ETXctx\DC2F\n\+ \\asuccess\CAN\STX \SOH(\v2*.BtcLsp.Method.SwapIntoLn.Response.SuccessH\NULR\asuccess\DC2F\n\+ \\afailure\CAN\ETX \SOH(\v2*.BtcLsp.Method.SwapIntoLn.Response.FailureH\NULR\afailure\SUB\175\SOH\n\+ \\aSuccess\DC2\\\n\+ \\NAKfund_on_chain_address\CAN\SOH \SOH(\v2).BtcLsp.Data.HighLevel.FundOnChainAddressR\DC2fundOnChainAddress\DC2F\n\+ \\SOmin_fund_money\CAN\STX \SOH(\v2 .BtcLsp.Data.HighLevel.FundMoneyR\fminFundMoney\SUB\211\STX\n\+ \\aFailure\DC2=\n\+ \\ageneric\CAN\SOH \ETX(\v2#.BtcLsp.Data.HighLevel.InputFailureR\ageneric\DC2S\n\+ \\bspecific\CAN\STX \ETX(\SO27.BtcLsp.Method.SwapIntoLn.Response.Failure.InputFailureR\bspecific\DC2B\n\+ \\binternal\CAN\ETX \ETX(\v2&.BtcLsp.Data.HighLevel.InternalFailureR\binternal\"p\n\+ \\fInputFailure\DC2\v\n\+ \\aDEFAULT\DLE\NUL\DC2(\n\+ \$REFUND_ON_CHAIN_ADDRESS_IS_NOT_VALID\DLE\ETX\DC2)\n\+ \%REFUND_ON_CHAIN_ADDRESS_IS_NOT_SEGWIT\DLE\EOTB\b\n\+ \\ACKeitherJ\149\SO\n\+ \\ACK\DC2\EOT\NUL\NUL8\SOH\n\+ \\b\n\+ \\SOH\f\DC2\ETX\NUL\NUL\DLE\n\+ \\b\n\+ \\SOH\STX\DC2\ETX\STX\NUL!\n\+ \\t\n\+ \\STX\ETX\NUL\DC2\ETX\EOT\NUL'\n\+ \\n\+ \\n\+ \\STX\EOT\NUL\DC2\EOT\ACK\NUL\DC4\SOH\n\+ \\n\+ \\n\+ \\ETX\EOT\NUL\SOH\DC2\ETX\ACK\b\SI\n\+ \\v\n\+ \\EOT\EOT\NUL\STX\NUL\DC2\ETX\a\STX%\n\+ \\f\n\+ \\ENQ\EOT\NUL\STX\NUL\ACK\DC2\ETX\a\STX\FS\n\+ \\f\n\+ \\ENQ\EOT\NUL\STX\NUL\SOH\DC2\ETX\a\GS \n\+ \\f\n\+ \\ENQ\EOT\NUL\STX\NUL\ETX\DC2\ETX\a#$\n\+ \\166\ETX\n\+ \\EOT\EOT\NUL\STX\SOH\DC2\ETX\DC2\STXJ\SUB\152\ETX\n\+ \ NOTE : Removed as redundant data after adopting\n\+ \ psbt-based channel opening procedure. Before there wasn't\n\+ \ much control over UTXOs, so it was not possible to safely\n\+ \ use push_sat, so fund_ln_invoice was a workaround used to\n\+ \ push liquidity. With precise UTXO control this is not\n\+ \ the issue anymore, bitcoin network solves double spend\n\+ \ problem.\n\+ \\n\+ \ .BtcLsp.Data.HighLevel.FundLnInvoice fund_ln_invoice = 2;\n\+ \\n\+ \\f\n\+ \\ENQ\EOT\NUL\STX\SOH\ACK\DC2\ETX\DC2\STX-\n\+ \\f\n\+ \\ENQ\EOT\NUL\STX\SOH\SOH\DC2\ETX\DC2.E\n\+ \\f\n\+ \\ENQ\EOT\NUL\STX\SOH\ETX\DC2\ETX\DC2HI\n\+ \\v\n\+ \\EOT\EOT\NUL\STX\STX\DC2\ETX\DC3\STX-\n\+ \\f\n\+ \\ENQ\EOT\NUL\STX\STX\ACK\DC2\ETX\DC3\STX \n\+ \\f\n\+ \\ENQ\EOT\NUL\STX\STX\SOH\DC2\ETX\DC3!(\n\+ \\f\n\+ \\ENQ\EOT\NUL\STX\STX\ETX\DC2\ETX\DC3+,\n\+ \\n\+ \\n\+ \\STX\EOT\SOH\DC2\EOT\SYN\NUL8\SOH\n\+ \\n\+ \\n\+ \\ETX\EOT\SOH\SOH\DC2\ETX\SYN\b\DLE\n\+ \\v\n\+ \\EOT\EOT\SOH\STX\NUL\DC2\ETX\ETB\STX%\n\+ \\f\n\+ \\ENQ\EOT\SOH\STX\NUL\ACK\DC2\ETX\ETB\STX\FS\n\+ \\f\n\+ \\ENQ\EOT\SOH\STX\NUL\SOH\DC2\ETX\ETB\GS \n\+ \\f\n\+ \\ENQ\EOT\SOH\STX\NUL\ETX\DC2\ETX\ETB#$\n\+ \\f\n\+ \\EOT\EOT\SOH\b\NUL\DC2\EOT\EM\STX\FS\ETX\n\+ \\f\n\+ \\ENQ\EOT\SOH\b\NUL\SOH\DC2\ETX\EM\b\SO\n\+ \\v\n\+ \\EOT\EOT\SOH\STX\SOH\DC2\ETX\SUB\EOT\CAN\n\+ \\f\n\+ \\ENQ\EOT\SOH\STX\SOH\ACK\DC2\ETX\SUB\EOT\v\n\+ \\f\n\+ \\ENQ\EOT\SOH\STX\SOH\SOH\DC2\ETX\SUB\f\DC3\n\+ \\f\n\+ \\ENQ\EOT\SOH\STX\SOH\ETX\DC2\ETX\SUB\SYN\ETB\n\+ \\v\n\+ \\EOT\EOT\SOH\STX\STX\DC2\ETX\ESC\EOT\CAN\n\+ \\f\n\+ \\ENQ\EOT\SOH\STX\STX\ACK\DC2\ETX\ESC\EOT\v\n\+ \\f\n\+ \\ENQ\EOT\SOH\STX\STX\SOH\DC2\ETX\ESC\f\DC3\n\+ \\f\n\+ \\ENQ\EOT\SOH\STX\STX\ETX\DC2\ETX\ESC\SYN\ETB\n\+ \\f\n\+ \\EOT\EOT\SOH\ETX\NUL\DC2\EOT\RS\STX#\ETX\n\+ \\f\n\+ \\ENQ\EOT\SOH\ETX\NUL\SOH\DC2\ETX\RS\n\+ \\DC1\n\+ \\r\n\+ \\ACK\EOT\SOH\ETX\NUL\STX\NUL\DC2\ETX\US\EOTH\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\NUL\STX\NUL\ACK\DC2\ETX\US\EOT-\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\NUL\STX\NUL\SOH\DC2\ETX\US.C\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\NUL\STX\NUL\ETX\DC2\ETX\USFG\n\+ \{\n\+ \\ACK\EOT\SOH\ETX\NUL\STX\SOH\DC2\ETX\"\EOT8\SUBl Minimal expected swap amount. Swap will not happen\n\+ \ until address balance is more or equal than FundMoney.\n\+ \\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\NUL\STX\SOH\ACK\DC2\ETX\"\EOT$\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\NUL\STX\SOH\SOH\DC2\ETX\"%3\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\NUL\STX\SOH\ETX\DC2\ETX\"67\n\+ \\f\n\+ \\EOT\EOT\SOH\ETX\SOH\DC2\EOT%\STX7\ETX\n\+ \\f\n\+ \\ENQ\EOT\SOH\ETX\SOH\SOH\DC2\ETX%\n\+ \\DC1\n\+ \\r\n\+ \\ACK\EOT\SOH\ETX\SOH\STX\NUL\DC2\ETX&\EOT=\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\NUL\EOT\DC2\ETX&\EOT\f\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\NUL\ACK\DC2\ETX&\r0\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\NUL\SOH\DC2\ETX&18\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\NUL\ETX\DC2\ETX&;<\n\+ \\r\n\+ \\ACK\EOT\SOH\ETX\SOH\STX\SOH\DC2\ETX'\EOT'\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\SOH\EOT\DC2\ETX'\EOT\f\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\SOH\ACK\DC2\ETX'\r\EM\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\SOH\SOH\DC2\ETX'\SUB\"\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\SOH\ETX\DC2\ETX'%&\n\+ \\r\n\+ \\ACK\EOT\SOH\ETX\SOH\STX\STX\DC2\ETX(\EOTA\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\STX\EOT\DC2\ETX(\EOT\f\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\STX\ACK\DC2\ETX(\r3\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\STX\SOH\DC2\ETX(4<\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\STX\STX\ETX\DC2\ETX(?@\n\+ \\SO\n\+ \\ACK\EOT\SOH\ETX\SOH\EOT\NUL\DC2\EOT*\EOT6\ENQ\n\+ \\SO\n\+ \\a\EOT\SOH\ETX\SOH\EOT\NUL\SOH\DC2\ETX*\t\NAK\n\+ \\SI\n\+ \\b\EOT\SOH\ETX\SOH\EOT\NUL\STX\NUL\DC2\ETX+\ACK\DC2\n\+ \\DLE\n\+ \\t\EOT\SOH\ETX\SOH\EOT\NUL\STX\NUL\SOH\DC2\ETX+\ACK\r\n\+ \\DLE\n\+ \\t\EOT\SOH\ETX\SOH\EOT\NUL\STX\NUL\STX\DC2\ETX+\DLE\DC1\n\+ \\250\SOH\n\+ \\b\EOT\SOH\ETX\SOH\EOT\NUL\STX\SOH\DC2\ETX4\ACK/\SUB\232\SOH\n\+ \ NOTE : Removed together with fund_ln_invoice\n\+ \ field from request as errors associated with\n\+ \ this field.\n\+ \\n\+ \ FUND_LN_INVOICE_HAS_NON_ZERO_AMT = 0;\n\+ \ FUND_LN_INVOICE_EXPIRES_TOO_SOON = 1;\n\+ \ FUND_LN_INVOICE_SIGNATURE_IS_NOT_GENUINE = 2;\n\+ \\n\+ \\DLE\n\+ \\t\EOT\SOH\ETX\SOH\EOT\NUL\STX\SOH\SOH\DC2\ETX4\ACK*\n\+ \\DLE\n\+ \\t\EOT\SOH\ETX\SOH\EOT\NUL\STX\SOH\STX\DC2\ETX4-.\n\+ \\SI\n\+ \\b\EOT\SOH\ETX\SOH\EOT\NUL\STX\STX\DC2\ETX5\ACK0\n\+ \\DLE\n\+ \\t\EOT\SOH\ETX\SOH\EOT\NUL\STX\STX\SOH\DC2\ETX5\ACK+\n\+ \\DLE\n\+ \\t\EOT\SOH\ETX\SOH\EOT\NUL\STX\STX\STX\DC2\ETX5./b\ACKproto3"
@@ -0,0 +1,150 @@+{- This file was auto-generated from btc_lsp/method/swap_into_ln.proto by the proto-lens-protoc program. -}+{-# LANGUAGE ScopedTypeVariables, DataKinds, TypeFamilies, UndecidableInstances, GeneralizedNewtypeDeriving, MultiParamTypeClasses, FlexibleContexts, FlexibleInstances, PatternSynonyms, MagicHash, NoImplicitPrelude, BangPatterns, TypeApplications, OverloadedStrings, DerivingStrategies, DeriveGeneric#-}+{-# OPTIONS_GHC -Wno-unused-imports#-}+{-# OPTIONS_GHC -Wno-duplicate-exports#-}+{-# OPTIONS_GHC -Wno-dodgy-exports#-}+module Proto.BtcLsp.Method.SwapIntoLn_Fields where+import qualified Data.ProtoLens.Runtime.Prelude as Prelude+import qualified Data.ProtoLens.Runtime.Data.Int as Data.Int+import qualified Data.ProtoLens.Runtime.Data.Monoid as Data.Monoid+import qualified Data.ProtoLens.Runtime.Data.Word as Data.Word+import qualified Data.ProtoLens.Runtime.Data.ProtoLens as Data.ProtoLens+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Bytes as Data.ProtoLens.Encoding.Bytes+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Growing as Data.ProtoLens.Encoding.Growing+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Parser.Unsafe as Data.ProtoLens.Encoding.Parser.Unsafe+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Wire as Data.ProtoLens.Encoding.Wire+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Field as Data.ProtoLens.Field+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Message.Enum as Data.ProtoLens.Message.Enum+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Service.Types as Data.ProtoLens.Service.Types+import qualified Data.ProtoLens.Runtime.Lens.Family2 as Lens.Family2+import qualified Data.ProtoLens.Runtime.Lens.Family2.Unchecked as Lens.Family2.Unchecked+import qualified Data.ProtoLens.Runtime.Data.Text as Data.Text+import qualified Data.ProtoLens.Runtime.Data.Map as Data.Map+import qualified Data.ProtoLens.Runtime.Data.ByteString as Data.ByteString+import qualified Data.ProtoLens.Runtime.Data.ByteString.Char8 as Data.ByteString.Char8+import qualified Data.ProtoLens.Runtime.Data.Text.Encoding as Data.Text.Encoding+import qualified Data.ProtoLens.Runtime.Data.Vector as Data.Vector+import qualified Data.ProtoLens.Runtime.Data.Vector.Generic as Data.Vector.Generic+import qualified Data.ProtoLens.Runtime.Data.Vector.Unboxed as Data.Vector.Unboxed+import qualified Data.ProtoLens.Runtime.Text.Read as Text.Read+import qualified Proto.BtcLsp.Data.HighLevel+ctx ::+ forall f s a.+ (Prelude.Functor f, Data.ProtoLens.Field.HasField s "ctx" a) =>+ Lens.Family2.LensLike' f s a+ctx = Data.ProtoLens.Field.field @"ctx"+failure ::+ forall f s a.+ (Prelude.Functor f, Data.ProtoLens.Field.HasField s "failure" a) =>+ Lens.Family2.LensLike' f s a+failure = Data.ProtoLens.Field.field @"failure"+fundOnChainAddress ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "fundOnChainAddress" a) =>+ Lens.Family2.LensLike' f s a+fundOnChainAddress+ = Data.ProtoLens.Field.field @"fundOnChainAddress"+generic ::+ forall f s a.+ (Prelude.Functor f, Data.ProtoLens.Field.HasField s "generic" a) =>+ Lens.Family2.LensLike' f s a+generic = Data.ProtoLens.Field.field @"generic"+internal ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "internal" a) =>+ Lens.Family2.LensLike' f s a+internal = Data.ProtoLens.Field.field @"internal"+maybe'ctx ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "maybe'ctx" a) =>+ Lens.Family2.LensLike' f s a+maybe'ctx = Data.ProtoLens.Field.field @"maybe'ctx"+maybe'either ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "maybe'either" a) =>+ Lens.Family2.LensLike' f s a+maybe'either = Data.ProtoLens.Field.field @"maybe'either"+maybe'failure ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "maybe'failure" a) =>+ Lens.Family2.LensLike' f s a+maybe'failure = Data.ProtoLens.Field.field @"maybe'failure"+maybe'fundOnChainAddress ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "maybe'fundOnChainAddress" a) =>+ Lens.Family2.LensLike' f s a+maybe'fundOnChainAddress+ = Data.ProtoLens.Field.field @"maybe'fundOnChainAddress"+maybe'minFundMoney ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "maybe'minFundMoney" a) =>+ Lens.Family2.LensLike' f s a+maybe'minFundMoney+ = Data.ProtoLens.Field.field @"maybe'minFundMoney"+maybe'refundOnChainAddress ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "maybe'refundOnChainAddress" a) =>+ Lens.Family2.LensLike' f s a+maybe'refundOnChainAddress+ = Data.ProtoLens.Field.field @"maybe'refundOnChainAddress"+maybe'success ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "maybe'success" a) =>+ Lens.Family2.LensLike' f s a+maybe'success = Data.ProtoLens.Field.field @"maybe'success"+minFundMoney ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "minFundMoney" a) =>+ Lens.Family2.LensLike' f s a+minFundMoney = Data.ProtoLens.Field.field @"minFundMoney"+privacy ::+ forall f s a.+ (Prelude.Functor f, Data.ProtoLens.Field.HasField s "privacy" a) =>+ Lens.Family2.LensLike' f s a+privacy = Data.ProtoLens.Field.field @"privacy"+refundOnChainAddress ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "refundOnChainAddress" a) =>+ Lens.Family2.LensLike' f s a+refundOnChainAddress+ = Data.ProtoLens.Field.field @"refundOnChainAddress"+specific ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "specific" a) =>+ Lens.Family2.LensLike' f s a+specific = Data.ProtoLens.Field.field @"specific"+success ::+ forall f s a.+ (Prelude.Functor f, Data.ProtoLens.Field.HasField s "success" a) =>+ Lens.Family2.LensLike' f s a+success = Data.ProtoLens.Field.field @"success"+vec'generic ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "vec'generic" a) =>+ Lens.Family2.LensLike' f s a+vec'generic = Data.ProtoLens.Field.field @"vec'generic"+vec'internal ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "vec'internal" a) =>+ Lens.Family2.LensLike' f s a+vec'internal = Data.ProtoLens.Field.field @"vec'internal"+vec'specific ::+ forall f s a.+ (Prelude.Functor f,+ Data.ProtoLens.Field.HasField s "vec'specific" a) =>+ Lens.Family2.LensLike' f s a+vec'specific = Data.ProtoLens.Field.field @"vec'specific"
@@ -0,0 +1,32 @@+{- This file was auto-generated from btc_lsp.proto by the proto-lens-protoc program. -}+{-# LANGUAGE ScopedTypeVariables, DataKinds, TypeFamilies, UndecidableInstances, GeneralizedNewtypeDeriving, MultiParamTypeClasses, FlexibleContexts, FlexibleInstances, PatternSynonyms, MagicHash, NoImplicitPrelude, BangPatterns, TypeApplications, OverloadedStrings, DerivingStrategies, DeriveGeneric#-}+{-# OPTIONS_GHC -Wno-unused-imports#-}+{-# OPTIONS_GHC -Wno-duplicate-exports#-}+{-# OPTIONS_GHC -Wno-dodgy-exports#-}+module Proto.BtcLsp_Fields where+import qualified Data.ProtoLens.Runtime.Prelude as Prelude+import qualified Data.ProtoLens.Runtime.Data.Int as Data.Int+import qualified Data.ProtoLens.Runtime.Data.Monoid as Data.Monoid+import qualified Data.ProtoLens.Runtime.Data.Word as Data.Word+import qualified Data.ProtoLens.Runtime.Data.ProtoLens as Data.ProtoLens+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Bytes as Data.ProtoLens.Encoding.Bytes+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Growing as Data.ProtoLens.Encoding.Growing+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Parser.Unsafe as Data.ProtoLens.Encoding.Parser.Unsafe+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Wire as Data.ProtoLens.Encoding.Wire+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Field as Data.ProtoLens.Field+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Message.Enum as Data.ProtoLens.Message.Enum+import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Service.Types as Data.ProtoLens.Service.Types+import qualified Data.ProtoLens.Runtime.Lens.Family2 as Lens.Family2+import qualified Data.ProtoLens.Runtime.Lens.Family2.Unchecked as Lens.Family2.Unchecked+import qualified Data.ProtoLens.Runtime.Data.Text as Data.Text+import qualified Data.ProtoLens.Runtime.Data.Map as Data.Map+import qualified Data.ProtoLens.Runtime.Data.ByteString as Data.ByteString+import qualified Data.ProtoLens.Runtime.Data.ByteString.Char8 as Data.ByteString.Char8+import qualified Data.ProtoLens.Runtime.Data.Text.Encoding as Data.Text.Encoding+import qualified Data.ProtoLens.Runtime.Data.Vector as Data.Vector+import qualified Data.ProtoLens.Runtime.Data.Vector.Generic as Data.Vector.Generic+import qualified Data.ProtoLens.Runtime.Data.Vector.Unboxed as Data.Vector.Unboxed+import qualified Data.ProtoLens.Runtime.Text.Read as Text.Read+import qualified Proto.BtcLsp.Method.GetCfg+import qualified Proto.BtcLsp.Method.SwapFromLn+import qualified Proto.BtcLsp.Method.SwapIntoLn
@@ -0,0 +1,67 @@+{-# LANGUAGE TypeApplications #-}++module BakSpec+ ( spec,+ )+where++import BtcLsp.Import+import qualified BtcLsp.Storage.Model.LnChan as LnChan+import qualified LndClient.Data.Channel as Lnd hiding (outputIndex)+import qualified LndClient.Data.ChannelBackup as Lnd+import qualified LndClient.Data.ChannelPoint as Lnd+import qualified LndClient.Data.ListChannels as Lnd+import LndClient.LndTest+import qualified LndClient.RPC.Silent as Lnd+import Test.Hspec+import TestAppM++spec :: Spec+spec = do+ itMainT @'LndLsp "Static Channel Backup" $ do+ cp <- lift $ setupOneChannel LndLsp LndAlice+ sleep1s+ mCh <-+ (entityVal <<$>>)+ . lift+ . runSql+ . LnChan.getByChannelPointSql (Lnd.fundingTxId cp)+ $ Lnd.outputIndex cp+ case mCh of+ Just (LnChan {lnChanBak = Just bak}) -> do+ cs0 <- getChansT+ liftIO $ length cs0 `shouldBe` 1+ withLndT Lnd.restoreChannelBackups ($ [Lnd.ChannelBackup cp bak])+ sleep1s+ lift $ mine 6 LndAlice+ sleep1s+ cs1 <- getChansT+ --+ -- TODO : fix it! For some reason there is still active+ -- channel even after static backup restore procedure.+ -- Maybe we need to shutdown LND node, remove volumes,+ -- spawn node again, initialize with the same seed+ -- and then restore, to properly test it.+ --+ -- liftIO $ length cs1 `shouldBe` 0+ --+ liftIO $ length cs1 `shouldBe` 1+ Just ch ->+ throwE . FailureInt . FailurePrivate $+ "Impossible empty ch " <> inspect ch+ Nothing ->+ throwE . FailureInt . FailurePrivate $+ "Impossible empty cp " <> inspect cp+ where+ getChansT :: (Env m) => ExceptT Failure m [Lnd.Channel]+ getChansT =+ withLndT+ Lnd.listChannels+ ( $+ Lnd.ListChannelsRequest+ False+ False+ False+ False+ Nothing+ )
@@ -0,0 +1,124 @@+{-# LANGUAGE TypeApplications #-}++module BlockScannerSpec+ ( spec,+ )+where++import BtcLsp.Import+import qualified BtcLsp.Math.OnChain as Math+import qualified BtcLsp.Storage.Model.SwapUtxo as SwapUtxo+import qualified BtcLsp.Thread.BlockScanner as BlockScanner+import LndClient.LndTest (mine)+import qualified Network.Bitcoin as Btc+import Test.Hspec+import TestAppM+import TestHelpers+import TestOrphan ()++spec :: Spec+spec = do+ itEnvT @'LndLsp "Block scanner works with 1 block" $ do+ wbal <- withBtcT Btc.getBalance id+ let amt = wbal / 10+ trAddr <-+ from+ . swapIntoLnFundAddress+ . entityVal+ <$> createDummySwap Nothing+ void $+ withBtcT+ Btc.sendToAddress+ (\h -> h trAddr amt Nothing Nothing)+ void $+ withBtcT+ Btc.sendToAddress+ (\h -> h trAddr amt Nothing Nothing)+ lift $ mine 1 LndLsp+ expectedAmt <-+ except+ . first (const (FailureInt $ FailurePrivate "expectedAmt overflow"))+ . Math.trySatToMsat+ $ amt * 2+ utxos <- BlockScanner.scan+ let gotAmt :: MSat = sum $ BlockScanner.utxoAmt <$> utxos+ liftIO $ expectedAmt `shouldBe` gotAmt+ itEnvT @'LndLsp "Block scanner works with 2 blocks" $ do+ wbal <- withBtcT Btc.getBalance id+ let amt = wbal / 10+ trAddr <-+ from+ . swapIntoLnFundAddress+ . entityVal+ <$> createDummySwap Nothing+ void $+ withBtcT+ Btc.sendToAddress+ (\h -> h trAddr amt Nothing Nothing)+ lift $ mine 1 LndLsp+ void $+ withBtcT+ Btc.sendToAddress+ (\h -> h trAddr amt Nothing Nothing)+ lift $ mine 1 LndLsp+ expectedAmt <-+ except . first (const (FailureInt $ FailurePrivate "expectedAmt overflow"))+ . Math.trySatToMsat+ $ amt * 2+ utxos <- BlockScanner.scan+ let gotAmt = sum $ BlockScanner.utxoAmt <$> utxos+ liftIO $ expectedAmt `shouldBe` gotAmt+ itEnvT @'LndLsp "Block scanner detects dust" $ do+ let amt0 = Math.trxDustLimit+ let amt1 = amt0 + 3000+ let amt2 = amt0 - 2000+ swapEnt <-+ createDummySwap Nothing+ let trAddr =+ from+ . swapIntoLnFundAddress+ $ entityVal swapEnt+ satsToSend <-+ mapM+ Math.tryMsatToSatT+ [amt0, amt1, amt2]+ mapM_+ ( \amt ->+ withBtcT+ Btc.sendToAddress+ (\h -> h trAddr amt Nothing Nothing)+ )+ satsToSend+ lift $+ mine 1 LndLsp+ scanUtxos <-+ BlockScanner.scan+ dbUtxos <-+ lift+ . runSql+ . (entityVal <<$>>)+ . SwapUtxo.getUtxosBySwapIdSql+ $ entityKey swapEnt+ let dbUtxosSpendable =+ filter+ ((== SwapUtxoUnspent) . swapUtxoStatus)+ dbUtxos+ let dbUtxosDust =+ filter+ ((== SwapUtxoUnspentDust) . swapUtxoStatus)+ dbUtxos+ liftIO $ do+ length scanUtxos+ `shouldBe` 3+ sum (BlockScanner.utxoAmt <$> scanUtxos)+ `shouldBe` amt0 + amt1 + amt2+ length dbUtxos+ `shouldBe` 3+ length dbUtxosSpendable+ `shouldBe` 2+ length dbUtxosDust+ `shouldBe` 1+ sum (swapUtxoAmount <$> dbUtxosSpendable)+ `shouldBe` from (amt0 + amt1)+ sum (swapUtxoAmount <$> dbUtxosDust)+ `shouldBe` from amt2
@@ -0,0 +1,160 @@+{-# LANGUAGE TypeApplications #-}++module LnChanWatcherSpec+ ( spec,+ )+where++import BtcLsp.Import hiding (newEmptyMVar, putMVar, takeMVar)+import qualified BtcLsp.Storage.Model.LnChan as LnChan+import LndClient+import qualified LndClient.Data.ChannelPoint as Lnd+import qualified LndClient.Data.CloseChannel as Lnd+import LndClient.Data.GetInfo+import qualified LndClient.Data.OpenChannel as OpenChannel+import LndClient.LndTest+import qualified LndClient.RPC.Silent as Lnd+import Test.Hspec+import TestAppM+import UnliftIO.Concurrent (killThread, threadDelay)++openChannelRequest ::+ NodePubKey ->+ OpenChannel.OpenChannelRequest+openChannelRequest nodePubkey =+ OpenChannel.OpenChannelRequest+ { OpenChannel.nodePubkey = nodePubkey,+ OpenChannel.localFundingAmount = MSat 200000000,+ OpenChannel.pushMSat = Just $ MSat 10000000,+ OpenChannel.targetConf = Nothing,+ OpenChannel.mSatPerByte = Nothing,+ OpenChannel.private = Nothing,+ OpenChannel.minHtlcMsat = Nothing,+ OpenChannel.remoteCsvDelay = Nothing,+ OpenChannel.minConfs = Nothing,+ OpenChannel.spendUnconfirmed = Nothing,+ OpenChannel.closeAddress = Nothing,+ OpenChannel.fundingShim = Nothing+ }++closeChannelRequest ::+ Lnd.ChannelPoint ->+ Lnd.CloseChannelRequest+closeChannelRequest cp =+ Lnd.CloseChannelRequest cp False Nothing Nothing Nothing++getNodePubKey :: MonadUnliftIO m => LndEnv -> m NodePubKey+getNodePubKey lndEnv = do+ GetInfoResponse merchantPubKey _ _ <-+ liftLndResult =<< Lnd.getInfo lndEnv+ pure merchantPubKey++queryChannel ::+ ( Storage m+ ) =>+ Lnd.ChannelPoint ->+ m (Maybe (Entity LnChan))+queryChannel (Lnd.ChannelPoint txid vout) =+ runSql $+ LnChan.getByChannelPointSql txid vout++tryTimes ::+ MonadUnliftIO m =>+ Int ->+ Int ->+ m (Maybe a) ->+ m (Maybe a)+tryTimes times delaySec tryFn = go times+ where+ go 0 = pure Nothing+ go n = do+ res <- tryFn+ case res of+ Just r -> pure $ Just r+ Nothing -> threadDelay (delaySec * 1000000) >> go (n - 1)++justTrue :: Maybe Bool -> Maybe Bool+justTrue (Just True) = Just True+justTrue _ = Nothing++testFun ::+ ( LndTest m TestOwner,+ Storage m+ ) =>+ m [Maybe Bool]+testFun = do+ lndFrom <- getLndEnv LndLsp+ lndTo <- getLndEnv LndAlice+ toPubKey <- getNodePubKey lndTo+ cp <-+ liftLndResult+ =<< Lnd.openChannelSync+ lndFrom+ (openChannelRequest toPubKey)+ isPendingOpenOk <-+ tryTimes 3 1 $+ justTrue+ . fmap+ ( (== LnChanStatusPendingOpen)+ . lnChanStatus+ . entityVal+ )+ <$> queryChannel cp+ mine 10 LndLsp+ isOpenedOk <- tryTimes 3 1 $ do+ ch <- fmap entityVal <$> queryChannel cp+ let r =+ and+ <$> sequence+ [(== LnChanStatusActive) . lnChanStatus <$> ch]+ pure $ justTrue r+ isBackedUp <- tryTimes 3 1 $ do+ ch <- fmap entityVal <$> queryChannel cp+ let r =+ and+ <$> sequence+ [isJust . lnChanBak <$> ch]+ pure $ justTrue r+ (ctid, _) <- forkThread $ do+ void $+ liftLndResult+ =<< Lnd.closeChannel+ (const $ pure ())+ lndFrom+ (closeChannelRequest cp)+ isInactivedOk <- tryTimes 3 1 $ do+ ch <- fmap entityVal <$> queryChannel cp+ let r =+ and+ <$> sequence+ [(== LnChanStatusInactive) . lnChanStatus <$> ch]+ pure $ justTrue r+ mine 10 LndLsp+ isClosedOk <- tryTimes 3 1 $ do+ ch <- fmap entityVal <$> queryChannel cp+ let r =+ and+ <$> sequence+ [ ( `elem`+ [ LnChanStatusFullyResolved,+ LnChanStatusClosed+ ]+ )+ . lnChanStatus+ <$> ch+ ]+ pure $ justTrue r+ void $ killThread ctid+ pure+ [ isPendingOpenOk,+ isOpenedOk,+ isBackedUp,+ isInactivedOk,+ isClosedOk+ ]++spec :: Spec+spec =+ itMain @'LndLsp "Watch channel" $ do+ r <- testFun+ liftIO $ r `shouldSatisfy` all (== Just True)
@@ -0,0 +1,19 @@+module Main+ ( main,+ )+where++import BtcLsp.Import+import qualified Spec+import Test.Hspec.Formatters+import Test.Hspec.Runner+import qualified TestAppM++main :: IO ()+main = do+ TestAppM.mainTestSetup+ hspecWith+ defaultConfig+ { configFormatter = Just progress+ }+ Spec.spec
@@ -0,0 +1,90 @@+{-# LANGUAGE TypeApplications #-}++module MathSpec+ ( spec,+ )+where++import BtcLsp.Import+import qualified BtcLsp.Math.OnChain as Math+import qualified BtcLsp.Math.Swap as Math+import qualified Network.Bitcoin as Btc+import Test.Hspec+import Test.QuickCheck+import Test.QuickCheck.Monadic+import TestAppM+import TestOrphan ()++spec :: Spec+spec = do+ it "newSwapIntoLnMinAmt abs" $+ Math.newSwapIntoLnMinAmt 20000000+ `shouldBe` 12000000+ it "newSwapIntoLnMinAmt perc" $+ Math.newSwapIntoLnMinAmt 1000000000+ `shouldBe` 502009000+ itEnv @'LndLsp "newSwapCapM abs" $ do+ res <- Math.newSwapCapM 12000000+ liftIO $+ res+ `shouldBe` Just+ ( SwapCap+ { swapCapUsr = 10000000,+ swapCapLsp = 10000000,+ swapCapFee = 2000000+ }+ )+ itEnv @'LndLsp "newSwapCapM perc" $ do+ res <- Math.newSwapCapM 502009000+ liftIO $+ res+ `shouldBe` Just+ ( SwapCap+ { swapCapUsr = 500000000,+ swapCapLsp = 500000000,+ swapCapFee = 2009000+ }+ )+ itProp @'LndLsp "newSwapCapM prop" $ do+ minSwp <- getSwapIntoLnMinAmt+ withRunInIO $ \run0 ->+ pure . monadicIO $ do+ swp <-+ from @MSat <$> pick arbitrary+ maybeM+ (assert $ swp < minSwp)+ ( \res -> do+ let usr = Math.swapCapUsr res+ let lsp = Math.swapCapLsp res+ let fee = Math.swapCapFee res+ assert $ swp >= minSwp+ assert $ usr > 0+ assert $ lsp > 0+ assert $ fee > 0+ assert $ usr > coerce fee+ assert $ lsp > coerce fee+ assert $ usr == coerce lsp+ assert $ (usr + coerce fee) == coerce swp+ )+ . liftIO+ . run0+ $ Math.newSwapCapM swp+ it "trySatToMsat" $+ mapM_+ ( \(sat, msat) ->+ Math.trySatToMsat sat `shouldBe` Right msat+ )+ satMsat+ it "tryMsatToSat" $+ mapM_+ ( \(sat, msat) ->+ Math.tryMsatToSat msat `shouldBe` Right sat+ )+ satMsat+ where+ satMsat :: [(Btc.BTC, MSat)]+ satMsat =+ [ (0.00000001, MSat 1000),+ (0.00000101, MSat 101000),+ (1.00000101, MSat 100000101000)+ ]
@@ -0,0 +1,111 @@+{-# LANGUAGE TemplateHaskell #-}++module PsbtOpenerSpec+ ( spec,+ )+where++import BtcLsp.Import+import qualified BtcLsp.Psbt.PsbtOpener as PO+import BtcLsp.Psbt.Utils (swapUtxoToPsbtUtxo)+import qualified BtcLsp.Storage.Model.SwapUtxo as SwapUtxo+import qualified BtcLsp.Thread.BlockScanner as BlockScanner+import qualified LndClient.Data.Channel as CH+import qualified LndClient.Data.GetInfo as Lnd+import qualified LndClient.Data.ListChannels as ListChannels+import qualified LndClient.Data.ListLeases as LL+import qualified LndClient.Data.NewAddress as Lnd+import qualified LndClient.Data.SendCoins as SendCoins+import LndClient.LndTest (mine)+import qualified LndClient.RPC.Silent as Lnd+import Test.Hspec+import TestAppM+import TestHelpers+import TestOrphan ()+import qualified UnliftIO.STM as T++sendAmt :: Env m => Text -> MSat -> ExceptT Failure m ()+sendAmt addr amt =+ void $+ withLndT+ Lnd.sendCoins+ ($ SendCoins.SendCoinsRequest {SendCoins.addr = addr, SendCoins.amount = amt})++lspFee :: MSat+lspFee = MSat 20000 * 1000++spec :: Spec+spec = do+ itEnvT "PsbtOpener Spec" $ do+ amt <- lift getSwapIntoLnMinAmt+ swp <- createDummySwap Nothing+ let swpId = entityKey swp+ let swpAddr = swapIntoLnFundAddress . entityVal $ swp+ void $ sendAmt (from swpAddr) (from (10 * amt))+ void $ sendAmt (from swpAddr) (from (10 * amt))+ void putLatestBlockToDB+ lift $ mine 4 LndLsp+ void BlockScanner.scan+ $(logTM) DebugS $ logStr $ "Expected remote balance:" <> inspect (coerce (20 * amt) - lspFee)+ utxos <- lift $ runSql $ SwapUtxo.getSpendableUtxosBySwapIdSql swpId+ void $ lift $ runSql $ SwapUtxo.updateRefundedSql (entityKey <$> utxos) (TxId "dummy refund tx")+ let psbtUtxos = swapUtxoToPsbtUtxo . entityVal <$> utxos+ profitAddr <- genAddress LndLsp+ Lnd.GetInfoResponse alicePubKey _ _ <- withLndTestT LndAlice Lnd.getInfo id+ openChanRes <- PO.openChannelPsbt psbtUtxos alicePubKey (unsafeNewOnChainAddress $ Lnd.address profitAddr) (coerce lspFee) Public+ void . lift . spawnLink $ do+ sleep1s+ mine 1 LndLsp+ chanEither <- liftIO $ wait $ PO.fundAsync openChanRes+ chan <- except chanEither+ $(logTM) DebugS $ logStr $ "Channel is opened:" <> inspect chan+ chnls <-+ withLndT+ Lnd.listChannels+ ( $+ ListChannels.ListChannelsRequest+ { ListChannels.activeOnly = True,+ ListChannels.inactiveOnly = False,+ ListChannels.publicOnly = False,+ ListChannels.privateOnly = False,+ ListChannels.peer = Nothing+ }+ )+ $(logTM) DebugS $ logStr $ "Channel is opened:" <> inspect chnls+ let (openedChanMaybe :: Maybe CH.Channel) = find (\c -> CH.channelPoint c == chan) chnls+ let (expectedRemoteBalance :: MSat) = coerce (20 * amt) - lspFee+ case openedChanMaybe of+ Just c -> do+ liftIO $ do+ shouldBe expectedRemoteBalance (CH.remoteBalance c)+ Nothing -> throwE . FailureInt $ FailurePrivate "Failed to open channel with psbt"++ itEnvT "PsbtOpener subscription exception" $ do+ amt <- lift getSwapIntoLnMinAmt+ swp <- createDummySwap Nothing+ let swpId = entityKey swp+ let swpAddr = swapIntoLnFundAddress . entityVal $ swp+ void $ sendAmt (from swpAddr) (from (10 * amt))+ void $ sendAmt (from swpAddr) (from (10 * amt))+ void putLatestBlockToDB+ lift $ mine 4 LndLsp+ void BlockScanner.scan+ $(logTM) DebugS $ logStr $ "Expected remote balance:" <> inspect (coerce (20 * amt) - lspFee)+ utxos <- lift $ runSql $ SwapUtxo.getSpendableUtxosBySwapIdSql swpId+ void $ lift $ runSql $ SwapUtxo.updateRefundedSql (entityKey <$> utxos) (TxId "dummy refund tx")+ let psbtUtxos = swapUtxoToPsbtUtxo . entityVal <$> utxos+ profitAddr <- genAddress LndLsp+ Lnd.GetInfoResponse alicePubKey _ _ <- withLndTestT LndAlice Lnd.getInfo id+ openChanRes <-+ PO.openChannelPsbt psbtUtxos alicePubKey (unsafeNewOnChainAddress $ Lnd.address profitAddr) (coerce lspFee) Public+ void . lift . spawnLink $ do+ sleep1s+ mine 1 LndLsp+ void . T.atomically . T.writeTChan (PO.tchan openChanRes) $ PO.LndSubFail+ chanEither <- liftIO $ wait $ PO.fundAsync openChanRes+ $(logTM) ErrorS $ logStr $ "Fails with:" <> inspect chanEither+ leases <- withLndT Lnd.listLeases ($ LL.ListLeasesRequest) <&> LL.lockedUtxos+ let allLockedAfterFail = all (\pu -> isJust $ find (\l -> LL.outpoint l == Just (getOutPoint pu)) leases) psbtUtxos+ liftIO $ do+ shouldSatisfy chanEither isLeft+ shouldBe allLockedAfterFail True
@@ -0,0 +1,220 @@+module RefunderSpec+ ( spec,+ )+where++import BtcLsp.Import hiding (setGrpcCtxT)+import BtcLsp.Storage.Model.SwapUtxo (getUtxosBySwapIdSql)+import Data.List (intersect)+import qualified Data.Vector as V+import LndClient (txIdParser)+import qualified LndClient as Lnd+import qualified LndClient.Data.SendCoins as SendCoins+import LndClient.LndTest (liftLndResult, mine)+import qualified LndClient.RPC.Silent as Lnd+import qualified Network.Bitcoin as Btc+import qualified Network.Bitcoin.Types as Btc+import Test.Hspec+import TestAppM+import TestHelpers+import TestOrphan ()++--import qualified BtcLsp.Thread.BlockScanner as BlockScanner+--import qualified Data.ByteString.Lazy as L+--import qualified Data.Digest.Pure.SHA as SHA+-- ( bytestringDigest,+-- sha256,+-- )+--import qualified LndClient.Data.LeaseOutput as LO+--import qualified LndClient.Data.ListLeases as LL+--import qualified LndClient.Data.OutPoint as OP+--import LndClient.RPC.Katip+--import Universum++allIn :: Eq a => [a] -> [a] -> Bool+allIn ax bx =+ intersect ax bx == ax++refundSucceded ::+ Entity SwapIntoLn ->+ [TxId 'Funding] ->+ TestAppM 'LndLsp IO (Bool, [TxId 'Funding])+refundSucceded swp preTrs = do+ res <- runExceptT $ do+ utxos <-+ lift+ . runSql+ $ getUtxosBySwapIdSql (entityKey swp)+ refIds <-+ sequence $+ ( except+ . maybeToRight+ (FailureInt $ FailurePrivate "missing txid")+ )+ . swapUtxoRefundTxId+ . entityVal+ <$> utxos+ trsInBlock' <-+ fmap (txIdParser . Btc.unTransactionID . Btc.decTxId)+ . V.toList+ . Btc.vSubTransactions+ <$> getLatestBlock+ trsInBlock <-+ liftLndResult $ sequence trsInBlock'+ let foundTrs = (from <$> trsInBlock) <> preTrs+ let allRefundTxsOnChain = allIn (nubOrd refIds) foundTrs+ let utxosMakedRefunded =+ notNull utxos+ && all+ ( (== SwapUtxoSpentRefund)+ . swapUtxoStatus+ . entityVal+ )+ utxos+ pure+ ( allRefundTxsOnChain && utxosMakedRefunded,+ foundTrs+ )+ pure $+ fromRight (False, preTrs) res++spec :: Spec+spec = do+ itMainT "Refunder Spec" $ do+ amt <-+ lift getSwapIntoLnMinAmt+ swp <-+ createDummySwap . Just+ =<< getFutureTime (Lnd.Seconds 5)+ sleep1s -- Let Expirer to expiry the swap+ void $+ withLndT+ Lnd.sendCoins+ ( $+ SendCoins.SendCoinsRequest+ { SendCoins.addr =+ from+ . swapIntoLnFundAddress+ . entityVal+ $ swp,+ SendCoins.amount =+ from amt+ }+ )+ lift $ mine 1 LndLsp+ sleep1s -- Let Refunder to refund UTXO+ res <- lift $ waitCond 10 (refundSucceded swp) []+ liftIO $ res `shouldSatisfy` fst++-- ============================================================================+-- Following test is break LeaseOutput lnd method (LeaseOutput Breaks specifies how)+-- ============================================================================+-- itMainT "Refunder + reorg Spec" $ do+-- void $ withBtcT Btc.setNetworkActive ($ False)+-- _ <- BlockScanner.scan+--+-- void $ withBtc2T Btc.generate (\h -> h 5 Nothing)+--+-- amt <-+-- lift getSwapIntoLnMinAmt+-- swp <-+-- createDummySwap . Just+-- =<< getFutureTime (Lnd.Seconds 5)+-- -- Let Expirer to expiry the swap+-- sleep1s+-- void $+-- withLndT+-- Lnd.sendCoins+-- ( $+-- SendCoins.SendCoinsRequest+-- { SendCoins.addr =+-- from+-- . swapIntoLnFundAddress+-- . entityVal+-- $ swp,+-- SendCoins.amount =+-- from amt+-- }+-- )+-- lift $ mine 1 LndLsp+-- -- Let Refunder to refund UTXO+-- sleep1s+-- let swpId = entityKey swp+-- res <- lift $ waitCond 10 (refundSucceded swp) []+-- utxos <- lift $ runSql $ getUtxosBySwapIdSql swpId+-- case listToMaybe utxos of+-- Just utxo -> do+-- liftIO $ swapUtxoStatus (entityVal utxo) `shouldBe` SwapUtxoSpentRefund+-- Nothing -> error "There should be one Utxo for Swap"+--+-- void $ withBtcT Btc.setNetworkActive ($ True)+-- void $ ExceptT $ waitTillNodesSynchronized 100+--+-- lift $ mine 20 LndLsp+-- utxos2 <- lift $ runSql $ getUtxosBySwapIdSql swpId+-- case listToMaybe utxos2 of+-- Just utxo2 -> do+-- liftIO $ swapUtxoStatus (entityVal utxo2) `shouldBe` SwapUtxoOrphan+-- Nothing -> error "There should be one Utxo for Swap"+-- liftIO $ res `shouldSatisfy` fst+-- itMainT @'LndLsp "LeaseOutput Breaks" $ do+-- void $ withBtcT Btc.setNetworkActive ($ False)+-- void $ withBtc2T Btc.generate (\h -> h 6 Nothing)+-- lift $ mine 5 LndLsp+-- void $ withBtcT Btc.setNetworkActive ($ True)+-- void $ ExceptT $ waitTillNodesSynchronized 100+-- sleep1s+-- bHeight <- withBtc2T Btc.getBlockCount id+-- hash <- withBtc2T Btc.getBlockHash ($ bHeight)+-- blk <- withBtc2T Btc.getBlockVerbose ($ hash)+-- let trs = case listToMaybe $ toList $ Btc.vSubTransactions blk of+-- Just t -> t+-- Nothing -> error "no transactions"+-- let vout = case listToMaybe $ toList $ Btc.decVout trs of+-- Just v -> v+-- Nothing -> error "no vout"+-- let expS :: Word64 = 3600 * 24 * 365 * 10+-- outP = newOutPoint (getTxOut $ Btc.decTxId trs) (getVout vout)+-- lockId = newLockId0 (getTxOut $ Btc.decTxId trs) (getVout vout)+-- where+-- getVout (Btc.TxOut _ vout _) = tryFrom vout+-- getTxOut txid = txIdParser $ Btc.unTransactionID txid+-- newLockId0 ::+-- Either LndError ByteString ->+-- Either (TryFromException Integer (Vout 'Funding)) (Vout 'Funding) ->+-- UtxoLockId+-- newLockId0 (Right txid0) (Right vout0) = do+-- let txid1 :: TxId 'Funding = from txid0+-- let txid = L.fromStrict $ coerce txid1+-- vout = Universum.show vout0+-- UtxoLockId+-- . L.toStrict+-- . SHA.bytestringDigest+-- . SHA.sha256+-- $ txid <> ":" <> vout+-- newLockId0 _ _ = error "newLockId0 error"+-- newOutPoint ::+-- Either LndError ByteString ->+-- Either (TryFromException Integer (Vout 'Funding)) (Vout 'Funding) ->+-- OP.OutPoint+-- newOutPoint (Right txid0) (Right vout0) = do+-- let txid1 :: TxId 'Funding = from txid0+-- let txid = coerce txid1+-- vout = coerce vout0+-- OP.OutPoint txid vout+-- newOutPoint _ _ = error "newOutPoint error"++--waitTillNodesSynchronized :: (MonadReader (TestEnv o) m, Env m) => Int -> m (Either Failure ())+--waitTillNodesSynchronized 0 = return $ Left $ FailureInternal "Cannot be synchronized"+--waitTillNodesSynchronized n = runExceptT $ do+-- sleep1s+-- blockCount1 <- withBtcT Btc.getBlockCount id+-- blockCount2 <- withBtc2T Btc.getBlockCount id+-- if blockCount1 == blockCount2+-- then do+-- blockHash1 <- withBtcT Btc.getBlockHash ($ blockCount1)+-- blockHash2 <- withBtc2T Btc.getBlockHash ($ blockCount2)+-- if blockHash1 == blockHash2+-- then return ()+-- else ExceptT $ waitTillNodesSynchronized (n -1)+-- else ExceptT $ waitTillNodesSynchronized (n -1)
@@ -0,0 +1,70 @@+{-# LANGUAGE TypeApplications #-}++module ReorgSpec+ ( spec,+ )+where++import BtcLsp.Grpc.Orphan ()+import BtcLsp.Import hiding (setGrpcCtx, setGrpcCtxT)+import qualified BtcLsp.Storage.Model.Block as Block+import qualified BtcLsp.Thread.BlockScanner as BlockScanner+import qualified Network.Bitcoin as Btc+import Test.Hspec+import TestAppM+import TestOrphan ()++spec :: Spec+spec = do+ itEnvT @'LndLsp "Reorg test" $ do+ void $ withBtcT Btc.setNetworkActive ($ False)+ _ <- BlockScanner.scan++ void $ withBtcT Btc.generate (\h -> h 5 Nothing)+ void $ withBtc2T Btc.generate (\h -> h 10 Nothing)+ blockCount <- withBtcT Btc.getBlockCount id+ _ <- BlockScanner.scan+ blkList1 <-+ lift . runSql+ . Block.getBlockByHeightSql+ . BlkHeight+ $ fromIntegral blockCount+ let blk1 = unsafeHead $ entityVal <$> blkList1+ blockHash1 <- withBtcT Btc.getBlockHash ($ blockCount)+ liftIO $ from (blockHash blk1) `shouldBe` blockHash1++ void $ withBtcT Btc.setNetworkActive ($ True)+ _ <- lift waitTillNodesSynchronized+ _ <- BlockScanner.scan+ blkList2 <-+ lift . runSql+ . Block.getBlockByHeightSql+ . BlkHeight+ $ fromIntegral blockCount+ let blk2 = unsafeHead $ entityVal <$> blkList2+ blockHash2 <- withBtcT Btc.getBlockHash ($ blockCount)+ liftIO $ from (blockHash blk2) `shouldBe` blockHash2++unsafeHead :: [Block] -> Block+unsafeHead blkList = do+ case blkList of+ [blk] -> blk+ _ -> error "There is no blocks in a list"++waitTillNodesSynchronized ::+ ( MonadReader (TestEnv o) m,+ Env m+ ) =>+ m (Either Failure ())+waitTillNodesSynchronized = runExceptT $ do+ sleep1s+ blockCount1 <- withBtcT Btc.getBlockCount id+ blockCount2 <- withBtc2T Btc.getBlockCount id+ if blockCount1 == blockCount2+ then do+ blockHash1 <- withBtcT Btc.getBlockHash ($ blockCount1)+ blockHash2 <- withBtc2T Btc.getBlockHash ($ blockCount2)+ if blockHash1 == blockHash2+ then return ()+ else ExceptT waitTillNodesSynchronized+ else ExceptT waitTillNodesSynchronized
@@ -0,0 +1,158 @@+{-# LANGUAGE TypeApplications #-}++module ServerSpec+ ( spec,+ )+where++import qualified BtcLsp.Grpc.Client.HighLevel as Client+import BtcLsp.Grpc.Client.LowLevel+import BtcLsp.Grpc.Orphan ()+import BtcLsp.Import hiding (setGrpcCtx, setGrpcCtxT)+import qualified BtcLsp.Storage.Model.LnChan as L+import qualified BtcLsp.Storage.Model.SwapIntoLn as S+import qualified BtcLsp.Storage.Model.SwapUtxo as SU+import qualified LndClient as Lnd+import qualified LndClient.Data.Channel as Lnd+import qualified LndClient.Data.ListChannels as ListChannels+import LndClient.LndTest (lazyConnectNodes, mine)+import qualified LndClient.RPC.Silent as Lnd+import qualified Network.Bitcoin as Btc+import qualified Proto.BtcLsp.Data.HighLevel as Proto+import qualified Proto.BtcLsp.Data.HighLevel_Fields as Proto+import qualified Proto.BtcLsp.Data.LowLevel_Fields as LowLevel+import qualified Proto.BtcLsp.Data.LowLevel_Fields as SwapIntoLn+import qualified Proto.BtcLsp.Method.GetCfg_Fields as GetCfg+import qualified Proto.BtcLsp.Method.SwapIntoLn_Fields as SwapIntoLn+import Test.Hspec+import TestAppM+import TestHelpers+import TestOrphan ()++getChannels :: Env m => Lnd.NodePubKey -> ExceptT Failure m [Lnd.Channel]+getChannels pub =+ withLndT+ Lnd.listChannels+ ( $+ ListChannels.ListChannelsRequest+ { ListChannels.activeOnly = True,+ ListChannels.inactiveOnly = False,+ ListChannels.publicOnly = False,+ ListChannels.privateOnly = False,+ ListChannels.peer = Just pub+ }+ )++spec :: Spec+spec = forM_ [Compressed, Uncompressed] $ \compressMode -> do+ itMainT @'LndLsp "GetCfg" $ do+ let minAmt :: Proto.LocalBalance =+ defMessage+ & Proto.val+ .~ ( defMessage+ & LowLevel.val .~ 12000000+ )+ let maxAmt :: Proto.LocalBalance =+ defMessage+ & Proto.val+ .~ ( defMessage+ & LowLevel.val .~ 10000000000+ )+ gcEnv <- lift getGCEnv+ pub <- getPubKeyT LndLsp+ res0 <-+ Client.getCfgT+ gcEnv+ { gcEnvCompressMode = compressMode+ }+ =<< setGrpcCtxT LndAlice defMessage+ liftIO $+ (res0 ^. GetCfg.success)+ `shouldBe` ( defMessage+ & GetCfg.lspLnNodes+ .~ [ defMessage+ & Proto.pubKey+ .~ from pub+ & Proto.host+ .~ ( defMessage+ & Proto.val .~ "127.0.0.1"+ )+ & Proto.port+ .~ ( defMessage+ & Proto.val .~ 9736+ )+ ]+ & GetCfg.swapIntoLnMinAmt .~ minAmt+ & GetCfg.swapIntoLnMaxAmt .~ maxAmt+ & GetCfg.swapFromLnMinAmt .~ minAmt+ & GetCfg.swapFromLnMaxAmt .~ maxAmt+ & GetCfg.swapLnFeeRate+ .~ ( defMessage+ & Proto.val+ .~ ( defMessage+ & LowLevel.numerator .~ 1+ & LowLevel.denominator .~ 250+ )+ )+ & GetCfg.swapLnMinFee+ .~ ( defMessage+ & Proto.val+ .~ ( defMessage+ & LowLevel.val .~ 2000000+ )+ )+ )+ itMainT @'LndLsp "Server SwapIntoLn" $ do+ gcEnv <- lift getGCEnv+ refundAddr <- from <$> genAddress LndAlice+ res0 <-+ Client.swapIntoLnT+ gcEnv+ { gcEnvCompressMode = compressMode+ }+ =<< setGrpcCtxT+ LndAlice+ ( defMessage+ & SwapIntoLn.refundOnChainAddress+ .~ from @(OnChainAddress 'Refund) refundAddr+ )++ liftIO $+ res0+ `shouldSatisfy` ( \msg ->+ isJust $+ msg ^. SwapIntoLn.maybe'success+ )+ let fundAddr =+ res0+ ^. ( SwapIntoLn.success+ . SwapIntoLn.fundOnChainAddress+ . SwapIntoLn.val+ . SwapIntoLn.val+ )+ alicePub <- getPubKeyT LndAlice+ void $ withBtcT Btc.sendToAddress (\h -> h fundAddr 0.01 Nothing Nothing)+ lift $ mine 5 LndLsp >> sleep1s >> lazyConnectNodes (Proxy :: Proxy TestOwner)+ checksPassed <-+ lift $+ waitCond+ 10+ ( \_ -> do+ mine 5 LndLsp+ eLndChans <- runExceptT $ getChannels alicePub+ mswp <- runSql $ S.getByFundAddressSql (unsafeNewOnChainAddress fundAddr)+ case (mswp, eLndChans) of+ (Just swp, Right lndChans) -> do+ let swapInDbSuccess = SwapSucceeded == swapIntoLnStatus (entityVal swp)+ utxos <- runSql $ SU.getUtxosBySwapIdSql $ entityKey swp+ let allUtxosMarkedAsUsed = all (\u -> swapUtxoStatus (entityVal u) == SwapUtxoSpentChanSwapped) utxos+ let expectedRemoteBalance = swapIntoLnChanCapUser $ entityVal swp+ dbChans <- runSql $ L.getBySwapIdSql $ entityKey swp+ let chanExistInDb = length dbChans == 1+ let openedChanWithRightCap = isJust $ find (\c -> Lnd.remoteBalance c == from expectedRemoteBalance) lndChans+ pure (swapInDbSuccess && allUtxosMarkedAsUsed && openedChanWithRightCap && chanExistInDb, ())+ _ -> pure (False, ())+ )+ ()+ liftIO $ do+ shouldBe (fst checksPassed) True
@@ -0,0 +1,51 @@+{-# LANGUAGE TypeApplications #-}++module SmartSpec+ ( spec,+ )+where++import qualified BtcLsp.Data.Smart as Smart+import BtcLsp.Import+import qualified LndClient.Data.NewAddress as Lnd+import qualified LndClient.RPC.Silent as Lnd+import Test.Hspec+import TestAppM++spec :: Spec+spec = do+ itEnvT @'LndLsp "newOnChainAddressT succeeds" $ do+ raw <-+ Lnd.address+ <$> withLndTestT+ LndAlice+ Lnd.newAddress+ ( $+ Lnd.NewAddressRequest+ { Lnd.addrType = Lnd.WITNESS_PUBKEY_HASH,+ Lnd.account = Nothing+ }+ )+ res <- Smart.newOnChainAddressT $ from raw+ liftIO $ raw `shouldBe` from res+ itEnv @'LndLsp "newOnChainAddressT fails" $ do+ res <- runExceptT $ do+ raw <-+ Lnd.address+ <$> withLndTestT+ LndAlice+ Lnd.newAddress+ ( $+ Lnd.NewAddressRequest+ { Lnd.addrType = Lnd.NESTED_PUBKEY_HASH,+ Lnd.account = Nothing+ }+ )+ Smart.newOnChainAddressT $ from raw+ liftIO $+ res `shouldBe` Left (FailureInp FailureNonSegwitAddr)+ itEnv @'LndLsp "newOnChainAddressT throws" $ do+ res <-+ Smart.newOnChainAddress $ from @Text "hello"+ liftIO $+ res `shouldBe` Left (FailureInp FailureNonValidAddr)
@@ -0,0 +1,2 @@+{-# OPTIONS_GHC -F -pgmF hspec-discover -optF --module-name=Spec #-}+{-# OPTIONS_GHC -Wno-missing-export-lists #-}
@@ -0,0 +1,558 @@+{-# LANGUAGE DeriveFunctor #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TypeApplications #-}++module TestAppM+ ( runTestApp,+ TestAppM,+ TestEnv (..),+ TestOwner (..),+ proxyOwner,+ assertChannelState,+ module ReExport,+ itProp,+ itEnv,+ itMain,+ itEnvT,+ itMainT,+ withTestEnv,+ getGCEnv,+ withLndTestT,+ getPubKeyT,+ setGrpcCtxT,+ withBtc2,+ withBtc2T,+ forkThread,+ mainTestSetup,+ )+where++import BtcLsp.Data.Env as Env+import BtcLsp.Grpc.Client.LowLevel+import qualified BtcLsp.Grpc.Sig as Sig+import BtcLsp.Import as I hiding (setGrpcCtxT)+import qualified BtcLsp.Import.Psql as Psql+import qualified BtcLsp.Storage.Migration as Migration+import qualified BtcLsp.Storage.Model.LnChan as LnChan+import qualified BtcLsp.Thread.Main as Main+import Data.Aeson (eitherDecodeStrict)+import qualified Data.ByteString as BS+import qualified Data.ByteString.Char8 as C8 hiding (filter, length)+import Data.ProtoLens.Field+import qualified Env as E+import LndClient (LndEnv (..))+import qualified LndClient as Lnd+import qualified LndClient.Data.GetInfo as GetInfo+import qualified LndClient.Data.SignMessage as Lnd+import qualified LndClient.Data.WalletBalance as Lnd+import LndClient.LndTest as ReExport (LndTest)+import qualified LndClient.LndTest as LndTest+import qualified LndClient.RPC.Silent as Lnd+import Network.Bitcoin as Btc (Client, getClient)+import qualified Proto.BtcLsp.Data.HighLevel as Proto+import qualified Proto.BtcLsp.Data.HighLevel_Fields as Proto+import Test.Hspec+import Test.QuickCheck+import UnliftIO.Concurrent+ ( ThreadId,+ forkFinally,+ )+import qualified UnliftIO.Exception as UnIO+import Prelude (show)++data TestOwner+ = LndLsp+ | LndAlice+ deriving stock+ ( Eq,+ Ord,+ Bounded,+ Enum,+ Show,+ Generic+ )++instance Out TestOwner++proxyOwner :: Proxy TestOwner+proxyOwner = Proxy++data TestEnv (owner :: TestOwner) = TestEnv+ { testEnvLsp :: Env.Env,+ testEnvBtc :: Btc.Client,+ testEnvBtc2 :: Btc.Client,+ testEnvLndLsp :: LndTest.TestEnv,+ testEnvLndAlice :: LndTest.TestEnv,+ testEnvKatipNS :: Namespace,+ testEnvKatipCTX :: LogContexts,+ testEnvKatipLE :: LogEnv,+ testEnvGCEnv :: GCEnv+ }++newtype TestAppM owner m a = TestAppM+ { unTestAppM :: ReaderT (TestEnv owner) m a+ }+ deriving stock (Functor)+ deriving newtype+ ( Applicative,+ Monad,+ MonadIO,+ MonadReader (TestEnv owner),+ MonadUnliftIO+ )++runTestApp :: TestEnv owner -> TestAppM owner m a -> m a+runTestApp env app =+ runReaderT (unTestAppM app) env++instance (MonadUnliftIO m) => I.Env (TestAppM 'LndLsp m) where+ getGsEnv =+ asks $ envGrpcServer . testEnvLsp+ getSwapIntoLnMinAmt =+ asks $ envSwapIntoLnMinAmt . testEnvLsp+ getMsatPerByte =+ asks $ envMsatPerByte . testEnvLsp+ getLspPubKeyVar =+ asks $ envLndPubKey . testEnvLsp+ getLspLndEnv =+ asks $ envLnd . testEnvLsp+ getYesodLog =+ asks $ envYesodLog . testEnvLsp+ getLndP2PSocketAddress = do+ host <- asks $ envLndP2PHost . testEnvLsp+ port <- asks $ envLndP2PPort . testEnvLsp+ pure+ SocketAddress+ { socketAddressHost = host,+ socketAddressPort = port+ }+ withLnd method args = do+ lnd <- asks $ envLnd . testEnvLsp+ first (const $ FailureInt FailureRedacted) <$> args (method lnd)+ withBtc method args = do+ env <- asks $ Env.envBtc . testEnvLsp+ liftIO $ first exHandler <$> UnIO.tryAny (args $ method env)+ where+ exHandler :: (Exception e) => e -> Failure+ exHandler =+ FailureInt+ . FailurePrivate+ . pack+ . displayException+ monitorTotalExtOutgoingLiquidity amt = do+ lim <- asks $ envMinTotalExtOutgoingLiquidity . testEnvLsp+ when (amt < lim) $+ $(logTM) CriticalS . logStr $+ "Not enough outgoing liquidity to the external "+ <> "lightning network, got "+ <> inspect amt+ <> " but minimum is "+ <> inspect lim+ <> "."+ monitorTotalExtIncomingLiquidity amt = do+ lim <- asks $ envMinTotalExtIncomingLiquidity . testEnvLsp+ when (amt < lim) $+ $(logTM) CriticalS . logStr $+ "Not enough incoming liquidity from the external "+ <> "lightning network, got "+ <> inspect amt+ <> " but minimum is "+ <> inspect lim+ <> "."+ monitorTotalOnChainLiquidity wal = do+ lim <- asks $ envMinTotalOnChainLiquidity . testEnvLsp+ when (Lnd.totalBalance wal < lim) $+ $(logTM) CriticalS . logStr $+ "Not enough onchain liquidity, got "+ <> inspect wal+ <> " but minimum is "+ <> inspect lim+ <> "."++instance (MonadUnliftIO m) => Katip (TestAppM owner m) where+ getLogEnv =+ asks testEnvKatipLE+ localLogEnv f (TestAppM m) =+ TestAppM+ ( local+ (\s -> s {testEnvKatipLE = f (testEnvKatipLE s)})+ m+ )++instance (MonadUnliftIO m) => KatipContext (TestAppM owner m) where+ getKatipContext =+ asks testEnvKatipCTX+ localKatipContext f (TestAppM m) =+ TestAppM+ ( local+ (\s -> s {testEnvKatipCTX = f (testEnvKatipCTX s)})+ m+ )+ getKatipNamespace =+ asks testEnvKatipNS+ localKatipNamespace f (TestAppM m) =+ TestAppM+ ( local+ (\s -> s {testEnvKatipNS = f (testEnvKatipNS s)})+ m+ )++instance (MonadUnliftIO m) => LndTest (TestAppM owner m) TestOwner where+ getBtcClient =+ const $ asks testEnvBtc+ getTestEnv = \case+ LndLsp -> asks testEnvLndLsp+ LndAlice -> asks testEnvLndAlice++instance (MonadUnliftIO m) => Storage (TestAppM owner m) where+ getSqlPool =+ envSQLPool <$> asks testEnvLsp+ runSql query = do+ pool <- getSqlPool+ Psql.runSqlPool query pool++withTestEnv :: (MonadUnliftIO m) => TestAppM owner m a -> m a+withTestEnv action =+ withTestEnv' $ \env ->+ runTestApp env $+ LndTest.setupZeroChannels proxyOwner >> action++withBtc2 ::+ (MonadReader (TestEnv owner) m, MonadUnliftIO m) =>+ (Client -> t) ->+ (t -> IO b) ->+ m (Either a b)+withBtc2 method args = do+ env <- asks testEnvBtc2+ liftIO $ Right <$> args (method env)++withBtc2T ::+ (MonadReader (TestEnv owner) m, MonadUnliftIO m) =>+ (Client -> t) ->+ (t -> IO a) ->+ ExceptT e m a+withBtc2T method =+ ExceptT . withBtc2 method++withLndTestT ::+ ( LndTest m owner+ ) =>+ owner ->+ (Lnd.LndEnv -> a) ->+ (a -> m (Either Lnd.LndError b)) ->+ ExceptT Failure m b+withLndTestT owner method args = do+ env <- lift $ LndTest.getLndEnv owner+ ExceptT $ first (const $ FailureInt FailureRedacted) <$> args (method env)++withTestEnv' ::+ ( MonadUnliftIO m+ ) =>+ (TestEnv owner -> m a) ->+ m a+withTestEnv' action = do+ gcEnv <- liftIO readGCEnv+ lspRc <- liftIO readRawConfig+ lndAliceEnv <- readLndAliceEnv+ btcClient <-+ liftIO $+ Btc.getClient+ (unpack . bitcoindEnvHost $ rawConfigBtcEnv lspRc)+ (encodeUtf8 . bitcoindEnvUsername $ rawConfigBtcEnv lspRc)+ (encodeUtf8 . bitcoindEnvPassword $ rawConfigBtcEnv lspRc)+ btcEnv2 <- readBtcEnv2+ btcClient2 <-+ liftIO $+ Btc.getClient+ (unpack . bitcoindEnvHost $ btcEnv2)+ (encodeUtf8 . bitcoindEnvUsername $ btcEnv2)+ (encodeUtf8 . bitcoindEnvPassword $ btcEnv2)+ let aliceRc =+ lspRc+ { rawConfigLndEnv = lndAliceEnv+ }+ withEnv lspRc $ \lspAppEnv ->+ lift . withEnv aliceRc $ \aliceAppEnv -> do+ let katipNS = envKatipNS lspAppEnv+ let katipLE = envKatipLE lspAppEnv+ let katipCTX = envKatipCTX lspAppEnv+ LndTest.withTestEnv+ (envLnd lspAppEnv)+ (Lnd.NodeLocation $ getP2PAddr (envLndP2PHost lspAppEnv) (envLndP2PPort lspAppEnv))+ $ \lspTestEnv ->+ LndTest.withTestEnv+ (envLnd aliceAppEnv)+ (Lnd.NodeLocation $ getP2PAddr (envLndP2PHost aliceAppEnv) (envLndP2PPort aliceAppEnv))+ $ \aliceTestEnv ->+ lift . action $+ TestEnv+ { testEnvLsp = lspAppEnv,+ testEnvBtc = btcClient,+ testEnvBtc2 = btcClient2,+ testEnvLndLsp = lspTestEnv,+ testEnvLndAlice = aliceTestEnv,+ testEnvKatipNS = katipNS,+ testEnvKatipLE = katipLE,+ testEnvKatipCTX = katipCTX,+ testEnvGCEnv =+ gcEnv+ { gcEnvSigner =+ runKatipContextT+ katipLE+ katipCTX+ katipNS+ . signT+ ( LndTest.testLndEnv+ aliceTestEnv+ )+ }+ }+ where+ getP2PAddr host port =+ pack host <> ":" <> pack (show port)++signT ::+ Lnd.LndEnv ->+ Sig.MsgToSign ->+ KatipContextT IO (Maybe Sig.LndSig)+signT env msg = do+ eSig <-+ Lnd.signMessage env $+ Lnd.SignMessageRequest+ { Lnd.message = Sig.unMsgToSign msg,+ Lnd.keyLoc =+ Lnd.KeyLocator+ { Lnd.keyFamily = 6,+ Lnd.keyIndex = 0+ },+ Lnd.doubleHash = False,+ Lnd.compactSig = False+ }+ case eSig of+ Left e -> do+ $(logTM) ErrorS . logStr $+ "Client ==> signing procedure failed "+ <> inspect e+ pure Nothing+ Right sig0 -> do+ let sig = coerce sig0+ $(logTM) DebugS . logStr $+ "Client ==> signing procedure succeeded for msg of "+ <> inspect (BS.length $ Sig.unMsgToSign msg)+ <> " bytes "+ <> inspect msg+ <> " got signature of "+ <> inspect (BS.length sig)+ <> " bytes "+ <> inspect sig+ pure . Just $ Sig.LndSig sig++itProp ::+ forall owner.+ String ->+ TestAppM owner IO Property ->+ SpecWith (Arg (IO ()))+itProp testName expr =+ it testName $ do+ ioProperty+ . withTestEnv+ $ katipAddContext+ (sl "TestName" testName)+ expr++itEnv ::+ forall owner.+ String ->+ TestAppM owner IO () ->+ SpecWith (Arg (IO ()))+itEnv testName expr =+ it testName $+ withTestEnv $+ katipAddContext+ (sl "TestName" testName)+ expr++itMain ::+ forall owner.+ ( I.Env (TestAppM owner IO)+ ) =>+ String ->+ TestAppM owner IO () ->+ SpecWith (Arg (IO ()))+itMain testName expr =+ it testName $+ withTestEnv $+ katipAddContext+ (sl "TestName" testName)+ ( withSpawnLink Main.apply . const $ do+ -- Let endpoints and watchers spawn+ sleep300ms+ -- Evaluate given expression+ expr+ )++itEnvT ::+ forall owner e.+ ( Show e+ ) =>+ String ->+ ExceptT e (TestAppM owner IO) () ->+ SpecWith (Arg (IO ()))+itEnvT testName expr =+ it testName $+ withTestEnv $+ katipAddContext+ (sl "TestName" testName)+ ( do+ res <- runExceptT expr+ liftIO $ res `shouldSatisfy` isRight+ )++itMainT ::+ forall owner e.+ ( Show e,+ I.Env (TestAppM owner IO)+ ) =>+ String ->+ ExceptT e (TestAppM owner IO) () ->+ SpecWith (Arg (IO ()))+itMainT testName expr =+ it testName $+ withTestEnv $+ katipAddContext+ (sl "TestName" testName)+ ( do+ res <-+ withSpawnLink Main.apply . const . runExceptT $ do+ -- Let endpoints and watchers spawn+ sleep300ms+ -- Evaluate given expression+ expr+ liftIO $+ res `shouldSatisfy` isRight+ )++readLndAliceEnv :: (MonadUnliftIO m) => m LndEnv+readLndAliceEnv =+ liftIO+ . E.parse (E.header "LndEnv")+ $ E.var+ (parser <=< E.nonempty)+ "LND_ALICE_ENV"+ (E.keep <> E.help "")+ where+ parser :: String -> Either E.Error LndEnv+ parser x =+ first E.UnreadError $ eitherDecodeStrict $ C8.pack x++readBtcEnv2 :: (MonadUnliftIO m) => m BitcoindEnv+readBtcEnv2 =+ liftIO+ . E.parse (E.header "BitcoindEnv")+ $ E.var+ (parser <=< E.nonempty)+ "LSP_BITCOIND_ENV2"+ (E.keep <> E.help "")+ where+ parser :: String -> Either E.Error BitcoindEnv+ parser x =+ first E.UnreadError $ eitherDecodeStrict $ C8.pack x++waitForChannelStatus ::+ (I.Env m) =>+ TxId 'Funding ->+ Vout 'Funding ->+ LnChanStatus ->+ Int ->+ m (Either Expectation LnChan)+waitForChannelStatus _ _ expectedStatus 0 =+ pure . Left . expectationFailure $+ "waiting for channel " <> inspectStr expectedStatus <> " tries exceeded"+waitForChannelStatus txid vout expectedStatus tries = do+ let loop = waitForChannelStatus txid vout expectedStatus (tries - 1)+ dbChannel <- runSql $ LnChan.getByChannelPointSql txid vout+ liftIO $ delay 1000000+ case dbChannel of+ Just db -> do+ let chModel = Psql.entityVal db+ let status = lnChanStatus chModel+ if status == expectedStatus+ then pure $ Right chModel+ else loop+ Nothing -> loop++assertChannelState ::+ (I.Env m) =>+ TxId 'Funding ->+ Vout 'Funding ->+ LnChanStatus ->+ m ()+assertChannelState txid vout state = do+ dbChannelPending <- waitForChannelStatus txid vout state 30+ liftIO $ case dbChannelPending of+ Right channel -> shouldBe (lnChanStatus channel) state+ Left triesExceded -> triesExceded++getGCEnv ::+ ( Monad m+ ) =>+ TestAppM owner m GCEnv+getGCEnv =+ asks testEnvGCEnv++getPubKeyT ::+ ( MonadUnliftIO m,+ LndTest m owner+ ) =>+ owner ->+ ExceptT Failure m Lnd.NodePubKey+getPubKeyT owner =+ GetInfo.identityPubkey+ <$> withLndTestT owner Lnd.getInfo id++setGrpcCtxT ::+ ( HasField msg "ctx" Proto.Ctx,+ MonadUnliftIO m,+ LndTest m owner+ ) =>+ owner ->+ msg ->+ ExceptT Failure m msg+setGrpcCtxT owner message = do+ nonce <- newNonce+ pubKey <- getPubKeyT owner+ pure $+ message+ & field @"ctx"+ .~ ( defMessage+ & Proto.nonce+ .~ from @Nonce @Proto.Nonce nonce+ & Proto.lnPubKey+ .~ from @Lnd.NodePubKey @Proto.LnPubKey pubKey+ )++forkThread ::+ ( MonadUnliftIO m+ ) =>+ m () ->+ m (ThreadId, MVar ())+forkThread proc = do+ handle <- newEmptyMVar+ tid <- forkFinally proc (const $ putMVar handle ())+ return (tid, handle)++mainTestSetup :: IO ()+mainTestSetup =+ withTestEnv $ do+ runSql cleanTestDbSql+ Migration.migrateAll++cleanTestDbSql :: (MonadUnliftIO m) => Psql.SqlPersistT m ()+cleanTestDbSql =+ Psql.rawExecute+ ( "DROP SCHEMA IF EXISTS public CASCADE;"+ <> "CREATE SCHEMA public;"+ <> "GRANT ALL ON SCHEMA public TO public;"+ <> "COMMENT ON SCHEMA public IS 'standard public schema';"+ )+ []
@@ -0,0 +1,106 @@+module TestHelpers+ ( genAddress,+ createDummySwap,+ getLatestBlock,+ putLatestBlockToDB,+ waitCond,+ )+where++import BtcLsp.Import+import qualified BtcLsp.Storage.Model.Block as Block+import qualified BtcLsp.Storage.Model.SwapIntoLn as SwapIntoLn+import qualified BtcLsp.Storage.Model.User as User+import qualified LndClient as Lnd+import qualified LndClient.Data.NewAddress as Lnd+import LndClient.LndTest (mine)+import qualified LndClient.RPC.Silent as Lnd+import qualified Network.Bitcoin as Btc+import TestAppM+import TestOrphan ()++genAddress ::+ TestOwner ->+ ExceptT+ Failure+ (TestAppM 'LndLsp IO)+ Lnd.NewAddressResponse+genAddress own =+ withLndTestT+ own+ Lnd.newAddress+ ( $+ Lnd.NewAddressRequest+ { Lnd.addrType = Lnd.WITNESS_PUBKEY_HASH,+ Lnd.account = Nothing+ }+ )++genUser ::+ TestOwner ->+ ExceptT Failure (TestAppM 'LndLsp IO) (Entity User)+genUser owner = do+ alicePub <- getPubKeyT owner+ nonce <- lift newNonce+ ExceptT . runSql $ User.createVerifySql alicePub nonce++createDummySwap ::+ Maybe UTCTime ->+ ExceptT Failure (TestAppM 'LndLsp IO) (Entity SwapIntoLn)+createDummySwap mExpAt = do+ usr <- genUser LndAlice+ fundAddr <- genAddress LndLsp+ changeAndFeeAddr <- genAddress LndLsp+ refundAddr <- genAddress LndAlice+ expAt <-+ maybeM+ (getFutureTime (Lnd.Seconds 3600))+ pure+ $ pure mExpAt+ lift . runSql $+ SwapIntoLn.createIgnoreSql+ usr+ (from fundAddr)+ (from changeAndFeeAddr)+ (from refundAddr)+ expAt+ Public++getLatestBlock :: ExceptT Failure (TestAppM 'LndLsp IO) Btc.BlockVerbose+getLatestBlock = do+ blkCount <- withBtcT Btc.getBlockCount id+ hash <- withBtcT Btc.getBlockHash ($ blkCount)+ withBtcT Btc.getBlockVerbose ($ hash)++putLatestBlockToDB :: ExceptT Failure (TestAppM 'LndLsp IO) (Btc.BlockVerbose, Entity Block)+putLatestBlockToDB = do+ blk <- getLatestBlock+ height <-+ tryFromT "putLatestBlockToDB block height" $+ Btc.vBlkHeight blk+ k <-+ lift . runSql $+ Block.createUpdateConfirmedSql+ height+ (from $ Btc.vBlockHash blk)+ pure (blk, k)++waitCond ::+ ( Env m,+ LndTest m TestOwner+ ) =>+ Integer ->+ (a -> m (Bool, a)) ->+ a ->+ m (Bool, a)+waitCond times condition st = do+ (cond, newSt) <- condition st+ if cond+ then pure (True, newSt)+ else+ if times == 0+ then pure (False, newSt)+ else do+ sleep1s+ mine 1 LndLsp+ waitCond (times - 1) condition newSt
@@ -0,0 +1,18 @@+{-# OPTIONS_GHC -Wno-orphans #-}++module TestOrphan () where++import BtcLsp.Import+import qualified LndClient.Data.NewAddress as Lnd+import Test.QuickCheck+import qualified Witch++instance From Lnd.NewAddressResponse (OnChainAddress 'Refund) where+ from =+ unsafeNewOnChainAddress . coerce++instance From (OnChainAddress 'Refund) Lnd.NewAddressResponse where+ from =+ coerce . unOnChainAddress++deriving newtype instance Arbitrary MSat
@@ -0,0 +1,13 @@+module TypeSpec+ ( spec,+ )+where++import BtcLsp.Import+import Test.Hspec++spec :: Spec+spec = do+ it "Swap statuses groups are complete" $+ swapStatusChain <> swapStatusLn <> swapStatusFinal+ `shouldBe` [minBound .. maxBound]