From 2ccbffadf32a0acfcc4072cfb16ef043f9ac295a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Delabrouille?= Date: Mon, 4 Nov 2024 17:29:20 +0100 Subject: [PATCH 1/3] test: add binary to run btcd and lnd --- .gitmodules | 0 integration-tests/Cargo.toml | 5 + integration-tests/src/main.rs | 48 + lib/cashubrew/application.ex | 1 + .../lightning/lightning_network_service.ex | 37 - lib/cashubrew/lightning/ln_bits.ex | 51 - lib/cashubrew/lightning/ln_lib.ex | 21 - lib/cashubrew/lightning/lnd_rpc.pb.ex | 3505 +++++++++++++++++ lib/cashubrew/lightning/lnrpc_client.ex | 57 + .../mock_lightning_network_service.ex | 55 - .../web/controllers/mint_controller.ex | 4 +- mix.exs | 4 +- mix.lock | 5 + scripts/protobuf.sh | 14 + 14 files changed, 3640 insertions(+), 167 deletions(-) create mode 100644 .gitmodules create mode 100644 integration-tests/src/main.rs delete mode 100644 lib/cashubrew/lightning/lightning_network_service.ex delete mode 100644 lib/cashubrew/lightning/ln_bits.ex delete mode 100644 lib/cashubrew/lightning/ln_lib.ex create mode 100644 lib/cashubrew/lightning/lnd_rpc.pb.ex create mode 100644 lib/cashubrew/lightning/lnrpc_client.ex delete mode 100644 lib/cashubrew/lightning/mock_lightning_network_service.ex create mode 100644 scripts/protobuf.sh diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..e69de29 diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index 7077e57..ace6c18 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -9,6 +9,11 @@ rand = "0.8.5" assert_matches = "1.5.0" tokio = "1.41.0" uuid = "1.11.0" +anyhow = "1.0.91" +bitcoind = { version = "0.34.2", features = ["26_0"] } +lnd = { version = "0.1.6", features = ["lnd_0_17_5"] } +tonic_lnd = "0.5.1" +ctrlc = "3.4" [[test]] name = "nut06" diff --git a/integration-tests/src/main.rs b/integration-tests/src/main.rs new file mode 100644 index 0000000..68d21b1 --- /dev/null +++ b/integration-tests/src/main.rs @@ -0,0 +1,48 @@ +use bitcoind::bitcoincore_rpc::RpcApi; +use lnd::Lnd; +use lnd::LndConf; +use std::sync::mpsc::channel; + +#[tokio::main] +async fn main() { + println!("Downloading bitcoind..."); + let bitcoind = bitcoind::BitcoinD::from_downloaded().unwrap(); + assert_eq!(0, bitcoind.client.get_blockchain_info().unwrap().blocks); + println!("Done"); + println!("bitcoind is running"); + + println!("Downloading lnd..."); + let lnd_conf = LndConf::default(); + let mut lnd = Lnd::with_conf( + lnd::exe_path().unwrap(), + &lnd_conf, + bitcoind + .params + .cookie_file + .clone() + .into_os_string() + .into_string() + .unwrap(), + bitcoind.params.rpc_socket.to_string(), + &bitcoind, + ) + .await + .unwrap(); + assert!(lnd + .client + .lightning() + .get_info(tonic_lnd::lnrpc::GetInfoRequest {}) + .await + .is_ok()); + println!("Done"); + println!("lnd is running"); + + let (tx, rx) = channel(); + + ctrlc::set_handler(move || tx.send(()).expect("Could not send signal on channel.")) + .expect("Error setting Ctrl-C handler"); + + println!("Press ctrl+c to exit"); + + rx.recv().expect("Could not receive from channel."); +} diff --git a/lib/cashubrew/application.ex b/lib/cashubrew/application.ex index fc247fa..e7afd57 100644 --- a/lib/cashubrew/application.ex +++ b/lib/cashubrew/application.ex @@ -7,6 +7,7 @@ defmodule Cashubrew.Application do def start(_type, _args) do children = [ Cashubrew.Web.Telemetry, + Cashubrew.LightingNetwork.Lnd, {Phoenix.PubSub, name: Cashubrew.PubSub}, Endpoint ] diff --git a/lib/cashubrew/lightning/lightning_network_service.ex b/lib/cashubrew/lightning/lightning_network_service.ex deleted file mode 100644 index 8c9f62b..0000000 --- a/lib/cashubrew/lightning/lightning_network_service.ex +++ /dev/null @@ -1,37 +0,0 @@ -defmodule Cashubrew.Lightning.LightningNetworkService do - @moduledoc """ - Lightning Network Services. - """ - alias Cashubrew.LNBitsApi - - def create_invoice!(amount, unit) do - body = %{ - out: "false", - amount: amount, - unit_input: unit - } - - case LNBitsApi.make_post("api/v1/payments", body) do - {:ok, response_body} -> - response_map = Jason.decode!(response_body) - payment_hash = response_map["payment_hash"] - payment_request = response_map["payment_request"] - {payment_request, payment_hash} - - {:error, reason} -> - raise reason - end - end - - def invoice_paid?(payment_request) do - case LNBitsApi.make_get("api/v1/payments/#{payment_request}") do - {:ok, response_body} -> - response_map = Jason.decode!(response_body) - paid = response_map["paid"] - paid - - {:error, reason} -> - raise reason - end - end -end diff --git a/lib/cashubrew/lightning/ln_bits.ex b/lib/cashubrew/lightning/ln_bits.ex deleted file mode 100644 index e55a6ee..0000000 --- a/lib/cashubrew/lightning/ln_bits.ex +++ /dev/null @@ -1,51 +0,0 @@ -defmodule Cashubrew.LNBitsApi do - @moduledoc """ - LN BITS Api Network Services. - """ - Dotenv.load() - - # Function to send a GET request - def make_get(endpoint) do - api_base_url = System.get_env("LN_BITS_API_ENDPOINT") - api_key = System.get_env("LN_BITS_API_KEY") - headers = [{"X-Api-Key", "#{api_key}"}] - full_url = "#{api_base_url}#{endpoint}" - - case HTTPoison.get(full_url, headers) do - {:ok, %HTTPoison.Response{status_code: 200, body: body}} -> - {:ok, body} - - {:ok, %HTTPoison.Response{status_code: status_code}} -> - {:error, "Received #{status_code} status code"} - - {:error, %HTTPoison.Error{reason: reason}} -> - {:error, reason} - end - end - - # Function to send a POST request with a JSON body - def make_post(endpoint, body) do - api_base_url = System.get_env("LN_BITS_API_ENDPOINT") - api_key = System.get_env("LN_BITS_API_KEY") - - headers = [ - {"X-Api-Key", "#{api_key}"}, - {"Content-Type", "application/json"} - ] - - # Convert Elixir map to JSON string - json_body = Jason.encode!(body) - full_url = "#{api_base_url}#{endpoint}" - - case HTTPoison.post(full_url, json_body, headers) do - {:ok, %HTTPoison.Response{status_code: 201, body: response_body}} -> - {:ok, response_body} - - {:ok, %HTTPoison.Response{status_code: status_code, body: error_body}} -> - {:error, "Received #{status_code}: #{error_body}"} - - {:error, %HTTPoison.Error{reason: reason}} -> - {:error, reason} - end - end -end diff --git a/lib/cashubrew/lightning/ln_lib.ex b/lib/cashubrew/lightning/ln_lib.ex deleted file mode 100644 index 848fbb1..0000000 --- a/lib/cashubrew/lightning/ln_lib.ex +++ /dev/null @@ -1,21 +0,0 @@ -defmodule Cashubrew.LightningLib do - @moduledoc """ - Mock Lightning Network Service for testing purposes. - """ - use GenServer - - def start_link(_) do - GenServer.start_link(__MODULE__, %{}, name: __MODULE__) - end - - def init(_) do - {:ok, %{invoices: %{}}} - end - - def decode_invoice(payment_hash) do - GenServer.call(__MODULE__, {:decode_invoice, payment_hash}) - end - - def handle_call({:decode_invoice, invoice}, _from, state) do - end -end diff --git a/lib/cashubrew/lightning/lnd_rpc.pb.ex b/lib/cashubrew/lightning/lnd_rpc.pb.ex new file mode 100644 index 0000000..42a1668 --- /dev/null +++ b/lib/cashubrew/lightning/lnd_rpc.pb.ex @@ -0,0 +1,3505 @@ +defmodule Cashubrew.Lnrpc.OutputScriptType do + @moduledoc false + + use Protobuf, enum: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:SCRIPT_TYPE_PUBKEY_HASH, 0) + field(:SCRIPT_TYPE_SCRIPT_HASH, 1) + field(:SCRIPT_TYPE_WITNESS_V0_PUBKEY_HASH, 2) + field(:SCRIPT_TYPE_WITNESS_V0_SCRIPT_HASH, 3) + field(:SCRIPT_TYPE_PUBKEY, 4) + field(:SCRIPT_TYPE_MULTISIG, 5) + field(:SCRIPT_TYPE_NULLDATA, 6) + field(:SCRIPT_TYPE_NON_STANDARD, 7) + field(:SCRIPT_TYPE_WITNESS_UNKNOWN, 8) + field(:SCRIPT_TYPE_WITNESS_V1_TAPROOT, 9) +end + +defmodule Cashubrew.Lnrpc.CoinSelectionStrategy do + @moduledoc false + + use Protobuf, enum: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:STRATEGY_USE_GLOBAL_CONFIG, 0) + field(:STRATEGY_LARGEST, 1) + field(:STRATEGY_RANDOM, 2) +end + +defmodule Cashubrew.Lnrpc.AddressType do + @moduledoc false + + use Protobuf, enum: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:WITNESS_PUBKEY_HASH, 0) + field(:NESTED_PUBKEY_HASH, 1) + field(:UNUSED_WITNESS_PUBKEY_HASH, 2) + field(:UNUSED_NESTED_PUBKEY_HASH, 3) + field(:TAPROOT_PUBKEY, 4) + field(:UNUSED_TAPROOT_PUBKEY, 5) +end + +defmodule Cashubrew.Lnrpc.CommitmentType do + @moduledoc false + + use Protobuf, enum: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:UNKNOWN_COMMITMENT_TYPE, 0) + field(:LEGACY, 1) + field(:STATIC_REMOTE_KEY, 2) + field(:ANCHORS, 3) + field(:SCRIPT_ENFORCED_LEASE, 4) + field(:SIMPLE_TAPROOT, 5) +end + +defmodule Cashubrew.Lnrpc.Initiator do + @moduledoc false + + use Protobuf, enum: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:INITIATOR_UNKNOWN, 0) + field(:INITIATOR_LOCAL, 1) + field(:INITIATOR_REMOTE, 2) + field(:INITIATOR_BOTH, 3) +end + +defmodule Cashubrew.Lnrpc.ResolutionType do + @moduledoc false + + use Protobuf, enum: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:TYPE_UNKNOWN, 0) + field(:ANCHOR, 1) + field(:INCOMING_HTLC, 2) + field(:OUTGOING_HTLC, 3) + field(:COMMIT, 4) +end + +defmodule Cashubrew.Lnrpc.ResolutionOutcome do + @moduledoc false + + use Protobuf, enum: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:OUTCOME_UNKNOWN, 0) + field(:CLAIMED, 1) + field(:UNCLAIMED, 2) + field(:ABANDONED, 3) + field(:FIRST_STAGE, 4) + field(:TIMEOUT, 5) +end + +defmodule Cashubrew.Lnrpc.NodeMetricType do + @moduledoc false + + use Protobuf, enum: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:UNKNOWN, 0) + field(:BETWEENNESS_CENTRALITY, 1) +end + +defmodule Cashubrew.Lnrpc.InvoiceHTLCState do + @moduledoc false + + use Protobuf, enum: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:ACCEPTED, 0) + field(:SETTLED, 1) + field(:CANCELED, 2) +end + +defmodule Cashubrew.Lnrpc.PaymentFailureReason do + @moduledoc false + + use Protobuf, enum: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:FAILURE_REASON_NONE, 0) + field(:FAILURE_REASON_TIMEOUT, 1) + field(:FAILURE_REASON_NO_ROUTE, 2) + field(:FAILURE_REASON_ERROR, 3) + field(:FAILURE_REASON_INCORRECT_PAYMENT_DETAILS, 4) + field(:FAILURE_REASON_INSUFFICIENT_BALANCE, 5) + field(:FAILURE_REASON_CANCELED, 6) +end + +defmodule Cashubrew.Lnrpc.FeatureBit do + @moduledoc false + + use Protobuf, enum: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:DATALOSS_PROTECT_REQ, 0) + field(:DATALOSS_PROTECT_OPT, 1) + field(:INITIAL_ROUING_SYNC, 3) + field(:UPFRONT_SHUTDOWN_SCRIPT_REQ, 4) + field(:UPFRONT_SHUTDOWN_SCRIPT_OPT, 5) + field(:GOSSIP_QUERIES_REQ, 6) + field(:GOSSIP_QUERIES_OPT, 7) + field(:TLV_ONION_REQ, 8) + field(:TLV_ONION_OPT, 9) + field(:EXT_GOSSIP_QUERIES_REQ, 10) + field(:EXT_GOSSIP_QUERIES_OPT, 11) + field(:STATIC_REMOTE_KEY_REQ, 12) + field(:STATIC_REMOTE_KEY_OPT, 13) + field(:PAYMENT_ADDR_REQ, 14) + field(:PAYMENT_ADDR_OPT, 15) + field(:MPP_REQ, 16) + field(:MPP_OPT, 17) + field(:WUMBO_CHANNELS_REQ, 18) + field(:WUMBO_CHANNELS_OPT, 19) + field(:ANCHORS_REQ, 20) + field(:ANCHORS_OPT, 21) + field(:ANCHORS_ZERO_FEE_HTLC_REQ, 22) + field(:ANCHORS_ZERO_FEE_HTLC_OPT, 23) + field(:ROUTE_BLINDING_REQUIRED, 24) + field(:ROUTE_BLINDING_OPTIONAL, 25) + field(:AMP_REQ, 30) + field(:AMP_OPT, 31) +end + +defmodule Cashubrew.Lnrpc.UpdateFailure do + @moduledoc false + + use Protobuf, enum: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:UPDATE_FAILURE_UNKNOWN, 0) + field(:UPDATE_FAILURE_PENDING, 1) + field(:UPDATE_FAILURE_NOT_FOUND, 2) + field(:UPDATE_FAILURE_INTERNAL_ERR, 3) + field(:UPDATE_FAILURE_INVALID_PARAMETER, 4) +end + +defmodule Cashubrew.Lnrpc.ChannelCloseSummary.ClosureType do + @moduledoc false + + use Protobuf, enum: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:COOPERATIVE_CLOSE, 0) + field(:LOCAL_FORCE_CLOSE, 1) + field(:REMOTE_FORCE_CLOSE, 2) + field(:BREACH_CLOSE, 3) + field(:FUNDING_CANCELED, 4) + field(:ABANDONED, 5) +end + +defmodule Cashubrew.Lnrpc.Peer.SyncType do + @moduledoc false + + use Protobuf, enum: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:UNKNOWN_SYNC, 0) + field(:ACTIVE_SYNC, 1) + field(:PASSIVE_SYNC, 2) + field(:PINNED_SYNC, 3) +end + +defmodule Cashubrew.Lnrpc.PeerEvent.EventType do + @moduledoc false + + use Protobuf, enum: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:PEER_ONLINE, 0) + field(:PEER_OFFLINE, 1) +end + +defmodule Cashubrew.Lnrpc.PendingChannelsResponse.ForceClosedChannel.AnchorState do + @moduledoc false + + use Protobuf, enum: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:LIMBO, 0) + field(:RECOVERED, 1) + field(:LOST, 2) +end + +defmodule Cashubrew.Lnrpc.ChannelEventUpdate.UpdateType do + @moduledoc false + + use Protobuf, enum: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:OPEN_CHANNEL, 0) + field(:CLOSED_CHANNEL, 1) + field(:ACTIVE_CHANNEL, 2) + field(:INACTIVE_CHANNEL, 3) + field(:PENDING_OPEN_CHANNEL, 4) + field(:FULLY_RESOLVED_CHANNEL, 5) +end + +defmodule Cashubrew.Lnrpc.Invoice.InvoiceState do + @moduledoc false + + use Protobuf, enum: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:OPEN, 0) + field(:SETTLED, 1) + field(:CANCELED, 2) + field(:ACCEPTED, 3) +end + +defmodule Cashubrew.Lnrpc.Payment.PaymentStatus do + @moduledoc false + + use Protobuf, enum: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:UNKNOWN, 0) + field(:IN_FLIGHT, 1) + field(:SUCCEEDED, 2) + field(:FAILED, 3) + field(:INITIATED, 4) +end + +defmodule Cashubrew.Lnrpc.HTLCAttempt.HTLCStatus do + @moduledoc false + + use Protobuf, enum: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:IN_FLIGHT, 0) + field(:SUCCEEDED, 1) + field(:FAILED, 2) +end + +defmodule Cashubrew.Lnrpc.Failure.FailureCode do + @moduledoc false + + use Protobuf, enum: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:RESERVED, 0) + field(:INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS, 1) + field(:INCORRECT_PAYMENT_AMOUNT, 2) + field(:FINAL_INCORRECT_CLTV_EXPIRY, 3) + field(:FINAL_INCORRECT_HTLC_AMOUNT, 4) + field(:FINAL_EXPIRY_TOO_SOON, 5) + field(:INVALID_REALM, 6) + field(:EXPIRY_TOO_SOON, 7) + field(:INVALID_ONION_VERSION, 8) + field(:INVALID_ONION_HMAC, 9) + field(:INVALID_ONION_KEY, 10) + field(:AMOUNT_BELOW_MINIMUM, 11) + field(:FEE_INSUFFICIENT, 12) + field(:INCORRECT_CLTV_EXPIRY, 13) + field(:CHANNEL_DISABLED, 14) + field(:TEMPORARY_CHANNEL_FAILURE, 15) + field(:REQUIRED_NODE_FEATURE_MISSING, 16) + field(:REQUIRED_CHANNEL_FEATURE_MISSING, 17) + field(:UNKNOWN_NEXT_PEER, 18) + field(:TEMPORARY_NODE_FAILURE, 19) + field(:PERMANENT_NODE_FAILURE, 20) + field(:PERMANENT_CHANNEL_FAILURE, 21) + field(:EXPIRY_TOO_FAR, 22) + field(:MPP_TIMEOUT, 23) + field(:INVALID_ONION_PAYLOAD, 24) + field(:INVALID_ONION_BLINDING, 25) + field(:INTERNAL_FAILURE, 997) + field(:UNKNOWN_FAILURE, 998) + field(:UNREADABLE_FAILURE, 999) +end + +defmodule Cashubrew.Lnrpc.LookupHtlcResolutionRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:chan_id, 1, type: :uint64, json_name: "chanId") + field(:htlc_index, 2, type: :uint64, json_name: "htlcIndex") +end + +defmodule Cashubrew.Lnrpc.LookupHtlcResolutionResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:settled, 1, type: :bool) + field(:offchain, 2, type: :bool) +end + +defmodule Cashubrew.Lnrpc.SubscribeCustomMessagesRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" +end + +defmodule Cashubrew.Lnrpc.CustomMessage do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:peer, 1, type: :bytes) + field(:type, 2, type: :uint32) + field(:data, 3, type: :bytes) +end + +defmodule Cashubrew.Lnrpc.SendCustomMessageRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:peer, 1, type: :bytes) + field(:type, 2, type: :uint32) + field(:data, 3, type: :bytes) +end + +defmodule Cashubrew.Lnrpc.SendCustomMessageResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" +end + +defmodule Cashubrew.Lnrpc.Utxo do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:address_type, 1, type: Cashubrew.Lnrpc.AddressType, json_name: "addressType", enum: true) + field(:address, 2, type: :string) + field(:amount_sat, 3, type: :int64, json_name: "amountSat") + field(:pk_script, 4, type: :string, json_name: "pkScript") + field(:outpoint, 5, type: Cashubrew.Lnrpc.OutPoint) + field(:confirmations, 6, type: :int64) +end + +defmodule Cashubrew.Lnrpc.OutputDetail do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:output_type, 1, + type: Cashubrew.Lnrpc.OutputScriptType, + json_name: "outputType", + enum: true + ) + + field(:address, 2, type: :string) + field(:pk_script, 3, type: :string, json_name: "pkScript") + field(:output_index, 4, type: :int64, json_name: "outputIndex") + field(:amount, 5, type: :int64) + field(:is_our_address, 6, type: :bool, json_name: "isOurAddress") +end + +defmodule Cashubrew.Lnrpc.Transaction do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:tx_hash, 1, type: :string, json_name: "txHash") + field(:amount, 2, type: :int64) + field(:num_confirmations, 3, type: :int32, json_name: "numConfirmations") + field(:block_hash, 4, type: :string, json_name: "blockHash") + field(:block_height, 5, type: :int32, json_name: "blockHeight") + field(:time_stamp, 6, type: :int64, json_name: "timeStamp") + field(:total_fees, 7, type: :int64, json_name: "totalFees") + + field(:dest_addresses, 8, + repeated: true, + type: :string, + json_name: "destAddresses", + deprecated: true + ) + + field(:output_details, 11, + repeated: true, + type: Cashubrew.Lnrpc.OutputDetail, + json_name: "outputDetails" + ) + + field(:raw_tx_hex, 9, type: :string, json_name: "rawTxHex") + field(:label, 10, type: :string) + + field(:previous_outpoints, 12, + repeated: true, + type: Cashubrew.Lnrpc.PreviousOutPoint, + json_name: "previousOutpoints" + ) +end + +defmodule Cashubrew.Lnrpc.GetTransactionsRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:start_height, 1, type: :int32, json_name: "startHeight") + field(:end_height, 2, type: :int32, json_name: "endHeight") + field(:account, 3, type: :string) +end + +defmodule Cashubrew.Lnrpc.TransactionDetails do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:transactions, 1, repeated: true, type: Cashubrew.Lnrpc.Transaction) +end + +defmodule Cashubrew.Lnrpc.FeeLimit do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + oneof(:limit, 0) + + field(:fixed, 1, type: :int64, oneof: 0) + field(:fixed_msat, 3, type: :int64, json_name: "fixedMsat", oneof: 0) + field(:percent, 2, type: :int64, oneof: 0) +end + +defmodule Cashubrew.Lnrpc.SendRequest.DestCustomRecordsEntry do + @moduledoc false + + use Protobuf, map: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:key, 1, type: :uint64) + field(:value, 2, type: :bytes) +end + +defmodule Cashubrew.Lnrpc.SendRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:dest, 1, type: :bytes) + field(:dest_string, 2, type: :string, json_name: "destString", deprecated: true) + field(:amt, 3, type: :int64) + field(:amt_msat, 12, type: :int64, json_name: "amtMsat") + field(:payment_hash, 4, type: :bytes, json_name: "paymentHash") + field(:payment_hash_string, 5, type: :string, json_name: "paymentHashString", deprecated: true) + field(:payment_request, 6, type: :string, json_name: "paymentRequest") + field(:final_cltv_delta, 7, type: :int32, json_name: "finalCltvDelta") + field(:fee_limit, 8, type: Cashubrew.Lnrpc.FeeLimit, json_name: "feeLimit") + field(:outgoing_chan_id, 9, type: :uint64, json_name: "outgoingChanId", deprecated: false) + field(:last_hop_pubkey, 13, type: :bytes, json_name: "lastHopPubkey") + field(:cltv_limit, 10, type: :uint32, json_name: "cltvLimit") + + field(:dest_custom_records, 11, + repeated: true, + type: Cashubrew.Lnrpc.SendRequest.DestCustomRecordsEntry, + json_name: "destCustomRecords", + map: true + ) + + field(:allow_self_payment, 14, type: :bool, json_name: "allowSelfPayment") + + field(:dest_features, 15, + repeated: true, + type: Cashubrew.Lnrpc.FeatureBit, + json_name: "destFeatures", + enum: true + ) + + field(:payment_addr, 16, type: :bytes, json_name: "paymentAddr") +end + +defmodule Cashubrew.Lnrpc.SendResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:payment_error, 1, type: :string, json_name: "paymentError") + field(:payment_preimage, 2, type: :bytes, json_name: "paymentPreimage") + field(:payment_route, 3, type: Cashubrew.Lnrpc.Route, json_name: "paymentRoute") + field(:payment_hash, 4, type: :bytes, json_name: "paymentHash") +end + +defmodule Cashubrew.Lnrpc.SendToRouteRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:payment_hash, 1, type: :bytes, json_name: "paymentHash") + field(:payment_hash_string, 2, type: :string, json_name: "paymentHashString", deprecated: true) + field(:route, 4, type: Cashubrew.Lnrpc.Route) +end + +defmodule Cashubrew.Lnrpc.ChannelAcceptRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:node_pubkey, 1, type: :bytes, json_name: "nodePubkey") + field(:chain_hash, 2, type: :bytes, json_name: "chainHash") + field(:pending_chan_id, 3, type: :bytes, json_name: "pendingChanId") + field(:funding_amt, 4, type: :uint64, json_name: "fundingAmt") + field(:push_amt, 5, type: :uint64, json_name: "pushAmt") + field(:dust_limit, 6, type: :uint64, json_name: "dustLimit") + field(:max_value_in_flight, 7, type: :uint64, json_name: "maxValueInFlight") + field(:channel_reserve, 8, type: :uint64, json_name: "channelReserve") + field(:min_htlc, 9, type: :uint64, json_name: "minHtlc") + field(:fee_per_kw, 10, type: :uint64, json_name: "feePerKw") + field(:csv_delay, 11, type: :uint32, json_name: "csvDelay") + field(:max_accepted_htlcs, 12, type: :uint32, json_name: "maxAcceptedHtlcs") + field(:channel_flags, 13, type: :uint32, json_name: "channelFlags") + + field(:commitment_type, 14, + type: Cashubrew.Lnrpc.CommitmentType, + json_name: "commitmentType", + enum: true + ) + + field(:wants_zero_conf, 15, type: :bool, json_name: "wantsZeroConf") + field(:wants_scid_alias, 16, type: :bool, json_name: "wantsScidAlias") +end + +defmodule Cashubrew.Lnrpc.ChannelAcceptResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:accept, 1, type: :bool) + field(:pending_chan_id, 2, type: :bytes, json_name: "pendingChanId") + field(:error, 3, type: :string) + field(:upfront_shutdown, 4, type: :string, json_name: "upfrontShutdown") + field(:csv_delay, 5, type: :uint32, json_name: "csvDelay") + field(:reserve_sat, 6, type: :uint64, json_name: "reserveSat") + field(:in_flight_max_msat, 7, type: :uint64, json_name: "inFlightMaxMsat") + field(:max_htlc_count, 8, type: :uint32, json_name: "maxHtlcCount") + field(:min_htlc_in, 9, type: :uint64, json_name: "minHtlcIn") + field(:min_accept_depth, 10, type: :uint32, json_name: "minAcceptDepth") + field(:zero_conf, 11, type: :bool, json_name: "zeroConf") +end + +defmodule Cashubrew.Lnrpc.ChannelPoint do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + oneof(:funding_txid, 0) + + field(:funding_txid_bytes, 1, type: :bytes, json_name: "fundingTxidBytes", oneof: 0) + field(:funding_txid_str, 2, type: :string, json_name: "fundingTxidStr", oneof: 0) + field(:output_index, 3, type: :uint32, json_name: "outputIndex") +end + +defmodule Cashubrew.Lnrpc.OutPoint do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:txid_bytes, 1, type: :bytes, json_name: "txidBytes") + field(:txid_str, 2, type: :string, json_name: "txidStr") + field(:output_index, 3, type: :uint32, json_name: "outputIndex") +end + +defmodule Cashubrew.Lnrpc.PreviousOutPoint do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:outpoint, 1, type: :string) + field(:is_our_output, 2, type: :bool, json_name: "isOurOutput") +end + +defmodule Cashubrew.Lnrpc.LightningAddress do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:pubkey, 1, type: :string) + field(:host, 2, type: :string) +end + +defmodule Cashubrew.Lnrpc.EstimateFeeRequest.AddrToAmountEntry do + @moduledoc false + + use Protobuf, map: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:key, 1, type: :string) + field(:value, 2, type: :int64) +end + +defmodule Cashubrew.Lnrpc.EstimateFeeRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:AddrToAmount, 1, + repeated: true, + type: Cashubrew.Lnrpc.EstimateFeeRequest.AddrToAmountEntry, + map: true + ) + + field(:target_conf, 2, type: :int32, json_name: "targetConf") + field(:min_confs, 3, type: :int32, json_name: "minConfs") + field(:spend_unconfirmed, 4, type: :bool, json_name: "spendUnconfirmed") + + field(:coin_selection_strategy, 5, + type: Cashubrew.Lnrpc.CoinSelectionStrategy, + json_name: "coinSelectionStrategy", + enum: true + ) +end + +defmodule Cashubrew.Lnrpc.EstimateFeeResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:fee_sat, 1, type: :int64, json_name: "feeSat") + field(:feerate_sat_per_byte, 2, type: :int64, json_name: "feerateSatPerByte", deprecated: true) + field(:sat_per_vbyte, 3, type: :uint64, json_name: "satPerVbyte") +end + +defmodule Cashubrew.Lnrpc.SendManyRequest.AddrToAmountEntry do + @moduledoc false + + use Protobuf, map: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:key, 1, type: :string) + field(:value, 2, type: :int64) +end + +defmodule Cashubrew.Lnrpc.SendManyRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:AddrToAmount, 1, + repeated: true, + type: Cashubrew.Lnrpc.SendManyRequest.AddrToAmountEntry, + map: true + ) + + field(:target_conf, 3, type: :int32, json_name: "targetConf") + field(:sat_per_vbyte, 4, type: :uint64, json_name: "satPerVbyte") + field(:sat_per_byte, 5, type: :int64, json_name: "satPerByte", deprecated: true) + field(:label, 6, type: :string) + field(:min_confs, 7, type: :int32, json_name: "minConfs") + field(:spend_unconfirmed, 8, type: :bool, json_name: "spendUnconfirmed") + + field(:coin_selection_strategy, 9, + type: Cashubrew.Lnrpc.CoinSelectionStrategy, + json_name: "coinSelectionStrategy", + enum: true + ) +end + +defmodule Cashubrew.Lnrpc.SendManyResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:txid, 1, type: :string) +end + +defmodule Cashubrew.Lnrpc.SendCoinsRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:addr, 1, type: :string) + field(:amount, 2, type: :int64) + field(:target_conf, 3, type: :int32, json_name: "targetConf") + field(:sat_per_vbyte, 4, type: :uint64, json_name: "satPerVbyte") + field(:sat_per_byte, 5, type: :int64, json_name: "satPerByte", deprecated: true) + field(:send_all, 6, type: :bool, json_name: "sendAll") + field(:label, 7, type: :string) + field(:min_confs, 8, type: :int32, json_name: "minConfs") + field(:spend_unconfirmed, 9, type: :bool, json_name: "spendUnconfirmed") + + field(:coin_selection_strategy, 10, + type: Cashubrew.Lnrpc.CoinSelectionStrategy, + json_name: "coinSelectionStrategy", + enum: true + ) + + field(:outpoints, 11, repeated: true, type: Cashubrew.Lnrpc.OutPoint) +end + +defmodule Cashubrew.Lnrpc.SendCoinsResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:txid, 1, type: :string) +end + +defmodule Cashubrew.Lnrpc.ListUnspentRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:min_confs, 1, type: :int32, json_name: "minConfs") + field(:max_confs, 2, type: :int32, json_name: "maxConfs") + field(:account, 3, type: :string) +end + +defmodule Cashubrew.Lnrpc.ListUnspentResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:utxos, 1, repeated: true, type: Cashubrew.Lnrpc.Utxo) +end + +defmodule Cashubrew.Lnrpc.NewAddressRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:type, 1, type: Cashubrew.Lnrpc.AddressType, enum: true) + field(:account, 2, type: :string) +end + +defmodule Cashubrew.Lnrpc.NewAddressResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:address, 1, type: :string) +end + +defmodule Cashubrew.Lnrpc.SignMessageRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:msg, 1, type: :bytes) + field(:single_hash, 2, type: :bool, json_name: "singleHash") +end + +defmodule Cashubrew.Lnrpc.SignMessageResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:signature, 1, type: :string) +end + +defmodule Cashubrew.Lnrpc.VerifyMessageRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:msg, 1, type: :bytes) + field(:signature, 2, type: :string) +end + +defmodule Cashubrew.Lnrpc.VerifyMessageResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:valid, 1, type: :bool) + field(:pubkey, 2, type: :string) +end + +defmodule Cashubrew.Lnrpc.ConnectPeerRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:addr, 1, type: Cashubrew.Lnrpc.LightningAddress) + field(:perm, 2, type: :bool) + field(:timeout, 3, type: :uint64) +end + +defmodule Cashubrew.Lnrpc.ConnectPeerResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" +end + +defmodule Cashubrew.Lnrpc.DisconnectPeerRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:pub_key, 1, type: :string, json_name: "pubKey") +end + +defmodule Cashubrew.Lnrpc.DisconnectPeerResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" +end + +defmodule Cashubrew.Lnrpc.HTLC do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:incoming, 1, type: :bool) + field(:amount, 2, type: :int64) + field(:hash_lock, 3, type: :bytes, json_name: "hashLock") + field(:expiration_height, 4, type: :uint32, json_name: "expirationHeight") + field(:htlc_index, 5, type: :uint64, json_name: "htlcIndex") + field(:forwarding_channel, 6, type: :uint64, json_name: "forwardingChannel") + field(:forwarding_htlc_index, 7, type: :uint64, json_name: "forwardingHtlcIndex") +end + +defmodule Cashubrew.Lnrpc.ChannelConstraints do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:csv_delay, 1, type: :uint32, json_name: "csvDelay") + field(:chan_reserve_sat, 2, type: :uint64, json_name: "chanReserveSat") + field(:dust_limit_sat, 3, type: :uint64, json_name: "dustLimitSat") + field(:max_pending_amt_msat, 4, type: :uint64, json_name: "maxPendingAmtMsat") + field(:min_htlc_msat, 5, type: :uint64, json_name: "minHtlcMsat") + field(:max_accepted_htlcs, 6, type: :uint32, json_name: "maxAcceptedHtlcs") +end + +defmodule Cashubrew.Lnrpc.Channel do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:active, 1, type: :bool) + field(:remote_pubkey, 2, type: :string, json_name: "remotePubkey") + field(:channel_point, 3, type: :string, json_name: "channelPoint") + field(:chan_id, 4, type: :uint64, json_name: "chanId", deprecated: false) + field(:capacity, 5, type: :int64) + field(:local_balance, 6, type: :int64, json_name: "localBalance") + field(:remote_balance, 7, type: :int64, json_name: "remoteBalance") + field(:commit_fee, 8, type: :int64, json_name: "commitFee") + field(:commit_weight, 9, type: :int64, json_name: "commitWeight") + field(:fee_per_kw, 10, type: :int64, json_name: "feePerKw") + field(:unsettled_balance, 11, type: :int64, json_name: "unsettledBalance") + field(:total_satoshis_sent, 12, type: :int64, json_name: "totalSatoshisSent") + field(:total_satoshis_received, 13, type: :int64, json_name: "totalSatoshisReceived") + field(:num_updates, 14, type: :uint64, json_name: "numUpdates") + field(:pending_htlcs, 15, repeated: true, type: Cashubrew.Lnrpc.HTLC, json_name: "pendingHtlcs") + field(:csv_delay, 16, type: :uint32, json_name: "csvDelay", deprecated: true) + field(:private, 17, type: :bool) + field(:initiator, 18, type: :bool) + field(:chan_status_flags, 19, type: :string, json_name: "chanStatusFlags") + + field(:local_chan_reserve_sat, 20, + type: :int64, + json_name: "localChanReserveSat", + deprecated: true + ) + + field(:remote_chan_reserve_sat, 21, + type: :int64, + json_name: "remoteChanReserveSat", + deprecated: true + ) + + field(:static_remote_key, 22, type: :bool, json_name: "staticRemoteKey", deprecated: true) + + field(:commitment_type, 26, + type: Cashubrew.Lnrpc.CommitmentType, + json_name: "commitmentType", + enum: true + ) + + field(:lifetime, 23, type: :int64) + field(:uptime, 24, type: :int64) + field(:close_address, 25, type: :string, json_name: "closeAddress") + field(:push_amount_sat, 27, type: :uint64, json_name: "pushAmountSat") + field(:thaw_height, 28, type: :uint32, json_name: "thawHeight") + + field(:local_constraints, 29, + type: Cashubrew.Lnrpc.ChannelConstraints, + json_name: "localConstraints" + ) + + field(:remote_constraints, 30, + type: Cashubrew.Lnrpc.ChannelConstraints, + json_name: "remoteConstraints" + ) + + field(:alias_scids, 31, repeated: true, type: :uint64, json_name: "aliasScids") + field(:zero_conf, 32, type: :bool, json_name: "zeroConf") + field(:zero_conf_confirmed_scid, 33, type: :uint64, json_name: "zeroConfConfirmedScid") + field(:peer_alias, 34, type: :string, json_name: "peerAlias") + field(:peer_scid_alias, 35, type: :uint64, json_name: "peerScidAlias", deprecated: false) + field(:memo, 36, type: :string) +end + +defmodule Cashubrew.Lnrpc.ListChannelsRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:active_only, 1, type: :bool, json_name: "activeOnly") + field(:inactive_only, 2, type: :bool, json_name: "inactiveOnly") + field(:public_only, 3, type: :bool, json_name: "publicOnly") + field(:private_only, 4, type: :bool, json_name: "privateOnly") + field(:peer, 5, type: :bytes) + field(:peer_alias_lookup, 6, type: :bool, json_name: "peerAliasLookup") +end + +defmodule Cashubrew.Lnrpc.ListChannelsResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:channels, 11, repeated: true, type: Cashubrew.Lnrpc.Channel) +end + +defmodule Cashubrew.Lnrpc.AliasMap do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:base_scid, 1, type: :uint64, json_name: "baseScid") + field(:aliases, 2, repeated: true, type: :uint64) +end + +defmodule Cashubrew.Lnrpc.ListAliasesRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" +end + +defmodule Cashubrew.Lnrpc.ListAliasesResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:alias_maps, 1, repeated: true, type: Cashubrew.Lnrpc.AliasMap, json_name: "aliasMaps") +end + +defmodule Cashubrew.Lnrpc.ChannelCloseSummary do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:channel_point, 1, type: :string, json_name: "channelPoint") + field(:chan_id, 2, type: :uint64, json_name: "chanId", deprecated: false) + field(:chain_hash, 3, type: :string, json_name: "chainHash") + field(:closing_tx_hash, 4, type: :string, json_name: "closingTxHash") + field(:remote_pubkey, 5, type: :string, json_name: "remotePubkey") + field(:capacity, 6, type: :int64) + field(:close_height, 7, type: :uint32, json_name: "closeHeight") + field(:settled_balance, 8, type: :int64, json_name: "settledBalance") + field(:time_locked_balance, 9, type: :int64, json_name: "timeLockedBalance") + + field(:close_type, 10, + type: Cashubrew.Lnrpc.ChannelCloseSummary.ClosureType, + json_name: "closeType", + enum: true + ) + + field(:open_initiator, 11, + type: Cashubrew.Lnrpc.Initiator, + json_name: "openInitiator", + enum: true + ) + + field(:close_initiator, 12, + type: Cashubrew.Lnrpc.Initiator, + json_name: "closeInitiator", + enum: true + ) + + field(:resolutions, 13, repeated: true, type: Cashubrew.Lnrpc.Resolution) + field(:alias_scids, 14, repeated: true, type: :uint64, json_name: "aliasScids") + + field(:zero_conf_confirmed_scid, 15, + type: :uint64, + json_name: "zeroConfConfirmedScid", + deprecated: false + ) +end + +defmodule Cashubrew.Lnrpc.Resolution do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:resolution_type, 1, + type: Cashubrew.Lnrpc.ResolutionType, + json_name: "resolutionType", + enum: true + ) + + field(:outcome, 2, type: Cashubrew.Lnrpc.ResolutionOutcome, enum: true) + field(:outpoint, 3, type: Cashubrew.Lnrpc.OutPoint) + field(:amount_sat, 4, type: :uint64, json_name: "amountSat") + field(:sweep_txid, 5, type: :string, json_name: "sweepTxid") +end + +defmodule Cashubrew.Lnrpc.ClosedChannelsRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:cooperative, 1, type: :bool) + field(:local_force, 2, type: :bool, json_name: "localForce") + field(:remote_force, 3, type: :bool, json_name: "remoteForce") + field(:breach, 4, type: :bool) + field(:funding_canceled, 5, type: :bool, json_name: "fundingCanceled") + field(:abandoned, 6, type: :bool) +end + +defmodule Cashubrew.Lnrpc.ClosedChannelsResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:channels, 1, repeated: true, type: Cashubrew.Lnrpc.ChannelCloseSummary) +end + +defmodule Cashubrew.Lnrpc.Peer.FeaturesEntry do + @moduledoc false + + use Protobuf, map: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:key, 1, type: :uint32) + field(:value, 2, type: Cashubrew.Lnrpc.Feature) +end + +defmodule Cashubrew.Lnrpc.Peer do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:pub_key, 1, type: :string, json_name: "pubKey") + field(:address, 3, type: :string) + field(:bytes_sent, 4, type: :uint64, json_name: "bytesSent") + field(:bytes_recv, 5, type: :uint64, json_name: "bytesRecv") + field(:sat_sent, 6, type: :int64, json_name: "satSent") + field(:sat_recv, 7, type: :int64, json_name: "satRecv") + field(:inbound, 8, type: :bool) + field(:ping_time, 9, type: :int64, json_name: "pingTime") + field(:sync_type, 10, type: Cashubrew.Lnrpc.Peer.SyncType, json_name: "syncType", enum: true) + field(:features, 11, repeated: true, type: Cashubrew.Lnrpc.Peer.FeaturesEntry, map: true) + field(:errors, 12, repeated: true, type: Cashubrew.Lnrpc.TimestampedError) + field(:flap_count, 13, type: :int32, json_name: "flapCount") + field(:last_flap_ns, 14, type: :int64, json_name: "lastFlapNs") + field(:last_ping_payload, 15, type: :bytes, json_name: "lastPingPayload") +end + +defmodule Cashubrew.Lnrpc.TimestampedError do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:timestamp, 1, type: :uint64) + field(:error, 2, type: :string) +end + +defmodule Cashubrew.Lnrpc.ListPeersRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:latest_error, 1, type: :bool, json_name: "latestError") +end + +defmodule Cashubrew.Lnrpc.ListPeersResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:peers, 1, repeated: true, type: Cashubrew.Lnrpc.Peer) +end + +defmodule Cashubrew.Lnrpc.PeerEventSubscription do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" +end + +defmodule Cashubrew.Lnrpc.PeerEvent do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:pub_key, 1, type: :string, json_name: "pubKey") + field(:type, 2, type: Cashubrew.Lnrpc.PeerEvent.EventType, enum: true) +end + +defmodule Cashubrew.Lnrpc.GetInfoRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" +end + +defmodule Cashubrew.Lnrpc.GetInfoResponse.FeaturesEntry do + @moduledoc false + + use Protobuf, map: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:key, 1, type: :uint32) + field(:value, 2, type: Cashubrew.Lnrpc.Feature) +end + +defmodule Cashubrew.Lnrpc.GetInfoResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:version, 14, type: :string) + field(:commit_hash, 20, type: :string, json_name: "commitHash") + field(:identity_pubkey, 1, type: :string, json_name: "identityPubkey") + field(:alias, 2, type: :string) + field(:color, 17, type: :string) + field(:num_pending_channels, 3, type: :uint32, json_name: "numPendingChannels") + field(:num_active_channels, 4, type: :uint32, json_name: "numActiveChannels") + field(:num_inactive_channels, 15, type: :uint32, json_name: "numInactiveChannels") + field(:num_peers, 5, type: :uint32, json_name: "numPeers") + field(:block_height, 6, type: :uint32, json_name: "blockHeight") + field(:block_hash, 8, type: :string, json_name: "blockHash") + field(:best_header_timestamp, 13, type: :int64, json_name: "bestHeaderTimestamp") + field(:synced_to_chain, 9, type: :bool, json_name: "syncedToChain") + field(:synced_to_graph, 18, type: :bool, json_name: "syncedToGraph") + field(:testnet, 10, type: :bool, deprecated: true) + field(:chains, 16, repeated: true, type: Cashubrew.Lnrpc.Chain) + field(:uris, 12, repeated: true, type: :string) + + field(:features, 19, + repeated: true, + type: Cashubrew.Lnrpc.GetInfoResponse.FeaturesEntry, + map: true + ) + + field(:require_htlc_interceptor, 21, type: :bool, json_name: "requireHtlcInterceptor") + field(:store_final_htlc_resolutions, 22, type: :bool, json_name: "storeFinalHtlcResolutions") +end + +defmodule Cashubrew.Lnrpc.GetDebugInfoRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" +end + +defmodule Cashubrew.Lnrpc.GetDebugInfoResponse.ConfigEntry do + @moduledoc false + + use Protobuf, map: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:key, 1, type: :string) + field(:value, 2, type: :string) +end + +defmodule Cashubrew.Lnrpc.GetDebugInfoResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:config, 1, + repeated: true, + type: Cashubrew.Lnrpc.GetDebugInfoResponse.ConfigEntry, + map: true + ) + + field(:log, 2, repeated: true, type: :string) +end + +defmodule Cashubrew.Lnrpc.GetRecoveryInfoRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" +end + +defmodule Cashubrew.Lnrpc.GetRecoveryInfoResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:recovery_mode, 1, type: :bool, json_name: "recoveryMode") + field(:recovery_finished, 2, type: :bool, json_name: "recoveryFinished") + field(:progress, 3, type: :double) +end + +defmodule Cashubrew.Lnrpc.Chain do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:chain, 1, type: :string, deprecated: true) + field(:network, 2, type: :string) +end + +defmodule Cashubrew.Lnrpc.ConfirmationUpdate do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:block_sha, 1, type: :bytes, json_name: "blockSha") + field(:block_height, 2, type: :int32, json_name: "blockHeight") + field(:num_confs_left, 3, type: :uint32, json_name: "numConfsLeft") +end + +defmodule Cashubrew.Lnrpc.ChannelOpenUpdate do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:channel_point, 1, type: Cashubrew.Lnrpc.ChannelPoint, json_name: "channelPoint") +end + +defmodule Cashubrew.Lnrpc.ChannelCloseUpdate do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:closing_txid, 1, type: :bytes, json_name: "closingTxid") + field(:success, 2, type: :bool) +end + +defmodule Cashubrew.Lnrpc.CloseChannelRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:channel_point, 1, type: Cashubrew.Lnrpc.ChannelPoint, json_name: "channelPoint") + field(:force, 2, type: :bool) + field(:target_conf, 3, type: :int32, json_name: "targetConf") + field(:sat_per_byte, 4, type: :int64, json_name: "satPerByte", deprecated: true) + field(:delivery_address, 5, type: :string, json_name: "deliveryAddress") + field(:sat_per_vbyte, 6, type: :uint64, json_name: "satPerVbyte") + field(:max_fee_per_vbyte, 7, type: :uint64, json_name: "maxFeePerVbyte") + field(:no_wait, 8, type: :bool, json_name: "noWait") +end + +defmodule Cashubrew.Lnrpc.CloseStatusUpdate do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + oneof(:update, 0) + + field(:close_pending, 1, + type: Cashubrew.Lnrpc.PendingUpdate, + json_name: "closePending", + oneof: 0 + ) + + field(:chan_close, 3, + type: Cashubrew.Lnrpc.ChannelCloseUpdate, + json_name: "chanClose", + oneof: 0 + ) + + field(:close_instant, 4, + type: Cashubrew.Lnrpc.InstantUpdate, + json_name: "closeInstant", + oneof: 0 + ) +end + +defmodule Cashubrew.Lnrpc.PendingUpdate do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:txid, 1, type: :bytes) + field(:output_index, 2, type: :uint32, json_name: "outputIndex") +end + +defmodule Cashubrew.Lnrpc.InstantUpdate do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" +end + +defmodule Cashubrew.Lnrpc.ReadyForPsbtFunding do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:funding_address, 1, type: :string, json_name: "fundingAddress") + field(:funding_amount, 2, type: :int64, json_name: "fundingAmount") + field(:psbt, 3, type: :bytes) +end + +defmodule Cashubrew.Lnrpc.BatchOpenChannelRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:channels, 1, repeated: true, type: Cashubrew.Lnrpc.BatchOpenChannel) + field(:target_conf, 2, type: :int32, json_name: "targetConf") + field(:sat_per_vbyte, 3, type: :int64, json_name: "satPerVbyte") + field(:min_confs, 4, type: :int32, json_name: "minConfs") + field(:spend_unconfirmed, 5, type: :bool, json_name: "spendUnconfirmed") + field(:label, 6, type: :string) + + field(:coin_selection_strategy, 7, + type: Cashubrew.Lnrpc.CoinSelectionStrategy, + json_name: "coinSelectionStrategy", + enum: true + ) +end + +defmodule Cashubrew.Lnrpc.BatchOpenChannel do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:node_pubkey, 1, type: :bytes, json_name: "nodePubkey") + field(:local_funding_amount, 2, type: :int64, json_name: "localFundingAmount") + field(:push_sat, 3, type: :int64, json_name: "pushSat") + field(:private, 4, type: :bool) + field(:min_htlc_msat, 5, type: :int64, json_name: "minHtlcMsat") + field(:remote_csv_delay, 6, type: :uint32, json_name: "remoteCsvDelay") + field(:close_address, 7, type: :string, json_name: "closeAddress") + field(:pending_chan_id, 8, type: :bytes, json_name: "pendingChanId") + + field(:commitment_type, 9, + type: Cashubrew.Lnrpc.CommitmentType, + json_name: "commitmentType", + enum: true + ) + + field(:remote_max_value_in_flight_msat, 10, + type: :uint64, + json_name: "remoteMaxValueInFlightMsat" + ) + + field(:remote_max_htlcs, 11, type: :uint32, json_name: "remoteMaxHtlcs") + field(:max_local_csv, 12, type: :uint32, json_name: "maxLocalCsv") + field(:zero_conf, 13, type: :bool, json_name: "zeroConf") + field(:scid_alias, 14, type: :bool, json_name: "scidAlias") + field(:base_fee, 15, type: :uint64, json_name: "baseFee") + field(:fee_rate, 16, type: :uint64, json_name: "feeRate") + field(:use_base_fee, 17, type: :bool, json_name: "useBaseFee") + field(:use_fee_rate, 18, type: :bool, json_name: "useFeeRate") + field(:remote_chan_reserve_sat, 19, type: :uint64, json_name: "remoteChanReserveSat") + field(:memo, 20, type: :string) +end + +defmodule Cashubrew.Lnrpc.BatchOpenChannelResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:pending_channels, 1, + repeated: true, + type: Cashubrew.Lnrpc.PendingUpdate, + json_name: "pendingChannels" + ) +end + +defmodule Cashubrew.Lnrpc.OpenChannelRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:sat_per_vbyte, 1, type: :uint64, json_name: "satPerVbyte") + field(:node_pubkey, 2, type: :bytes, json_name: "nodePubkey") + field(:node_pubkey_string, 3, type: :string, json_name: "nodePubkeyString", deprecated: true) + field(:local_funding_amount, 4, type: :int64, json_name: "localFundingAmount") + field(:push_sat, 5, type: :int64, json_name: "pushSat") + field(:target_conf, 6, type: :int32, json_name: "targetConf") + field(:sat_per_byte, 7, type: :int64, json_name: "satPerByte", deprecated: true) + field(:private, 8, type: :bool) + field(:min_htlc_msat, 9, type: :int64, json_name: "minHtlcMsat") + field(:remote_csv_delay, 10, type: :uint32, json_name: "remoteCsvDelay") + field(:min_confs, 11, type: :int32, json_name: "minConfs") + field(:spend_unconfirmed, 12, type: :bool, json_name: "spendUnconfirmed") + field(:close_address, 13, type: :string, json_name: "closeAddress") + field(:funding_shim, 14, type: Cashubrew.Lnrpc.FundingShim, json_name: "fundingShim") + + field(:remote_max_value_in_flight_msat, 15, + type: :uint64, + json_name: "remoteMaxValueInFlightMsat" + ) + + field(:remote_max_htlcs, 16, type: :uint32, json_name: "remoteMaxHtlcs") + field(:max_local_csv, 17, type: :uint32, json_name: "maxLocalCsv") + + field(:commitment_type, 18, + type: Cashubrew.Lnrpc.CommitmentType, + json_name: "commitmentType", + enum: true + ) + + field(:zero_conf, 19, type: :bool, json_name: "zeroConf") + field(:scid_alias, 20, type: :bool, json_name: "scidAlias") + field(:base_fee, 21, type: :uint64, json_name: "baseFee") + field(:fee_rate, 22, type: :uint64, json_name: "feeRate") + field(:use_base_fee, 23, type: :bool, json_name: "useBaseFee") + field(:use_fee_rate, 24, type: :bool, json_name: "useFeeRate") + field(:remote_chan_reserve_sat, 25, type: :uint64, json_name: "remoteChanReserveSat") + field(:fund_max, 26, type: :bool, json_name: "fundMax") + field(:memo, 27, type: :string) + field(:outpoints, 28, repeated: true, type: Cashubrew.Lnrpc.OutPoint) +end + +defmodule Cashubrew.Lnrpc.OpenStatusUpdate do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + oneof(:update, 0) + + field(:chan_pending, 1, type: Cashubrew.Lnrpc.PendingUpdate, json_name: "chanPending", oneof: 0) + field(:chan_open, 3, type: Cashubrew.Lnrpc.ChannelOpenUpdate, json_name: "chanOpen", oneof: 0) + field(:psbt_fund, 5, type: Cashubrew.Lnrpc.ReadyForPsbtFunding, json_name: "psbtFund", oneof: 0) + field(:pending_chan_id, 4, type: :bytes, json_name: "pendingChanId") +end + +defmodule Cashubrew.Lnrpc.KeyLocator do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:key_family, 1, type: :int32, json_name: "keyFamily") + field(:key_index, 2, type: :int32, json_name: "keyIndex") +end + +defmodule Cashubrew.Lnrpc.KeyDescriptor do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:raw_key_bytes, 1, type: :bytes, json_name: "rawKeyBytes") + field(:key_loc, 2, type: Cashubrew.Lnrpc.KeyLocator, json_name: "keyLoc") +end + +defmodule Cashubrew.Lnrpc.ChanPointShim do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:amt, 1, type: :int64) + field(:chan_point, 2, type: Cashubrew.Lnrpc.ChannelPoint, json_name: "chanPoint") + field(:local_key, 3, type: Cashubrew.Lnrpc.KeyDescriptor, json_name: "localKey") + field(:remote_key, 4, type: :bytes, json_name: "remoteKey") + field(:pending_chan_id, 5, type: :bytes, json_name: "pendingChanId") + field(:thaw_height, 6, type: :uint32, json_name: "thawHeight") + field(:musig2, 7, type: :bool) +end + +defmodule Cashubrew.Lnrpc.PsbtShim do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:pending_chan_id, 1, type: :bytes, json_name: "pendingChanId") + field(:base_psbt, 2, type: :bytes, json_name: "basePsbt") + field(:no_publish, 3, type: :bool, json_name: "noPublish") +end + +defmodule Cashubrew.Lnrpc.FundingShim do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + oneof(:shim, 0) + + field(:chan_point_shim, 1, + type: Cashubrew.Lnrpc.ChanPointShim, + json_name: "chanPointShim", + oneof: 0 + ) + + field(:psbt_shim, 2, type: Cashubrew.Lnrpc.PsbtShim, json_name: "psbtShim", oneof: 0) +end + +defmodule Cashubrew.Lnrpc.FundingShimCancel do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:pending_chan_id, 1, type: :bytes, json_name: "pendingChanId") +end + +defmodule Cashubrew.Lnrpc.FundingPsbtVerify do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:funded_psbt, 1, type: :bytes, json_name: "fundedPsbt") + field(:pending_chan_id, 2, type: :bytes, json_name: "pendingChanId") + field(:skip_finalize, 3, type: :bool, json_name: "skipFinalize") +end + +defmodule Cashubrew.Lnrpc.FundingPsbtFinalize do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:signed_psbt, 1, type: :bytes, json_name: "signedPsbt") + field(:pending_chan_id, 2, type: :bytes, json_name: "pendingChanId") + field(:final_raw_tx, 3, type: :bytes, json_name: "finalRawTx") +end + +defmodule Cashubrew.Lnrpc.FundingTransitionMsg do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + oneof(:trigger, 0) + + field(:shim_register, 1, type: Cashubrew.Lnrpc.FundingShim, json_name: "shimRegister", oneof: 0) + + field(:shim_cancel, 2, + type: Cashubrew.Lnrpc.FundingShimCancel, + json_name: "shimCancel", + oneof: 0 + ) + + field(:psbt_verify, 3, + type: Cashubrew.Lnrpc.FundingPsbtVerify, + json_name: "psbtVerify", + oneof: 0 + ) + + field(:psbt_finalize, 4, + type: Cashubrew.Lnrpc.FundingPsbtFinalize, + json_name: "psbtFinalize", + oneof: 0 + ) +end + +defmodule Cashubrew.Lnrpc.FundingStateStepResp do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" +end + +defmodule Cashubrew.Lnrpc.PendingHTLC do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:incoming, 1, type: :bool) + field(:amount, 2, type: :int64) + field(:outpoint, 3, type: :string) + field(:maturity_height, 4, type: :uint32, json_name: "maturityHeight") + field(:blocks_til_maturity, 5, type: :int32, json_name: "blocksTilMaturity") + field(:stage, 6, type: :uint32) +end + +defmodule Cashubrew.Lnrpc.PendingChannelsRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:include_raw_tx, 1, type: :bool, json_name: "includeRawTx") +end + +defmodule Cashubrew.Lnrpc.PendingChannelsResponse.PendingChannel do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:remote_node_pub, 1, type: :string, json_name: "remoteNodePub") + field(:channel_point, 2, type: :string, json_name: "channelPoint") + field(:capacity, 3, type: :int64) + field(:local_balance, 4, type: :int64, json_name: "localBalance") + field(:remote_balance, 5, type: :int64, json_name: "remoteBalance") + field(:local_chan_reserve_sat, 6, type: :int64, json_name: "localChanReserveSat") + field(:remote_chan_reserve_sat, 7, type: :int64, json_name: "remoteChanReserveSat") + field(:initiator, 8, type: Cashubrew.Lnrpc.Initiator, enum: true) + + field(:commitment_type, 9, + type: Cashubrew.Lnrpc.CommitmentType, + json_name: "commitmentType", + enum: true + ) + + field(:num_forwarding_packages, 10, type: :int64, json_name: "numForwardingPackages") + field(:chan_status_flags, 11, type: :string, json_name: "chanStatusFlags") + field(:private, 12, type: :bool) + field(:memo, 13, type: :string) +end + +defmodule Cashubrew.Lnrpc.PendingChannelsResponse.PendingOpenChannel do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:channel, 1, type: Cashubrew.Lnrpc.PendingChannelsResponse.PendingChannel) + field(:commit_fee, 4, type: :int64, json_name: "commitFee") + field(:commit_weight, 5, type: :int64, json_name: "commitWeight") + field(:fee_per_kw, 6, type: :int64, json_name: "feePerKw") + field(:funding_expiry_blocks, 3, type: :int32, json_name: "fundingExpiryBlocks") +end + +defmodule Cashubrew.Lnrpc.PendingChannelsResponse.WaitingCloseChannel do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:channel, 1, type: Cashubrew.Lnrpc.PendingChannelsResponse.PendingChannel) + field(:limbo_balance, 2, type: :int64, json_name: "limboBalance") + field(:commitments, 3, type: Cashubrew.Lnrpc.PendingChannelsResponse.Commitments) + field(:closing_txid, 4, type: :string, json_name: "closingTxid") + field(:closing_tx_hex, 5, type: :string, json_name: "closingTxHex") +end + +defmodule Cashubrew.Lnrpc.PendingChannelsResponse.Commitments do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:local_txid, 1, type: :string, json_name: "localTxid") + field(:remote_txid, 2, type: :string, json_name: "remoteTxid") + field(:remote_pending_txid, 3, type: :string, json_name: "remotePendingTxid") + field(:local_commit_fee_sat, 4, type: :uint64, json_name: "localCommitFeeSat") + field(:remote_commit_fee_sat, 5, type: :uint64, json_name: "remoteCommitFeeSat") + field(:remote_pending_commit_fee_sat, 6, type: :uint64, json_name: "remotePendingCommitFeeSat") +end + +defmodule Cashubrew.Lnrpc.PendingChannelsResponse.ClosedChannel do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:channel, 1, type: Cashubrew.Lnrpc.PendingChannelsResponse.PendingChannel) + field(:closing_txid, 2, type: :string, json_name: "closingTxid") +end + +defmodule Cashubrew.Lnrpc.PendingChannelsResponse.ForceClosedChannel do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:channel, 1, type: Cashubrew.Lnrpc.PendingChannelsResponse.PendingChannel) + field(:closing_txid, 2, type: :string, json_name: "closingTxid") + field(:limbo_balance, 3, type: :int64, json_name: "limboBalance") + field(:maturity_height, 4, type: :uint32, json_name: "maturityHeight") + field(:blocks_til_maturity, 5, type: :int32, json_name: "blocksTilMaturity") + field(:recovered_balance, 6, type: :int64, json_name: "recoveredBalance") + + field(:pending_htlcs, 8, + repeated: true, + type: Cashubrew.Lnrpc.PendingHTLC, + json_name: "pendingHtlcs" + ) + + field(:anchor, 9, + type: Cashubrew.Lnrpc.PendingChannelsResponse.ForceClosedChannel.AnchorState, + enum: true + ) +end + +defmodule Cashubrew.Lnrpc.PendingChannelsResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:total_limbo_balance, 1, type: :int64, json_name: "totalLimboBalance") + + field(:pending_open_channels, 2, + repeated: true, + type: Cashubrew.Lnrpc.PendingChannelsResponse.PendingOpenChannel, + json_name: "pendingOpenChannels" + ) + + field(:pending_closing_channels, 3, + repeated: true, + type: Cashubrew.Lnrpc.PendingChannelsResponse.ClosedChannel, + json_name: "pendingClosingChannels", + deprecated: true + ) + + field(:pending_force_closing_channels, 4, + repeated: true, + type: Cashubrew.Lnrpc.PendingChannelsResponse.ForceClosedChannel, + json_name: "pendingForceClosingChannels" + ) + + field(:waiting_close_channels, 5, + repeated: true, + type: Cashubrew.Lnrpc.PendingChannelsResponse.WaitingCloseChannel, + json_name: "waitingCloseChannels" + ) +end + +defmodule Cashubrew.Lnrpc.ChannelEventSubscription do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" +end + +defmodule Cashubrew.Lnrpc.ChannelEventUpdate do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + oneof(:channel, 0) + + field(:open_channel, 1, type: Cashubrew.Lnrpc.Channel, json_name: "openChannel", oneof: 0) + + field(:closed_channel, 2, + type: Cashubrew.Lnrpc.ChannelCloseSummary, + json_name: "closedChannel", + oneof: 0 + ) + + field(:active_channel, 3, + type: Cashubrew.Lnrpc.ChannelPoint, + json_name: "activeChannel", + oneof: 0 + ) + + field(:inactive_channel, 4, + type: Cashubrew.Lnrpc.ChannelPoint, + json_name: "inactiveChannel", + oneof: 0 + ) + + field(:pending_open_channel, 6, + type: Cashubrew.Lnrpc.PendingUpdate, + json_name: "pendingOpenChannel", + oneof: 0 + ) + + field(:fully_resolved_channel, 7, + type: Cashubrew.Lnrpc.ChannelPoint, + json_name: "fullyResolvedChannel", + oneof: 0 + ) + + field(:type, 5, type: Cashubrew.Lnrpc.ChannelEventUpdate.UpdateType, enum: true) +end + +defmodule Cashubrew.Lnrpc.WalletAccountBalance do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:confirmed_balance, 1, type: :int64, json_name: "confirmedBalance") + field(:unconfirmed_balance, 2, type: :int64, json_name: "unconfirmedBalance") +end + +defmodule Cashubrew.Lnrpc.WalletBalanceRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:account, 1, type: :string) + field(:min_confs, 2, type: :int32, json_name: "minConfs") +end + +defmodule Cashubrew.Lnrpc.WalletBalanceResponse.AccountBalanceEntry do + @moduledoc false + + use Protobuf, map: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:key, 1, type: :string) + field(:value, 2, type: Cashubrew.Lnrpc.WalletAccountBalance) +end + +defmodule Cashubrew.Lnrpc.WalletBalanceResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:total_balance, 1, type: :int64, json_name: "totalBalance") + field(:confirmed_balance, 2, type: :int64, json_name: "confirmedBalance") + field(:unconfirmed_balance, 3, type: :int64, json_name: "unconfirmedBalance") + field(:locked_balance, 5, type: :int64, json_name: "lockedBalance") + field(:reserved_balance_anchor_chan, 6, type: :int64, json_name: "reservedBalanceAnchorChan") + + field(:account_balance, 4, + repeated: true, + type: Cashubrew.Lnrpc.WalletBalanceResponse.AccountBalanceEntry, + json_name: "accountBalance", + map: true + ) +end + +defmodule Cashubrew.Lnrpc.Amount do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:sat, 1, type: :uint64) + field(:msat, 2, type: :uint64) +end + +defmodule Cashubrew.Lnrpc.ChannelBalanceRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" +end + +defmodule Cashubrew.Lnrpc.ChannelBalanceResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:balance, 1, type: :int64, deprecated: true) + field(:pending_open_balance, 2, type: :int64, json_name: "pendingOpenBalance", deprecated: true) + field(:local_balance, 3, type: Cashubrew.Lnrpc.Amount, json_name: "localBalance") + field(:remote_balance, 4, type: Cashubrew.Lnrpc.Amount, json_name: "remoteBalance") + + field(:unsettled_local_balance, 5, + type: Cashubrew.Lnrpc.Amount, + json_name: "unsettledLocalBalance" + ) + + field(:unsettled_remote_balance, 6, + type: Cashubrew.Lnrpc.Amount, + json_name: "unsettledRemoteBalance" + ) + + field(:pending_open_local_balance, 7, + type: Cashubrew.Lnrpc.Amount, + json_name: "pendingOpenLocalBalance" + ) + + field(:pending_open_remote_balance, 8, + type: Cashubrew.Lnrpc.Amount, + json_name: "pendingOpenRemoteBalance" + ) +end + +defmodule Cashubrew.Lnrpc.QueryRoutesRequest.DestCustomRecordsEntry do + @moduledoc false + + use Protobuf, map: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:key, 1, type: :uint64) + field(:value, 2, type: :bytes) +end + +defmodule Cashubrew.Lnrpc.QueryRoutesRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:pub_key, 1, type: :string, json_name: "pubKey") + field(:amt, 2, type: :int64) + field(:amt_msat, 12, type: :int64, json_name: "amtMsat") + field(:final_cltv_delta, 4, type: :int32, json_name: "finalCltvDelta") + field(:fee_limit, 5, type: Cashubrew.Lnrpc.FeeLimit, json_name: "feeLimit") + field(:ignored_nodes, 6, repeated: true, type: :bytes, json_name: "ignoredNodes") + + field(:ignored_edges, 7, + repeated: true, + type: Cashubrew.Lnrpc.EdgeLocator, + json_name: "ignoredEdges", + deprecated: true + ) + + field(:source_pub_key, 8, type: :string, json_name: "sourcePubKey") + field(:use_mission_control, 9, type: :bool, json_name: "useMissionControl") + + field(:ignored_pairs, 10, + repeated: true, + type: Cashubrew.Lnrpc.NodePair, + json_name: "ignoredPairs" + ) + + field(:cltv_limit, 11, type: :uint32, json_name: "cltvLimit") + + field(:dest_custom_records, 13, + repeated: true, + type: Cashubrew.Lnrpc.QueryRoutesRequest.DestCustomRecordsEntry, + json_name: "destCustomRecords", + map: true + ) + + field(:outgoing_chan_id, 14, type: :uint64, json_name: "outgoingChanId", deprecated: false) + field(:last_hop_pubkey, 15, type: :bytes, json_name: "lastHopPubkey") + + field(:route_hints, 16, + repeated: true, + type: Cashubrew.Lnrpc.RouteHint, + json_name: "routeHints" + ) + + field(:blinded_payment_paths, 19, + repeated: true, + type: Cashubrew.Lnrpc.BlindedPaymentPath, + json_name: "blindedPaymentPaths" + ) + + field(:dest_features, 17, + repeated: true, + type: Cashubrew.Lnrpc.FeatureBit, + json_name: "destFeatures", + enum: true + ) + + field(:time_pref, 18, type: :double, json_name: "timePref") +end + +defmodule Cashubrew.Lnrpc.NodePair do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:from, 1, type: :bytes) + field(:to, 2, type: :bytes) +end + +defmodule Cashubrew.Lnrpc.EdgeLocator do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:channel_id, 1, type: :uint64, json_name: "channelId", deprecated: false) + field(:direction_reverse, 2, type: :bool, json_name: "directionReverse") +end + +defmodule Cashubrew.Lnrpc.QueryRoutesResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:routes, 1, repeated: true, type: Cashubrew.Lnrpc.Route) + field(:success_prob, 2, type: :double, json_name: "successProb") +end + +defmodule Cashubrew.Lnrpc.Hop.CustomRecordsEntry do + @moduledoc false + + use Protobuf, map: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:key, 1, type: :uint64) + field(:value, 2, type: :bytes) +end + +defmodule Cashubrew.Lnrpc.Hop do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:chan_id, 1, type: :uint64, json_name: "chanId", deprecated: false) + field(:chan_capacity, 2, type: :int64, json_name: "chanCapacity", deprecated: true) + field(:amt_to_forward, 3, type: :int64, json_name: "amtToForward", deprecated: true) + field(:fee, 4, type: :int64, deprecated: true) + field(:expiry, 5, type: :uint32) + field(:amt_to_forward_msat, 6, type: :int64, json_name: "amtToForwardMsat") + field(:fee_msat, 7, type: :int64, json_name: "feeMsat") + field(:pub_key, 8, type: :string, json_name: "pubKey") + field(:tlv_payload, 9, type: :bool, json_name: "tlvPayload", deprecated: true) + field(:mpp_record, 10, type: Cashubrew.Lnrpc.MPPRecord, json_name: "mppRecord") + field(:amp_record, 12, type: Cashubrew.Lnrpc.AMPRecord, json_name: "ampRecord") + + field(:custom_records, 11, + repeated: true, + type: Cashubrew.Lnrpc.Hop.CustomRecordsEntry, + json_name: "customRecords", + map: true + ) + + field(:metadata, 13, type: :bytes) + field(:blinding_point, 14, type: :bytes, json_name: "blindingPoint") + field(:encrypted_data, 15, type: :bytes, json_name: "encryptedData") + field(:total_amt_msat, 16, type: :uint64, json_name: "totalAmtMsat") +end + +defmodule Cashubrew.Lnrpc.MPPRecord do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:payment_addr, 11, type: :bytes, json_name: "paymentAddr") + field(:total_amt_msat, 10, type: :int64, json_name: "totalAmtMsat") +end + +defmodule Cashubrew.Lnrpc.AMPRecord do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:root_share, 1, type: :bytes, json_name: "rootShare") + field(:set_id, 2, type: :bytes, json_name: "setId") + field(:child_index, 3, type: :uint32, json_name: "childIndex") +end + +defmodule Cashubrew.Lnrpc.Route do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:total_time_lock, 1, type: :uint32, json_name: "totalTimeLock") + field(:total_fees, 2, type: :int64, json_name: "totalFees", deprecated: true) + field(:total_amt, 3, type: :int64, json_name: "totalAmt", deprecated: true) + field(:hops, 4, repeated: true, type: Cashubrew.Lnrpc.Hop) + field(:total_fees_msat, 5, type: :int64, json_name: "totalFeesMsat") + field(:total_amt_msat, 6, type: :int64, json_name: "totalAmtMsat") +end + +defmodule Cashubrew.Lnrpc.NodeInfoRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:pub_key, 1, type: :string, json_name: "pubKey") + field(:include_channels, 2, type: :bool, json_name: "includeChannels") +end + +defmodule Cashubrew.Lnrpc.NodeInfo do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:node, 1, type: Cashubrew.Lnrpc.LightningNode) + field(:num_channels, 2, type: :uint32, json_name: "numChannels") + field(:total_capacity, 3, type: :int64, json_name: "totalCapacity") + field(:channels, 4, repeated: true, type: Cashubrew.Lnrpc.ChannelEdge) +end + +defmodule Cashubrew.Lnrpc.LightningNode.FeaturesEntry do + @moduledoc false + + use Protobuf, map: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:key, 1, type: :uint32) + field(:value, 2, type: Cashubrew.Lnrpc.Feature) +end + +defmodule Cashubrew.Lnrpc.LightningNode.CustomRecordsEntry do + @moduledoc false + + use Protobuf, map: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:key, 1, type: :uint64) + field(:value, 2, type: :bytes) +end + +defmodule Cashubrew.Lnrpc.LightningNode do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:last_update, 1, type: :uint32, json_name: "lastUpdate") + field(:pub_key, 2, type: :string, json_name: "pubKey") + field(:alias, 3, type: :string) + field(:addresses, 4, repeated: true, type: Cashubrew.Lnrpc.NodeAddress) + field(:color, 5, type: :string) + + field(:features, 6, + repeated: true, + type: Cashubrew.Lnrpc.LightningNode.FeaturesEntry, + map: true + ) + + field(:custom_records, 7, + repeated: true, + type: Cashubrew.Lnrpc.LightningNode.CustomRecordsEntry, + json_name: "customRecords", + map: true + ) +end + +defmodule Cashubrew.Lnrpc.NodeAddress do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:network, 1, type: :string) + field(:addr, 2, type: :string) +end + +defmodule Cashubrew.Lnrpc.RoutingPolicy.CustomRecordsEntry do + @moduledoc false + + use Protobuf, map: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:key, 1, type: :uint64) + field(:value, 2, type: :bytes) +end + +defmodule Cashubrew.Lnrpc.RoutingPolicy do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:time_lock_delta, 1, type: :uint32, json_name: "timeLockDelta") + field(:min_htlc, 2, type: :int64, json_name: "minHtlc") + field(:fee_base_msat, 3, type: :int64, json_name: "feeBaseMsat") + field(:fee_rate_milli_msat, 4, type: :int64, json_name: "feeRateMilliMsat") + field(:disabled, 5, type: :bool) + field(:max_htlc_msat, 6, type: :uint64, json_name: "maxHtlcMsat") + field(:last_update, 7, type: :uint32, json_name: "lastUpdate") + + field(:custom_records, 8, + repeated: true, + type: Cashubrew.Lnrpc.RoutingPolicy.CustomRecordsEntry, + json_name: "customRecords", + map: true + ) + + field(:inbound_fee_base_msat, 9, type: :int32, json_name: "inboundFeeBaseMsat") + field(:inbound_fee_rate_milli_msat, 10, type: :int32, json_name: "inboundFeeRateMilliMsat") +end + +defmodule Cashubrew.Lnrpc.ChannelEdge.CustomRecordsEntry do + @moduledoc false + + use Protobuf, map: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:key, 1, type: :uint64) + field(:value, 2, type: :bytes) +end + +defmodule Cashubrew.Lnrpc.ChannelEdge do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:channel_id, 1, type: :uint64, json_name: "channelId", deprecated: false) + field(:chan_point, 2, type: :string, json_name: "chanPoint") + field(:last_update, 3, type: :uint32, json_name: "lastUpdate", deprecated: true) + field(:node1_pub, 4, type: :string, json_name: "node1Pub") + field(:node2_pub, 5, type: :string, json_name: "node2Pub") + field(:capacity, 6, type: :int64) + field(:node1_policy, 7, type: Cashubrew.Lnrpc.RoutingPolicy, json_name: "node1Policy") + field(:node2_policy, 8, type: Cashubrew.Lnrpc.RoutingPolicy, json_name: "node2Policy") + + field(:custom_records, 9, + repeated: true, + type: Cashubrew.Lnrpc.ChannelEdge.CustomRecordsEntry, + json_name: "customRecords", + map: true + ) +end + +defmodule Cashubrew.Lnrpc.ChannelGraphRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:include_unannounced, 1, type: :bool, json_name: "includeUnannounced") +end + +defmodule Cashubrew.Lnrpc.ChannelGraph do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:nodes, 1, repeated: true, type: Cashubrew.Lnrpc.LightningNode) + field(:edges, 2, repeated: true, type: Cashubrew.Lnrpc.ChannelEdge) +end + +defmodule Cashubrew.Lnrpc.NodeMetricsRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:types, 1, repeated: true, type: Cashubrew.Lnrpc.NodeMetricType, enum: true) +end + +defmodule Cashubrew.Lnrpc.NodeMetricsResponse.BetweennessCentralityEntry do + @moduledoc false + + use Protobuf, map: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:key, 1, type: :string) + field(:value, 2, type: Cashubrew.Lnrpc.FloatMetric) +end + +defmodule Cashubrew.Lnrpc.NodeMetricsResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:betweenness_centrality, 1, + repeated: true, + type: Cashubrew.Lnrpc.NodeMetricsResponse.BetweennessCentralityEntry, + json_name: "betweennessCentrality", + map: true + ) +end + +defmodule Cashubrew.Lnrpc.FloatMetric do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:value, 1, type: :double) + field(:normalized_value, 2, type: :double, json_name: "normalizedValue") +end + +defmodule Cashubrew.Lnrpc.ChanInfoRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:chan_id, 1, type: :uint64, json_name: "chanId", deprecated: false) + field(:chan_point, 2, type: :string, json_name: "chanPoint") +end + +defmodule Cashubrew.Lnrpc.NetworkInfoRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" +end + +defmodule Cashubrew.Lnrpc.NetworkInfo do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:graph_diameter, 1, type: :uint32, json_name: "graphDiameter") + field(:avg_out_degree, 2, type: :double, json_name: "avgOutDegree") + field(:max_out_degree, 3, type: :uint32, json_name: "maxOutDegree") + field(:num_nodes, 4, type: :uint32, json_name: "numNodes") + field(:num_channels, 5, type: :uint32, json_name: "numChannels") + field(:total_network_capacity, 6, type: :int64, json_name: "totalNetworkCapacity") + field(:avg_channel_size, 7, type: :double, json_name: "avgChannelSize") + field(:min_channel_size, 8, type: :int64, json_name: "minChannelSize") + field(:max_channel_size, 9, type: :int64, json_name: "maxChannelSize") + field(:median_channel_size_sat, 10, type: :int64, json_name: "medianChannelSizeSat") + field(:num_zombie_chans, 11, type: :uint64, json_name: "numZombieChans") +end + +defmodule Cashubrew.Lnrpc.StopRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" +end + +defmodule Cashubrew.Lnrpc.StopResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" +end + +defmodule Cashubrew.Lnrpc.GraphTopologySubscription do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" +end + +defmodule Cashubrew.Lnrpc.GraphTopologyUpdate do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:node_updates, 1, + repeated: true, + type: Cashubrew.Lnrpc.NodeUpdate, + json_name: "nodeUpdates" + ) + + field(:channel_updates, 2, + repeated: true, + type: Cashubrew.Lnrpc.ChannelEdgeUpdate, + json_name: "channelUpdates" + ) + + field(:closed_chans, 3, + repeated: true, + type: Cashubrew.Lnrpc.ClosedChannelUpdate, + json_name: "closedChans" + ) +end + +defmodule Cashubrew.Lnrpc.NodeUpdate.FeaturesEntry do + @moduledoc false + + use Protobuf, map: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:key, 1, type: :uint32) + field(:value, 2, type: Cashubrew.Lnrpc.Feature) +end + +defmodule Cashubrew.Lnrpc.NodeUpdate do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:addresses, 1, repeated: true, type: :string, deprecated: true) + field(:identity_key, 2, type: :string, json_name: "identityKey") + field(:global_features, 3, type: :bytes, json_name: "globalFeatures", deprecated: true) + field(:alias, 4, type: :string) + field(:color, 5, type: :string) + + field(:node_addresses, 7, + repeated: true, + type: Cashubrew.Lnrpc.NodeAddress, + json_name: "nodeAddresses" + ) + + field(:features, 6, repeated: true, type: Cashubrew.Lnrpc.NodeUpdate.FeaturesEntry, map: true) +end + +defmodule Cashubrew.Lnrpc.ChannelEdgeUpdate do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:chan_id, 1, type: :uint64, json_name: "chanId", deprecated: false) + field(:chan_point, 2, type: Cashubrew.Lnrpc.ChannelPoint, json_name: "chanPoint") + field(:capacity, 3, type: :int64) + field(:routing_policy, 4, type: Cashubrew.Lnrpc.RoutingPolicy, json_name: "routingPolicy") + field(:advertising_node, 5, type: :string, json_name: "advertisingNode") + field(:connecting_node, 6, type: :string, json_name: "connectingNode") +end + +defmodule Cashubrew.Lnrpc.ClosedChannelUpdate do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:chan_id, 1, type: :uint64, json_name: "chanId", deprecated: false) + field(:capacity, 2, type: :int64) + field(:closed_height, 3, type: :uint32, json_name: "closedHeight") + field(:chan_point, 4, type: Cashubrew.Lnrpc.ChannelPoint, json_name: "chanPoint") +end + +defmodule Cashubrew.Lnrpc.HopHint do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:node_id, 1, type: :string, json_name: "nodeId") + field(:chan_id, 2, type: :uint64, json_name: "chanId", deprecated: false) + field(:fee_base_msat, 3, type: :uint32, json_name: "feeBaseMsat") + field(:fee_proportional_millionths, 4, type: :uint32, json_name: "feeProportionalMillionths") + field(:cltv_expiry_delta, 5, type: :uint32, json_name: "cltvExpiryDelta") +end + +defmodule Cashubrew.Lnrpc.SetID do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:set_id, 1, type: :bytes, json_name: "setId") +end + +defmodule Cashubrew.Lnrpc.RouteHint do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:hop_hints, 1, repeated: true, type: Cashubrew.Lnrpc.HopHint, json_name: "hopHints") +end + +defmodule Cashubrew.Lnrpc.BlindedPaymentPath do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:blinded_path, 1, type: Cashubrew.Lnrpc.BlindedPath, json_name: "blindedPath") + field(:base_fee_msat, 2, type: :uint64, json_name: "baseFeeMsat") + field(:proportional_fee_rate, 3, type: :uint32, json_name: "proportionalFeeRate") + field(:total_cltv_delta, 4, type: :uint32, json_name: "totalCltvDelta") + field(:htlc_min_msat, 5, type: :uint64, json_name: "htlcMinMsat") + field(:htlc_max_msat, 6, type: :uint64, json_name: "htlcMaxMsat") + field(:features, 7, repeated: true, type: Cashubrew.Lnrpc.FeatureBit, enum: true) +end + +defmodule Cashubrew.Lnrpc.BlindedPath do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:introduction_node, 1, type: :bytes, json_name: "introductionNode") + field(:blinding_point, 2, type: :bytes, json_name: "blindingPoint") + + field(:blinded_hops, 3, + repeated: true, + type: Cashubrew.Lnrpc.BlindedHop, + json_name: "blindedHops" + ) +end + +defmodule Cashubrew.Lnrpc.BlindedHop do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:blinded_node, 1, type: :bytes, json_name: "blindedNode") + field(:encrypted_data, 2, type: :bytes, json_name: "encryptedData") +end + +defmodule Cashubrew.Lnrpc.AMPInvoiceState do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:state, 1, type: Cashubrew.Lnrpc.InvoiceHTLCState, enum: true) + field(:settle_index, 2, type: :uint64, json_name: "settleIndex") + field(:settle_time, 3, type: :int64, json_name: "settleTime") + field(:amt_paid_msat, 5, type: :int64, json_name: "amtPaidMsat") +end + +defmodule Cashubrew.Lnrpc.Invoice.FeaturesEntry do + @moduledoc false + + use Protobuf, map: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:key, 1, type: :uint32) + field(:value, 2, type: Cashubrew.Lnrpc.Feature) +end + +defmodule Cashubrew.Lnrpc.Invoice.AmpInvoiceStateEntry do + @moduledoc false + + use Protobuf, map: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:key, 1, type: :string) + field(:value, 2, type: Cashubrew.Lnrpc.AMPInvoiceState) +end + +defmodule Cashubrew.Lnrpc.Invoice do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:memo, 1, type: :string) + field(:r_preimage, 3, type: :bytes, json_name: "rPreimage") + field(:r_hash, 4, type: :bytes, json_name: "rHash") + field(:value, 5, type: :int64) + field(:value_msat, 23, type: :int64, json_name: "valueMsat") + field(:settled, 6, type: :bool, deprecated: true) + field(:creation_date, 7, type: :int64, json_name: "creationDate") + field(:settle_date, 8, type: :int64, json_name: "settleDate") + field(:payment_request, 9, type: :string, json_name: "paymentRequest") + field(:description_hash, 10, type: :bytes, json_name: "descriptionHash") + field(:expiry, 11, type: :int64) + field(:fallback_addr, 12, type: :string, json_name: "fallbackAddr") + field(:cltv_expiry, 13, type: :uint64, json_name: "cltvExpiry") + + field(:route_hints, 14, + repeated: true, + type: Cashubrew.Lnrpc.RouteHint, + json_name: "routeHints" + ) + + field(:private, 15, type: :bool) + field(:add_index, 16, type: :uint64, json_name: "addIndex") + field(:settle_index, 17, type: :uint64, json_name: "settleIndex") + field(:amt_paid, 18, type: :int64, json_name: "amtPaid", deprecated: true) + field(:amt_paid_sat, 19, type: :int64, json_name: "amtPaidSat") + field(:amt_paid_msat, 20, type: :int64, json_name: "amtPaidMsat") + field(:state, 21, type: Cashubrew.Lnrpc.Invoice.InvoiceState, enum: true) + field(:htlcs, 22, repeated: true, type: Cashubrew.Lnrpc.InvoiceHTLC) + field(:features, 24, repeated: true, type: Cashubrew.Lnrpc.Invoice.FeaturesEntry, map: true) + field(:is_keysend, 25, type: :bool, json_name: "isKeysend") + field(:payment_addr, 26, type: :bytes, json_name: "paymentAddr") + field(:is_amp, 27, type: :bool, json_name: "isAmp") + + field(:amp_invoice_state, 28, + repeated: true, + type: Cashubrew.Lnrpc.Invoice.AmpInvoiceStateEntry, + json_name: "ampInvoiceState", + map: true + ) + + field(:is_blinded, 29, type: :bool, json_name: "isBlinded") + + field(:blinded_path_config, 30, + type: Cashubrew.Lnrpc.BlindedPathConfig, + json_name: "blindedPathConfig" + ) +end + +defmodule Cashubrew.Lnrpc.BlindedPathConfig do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:min_num_real_hops, 1, proto3_optional: true, type: :uint32, json_name: "minNumRealHops") + field(:num_hops, 2, proto3_optional: true, type: :uint32, json_name: "numHops") + field(:max_num_paths, 3, proto3_optional: true, type: :uint32, json_name: "maxNumPaths") + field(:node_omission_list, 4, repeated: true, type: :bytes, json_name: "nodeOmissionList") +end + +defmodule Cashubrew.Lnrpc.InvoiceHTLC.CustomRecordsEntry do + @moduledoc false + + use Protobuf, map: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:key, 1, type: :uint64) + field(:value, 2, type: :bytes) +end + +defmodule Cashubrew.Lnrpc.InvoiceHTLC do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:chan_id, 1, type: :uint64, json_name: "chanId", deprecated: false) + field(:htlc_index, 2, type: :uint64, json_name: "htlcIndex") + field(:amt_msat, 3, type: :uint64, json_name: "amtMsat") + field(:accept_height, 4, type: :int32, json_name: "acceptHeight") + field(:accept_time, 5, type: :int64, json_name: "acceptTime") + field(:resolve_time, 6, type: :int64, json_name: "resolveTime") + field(:expiry_height, 7, type: :int32, json_name: "expiryHeight") + field(:state, 8, type: Cashubrew.Lnrpc.InvoiceHTLCState, enum: true) + + field(:custom_records, 9, + repeated: true, + type: Cashubrew.Lnrpc.InvoiceHTLC.CustomRecordsEntry, + json_name: "customRecords", + map: true + ) + + field(:mpp_total_amt_msat, 10, type: :uint64, json_name: "mppTotalAmtMsat") + field(:amp, 11, type: Cashubrew.Lnrpc.AMP) +end + +defmodule Cashubrew.Lnrpc.AMP do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:root_share, 1, type: :bytes, json_name: "rootShare") + field(:set_id, 2, type: :bytes, json_name: "setId") + field(:child_index, 3, type: :uint32, json_name: "childIndex") + field(:hash, 4, type: :bytes) + field(:preimage, 5, type: :bytes) +end + +defmodule Cashubrew.Lnrpc.AddInvoiceResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:r_hash, 1, type: :bytes, json_name: "rHash") + field(:payment_request, 2, type: :string, json_name: "paymentRequest") + field(:add_index, 16, type: :uint64, json_name: "addIndex") + field(:payment_addr, 17, type: :bytes, json_name: "paymentAddr") +end + +defmodule Cashubrew.Lnrpc.PaymentHash do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:r_hash_str, 1, type: :string, json_name: "rHashStr", deprecated: true) + field(:r_hash, 2, type: :bytes, json_name: "rHash") +end + +defmodule Cashubrew.Lnrpc.ListInvoiceRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:pending_only, 1, type: :bool, json_name: "pendingOnly") + field(:index_offset, 4, type: :uint64, json_name: "indexOffset") + field(:num_max_invoices, 5, type: :uint64, json_name: "numMaxInvoices") + field(:reversed, 6, type: :bool) + field(:creation_date_start, 7, type: :uint64, json_name: "creationDateStart") + field(:creation_date_end, 8, type: :uint64, json_name: "creationDateEnd") +end + +defmodule Cashubrew.Lnrpc.ListInvoiceResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:invoices, 1, repeated: true, type: Cashubrew.Lnrpc.Invoice) + field(:last_index_offset, 2, type: :uint64, json_name: "lastIndexOffset") + field(:first_index_offset, 3, type: :uint64, json_name: "firstIndexOffset") +end + +defmodule Cashubrew.Lnrpc.InvoiceSubscription do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:add_index, 1, type: :uint64, json_name: "addIndex") + field(:settle_index, 2, type: :uint64, json_name: "settleIndex") +end + +defmodule Cashubrew.Lnrpc.Payment do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:payment_hash, 1, type: :string, json_name: "paymentHash") + field(:value, 2, type: :int64, deprecated: true) + field(:creation_date, 3, type: :int64, json_name: "creationDate", deprecated: true) + field(:fee, 5, type: :int64, deprecated: true) + field(:payment_preimage, 6, type: :string, json_name: "paymentPreimage") + field(:value_sat, 7, type: :int64, json_name: "valueSat") + field(:value_msat, 8, type: :int64, json_name: "valueMsat") + field(:payment_request, 9, type: :string, json_name: "paymentRequest") + field(:status, 10, type: Cashubrew.Lnrpc.Payment.PaymentStatus, enum: true) + field(:fee_sat, 11, type: :int64, json_name: "feeSat") + field(:fee_msat, 12, type: :int64, json_name: "feeMsat") + field(:creation_time_ns, 13, type: :int64, json_name: "creationTimeNs") + field(:htlcs, 14, repeated: true, type: Cashubrew.Lnrpc.HTLCAttempt) + field(:payment_index, 15, type: :uint64, json_name: "paymentIndex") + + field(:failure_reason, 16, + type: Cashubrew.Lnrpc.PaymentFailureReason, + json_name: "failureReason", + enum: true + ) +end + +defmodule Cashubrew.Lnrpc.HTLCAttempt do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:attempt_id, 7, type: :uint64, json_name: "attemptId") + field(:status, 1, type: Cashubrew.Lnrpc.HTLCAttempt.HTLCStatus, enum: true) + field(:route, 2, type: Cashubrew.Lnrpc.Route) + field(:attempt_time_ns, 3, type: :int64, json_name: "attemptTimeNs") + field(:resolve_time_ns, 4, type: :int64, json_name: "resolveTimeNs") + field(:failure, 5, type: Cashubrew.Lnrpc.Failure) + field(:preimage, 6, type: :bytes) +end + +defmodule Cashubrew.Lnrpc.ListPaymentsRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:include_incomplete, 1, type: :bool, json_name: "includeIncomplete") + field(:index_offset, 2, type: :uint64, json_name: "indexOffset") + field(:max_payments, 3, type: :uint64, json_name: "maxPayments") + field(:reversed, 4, type: :bool) + field(:count_total_payments, 5, type: :bool, json_name: "countTotalPayments") + field(:creation_date_start, 6, type: :uint64, json_name: "creationDateStart") + field(:creation_date_end, 7, type: :uint64, json_name: "creationDateEnd") +end + +defmodule Cashubrew.Lnrpc.ListPaymentsResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:payments, 1, repeated: true, type: Cashubrew.Lnrpc.Payment) + field(:first_index_offset, 2, type: :uint64, json_name: "firstIndexOffset") + field(:last_index_offset, 3, type: :uint64, json_name: "lastIndexOffset") + field(:total_num_payments, 4, type: :uint64, json_name: "totalNumPayments") +end + +defmodule Cashubrew.Lnrpc.DeletePaymentRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:payment_hash, 1, type: :bytes, json_name: "paymentHash") + field(:failed_htlcs_only, 2, type: :bool, json_name: "failedHtlcsOnly") +end + +defmodule Cashubrew.Lnrpc.DeleteAllPaymentsRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:failed_payments_only, 1, type: :bool, json_name: "failedPaymentsOnly") + field(:failed_htlcs_only, 2, type: :bool, json_name: "failedHtlcsOnly") + field(:all_payments, 3, type: :bool, json_name: "allPayments") +end + +defmodule Cashubrew.Lnrpc.DeletePaymentResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" +end + +defmodule Cashubrew.Lnrpc.DeleteAllPaymentsResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" +end + +defmodule Cashubrew.Lnrpc.AbandonChannelRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:channel_point, 1, type: Cashubrew.Lnrpc.ChannelPoint, json_name: "channelPoint") + field(:pending_funding_shim_only, 2, type: :bool, json_name: "pendingFundingShimOnly") + field(:i_know_what_i_am_doing, 3, type: :bool, json_name: "iKnowWhatIAmDoing") +end + +defmodule Cashubrew.Lnrpc.AbandonChannelResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" +end + +defmodule Cashubrew.Lnrpc.DebugLevelRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:show, 1, type: :bool) + field(:level_spec, 2, type: :string, json_name: "levelSpec") +end + +defmodule Cashubrew.Lnrpc.DebugLevelResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:sub_systems, 1, type: :string, json_name: "subSystems") +end + +defmodule Cashubrew.Lnrpc.PayReqString do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:pay_req, 1, type: :string, json_name: "payReq") +end + +defmodule Cashubrew.Lnrpc.PayReq.FeaturesEntry do + @moduledoc false + + use Protobuf, map: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:key, 1, type: :uint32) + field(:value, 2, type: Cashubrew.Lnrpc.Feature) +end + +defmodule Cashubrew.Lnrpc.PayReq do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:destination, 1, type: :string) + field(:payment_hash, 2, type: :string, json_name: "paymentHash") + field(:num_satoshis, 3, type: :int64, json_name: "numSatoshis") + field(:timestamp, 4, type: :int64) + field(:expiry, 5, type: :int64) + field(:description, 6, type: :string) + field(:description_hash, 7, type: :string, json_name: "descriptionHash") + field(:fallback_addr, 8, type: :string, json_name: "fallbackAddr") + field(:cltv_expiry, 9, type: :int64, json_name: "cltvExpiry") + + field(:route_hints, 10, + repeated: true, + type: Cashubrew.Lnrpc.RouteHint, + json_name: "routeHints" + ) + + field(:payment_addr, 11, type: :bytes, json_name: "paymentAddr") + field(:num_msat, 12, type: :int64, json_name: "numMsat") + field(:features, 13, repeated: true, type: Cashubrew.Lnrpc.PayReq.FeaturesEntry, map: true) + + field(:blinded_paths, 14, + repeated: true, + type: Cashubrew.Lnrpc.BlindedPaymentPath, + json_name: "blindedPaths" + ) +end + +defmodule Cashubrew.Lnrpc.Feature do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:name, 2, type: :string) + field(:is_required, 3, type: :bool, json_name: "isRequired") + field(:is_known, 4, type: :bool, json_name: "isKnown") +end + +defmodule Cashubrew.Lnrpc.FeeReportRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" +end + +defmodule Cashubrew.Lnrpc.ChannelFeeReport do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:chan_id, 5, type: :uint64, json_name: "chanId", deprecated: false) + field(:channel_point, 1, type: :string, json_name: "channelPoint") + field(:base_fee_msat, 2, type: :int64, json_name: "baseFeeMsat") + field(:fee_per_mil, 3, type: :int64, json_name: "feePerMil") + field(:fee_rate, 4, type: :double, json_name: "feeRate") + field(:inbound_base_fee_msat, 6, type: :int32, json_name: "inboundBaseFeeMsat") + field(:inbound_fee_per_mil, 7, type: :int32, json_name: "inboundFeePerMil") +end + +defmodule Cashubrew.Lnrpc.FeeReportResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:channel_fees, 1, + repeated: true, + type: Cashubrew.Lnrpc.ChannelFeeReport, + json_name: "channelFees" + ) + + field(:day_fee_sum, 2, type: :uint64, json_name: "dayFeeSum") + field(:week_fee_sum, 3, type: :uint64, json_name: "weekFeeSum") + field(:month_fee_sum, 4, type: :uint64, json_name: "monthFeeSum") +end + +defmodule Cashubrew.Lnrpc.InboundFee do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:base_fee_msat, 1, type: :int32, json_name: "baseFeeMsat") + field(:fee_rate_ppm, 2, type: :int32, json_name: "feeRatePpm") +end + +defmodule Cashubrew.Lnrpc.PolicyUpdateRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + oneof(:scope, 0) + + field(:global, 1, type: :bool, oneof: 0) + field(:chan_point, 2, type: Cashubrew.Lnrpc.ChannelPoint, json_name: "chanPoint", oneof: 0) + field(:base_fee_msat, 3, type: :int64, json_name: "baseFeeMsat") + field(:fee_rate, 4, type: :double, json_name: "feeRate") + field(:fee_rate_ppm, 9, type: :uint32, json_name: "feeRatePpm") + field(:time_lock_delta, 5, type: :uint32, json_name: "timeLockDelta") + field(:max_htlc_msat, 6, type: :uint64, json_name: "maxHtlcMsat") + field(:min_htlc_msat, 7, type: :uint64, json_name: "minHtlcMsat") + field(:min_htlc_msat_specified, 8, type: :bool, json_name: "minHtlcMsatSpecified") + field(:inbound_fee, 10, type: Cashubrew.Lnrpc.InboundFee, json_name: "inboundFee") +end + +defmodule Cashubrew.Lnrpc.FailedUpdate do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:outpoint, 1, type: Cashubrew.Lnrpc.OutPoint) + field(:reason, 2, type: Cashubrew.Lnrpc.UpdateFailure, enum: true) + field(:update_error, 3, type: :string, json_name: "updateError") +end + +defmodule Cashubrew.Lnrpc.PolicyUpdateResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:failed_updates, 1, + repeated: true, + type: Cashubrew.Lnrpc.FailedUpdate, + json_name: "failedUpdates" + ) +end + +defmodule Cashubrew.Lnrpc.ForwardingHistoryRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:start_time, 1, type: :uint64, json_name: "startTime") + field(:end_time, 2, type: :uint64, json_name: "endTime") + field(:index_offset, 3, type: :uint32, json_name: "indexOffset") + field(:num_max_events, 4, type: :uint32, json_name: "numMaxEvents") + field(:peer_alias_lookup, 5, type: :bool, json_name: "peerAliasLookup") +end + +defmodule Cashubrew.Lnrpc.ForwardingEvent do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:timestamp, 1, type: :uint64, deprecated: true) + field(:chan_id_in, 2, type: :uint64, json_name: "chanIdIn", deprecated: false) + field(:chan_id_out, 4, type: :uint64, json_name: "chanIdOut", deprecated: false) + field(:amt_in, 5, type: :uint64, json_name: "amtIn") + field(:amt_out, 6, type: :uint64, json_name: "amtOut") + field(:fee, 7, type: :uint64) + field(:fee_msat, 8, type: :uint64, json_name: "feeMsat") + field(:amt_in_msat, 9, type: :uint64, json_name: "amtInMsat") + field(:amt_out_msat, 10, type: :uint64, json_name: "amtOutMsat") + field(:timestamp_ns, 11, type: :uint64, json_name: "timestampNs") + field(:peer_alias_in, 12, type: :string, json_name: "peerAliasIn") + field(:peer_alias_out, 13, type: :string, json_name: "peerAliasOut") +end + +defmodule Cashubrew.Lnrpc.ForwardingHistoryResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:forwarding_events, 1, + repeated: true, + type: Cashubrew.Lnrpc.ForwardingEvent, + json_name: "forwardingEvents" + ) + + field(:last_offset_index, 2, type: :uint32, json_name: "lastOffsetIndex") +end + +defmodule Cashubrew.Lnrpc.ExportChannelBackupRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:chan_point, 1, type: Cashubrew.Lnrpc.ChannelPoint, json_name: "chanPoint") +end + +defmodule Cashubrew.Lnrpc.ChannelBackup do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:chan_point, 1, type: Cashubrew.Lnrpc.ChannelPoint, json_name: "chanPoint") + field(:chan_backup, 2, type: :bytes, json_name: "chanBackup") +end + +defmodule Cashubrew.Lnrpc.MultiChanBackup do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:chan_points, 1, + repeated: true, + type: Cashubrew.Lnrpc.ChannelPoint, + json_name: "chanPoints" + ) + + field(:multi_chan_backup, 2, type: :bytes, json_name: "multiChanBackup") +end + +defmodule Cashubrew.Lnrpc.ChanBackupExportRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" +end + +defmodule Cashubrew.Lnrpc.ChanBackupSnapshot do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:single_chan_backups, 1, + type: Cashubrew.Lnrpc.ChannelBackups, + json_name: "singleChanBackups" + ) + + field(:multi_chan_backup, 2, + type: Cashubrew.Lnrpc.MultiChanBackup, + json_name: "multiChanBackup" + ) +end + +defmodule Cashubrew.Lnrpc.ChannelBackups do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:chan_backups, 1, + repeated: true, + type: Cashubrew.Lnrpc.ChannelBackup, + json_name: "chanBackups" + ) +end + +defmodule Cashubrew.Lnrpc.RestoreChanBackupRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + oneof(:backup, 0) + + field(:chan_backups, 1, + type: Cashubrew.Lnrpc.ChannelBackups, + json_name: "chanBackups", + oneof: 0 + ) + + field(:multi_chan_backup, 2, type: :bytes, json_name: "multiChanBackup", oneof: 0) +end + +defmodule Cashubrew.Lnrpc.RestoreBackupResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" +end + +defmodule Cashubrew.Lnrpc.ChannelBackupSubscription do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" +end + +defmodule Cashubrew.Lnrpc.VerifyChanBackupResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" +end + +defmodule Cashubrew.Lnrpc.MacaroonPermission do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:entity, 1, type: :string) + field(:action, 2, type: :string) +end + +defmodule Cashubrew.Lnrpc.BakeMacaroonRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:permissions, 1, repeated: true, type: Cashubrew.Lnrpc.MacaroonPermission) + field(:root_key_id, 2, type: :uint64, json_name: "rootKeyId") + field(:allow_external_permissions, 3, type: :bool, json_name: "allowExternalPermissions") +end + +defmodule Cashubrew.Lnrpc.BakeMacaroonResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:macaroon, 1, type: :string) +end + +defmodule Cashubrew.Lnrpc.ListMacaroonIDsRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" +end + +defmodule Cashubrew.Lnrpc.ListMacaroonIDsResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:root_key_ids, 1, repeated: true, type: :uint64, json_name: "rootKeyIds") +end + +defmodule Cashubrew.Lnrpc.DeleteMacaroonIDRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:root_key_id, 1, type: :uint64, json_name: "rootKeyId") +end + +defmodule Cashubrew.Lnrpc.DeleteMacaroonIDResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:deleted, 1, type: :bool) +end + +defmodule Cashubrew.Lnrpc.MacaroonPermissionList do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:permissions, 1, repeated: true, type: Cashubrew.Lnrpc.MacaroonPermission) +end + +defmodule Cashubrew.Lnrpc.ListPermissionsRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" +end + +defmodule Cashubrew.Lnrpc.ListPermissionsResponse.MethodPermissionsEntry do + @moduledoc false + + use Protobuf, map: true, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:key, 1, type: :string) + field(:value, 2, type: Cashubrew.Lnrpc.MacaroonPermissionList) +end + +defmodule Cashubrew.Lnrpc.ListPermissionsResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:method_permissions, 1, + repeated: true, + type: Cashubrew.Lnrpc.ListPermissionsResponse.MethodPermissionsEntry, + json_name: "methodPermissions", + map: true + ) +end + +defmodule Cashubrew.Lnrpc.Failure do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:code, 1, type: Cashubrew.Lnrpc.Failure.FailureCode, enum: true) + field(:channel_update, 3, type: Cashubrew.Lnrpc.ChannelUpdate, json_name: "channelUpdate") + field(:htlc_msat, 4, type: :uint64, json_name: "htlcMsat") + field(:onion_sha_256, 5, type: :bytes, json_name: "onionSha256") + field(:cltv_expiry, 6, type: :uint32, json_name: "cltvExpiry") + field(:flags, 7, type: :uint32) + field(:failure_source_index, 8, type: :uint32, json_name: "failureSourceIndex") + field(:height, 9, type: :uint32) +end + +defmodule Cashubrew.Lnrpc.ChannelUpdate do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:signature, 1, type: :bytes) + field(:chain_hash, 2, type: :bytes, json_name: "chainHash") + field(:chan_id, 3, type: :uint64, json_name: "chanId", deprecated: false) + field(:timestamp, 4, type: :uint32) + field(:message_flags, 10, type: :uint32, json_name: "messageFlags") + field(:channel_flags, 5, type: :uint32, json_name: "channelFlags") + field(:time_lock_delta, 6, type: :uint32, json_name: "timeLockDelta") + field(:htlc_minimum_msat, 7, type: :uint64, json_name: "htlcMinimumMsat") + field(:base_fee, 8, type: :uint32, json_name: "baseFee") + field(:fee_rate, 9, type: :uint32, json_name: "feeRate") + field(:htlc_maximum_msat, 11, type: :uint64, json_name: "htlcMaximumMsat") + field(:extra_opaque_data, 12, type: :bytes, json_name: "extraOpaqueData") +end + +defmodule Cashubrew.Lnrpc.MacaroonId do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:nonce, 1, type: :bytes) + field(:storageId, 2, type: :bytes) + field(:ops, 3, repeated: true, type: Cashubrew.Lnrpc.Op) +end + +defmodule Cashubrew.Lnrpc.Op do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:entity, 1, type: :string) + field(:actions, 2, repeated: true, type: :string) +end + +defmodule Cashubrew.Lnrpc.CheckMacPermRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:macaroon, 1, type: :bytes) + field(:permissions, 2, repeated: true, type: Cashubrew.Lnrpc.MacaroonPermission) + field(:fullMethod, 3, type: :string) +end + +defmodule Cashubrew.Lnrpc.CheckMacPermResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:valid, 1, type: :bool) +end + +defmodule Cashubrew.Lnrpc.RPCMiddlewareRequest do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + oneof(:intercept_type, 0) + + field(:request_id, 1, type: :uint64, json_name: "requestId") + field(:raw_macaroon, 2, type: :bytes, json_name: "rawMacaroon") + field(:custom_caveat_condition, 3, type: :string, json_name: "customCaveatCondition") + field(:stream_auth, 4, type: Cashubrew.Lnrpc.StreamAuth, json_name: "streamAuth", oneof: 0) + field(:request, 5, type: Cashubrew.Lnrpc.RPCMessage, oneof: 0) + field(:response, 6, type: Cashubrew.Lnrpc.RPCMessage, oneof: 0) + field(:reg_complete, 8, type: :bool, json_name: "regComplete", oneof: 0) + field(:msg_id, 7, type: :uint64, json_name: "msgId") +end + +defmodule Cashubrew.Lnrpc.StreamAuth do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:method_full_uri, 1, type: :string, json_name: "methodFullUri") +end + +defmodule Cashubrew.Lnrpc.RPCMessage do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:method_full_uri, 1, type: :string, json_name: "methodFullUri") + field(:stream_rpc, 2, type: :bool, json_name: "streamRpc") + field(:type_name, 3, type: :string, json_name: "typeName") + field(:serialized, 4, type: :bytes) + field(:is_error, 5, type: :bool, json_name: "isError") +end + +defmodule Cashubrew.Lnrpc.RPCMiddlewareResponse do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + oneof(:middleware_message, 0) + + field(:ref_msg_id, 1, type: :uint64, json_name: "refMsgId") + field(:register, 2, type: Cashubrew.Lnrpc.MiddlewareRegistration, oneof: 0) + field(:feedback, 3, type: Cashubrew.Lnrpc.InterceptFeedback, oneof: 0) +end + +defmodule Cashubrew.Lnrpc.MiddlewareRegistration do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:middleware_name, 1, type: :string, json_name: "middlewareName") + field(:custom_macaroon_caveat_name, 2, type: :string, json_name: "customMacaroonCaveatName") + field(:read_only_mode, 3, type: :bool, json_name: "readOnlyMode") +end + +defmodule Cashubrew.Lnrpc.InterceptFeedback do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.13.0" + + field(:error, 1, type: :string) + field(:replace_response, 2, type: :bool, json_name: "replaceResponse") + field(:replacement_serialized, 3, type: :bytes, json_name: "replacementSerialized") +end + +defmodule Cashubrew.Lnrpc.Lightning.Service do + @moduledoc false + + use GRPC.Service, name: "lnrpc.Lightning", protoc_gen_elixir_version: "0.13.0" + + rpc(:WalletBalance, Cashubrew.Lnrpc.WalletBalanceRequest, Cashubrew.Lnrpc.WalletBalanceResponse) + + rpc( + :ChannelBalance, + Cashubrew.Lnrpc.ChannelBalanceRequest, + Cashubrew.Lnrpc.ChannelBalanceResponse + ) + + rpc( + :GetTransactions, + Cashubrew.Lnrpc.GetTransactionsRequest, + Cashubrew.Lnrpc.TransactionDetails + ) + + rpc(:EstimateFee, Cashubrew.Lnrpc.EstimateFeeRequest, Cashubrew.Lnrpc.EstimateFeeResponse) + + rpc(:SendCoins, Cashubrew.Lnrpc.SendCoinsRequest, Cashubrew.Lnrpc.SendCoinsResponse) + + rpc(:ListUnspent, Cashubrew.Lnrpc.ListUnspentRequest, Cashubrew.Lnrpc.ListUnspentResponse) + + rpc( + :SubscribeTransactions, + Cashubrew.Lnrpc.GetTransactionsRequest, + stream(Cashubrew.Lnrpc.Transaction) + ) + + rpc(:SendMany, Cashubrew.Lnrpc.SendManyRequest, Cashubrew.Lnrpc.SendManyResponse) + + rpc(:NewAddress, Cashubrew.Lnrpc.NewAddressRequest, Cashubrew.Lnrpc.NewAddressResponse) + + rpc(:SignMessage, Cashubrew.Lnrpc.SignMessageRequest, Cashubrew.Lnrpc.SignMessageResponse) + + rpc(:VerifyMessage, Cashubrew.Lnrpc.VerifyMessageRequest, Cashubrew.Lnrpc.VerifyMessageResponse) + + rpc(:ConnectPeer, Cashubrew.Lnrpc.ConnectPeerRequest, Cashubrew.Lnrpc.ConnectPeerResponse) + + rpc( + :DisconnectPeer, + Cashubrew.Lnrpc.DisconnectPeerRequest, + Cashubrew.Lnrpc.DisconnectPeerResponse + ) + + rpc(:ListPeers, Cashubrew.Lnrpc.ListPeersRequest, Cashubrew.Lnrpc.ListPeersResponse) + + rpc( + :SubscribePeerEvents, + Cashubrew.Lnrpc.PeerEventSubscription, + stream(Cashubrew.Lnrpc.PeerEvent) + ) + + rpc(:GetInfo, Cashubrew.Lnrpc.GetInfoRequest, Cashubrew.Lnrpc.GetInfoResponse) + + rpc(:GetDebugInfo, Cashubrew.Lnrpc.GetDebugInfoRequest, Cashubrew.Lnrpc.GetDebugInfoResponse) + + rpc( + :GetRecoveryInfo, + Cashubrew.Lnrpc.GetRecoveryInfoRequest, + Cashubrew.Lnrpc.GetRecoveryInfoResponse + ) + + rpc( + :PendingChannels, + Cashubrew.Lnrpc.PendingChannelsRequest, + Cashubrew.Lnrpc.PendingChannelsResponse + ) + + rpc(:ListChannels, Cashubrew.Lnrpc.ListChannelsRequest, Cashubrew.Lnrpc.ListChannelsResponse) + + rpc( + :SubscribeChannelEvents, + Cashubrew.Lnrpc.ChannelEventSubscription, + stream(Cashubrew.Lnrpc.ChannelEventUpdate) + ) + + rpc( + :ClosedChannels, + Cashubrew.Lnrpc.ClosedChannelsRequest, + Cashubrew.Lnrpc.ClosedChannelsResponse + ) + + rpc(:OpenChannelSync, Cashubrew.Lnrpc.OpenChannelRequest, Cashubrew.Lnrpc.ChannelPoint) + + rpc(:OpenChannel, Cashubrew.Lnrpc.OpenChannelRequest, stream(Cashubrew.Lnrpc.OpenStatusUpdate)) + + rpc( + :BatchOpenChannel, + Cashubrew.Lnrpc.BatchOpenChannelRequest, + Cashubrew.Lnrpc.BatchOpenChannelResponse + ) + + rpc( + :FundingStateStep, + Cashubrew.Lnrpc.FundingTransitionMsg, + Cashubrew.Lnrpc.FundingStateStepResp + ) + + rpc( + :ChannelAcceptor, + stream(Cashubrew.Lnrpc.ChannelAcceptResponse), + stream(Cashubrew.Lnrpc.ChannelAcceptRequest) + ) + + rpc( + :CloseChannel, + Cashubrew.Lnrpc.CloseChannelRequest, + stream(Cashubrew.Lnrpc.CloseStatusUpdate) + ) + + rpc( + :AbandonChannel, + Cashubrew.Lnrpc.AbandonChannelRequest, + Cashubrew.Lnrpc.AbandonChannelResponse + ) + + rpc(:SendPayment, stream(Cashubrew.Lnrpc.SendRequest), stream(Cashubrew.Lnrpc.SendResponse)) + + rpc(:SendPaymentSync, Cashubrew.Lnrpc.SendRequest, Cashubrew.Lnrpc.SendResponse) + + rpc( + :SendToRoute, + stream(Cashubrew.Lnrpc.SendToRouteRequest), + stream(Cashubrew.Lnrpc.SendResponse) + ) + + rpc(:SendToRouteSync, Cashubrew.Lnrpc.SendToRouteRequest, Cashubrew.Lnrpc.SendResponse) + + rpc(:AddInvoice, Cashubrew.Lnrpc.Invoice, Cashubrew.Lnrpc.AddInvoiceResponse) + + rpc(:ListInvoices, Cashubrew.Lnrpc.ListInvoiceRequest, Cashubrew.Lnrpc.ListInvoiceResponse) + + rpc(:LookupInvoice, Cashubrew.Lnrpc.PaymentHash, Cashubrew.Lnrpc.Invoice) + + rpc(:SubscribeInvoices, Cashubrew.Lnrpc.InvoiceSubscription, stream(Cashubrew.Lnrpc.Invoice)) + + rpc(:DecodePayReq, Cashubrew.Lnrpc.PayReqString, Cashubrew.Lnrpc.PayReq) + + rpc(:ListPayments, Cashubrew.Lnrpc.ListPaymentsRequest, Cashubrew.Lnrpc.ListPaymentsResponse) + + rpc(:DeletePayment, Cashubrew.Lnrpc.DeletePaymentRequest, Cashubrew.Lnrpc.DeletePaymentResponse) + + rpc( + :DeleteAllPayments, + Cashubrew.Lnrpc.DeleteAllPaymentsRequest, + Cashubrew.Lnrpc.DeleteAllPaymentsResponse + ) + + rpc(:DescribeGraph, Cashubrew.Lnrpc.ChannelGraphRequest, Cashubrew.Lnrpc.ChannelGraph) + + rpc(:GetNodeMetrics, Cashubrew.Lnrpc.NodeMetricsRequest, Cashubrew.Lnrpc.NodeMetricsResponse) + + rpc(:GetChanInfo, Cashubrew.Lnrpc.ChanInfoRequest, Cashubrew.Lnrpc.ChannelEdge) + + rpc(:GetNodeInfo, Cashubrew.Lnrpc.NodeInfoRequest, Cashubrew.Lnrpc.NodeInfo) + + rpc(:QueryRoutes, Cashubrew.Lnrpc.QueryRoutesRequest, Cashubrew.Lnrpc.QueryRoutesResponse) + + rpc(:GetNetworkInfo, Cashubrew.Lnrpc.NetworkInfoRequest, Cashubrew.Lnrpc.NetworkInfo) + + rpc(:StopDaemon, Cashubrew.Lnrpc.StopRequest, Cashubrew.Lnrpc.StopResponse) + + rpc( + :SubscribeChannelGraph, + Cashubrew.Lnrpc.GraphTopologySubscription, + stream(Cashubrew.Lnrpc.GraphTopologyUpdate) + ) + + rpc(:DebugLevel, Cashubrew.Lnrpc.DebugLevelRequest, Cashubrew.Lnrpc.DebugLevelResponse) + + rpc(:FeeReport, Cashubrew.Lnrpc.FeeReportRequest, Cashubrew.Lnrpc.FeeReportResponse) + + rpc( + :UpdateChannelPolicy, + Cashubrew.Lnrpc.PolicyUpdateRequest, + Cashubrew.Lnrpc.PolicyUpdateResponse + ) + + rpc( + :ForwardingHistory, + Cashubrew.Lnrpc.ForwardingHistoryRequest, + Cashubrew.Lnrpc.ForwardingHistoryResponse + ) + + rpc( + :ExportChannelBackup, + Cashubrew.Lnrpc.ExportChannelBackupRequest, + Cashubrew.Lnrpc.ChannelBackup + ) + + rpc( + :ExportAllChannelBackups, + Cashubrew.Lnrpc.ChanBackupExportRequest, + Cashubrew.Lnrpc.ChanBackupSnapshot + ) + + rpc( + :VerifyChanBackup, + Cashubrew.Lnrpc.ChanBackupSnapshot, + Cashubrew.Lnrpc.VerifyChanBackupResponse + ) + + rpc( + :RestoreChannelBackups, + Cashubrew.Lnrpc.RestoreChanBackupRequest, + Cashubrew.Lnrpc.RestoreBackupResponse + ) + + rpc( + :SubscribeChannelBackups, + Cashubrew.Lnrpc.ChannelBackupSubscription, + stream(Cashubrew.Lnrpc.ChanBackupSnapshot) + ) + + rpc(:BakeMacaroon, Cashubrew.Lnrpc.BakeMacaroonRequest, Cashubrew.Lnrpc.BakeMacaroonResponse) + + rpc( + :ListMacaroonIDs, + Cashubrew.Lnrpc.ListMacaroonIDsRequest, + Cashubrew.Lnrpc.ListMacaroonIDsResponse + ) + + rpc( + :DeleteMacaroonID, + Cashubrew.Lnrpc.DeleteMacaroonIDRequest, + Cashubrew.Lnrpc.DeleteMacaroonIDResponse + ) + + rpc( + :ListPermissions, + Cashubrew.Lnrpc.ListPermissionsRequest, + Cashubrew.Lnrpc.ListPermissionsResponse + ) + + rpc( + :CheckMacaroonPermissions, + Cashubrew.Lnrpc.CheckMacPermRequest, + Cashubrew.Lnrpc.CheckMacPermResponse + ) + + rpc( + :RegisterRPCMiddleware, + stream(Cashubrew.Lnrpc.RPCMiddlewareResponse), + stream(Cashubrew.Lnrpc.RPCMiddlewareRequest) + ) + + rpc( + :SendCustomMessage, + Cashubrew.Lnrpc.SendCustomMessageRequest, + Cashubrew.Lnrpc.SendCustomMessageResponse + ) + + rpc( + :SubscribeCustomMessages, + Cashubrew.Lnrpc.SubscribeCustomMessagesRequest, + stream(Cashubrew.Lnrpc.CustomMessage) + ) + + rpc(:ListAliases, Cashubrew.Lnrpc.ListAliasesRequest, Cashubrew.Lnrpc.ListAliasesResponse) + + rpc( + :LookupHtlcResolution, + Cashubrew.Lnrpc.LookupHtlcResolutionRequest, + Cashubrew.Lnrpc.LookupHtlcResolutionResponse + ) +end + +defmodule Cashubrew.Lnrpc.Lightning.Stub do + @moduledoc false + + use GRPC.Stub, service: Cashubrew.Lnrpc.Lightning.Service +end diff --git a/lib/cashubrew/lightning/lnrpc_client.ex b/lib/cashubrew/lightning/lnrpc_client.ex new file mode 100644 index 0000000..018e5cc --- /dev/null +++ b/lib/cashubrew/lightning/lnrpc_client.ex @@ -0,0 +1,57 @@ +defmodule Cashubrew.LightingNetwork.Lnd do + @moduledoc """ + Client to interact with lnd + """ + use GenServer + require Logger + + def get_address, do: "https://localhost" + + def start_link(arg) do + # Todo: validate args are valid url to ln server + Supervisor.start_link(__MODULE__, arg, name: __MODULE__) + end + + def init(_) do + Logger.debug("gRPC client connecting to gateway at #{get_address()}") + + case GRPC.Stub.connect(get_address(), + interceptors: [GRPC.Logger.Client] + ) do + {:error, error} -> + Logger.critical("Could not connect. Retrying... #{error}") + Process.sleep(5000) + init(%{}) + + {:ok, channel} -> + Logger.debug("Connected to the gateway at #{get_address()}") + {:ok, channel} + end + end + + # one day + def validity, do: 86_400 + + def create_invoice!(amount, unit, description) do + GenServer.call(__MODULE__, {:create_invoice, amount, unit, description}) + end + + def handle_call({:create_invoice, amount, unit, description}, _from, channel) do + if unit != "sat" do + raise "UnsuportedUnit" + end + + amount_ms = amount * 1000 + + expiry = validity() + System.os_time(:second) + + request = %Cashubrew.Lnrpc.Invoice{ + memo: description, + value_msat: amount_ms, + expiry: expiry + } + + {:ok, response} = Cashubrew.Lnrpc.Lightning.Stub.add_invoice(channel, request) + {:reply, response, channel} + end +end diff --git a/lib/cashubrew/lightning/mock_lightning_network_service.ex b/lib/cashubrew/lightning/mock_lightning_network_service.ex deleted file mode 100644 index ed7ecc2..0000000 --- a/lib/cashubrew/lightning/mock_lightning_network_service.ex +++ /dev/null @@ -1,55 +0,0 @@ -defmodule Cashubrew.Lightning.MockLightningNetworkService do - @moduledoc """ - Mock Lightning Network Service for testing purposes. - """ - use GenServer - - def start_link(_) do - GenServer.start_link(__MODULE__, %{}, name: __MODULE__) - end - - def init(_) do - {:ok, %{invoices: %{}}} - end - - def create_invoice(amount, description) do - GenServer.call(__MODULE__, {:create_invoice, amount, description}) - end - - def check_payment(payment_hash) do - GenServer.call(__MODULE__, {:check_payment, payment_hash}) - end - - def handle_call({:create_invoice, amount, _description}, _from, state) do - payment_hash = :crypto.strong_rand_bytes(32) |> Base.encode16(case: :lower) - payment_request = "lnbc#{amount}n1#{payment_hash}" - - new_state = put_in(state, [:invoices, payment_hash], %{amount: amount, paid: false}) - - {:reply, {:ok, payment_request, payment_hash}, new_state} - end - - def handle_call({:check_payment, payment_hash}, _from, state) do - case get_in(state, [:invoices, payment_hash]) do - nil -> {:reply, {:error, :not_found}, state} - %{paid: true} -> {:reply, {:ok, :paid}, state} - %{paid: false} -> {:reply, {:ok, :unpaid}, state} - end - end - - def handle_call({:simulate_payment, payment_hash}, _from, state) do - case get_in(state, [:invoices, payment_hash]) do - nil -> - {:reply, {:error, :not_found}, state} - - _ -> - new_state = put_in(state, [:invoices, payment_hash, :paid], true) - {:reply, :ok, new_state} - end - end - - # For testing purposes, we'll add a function to simulate payment - def simulate_payment(payment_hash) do - GenServer.call(__MODULE__, {:simulate_payment, payment_hash}) - end -end diff --git a/lib/cashubrew/web/controllers/mint_controller.ex b/lib/cashubrew/web/controllers/mint_controller.ex index 223994d..add07e1 100644 --- a/lib/cashubrew/web/controllers/mint_controller.ex +++ b/lib/cashubrew/web/controllers/mint_controller.ex @@ -59,10 +59,10 @@ defmodule Cashubrew.Web.MintController do %Nut04.Serde.PostMintQuoteBolt11Request{ amount: amount, unit: unit, - description: _description + description: description } = params["body"] - res = Nut04.Impl.create_mint_quote!(amount, unit) + res = Nut04.Impl.create_mint_quote!(amount, unit, description) json(conn, struct(Nut04.Serde.PostMintBolt11Response, Map.put(res, :state, "UNPAID"))) rescue e in RuntimeError -> conn |> put_status(:bad_request) |> json(Nut00.Error.new_error(0, e)) diff --git a/mix.exs b/mix.exs index 8b7240f..488d876 100644 --- a/mix.exs +++ b/mix.exs @@ -61,7 +61,9 @@ defmodule Cashubrew.MixProject do {:telemetry_poller, "~> 1.0"}, {:bitcoinex, "~> 0.1.7"}, {:dotenv, "~> 3.0.0"}, - {:meck, "~> 0.9"} + {:meck, "~> 0.9"}, + {:protobuf, "~> 0.13.0"}, + {:grpc, "~> 0.9.0"} ] end diff --git a/mix.lock b/mix.lock index cd62024..b2ea6d5 100644 --- a/mix.lock +++ b/mix.lock @@ -30,7 +30,10 @@ "file_system": {:hex, :file_system, "1.0.1", "79e8ceaddb0416f8b8cd02a0127bdbababe7bf4a23d2a395b983c1f8b3f73edd", [:mix], [], "hexpm", "4414d1f38863ddf9120720cd976fce5bdde8e91d8283353f0e31850fa89feb9e"}, "floki": {:hex, :floki, "0.36.2", "a7da0193538c93f937714a6704369711998a51a6164a222d710ebd54020aa7a3", [:mix], [], "hexpm", "a8766c0bc92f074e5cb36c4f9961982eda84c5d2b8e979ca67f5c268ec8ed580"}, "gettext": {:hex, :gettext, "0.26.1", "38e14ea5dcf962d1fc9f361b63ea07c0ce715a8ef1f9e82d3dfb8e67e0416715", [:mix], [{:expo, "~> 0.5.1 or ~> 1.0", [hex: :expo, repo: "hexpm", optional: false]}], "hexpm", "01ce56f188b9dc28780a52783d6529ad2bc7124f9744e571e1ee4ea88bf08734"}, + "grpc": {:hex, :grpc, "0.9.0", "1b930a57272d4356ea65969b984c2eb04f3dab81420e1e28f0e6ec04b8f88515", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:cowboy, "~> 2.10", [hex: :cowboy, repo: "hexpm", optional: false]}, {:cowlib, "~> 2.12", [hex: :cowlib, repo: "hexpm", optional: false]}, {:gun, "~> 2.0", [hex: :gun, repo: "hexpm", optional: false]}, {:jason, ">= 0.0.0", [hex: :jason, repo: "hexpm", optional: true]}, {:mint, "~> 1.5", [hex: :mint, repo: "hexpm", optional: false]}, {:protobuf, "~> 0.11", [hex: :protobuf, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7c059698248738fcf7ad551f1d78f4a3d2e0642a72a5834f2a0b0db4b9f3d2b5"}, + "gun": {:hex, :gun, "2.1.0", "b4e4cbbf3026d21981c447e9e7ca856766046eff693720ba43114d7f5de36e87", [:make, :rebar3], [{:cowlib, "2.13.0", [hex: :cowlib, repo: "hexpm", optional: false]}], "hexpm", "52fc7fc246bfc3b00e01aea1c2854c70a366348574ab50c57dfe796d24a0101d"}, "hackney": {:hex, :hackney, "1.20.1", "8d97aec62ddddd757d128bfd1df6c5861093419f8f7a4223823537bad5d064e2", [:rebar3], [{:certifi, "~> 2.12.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~> 6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~> 1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~> 1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.4.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~> 1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "fe9094e5f1a2a2c0a7d10918fee36bfec0ec2a979994cff8cfe8058cd9af38e3"}, + "hpax": {:hex, :hpax, "1.0.0", "28dcf54509fe2152a3d040e4e3df5b265dcb6cb532029ecbacf4ce52caea3fd2", [:mix], [], "hexpm", "7f1314731d711e2ca5fdc7fd361296593fc2542570b3105595bb0bc6d0fad601"}, "httpoison": {:hex, :httpoison, "1.8.2", "9eb9c63ae289296a544842ef816a85d881d4a31f518a0fec089aaa744beae290", [:mix], [{:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "2bb350d26972e30c96e2ca74a1aaf8293d61d0742ff17f01e0279fef11599921"}, "idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"}, "jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"}, @@ -38,6 +41,7 @@ "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"}, "mime": {:hex, :mime, "2.0.6", "8f18486773d9b15f95f4f4f1e39b710045fa1de891fada4516559967276e4dc2", [:mix], [], "hexpm", "c9945363a6b26d747389aac3643f8e0e09d30499a138ad64fe8fd1d13d9b153e"}, "mimerl": {:hex, :mimerl, "1.3.0", "d0cd9fc04b9061f82490f6581e0128379830e78535e017f7780f37fea7545726", [:rebar3], [], "hexpm", "a1e15a50d1887217de95f0b9b0793e32853f7c258a5cd227650889b38839fe9d"}, + "mint": {:hex, :mint, "1.6.2", "af6d97a4051eee4f05b5500671d47c3a67dac7386045d87a904126fd4bbcea2e", [:mix], [{:castore, "~> 0.1.0 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:hpax, "~> 0.1.1 or ~> 0.2.0 or ~> 1.0", [hex: :hpax, repo: "hexpm", optional: false]}], "hexpm", "5ee441dffc1892f1ae59127f74afe8fd82fda6587794278d924e4d90ea3d63f9"}, "parse_trans": {:hex, :parse_trans, "3.4.1", "6e6aa8167cb44cc8f39441d05193be6e6f4e7c2946cb2759f015f8c56b76e5ff", [:rebar3], [], "hexpm", "620a406ce75dada827b82e453c19cf06776be266f5a67cff34e1ef2cbb60e49a"}, "phoenix": {:hex, :phoenix, "1.7.14", "a7d0b3f1bc95987044ddada111e77bd7f75646a08518942c72a8440278ae7825", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:phoenix_template, "~> 1.0", [hex: :phoenix_template, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.7", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:websock_adapter, "~> 0.5.3", [hex: :websock_adapter, repo: "hexpm", optional: false]}], "hexpm", "c7859bc56cc5dfef19ecfc240775dae358cbaa530231118a9e014df392ace61a"}, "phoenix_ecto": {:hex, :phoenix_ecto, "4.6.2", "3b83b24ab5a2eb071a20372f740d7118767c272db386831b2e77638c4dcc606d", [:mix], [{:ecto, "~> 3.5", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.14.2 or ~> 3.0 or ~> 4.1", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.9", [hex: :plug, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.16 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}], "hexpm", "3f94d025f59de86be00f5f8c5dd7b5965a3298458d21ab1c328488be3b5fcd59"}, @@ -51,6 +55,7 @@ "plug_cowboy": {:hex, :plug_cowboy, "2.7.2", "fdadb973799ae691bf9ecad99125b16625b1c6039999da5fe544d99218e662e4", [:mix], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:cowboy_telemetry, "~> 0.3", [hex: :cowboy_telemetry, repo: "hexpm", optional: false]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "245d8a11ee2306094840c000e8816f0cbed69a23fc0ac2bcf8d7835ae019bb2f"}, "plug_crypto": {:hex, :plug_crypto, "2.1.0", "f44309c2b06d249c27c8d3f65cfe08158ade08418cf540fd4f72d4d6863abb7b", [:mix], [], "hexpm", "131216a4b030b8f8ce0f26038bc4421ae60e4bb95c5cf5395e1421437824c4fa"}, "postgrex": {:hex, :postgrex, "0.19.1", "73b498508b69aded53907fe48a1fee811be34cc720e69ef4ccd568c8715495ea", [:mix], [{:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "8bac7885a18f381e091ec6caf41bda7bb8c77912bb0e9285212829afe5d8a8f8"}, + "protobuf": {:hex, :protobuf, "0.13.0", "7a9d9aeb039f68a81717eb2efd6928fdf44f03d2c0dfdcedc7b560f5f5aae93d", [:mix], [{:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "21092a223e3c6c144c1a291ab082a7ead32821ba77073b72c68515aa51fef570"}, "ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"}, "rustler_precompiled": {:hex, :rustler_precompiled, "0.8.1", "8afe0b6f3a9a677ada046cdd23e3f4c6399618b91a6122289324774961281e1e", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:rustler, "~> 0.23", [hex: :rustler, repo: "hexpm", optional: true]}], "hexpm", "90b8c2297bf7959cfa1c927b2881faad7bb0707183124955369991b76177a166"}, "sobelow": {:hex, :sobelow, "0.13.0", "218afe9075904793f5c64b8837cc356e493d88fddde126a463839351870b8d1e", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "cd6e9026b85fc35d7529da14f95e85a078d9dd1907a9097b3ba6ac7ebbe34a0d"}, diff --git a/scripts/protobuf.sh b/scripts/protobuf.sh new file mode 100644 index 0000000..d3d07b2 --- /dev/null +++ b/scripts/protobuf.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +TMP_DIR="tmp-protobuf" +RAW_LNRPC_PROTO_URL="https://raw.githubusercontent.com/lightningnetwork/lnd/refs/tags/v0.18.3-beta/lnrpc/lightning.proto" + +mkdir $TMP_DIR +cd $TMP_DIR + +curl $RAW_LNRPC_PROTO_URL > "lightning.proto" +protoc --elixir_opt=package_prefix=Cashubrew --elixir_out=plugins=grpc:./ lightning.proto +mv lightning.pb.ex ../lib/cashubrew/lightning/lnd_rpc.pb.ex + +cd .. +rm -rf $TMP_DIR From 413a2880a707c18273a9b34b7f1035e48908e14f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Delabrouille?= Date: Wed, 6 Nov 2024 16:49:04 +0100 Subject: [PATCH 2/3] feat: actually connected that lnd node --- integration-tests/src/main.rs | 20 +++++++++-- lib/cashubrew/NUTs/NUT-04/impl.ex | 6 ++-- lib/cashubrew/lightning/lnrpc_client.ex | 46 +++++++++++++++++-------- mix.exs | 2 +- mix.lock | 19 +++++----- 5 files changed, 62 insertions(+), 31 deletions(-) diff --git a/integration-tests/src/main.rs b/integration-tests/src/main.rs index 68d21b1..22822ed 100644 --- a/integration-tests/src/main.rs +++ b/integration-tests/src/main.rs @@ -9,10 +9,15 @@ async fn main() { let bitcoind = bitcoind::BitcoinD::from_downloaded().unwrap(); assert_eq!(0, bitcoind.client.get_blockchain_info().unwrap().blocks); println!("Done"); - println!("bitcoind is running"); + println!( + "bitcoind is running. Listening to {:?}", + bitcoind.params.rpc_socket + ); println!("Downloading lnd..."); - let lnd_conf = LndConf::default(); + let mut lnd_conf = LndConf::default(); + lnd_conf.view_stdout = true; + lnd_conf.view_stderr = true; let mut lnd = Lnd::with_conf( lnd::exe_path().unwrap(), &lnd_conf, @@ -35,7 +40,16 @@ async fn main() { .await .is_ok()); println!("Done"); - println!("lnd is running"); + std::fs::write( + "../.env", + format!( + "export LND_URL={:?}\nexport LND_CERT={:?}\nexport LND_MACAROON={:?}", + lnd.grpc_url, + lnd.tls_cert_path(), + lnd.admin_macaroon_path() + ), + ) + .unwrap(); let (tx, rx) = channel(); diff --git a/lib/cashubrew/NUTs/NUT-04/impl.ex b/lib/cashubrew/NUTs/NUT-04/impl.ex index bf12020..4acf47b 100644 --- a/lib/cashubrew/NUTs/NUT-04/impl.ex +++ b/lib/cashubrew/NUTs/NUT-04/impl.ex @@ -2,16 +2,16 @@ defmodule Cashubrew.Nuts.Nut04.Impl do @moduledoc """ Implementation and structs of the NUT-04 """ - alias Cashubrew.Lightning.LightningNetworkService alias Cashubrew.Mint alias Cashubrew.Nuts.Nut00 alias Cashubrew.Nuts.Nut04.Impl.MintQuoteMutex alias Cashubrew.Schema - def create_mint_quote!(amount, unit) do + def create_mint_quote!(amount, unit, description) do repo = Application.get_env(:cashubrew, :repo) - {payment_request, _payment_hash} = LightningNetworkService.create_invoice!(amount, unit) + {payment_request, _payment_hash} = + Cashubrew.LightingNetwork.Lnd.create_invoice!(amount, unit, description) # Note: quote is a unique and random id generated by the mint to internally look up the payment state. # quote MUST remain a secret between user and mint and MUST NOT be derivable from the payment request. diff --git a/lib/cashubrew/lightning/lnrpc_client.ex b/lib/cashubrew/lightning/lnrpc_client.ex index 018e5cc..fec38c1 100644 --- a/lib/cashubrew/lightning/lnrpc_client.ex +++ b/lib/cashubrew/lightning/lnrpc_client.ex @@ -5,27 +5,28 @@ defmodule Cashubrew.LightingNetwork.Lnd do use GenServer require Logger - def get_address, do: "https://localhost" - def start_link(arg) do # Todo: validate args are valid url to ln server - Supervisor.start_link(__MODULE__, arg, name: __MODULE__) + GenServer.start_link(__MODULE__, arg, name: __MODULE__) end - def init(_) do - Logger.debug("gRPC client connecting to gateway at #{get_address()}") + def init(args) do + node_url = URI.parse(System.get_env("LND_URL")) + creds = get_creds(System.get_env("LND_CERT")) + macaroon = get_macaroon(System.get_env("LND_MACAROON")) + + Logger.debug("gRPC client connecting to gateway at #{node_url}") - case GRPC.Stub.connect(get_address(), - interceptors: [GRPC.Logger.Client] + case GRPC.Stub.connect("#{node_url.host}:#{node_url.port}", + cred: creds ) do {:error, error} -> Logger.critical("Could not connect. Retrying... #{error}") - Process.sleep(5000) - init(%{}) + init(args) {:ok, channel} -> - Logger.debug("Connected to the gateway at #{get_address()}") - {:ok, channel} + Logger.info("Connected to the gateway at #{node_url}") + {:ok, %{channel: channel, macaroon: macaroon}} end end @@ -33,10 +34,10 @@ defmodule Cashubrew.LightingNetwork.Lnd do def validity, do: 86_400 def create_invoice!(amount, unit, description) do - GenServer.call(__MODULE__, {:create_invoice, amount, unit, description}) + GenServer.call(__MODULE__, {:create_invoice, amount, unit, description}, __MODULE__) end - def handle_call({:create_invoice, amount, unit, description}, _from, channel) do + def handle_call({:create_invoice, amount, unit, description}, _from, state) do if unit != "sat" do raise "UnsuportedUnit" end @@ -51,7 +52,22 @@ defmodule Cashubrew.LightingNetwork.Lnd do expiry: expiry } - {:ok, response} = Cashubrew.Lnrpc.Lightning.Stub.add_invoice(channel, request) - {:reply, response, channel} + {:ok, response} = Cashubrew.Lnrpc.Lightning.Stub.add_invoice(state["channel"], request) + {:reply, response, state} + end + + defp get_creds(cert_path) do + filename = Path.expand(cert_path) + + # ++ [verify: true/:verify_none] + ssl_opts = [cacertfile: filename] + + GRPC.Credential.new(ssl: ssl_opts) + end + + defp get_macaroon(macaroon_path) do + filename = Path.expand(macaroon_path) + + File.read!(filename) |> Base.encode16() end end diff --git a/mix.exs b/mix.exs index 488d876..3642b81 100644 --- a/mix.exs +++ b/mix.exs @@ -63,7 +63,7 @@ defmodule Cashubrew.MixProject do {:dotenv, "~> 3.0.0"}, {:meck, "~> 0.9"}, {:protobuf, "~> 0.13.0"}, - {:grpc, "~> 0.9.0"} + {:grpc, "~> 0.9"} ] end diff --git a/mix.lock b/mix.lock index b2ea6d5..0c1d8f1 100644 --- a/mix.lock +++ b/mix.lock @@ -5,21 +5,21 @@ "bitcoinex": {:hex, :bitcoinex, "0.1.8", "f1d12df7e9f7235ce699f3ecbfbf833361c8b5961cb6e0bca6d34548a0830716", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:timex, "~> 3.1", [hex: :timex, repo: "hexpm", optional: false]}], "hexpm", "9953101cf4dad21c5a07a7044044d67c2799a85be9323b08e4dd190ae2ae7872"}, "block_keys": {:hex, :block_keys, "1.0.2", "8ec4808256af826e407f1011571682d941e14c38b7a9241a1ce4af724d5d3f43", [:mix], [{:ed25519, "~> 1.3", [hex: :ed25519, repo: "hexpm", optional: false]}, {:ex_keccak, "~> 0.7.3", [hex: :ex_keccak, repo: "hexpm", optional: false]}, {:ex_secp256k1, "~> 0.7.2", [hex: :ex_secp256k1, repo: "hexpm", optional: false]}], "hexpm", "eda5508f7d2c65cad58baebc79fa27a88d1ec6f781cb34a76597794d7598dcd1"}, "bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"}, - "castore": {:hex, :castore, "1.0.8", "dedcf20ea746694647f883590b82d9e96014057aff1d44d03ec90f36a5c0dc6e", [:mix], [], "hexpm", "0b2b66d2ee742cb1d9cb8c8be3b43c3a70ee8651f37b75a8b982e036752983f1"}, + "castore": {:hex, :castore, "1.0.9", "5cc77474afadf02c7c017823f460a17daa7908e991b0cc917febc90e466a375c", [:mix], [], "hexpm", "5ea956504f1ba6f2b4eb707061d8e17870de2bee95fb59d512872c2ef06925e7"}, "cbor": {:hex, :cbor, "1.0.1", "39511158e8ea5a57c1fcb9639aaa7efde67129678fee49ebbda780f6f24959b0", [:mix], [], "hexpm", "5431acbe7a7908f17f6a9cd43311002836a34a8ab01876918d8cfb709cd8b6a2"}, "certifi": {:hex, :certifi, "2.12.0", "2d1cca2ec95f59643862af91f001478c9863c2ac9cb6e2f89780bfd8de987329", [:rebar3], [], "hexpm", "ee68d85df22e554040cdb4be100f33873ac6051387baf6a8f6ce82272340ff1c"}, "combine": {:hex, :combine, "0.10.0", "eff8224eeb56498a2af13011d142c5e7997a80c8f5b97c499f84c841032e429f", [:mix], [], "hexpm", "1b1dbc1790073076580d0d1d64e42eae2366583e7aecd455d1215b0d16f2451b"}, "cowboy": {:hex, :cowboy, "2.12.0", "f276d521a1ff88b2b9b4c54d0e753da6c66dd7be6c9fca3d9418b561828a3731", [:make, :rebar3], [{:cowlib, "2.13.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "8a7abe6d183372ceb21caa2709bec928ab2b72e18a3911aa1771639bef82651e"}, "cowboy_telemetry": {:hex, :cowboy_telemetry, "0.4.0", "f239f68b588efa7707abce16a84d0d2acf3a0f50571f8bb7f56a15865aae820c", [:rebar3], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7d98bac1ee4565d31b62d59f8823dfd8356a169e7fcbb83831b8a5397404c9de"}, "cowlib": {:hex, :cowlib, "2.13.0", "db8f7505d8332d98ef50a3ef34b34c1afddec7506e4ee4dd4a3a266285d282ca", [:make, :rebar3], [], "hexpm", "e1e1284dc3fc030a64b1ad0d8382ae7e99da46c3246b815318a4b848873800a4"}, - "credo": {:hex, :credo, "1.7.7", "771445037228f763f9b2afd612b6aa2fd8e28432a95dbbc60d8e03ce71ba4446", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "8bc87496c9aaacdc3f90f01b7b0582467b69b4bd2441fe8aae3109d843cc2f2e"}, + "credo": {:hex, :credo, "1.7.10", "6e64fe59be8da5e30a1b96273b247b5cf1cc9e336b5fd66302a64b25749ad44d", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "71fbc9a6b8be21d993deca85bf151df023a3097b01e09a2809d460348561d8cd"}, "db_connection": {:hex, :db_connection, "2.7.0", "b99faa9291bb09892c7da373bb82cba59aefa9b36300f6145c5f201c7adf48ec", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "dcf08f31b2701f857dfc787fbad78223d61a32204f217f15e881dd93e4bdd3ff"}, "decimal": {:hex, :decimal, "2.1.1", "5611dca5d4b2c3dd497dec8f68751f1f1a54755e8ed2a966c2633cf885973ad6", [:mix], [], "hexpm", "53cfe5f497ed0e7771ae1a475575603d77425099ba5faef9394932b35020ffcc"}, "deep_merge": {:hex, :deep_merge, "1.0.0", "b4aa1a0d1acac393bdf38b2291af38cb1d4a52806cf7a4906f718e1feb5ee961", [:mix], [], "hexpm", "ce708e5f094b9cd4e8f2be4f00d2f4250c4095be93f8cd6d018c753894885430"}, - "dialyxir": {:hex, :dialyxir, "1.4.3", "edd0124f358f0b9e95bfe53a9fcf806d615d8f838e2202a9f430d59566b6b53b", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "bf2cfb75cd5c5006bec30141b131663299c661a864ec7fbbc72dfa557487a986"}, + "dialyxir": {:hex, :dialyxir, "1.4.4", "fb3ce8741edeaea59c9ae84d5cec75da00fa89fe401c72d6e047d11a61f65f70", [:mix], [{:erlex, ">= 0.2.7", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "cd6111e8017ccd563e65621a4d9a4a1c5cd333df30cebc7face8029cacb4eff6"}, "dotenv": {:hex, :dotenv, "3.0.0", "52a28976955070d8312a81d59105b57ecf5d6a755c728b49c70a7e2120e6cb40", [:mix], [], "hexpm", "f8a7d800b6b419a8d8a8bc5b5cd820a181c2b713aab7621794febe934f7bd84e"}, - "ecto": {:hex, :ecto, "3.12.3", "1a9111560731f6c3606924c81c870a68a34c819f6d4f03822f370ea31a582208", [:mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "9efd91506ae722f95e48dc49e70d0cb632ede3b7a23896252a60a14ac6d59165"}, - "ecto_sql": {:hex, :ecto_sql, "3.12.0", "73cea17edfa54bde76ee8561b30d29ea08f630959685006d9c6e7d1e59113b7d", [:mix], [{:db_connection, "~> 2.4.1 or ~> 2.5", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.12", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.7", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.19 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1 or ~> 2.2", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "dc9e4d206f274f3947e96142a8fdc5f69a2a6a9abb4649ef5c882323b6d512f0"}, + "ecto": {:hex, :ecto, "3.12.4", "267c94d9f2969e6acc4dd5e3e3af5b05cdae89a4d549925f3008b2b7eb0b93c3", [:mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "ef04e4101688a67d061e1b10d7bc1fbf00d1d13c17eef08b71d070ff9188f747"}, + "ecto_sql": {:hex, :ecto_sql, "3.12.1", "c0d0d60e85d9ff4631f12bafa454bc392ce8b9ec83531a412c12a0d415a3a4d0", [:mix], [{:db_connection, "~> 2.4.1 or ~> 2.5", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.12", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.7", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.19 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1 or ~> 2.2", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "aff5b958a899762c5f09028c847569f7dfb9cc9d63bdb8133bff8a5546de6bf5"}, "ed25519": {:hex, :ed25519, "1.4.1", "479fb83c3e31987c9cad780e6aeb8f2015fb5a482618cdf2a825c9aff809afc4", [:mix], [], "hexpm", "0dacb84f3faa3d8148e81019ca35f9d8dcee13232c32c9db5c2fb8ff48c80ec7"}, "erlex": {:hex, :erlex, "0.2.7", "810e8725f96ab74d17aac676e748627a07bc87eb950d2b83acd29dc047a30595", [:mix], [], "hexpm", "3ed95f79d1a844c3f6bf0cea61e0d5612a42ce56da9c03f01df538685365efb0"}, "ex_bech32": {:hex, :ex_bech32, "0.5.1", "7adbd9969ba06c2f8426d0692bc0a603c44e84c39f7fab46446191fde46b17fb", [:mix], [{:rustler, ">= 0.0.0", [hex: :rustler, repo: "hexpm", optional: true]}, {:rustler_precompiled, "~> 0.6", [hex: :rustler_precompiled, repo: "hexpm", optional: false]}], "hexpm", "ccf16f7030dc6d652fbae8de77c31b5781bdda6492f12c32f604ef8e8e944895"}, @@ -28,7 +28,7 @@ "excoveralls": {:hex, :excoveralls, "0.18.3", "bca47a24d69a3179951f51f1db6d3ed63bca9017f476fe520eb78602d45f7756", [:mix], [{:castore, "~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "746f404fcd09d5029f1b211739afb8fb8575d775b21f6a3908e7ce3e640724c6"}, "expo": {:hex, :expo, "1.1.0", "f7b9ed7fb5745ebe1eeedf3d6f29226c5dd52897ac67c0f8af62a07e661e5c75", [:mix], [], "hexpm", "fbadf93f4700fb44c331362177bdca9eeb8097e8b0ef525c9cc501cb9917c960"}, "file_system": {:hex, :file_system, "1.0.1", "79e8ceaddb0416f8b8cd02a0127bdbababe7bf4a23d2a395b983c1f8b3f73edd", [:mix], [], "hexpm", "4414d1f38863ddf9120720cd976fce5bdde8e91d8283353f0e31850fa89feb9e"}, - "floki": {:hex, :floki, "0.36.2", "a7da0193538c93f937714a6704369711998a51a6164a222d710ebd54020aa7a3", [:mix], [], "hexpm", "a8766c0bc92f074e5cb36c4f9961982eda84c5d2b8e979ca67f5c268ec8ed580"}, + "floki": {:hex, :floki, "0.36.3", "1102f93b16a55bc5383b85ae3ec470f82dee056eaeff9195e8afdf0ef2a43c30", [:mix], [], "hexpm", "fe0158bff509e407735f6d40b3ee0d7deb47f3f3ee7c6c182ad28599f9f6b27a"}, "gettext": {:hex, :gettext, "0.26.1", "38e14ea5dcf962d1fc9f361b63ea07c0ce715a8ef1f9e82d3dfb8e67e0416715", [:mix], [{:expo, "~> 0.5.1 or ~> 1.0", [hex: :expo, repo: "hexpm", optional: false]}], "hexpm", "01ce56f188b9dc28780a52783d6529ad2bc7124f9744e571e1ee4ea88bf08734"}, "grpc": {:hex, :grpc, "0.9.0", "1b930a57272d4356ea65969b984c2eb04f3dab81420e1e28f0e6ec04b8f88515", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:cowboy, "~> 2.10", [hex: :cowboy, repo: "hexpm", optional: false]}, {:cowlib, "~> 2.12", [hex: :cowlib, repo: "hexpm", optional: false]}, {:gun, "~> 2.0", [hex: :gun, repo: "hexpm", optional: false]}, {:jason, ">= 0.0.0", [hex: :jason, repo: "hexpm", optional: true]}, {:mint, "~> 1.5", [hex: :mint, repo: "hexpm", optional: false]}, {:protobuf, "~> 0.11", [hex: :protobuf, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7c059698248738fcf7ad551f1d78f4a3d2e0642a72a5834f2a0b0db4b9f3d2b5"}, "gun": {:hex, :gun, "2.1.0", "b4e4cbbf3026d21981c447e9e7ca856766046eff693720ba43114d7f5de36e87", [:make, :rebar3], [{:cowlib, "2.13.0", [hex: :cowlib, repo: "hexpm", optional: false]}], "hexpm", "52fc7fc246bfc3b00e01aea1c2854c70a366348574ab50c57dfe796d24a0101d"}, @@ -37,6 +37,7 @@ "httpoison": {:hex, :httpoison, "1.8.2", "9eb9c63ae289296a544842ef816a85d881d4a31f518a0fec089aaa744beae290", [:mix], [{:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "2bb350d26972e30c96e2ca74a1aaf8293d61d0742ff17f01e0279fef11599921"}, "idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"}, "jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"}, + "lnd_client": {:git, "https://github.com/RooSoft/lnd_client", "00e97b610c7a87a3224995a42d5a6c0a4d269497", [ref: "00e97b610c7a87a3224995a42d5a6c0a4d269497"]}, "meck": {:hex, :meck, "0.9.2", "85ccbab053f1db86c7ca240e9fc718170ee5bda03810a6292b5306bf31bae5f5", [:rebar3], [], "hexpm", "81344f561357dc40a8344afa53767c32669153355b626ea9fcbc8da6b3045826"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"}, "mime": {:hex, :mime, "2.0.6", "8f18486773d9b15f95f4f4f1e39b710045fa1de891fada4516559967276e4dc2", [:mix], [], "hexpm", "c9945363a6b26d747389aac3643f8e0e09d30499a138ad64fe8fd1d13d9b153e"}, @@ -44,7 +45,7 @@ "mint": {:hex, :mint, "1.6.2", "af6d97a4051eee4f05b5500671d47c3a67dac7386045d87a904126fd4bbcea2e", [:mix], [{:castore, "~> 0.1.0 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:hpax, "~> 0.1.1 or ~> 0.2.0 or ~> 1.0", [hex: :hpax, repo: "hexpm", optional: false]}], "hexpm", "5ee441dffc1892f1ae59127f74afe8fd82fda6587794278d924e4d90ea3d63f9"}, "parse_trans": {:hex, :parse_trans, "3.4.1", "6e6aa8167cb44cc8f39441d05193be6e6f4e7c2946cb2759f015f8c56b76e5ff", [:rebar3], [], "hexpm", "620a406ce75dada827b82e453c19cf06776be266f5a67cff34e1ef2cbb60e49a"}, "phoenix": {:hex, :phoenix, "1.7.14", "a7d0b3f1bc95987044ddada111e77bd7f75646a08518942c72a8440278ae7825", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:phoenix_template, "~> 1.0", [hex: :phoenix_template, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.7", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:websock_adapter, "~> 0.5.3", [hex: :websock_adapter, repo: "hexpm", optional: false]}], "hexpm", "c7859bc56cc5dfef19ecfc240775dae358cbaa530231118a9e014df392ace61a"}, - "phoenix_ecto": {:hex, :phoenix_ecto, "4.6.2", "3b83b24ab5a2eb071a20372f740d7118767c272db386831b2e77638c4dcc606d", [:mix], [{:ecto, "~> 3.5", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.14.2 or ~> 3.0 or ~> 4.1", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.9", [hex: :plug, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.16 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}], "hexpm", "3f94d025f59de86be00f5f8c5dd7b5965a3298458d21ab1c328488be3b5fcd59"}, + "phoenix_ecto": {:hex, :phoenix_ecto, "4.6.3", "f686701b0499a07f2e3b122d84d52ff8a31f5def386e03706c916f6feddf69ef", [:mix], [{:ecto, "~> 3.5", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.14.2 or ~> 3.0 or ~> 4.1", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.9", [hex: :plug, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.16 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}], "hexpm", "909502956916a657a197f94cc1206d9a65247538de8a5e186f7537c895d95764"}, "phoenix_html": {:hex, :phoenix_html, "3.3.4", "42a09fc443bbc1da37e372a5c8e6755d046f22b9b11343bf885067357da21cb3", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "0249d3abec3714aff3415e7ee3d9786cb325be3151e6c4b3021502c585bf53fb"}, "phoenix_live_dashboard": {:hex, :phoenix_live_dashboard, "0.8.4", "4508e481f791ce62ec6a096e13b061387158cbeefacca68c6c1928e1305e23ed", [:mix], [{:ecto, "~> 3.6.2 or ~> 3.7", [hex: :ecto, repo: "hexpm", optional: true]}, {:ecto_mysql_extras, "~> 0.5", [hex: :ecto_mysql_extras, repo: "hexpm", optional: true]}, {:ecto_psql_extras, "~> 0.7", [hex: :ecto_psql_extras, repo: "hexpm", optional: true]}, {:ecto_sqlite3_extras, "~> 1.1.7 or ~> 1.2.0", [hex: :ecto_sqlite3_extras, repo: "hexpm", optional: true]}, {:mime, "~> 1.6 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 0.19 or ~> 1.0", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}, {:telemetry_metrics, "~> 0.6 or ~> 1.0", [hex: :telemetry_metrics, repo: "hexpm", optional: false]}], "hexpm", "2984aae96994fbc5c61795a73b8fb58153b41ff934019cfb522343d2d3817d59"}, "phoenix_live_reload": {:hex, :phoenix_live_reload, "1.5.3", "f2161c207fda0e4fb55165f650f7f8db23f02b29e3bff00ff7ef161d6ac1f09d", [:mix], [{:file_system, "~> 0.3 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm", "b4ec9cd73cb01ff1bd1cac92e045d13e7030330b74164297d1aee3907b54803c"}, @@ -54,10 +55,10 @@ "plug": {:hex, :plug, "1.16.1", "40c74619c12f82736d2214557dedec2e9762029b2438d6d175c5074c933edc9d", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "a13ff6b9006b03d7e33874945b2755253841b238c34071ed85b0e86057f8cddc"}, "plug_cowboy": {:hex, :plug_cowboy, "2.7.2", "fdadb973799ae691bf9ecad99125b16625b1c6039999da5fe544d99218e662e4", [:mix], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:cowboy_telemetry, "~> 0.3", [hex: :cowboy_telemetry, repo: "hexpm", optional: false]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "245d8a11ee2306094840c000e8816f0cbed69a23fc0ac2bcf8d7835ae019bb2f"}, "plug_crypto": {:hex, :plug_crypto, "2.1.0", "f44309c2b06d249c27c8d3f65cfe08158ade08418cf540fd4f72d4d6863abb7b", [:mix], [], "hexpm", "131216a4b030b8f8ce0f26038bc4421ae60e4bb95c5cf5395e1421437824c4fa"}, - "postgrex": {:hex, :postgrex, "0.19.1", "73b498508b69aded53907fe48a1fee811be34cc720e69ef4ccd568c8715495ea", [:mix], [{:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "8bac7885a18f381e091ec6caf41bda7bb8c77912bb0e9285212829afe5d8a8f8"}, + "postgrex": {:hex, :postgrex, "0.19.2", "34d6884a332c7bf1e367fc8b9a849d23b43f7da5c6e263def92784d03f9da468", [:mix], [{:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "618988886ab7ae8561ebed9a3c7469034bf6a88b8995785a3378746a4b9835ec"}, "protobuf": {:hex, :protobuf, "0.13.0", "7a9d9aeb039f68a81717eb2efd6928fdf44f03d2c0dfdcedc7b560f5f5aae93d", [:mix], [{:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "21092a223e3c6c144c1a291ab082a7ead32821ba77073b72c68515aa51fef570"}, "ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"}, - "rustler_precompiled": {:hex, :rustler_precompiled, "0.8.1", "8afe0b6f3a9a677ada046cdd23e3f4c6399618b91a6122289324774961281e1e", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:rustler, "~> 0.23", [hex: :rustler, repo: "hexpm", optional: true]}], "hexpm", "90b8c2297bf7959cfa1c927b2881faad7bb0707183124955369991b76177a166"}, + "rustler_precompiled": {:hex, :rustler_precompiled, "0.8.2", "5f25cbe220a8fac3e7ad62e6f950fcdca5a5a5f8501835d2823e8c74bf4268d5", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:rustler, "~> 0.23", [hex: :rustler, repo: "hexpm", optional: true]}], "hexpm", "63d1bd5f8e23096d1ff851839923162096364bac8656a4a3c00d1fff8e83ee0a"}, "sobelow": {:hex, :sobelow, "0.13.0", "218afe9075904793f5c64b8837cc356e493d88fddde126a463839351870b8d1e", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "cd6e9026b85fc35d7529da14f95e85a078d9dd1907a9097b3ba6ac7ebbe34a0d"}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.7", "354c321cf377240c7b8716899e182ce4890c5938111a1296add3ec74cf1715df", [:make, :mix, :rebar3], [], "hexpm", "fe4c190e8f37401d30167c8c405eda19469f34577987c76dde613e838bbc67f8"}, "statistex": {:hex, :statistex, "1.0.0", "f3dc93f3c0c6c92e5f291704cf62b99b553253d7969e9a5fa713e5481cd858a5", [:mix], [], "hexpm", "ff9d8bee7035028ab4742ff52fc80a2aa35cece833cf5319009b52f1b5a86c27"}, From 669483fe7e027c312ee401da742d7cf4644939f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Delabrouille?= Date: Wed, 6 Nov 2024 17:35:26 +0100 Subject: [PATCH 3/3] fix: test and CI --- .github/workflows/ci.yml | 19 +++++++++++++++---- config/dev.exs | 2 ++ config/prod.exs | 2 ++ config/runtime.exs | 2 ++ config/test.exs | 2 ++ integration-tests/src/main.rs | 6 ++---- lib/cashubrew/application.ex | 17 ++++------------- .../{lnrpc_client.ex => lnd_client.ex} | 1 - lib/cashubrew/lightning/mock_lnd_client.ex | 19 +++++++++++++++++++ 9 files changed, 48 insertions(+), 22 deletions(-) rename lib/cashubrew/lightning/{lnrpc_client.ex => lnd_client.ex} (97%) create mode 100644 lib/cashubrew/lightning/mock_lnd_client.ex diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 94f4ac8..4f21371 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -77,10 +77,21 @@ jobs: - name: Integration tests run: |- - mix phx.server & - CASHUBREW_SERVER_PID=$! - cd integration-tests && cargo test - kill $CASHUBREW_SERVER_PID + cd integration-tests + touch .env + cargo run & + BTCD_AND_LND_SERVERS_PID=$! + # Wait until the nodes are running by checking if the the env var are exported + while [[ -z "${LND_URL}" ]]; do sleep 1 && source .env; done + cd .. + # mix doesn't behave when run in background, so we use `erlang -detached` instead + # but the `$!` thing won't work coz the app is run in another thread, + # so we write the actual pid in a file and later read it to kill it + elixir --erl "-detached" -e "File.write! 'pid', :os.getpid" -S mix phx.server + cd integration-tests + cargo test + cat ../pid | xargs kill + kill $BTCD_AND_LND_SERVERS_PID diff --git a/config/dev.exs b/config/dev.exs index 76ee36b..00b48e2 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -42,3 +42,5 @@ config :cashubrew, Cashubrew.Repo, config :cashubrew, :repo, Cashubrew.Repo config :cashubrew, ecto_repos: [Cashubrew.Repo] + +config :cashubrew, :lnd_client, Cashubrew.LightingNetwork.Lnd diff --git a/config/prod.exs b/config/prod.exs index db37ff8..a089e9b 100644 --- a/config/prod.exs +++ b/config/prod.exs @@ -21,3 +21,5 @@ config :cashubrew, Cashubrew.Web.Endpoint, secret_key_base: System.get_env("SECR # Do not print debug messages in production config :logger, level: :info + +config :cashubrew, :lnd_client, Cashubrew.LightingNetwork.Lnd diff --git a/config/runtime.exs b/config/runtime.exs index 8652712..cafe6b4 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -1,5 +1,7 @@ import Config +config :cashubrew, :lnd_client, Cashubrew.LightingNetwork.MockLnd + if config_env() == :prod do database_url = System.get_env("DATABASE_URL") || diff --git a/config/test.exs b/config/test.exs index 9a61a35..5dfa369 100644 --- a/config/test.exs +++ b/config/test.exs @@ -25,4 +25,6 @@ else pool_size: 10 config :cashubrew, :repo, Cashubrew.Repo + + config :cashubrew, :lnd_client, Cashubrew.LightingNetwork.MockLnd end diff --git a/integration-tests/src/main.rs b/integration-tests/src/main.rs index 22822ed..af80c53 100644 --- a/integration-tests/src/main.rs +++ b/integration-tests/src/main.rs @@ -15,9 +15,7 @@ async fn main() { ); println!("Downloading lnd..."); - let mut lnd_conf = LndConf::default(); - lnd_conf.view_stdout = true; - lnd_conf.view_stderr = true; + let lnd_conf = LndConf::default(); let mut lnd = Lnd::with_conf( lnd::exe_path().unwrap(), &lnd_conf, @@ -41,7 +39,7 @@ async fn main() { .is_ok()); println!("Done"); std::fs::write( - "../.env", + ".env", format!( "export LND_URL={:?}\nexport LND_CERT={:?}\nexport LND_MACAROON={:?}", lnd.grpc_url, diff --git a/lib/cashubrew/application.ex b/lib/cashubrew/application.ex index e7afd57..92903da 100644 --- a/lib/cashubrew/application.ex +++ b/lib/cashubrew/application.ex @@ -7,22 +7,13 @@ defmodule Cashubrew.Application do def start(_type, _args) do children = [ Cashubrew.Web.Telemetry, - Cashubrew.LightingNetwork.Lnd, + Application.get_env(:cashubrew, :lnd_client), {Phoenix.PubSub, name: Cashubrew.PubSub}, - Endpoint + Endpoint, + Application.get_env(:cashubrew, :repo), + {Task, fn -> Cashubrew.Mint.init() end} ] - # Conditionally add the appropriate repo to the children list - children = - case Application.get_env(:cashubrew, :repo) do - Cashubrew.MockRepo -> [Cashubrew.MockRepo | children] - Cashubrew.Repo -> [Cashubrew.Repo | children] - _ -> children - end - - # Always add Cashubrew.Mint after the repo - children = children ++ [{Task, fn -> Cashubrew.Mint.init() end}] - opts = [strategy: :one_for_one, name: Cashubrew.Supervisor] Supervisor.start_link(children, opts) end diff --git a/lib/cashubrew/lightning/lnrpc_client.ex b/lib/cashubrew/lightning/lnd_client.ex similarity index 97% rename from lib/cashubrew/lightning/lnrpc_client.ex rename to lib/cashubrew/lightning/lnd_client.ex index fec38c1..a189665 100644 --- a/lib/cashubrew/lightning/lnrpc_client.ex +++ b/lib/cashubrew/lightning/lnd_client.ex @@ -6,7 +6,6 @@ defmodule Cashubrew.LightingNetwork.Lnd do require Logger def start_link(arg) do - # Todo: validate args are valid url to ln server GenServer.start_link(__MODULE__, arg, name: __MODULE__) end diff --git a/lib/cashubrew/lightning/mock_lnd_client.ex b/lib/cashubrew/lightning/mock_lnd_client.ex new file mode 100644 index 0000000..dcf8fa6 --- /dev/null +++ b/lib/cashubrew/lightning/mock_lnd_client.ex @@ -0,0 +1,19 @@ +defmodule Cashubrew.LightingNetwork.MockLnd do + @moduledoc """ + Mock client to compile test without running an lnd node + """ + use GenServer + require Logger + + def start_link(arg) do + GenServer.start_link(__MODULE__, arg, name: __MODULE__) + end + + def init(_args) do + {:ok, %{}} + end + + def create_invoice!(_amount, _unit, _description) do + %{} + end +end