diff --git a/cli/src/main.rs b/cli/src/main.rs index 0db105d..e7cd9a7 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -1,7 +1,7 @@ use clap::{Parser, Subcommand}; use client::client::LdkNodeServerClient; use client::error::LdkNodeServerError; -use client::protos::{ +use client::protos::api::{ Bolt11ReceiveRequest, Bolt11SendRequest, Bolt12ReceiveRequest, Bolt12SendRequest, OnchainReceiveRequest, OnchainSendRequest, OpenChannelRequest, }; diff --git a/client/src/client.rs b/client/src/client.rs index ea97b7a..b7a2830 100644 --- a/client/src/client.rs +++ b/client/src/client.rs @@ -1,7 +1,7 @@ use prost::Message; use crate::error::LdkNodeServerError; -use protos::{ +use protos::api::{ Bolt11ReceiveRequest, Bolt11ReceiveResponse, Bolt11SendRequest, Bolt11SendResponse, Bolt12ReceiveRequest, Bolt12ReceiveResponse, Bolt12SendRequest, Bolt12SendResponse, CloseChannelRequest, CloseChannelResponse, ListChannelsRequest, ListChannelsResponse, diff --git a/protos/build.rs b/protos/build.rs index 5a1a185..e120888 100644 --- a/protos/build.rs +++ b/protos/build.rs @@ -14,9 +14,13 @@ fn main() { fn generate_protos() { prost_build::Config::new() .bytes(&["."]) - .compile_protos(&["src/proto/ldk_node_server.proto"], &["src/"]) + .compile_protos(&["src/proto/api.proto", "src/proto/types.proto", "src/proto/error.proto"], &["src/proto/"]) .expect("protobuf compilation failed"); println!("OUT_DIR: {}", &env::var("OUT_DIR").unwrap()); - let from_path = Path::new(&env::var("OUT_DIR").unwrap()).join("ldk_node_server.rs"); - fs::copy(from_path, "src/lib.rs").unwrap(); + let from_path = Path::new(&env::var("OUT_DIR").unwrap()).join("api.rs"); + fs::copy(from_path, "src/api.rs").unwrap(); + let from_path = Path::new(&env::var("OUT_DIR").unwrap()).join("types.rs"); + fs::copy(from_path, "src/types.rs").unwrap(); + let from_path = Path::new(&env::var("OUT_DIR").unwrap()).join("error.rs"); + fs::copy(from_path, "src/error.rs").unwrap(); } diff --git a/protos/src/api.rs b/protos/src/api.rs new file mode 100644 index 0000000..f499214 --- /dev/null +++ b/protos/src/api.rs @@ -0,0 +1,319 @@ +/// Retrieve the latest node info like `node_id`, `current_best_block` etc. +/// See more: +/// - +/// - +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetNodeInfoRequest { +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetNodeInfoResponse { + /// The hex-encoded `node-id` or public key for our own lightning node. + #[prost(string, tag="1")] + pub node_id: ::prost::alloc::string::String, + /// The best block to which our Lightning wallet is currently synced. + /// + /// Should be always set, will never be `None`. + #[prost(message, optional, tag="3")] + pub current_best_block: ::core::option::Option, + /// The timestamp, in seconds since start of the UNIX epoch, when we last successfully synced our Lightning wallet to + /// the chain tip. + /// + /// Will be `None` if the wallet hasn't been synced yet. + #[prost(uint64, optional, tag="4")] + pub latest_lightning_wallet_sync_timestamp: ::core::option::Option, + /// The timestamp, in seconds since start of the UNIX epoch, when we last successfully synced our on-chain + /// wallet to the chain tip. + /// + /// Will be `None` if the wallet hasn’t been synced since the node was initialized. + #[prost(uint64, optional, tag="5")] + pub latest_onchain_wallet_sync_timestamp: ::core::option::Option, + /// The timestamp, in seconds since start of the UNIX epoch, when we last successfully update our fee rate cache. + /// + /// Will be `None` if the cache hasn’t been updated since the node was initialized. + #[prost(uint64, optional, tag="6")] + pub latest_fee_rate_cache_update_timestamp: ::core::option::Option, + /// The timestamp, in seconds since start of the UNIX epoch, when the last rapid gossip sync (RGS) snapshot we + /// successfully applied was generated. + /// + /// Will be `None` if RGS isn’t configured or the snapshot hasn’t been updated since the node was initialized. + #[prost(uint64, optional, tag="7")] + pub latest_rgs_snapshot_timestamp: ::core::option::Option, + /// The timestamp, in seconds since start of the UNIX epoch, when we last broadcasted a node announcement. + /// + /// Will be `None` if we have no public channels or we haven’t broadcasted since the node was initialized. + #[prost(uint64, optional, tag="8")] + pub latest_node_announcement_broadcast_timestamp: ::core::option::Option, +} +/// Retrieve a new on-chain funding address. +/// See more: +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct OnchainReceiveRequest { +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct OnchainReceiveResponse { + /// A Bitcoin on-chain address. + #[prost(string, tag="1")] + pub address: ::prost::alloc::string::String, +} +/// Send an on-chain payment to the given address. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct OnchainSendRequest { + /// The address to send coins to. + #[prost(string, tag="1")] + pub address: ::prost::alloc::string::String, + /// The amount in satoshis to send. + /// While sending the specified amount, we will respect any on-chain reserve we need to keep, + /// i.e., won't allow to cut into `total_anchor_channels_reserve_sats`. + /// See more: + #[prost(uint64, optional, tag="2")] + pub amount_sats: ::core::option::Option, + /// If set, the amount_sats field should be unset. + /// It indicates that node will send full balance to the specified address. + /// + /// Please note that when send_all is used this operation will **not** retain any on-chain reserves, + /// which might be potentially dangerous if you have open Anchor channels for which you can't trust + /// the counterparty to spend the Anchor output after channel closure. + /// See more: + #[prost(bool, optional, tag="3")] + pub send_all: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct OnchainSendResponse { + /// The transaction ID of the broadcasted transaction. + #[prost(string, tag="1")] + pub txid: ::prost::alloc::string::String, +} +/// Return a BOLT11 payable invoice that can be used to request and receive a payment +/// for the given amount, if specified. +/// The inbound payment will be automatically claimed upon arrival. +/// See more: +/// - +/// - +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Bolt11ReceiveRequest { + /// The amount in millisatoshi to send. If unset, a "zero-amount" or variable-amount invoice is returned. + #[prost(uint64, optional, tag="1")] + pub amount_msat: ::core::option::Option, + /// An optional description to attach along with the invoice. + /// Will be set in the description field of the encoded payment request. + #[prost(string, tag="2")] + pub description: ::prost::alloc::string::String, + /// Invoice expiry time in seconds. + #[prost(uint32, tag="3")] + pub expiry_secs: u32, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Bolt11ReceiveResponse { + /// An invoice for a payment within the Lightning Network. + /// With the details of the invoice, the sender has all the data necessary to send a payment + /// to the recipient. + #[prost(string, tag="1")] + pub invoice: ::prost::alloc::string::String, +} +/// Send a payment for a BOLT11 invoice. +/// See more: +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Bolt11SendRequest { + /// An invoice for a payment within the Lightning Network. + #[prost(string, tag="1")] + pub invoice: ::prost::alloc::string::String, + /// Set this field when paying a so-called "zero-amount" invoice, i.e., an invoice that leaves the + /// amount paid to be determined by the user. + /// This operation will fail if the amount specified is less than the value required by the given invoice. + #[prost(uint64, optional, tag="2")] + pub amount_msat: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Bolt11SendResponse { + /// An identifier used to uniquely identify a payment. + #[prost(bytes="bytes", tag="1")] + pub payment_id: ::prost::bytes::Bytes, +} +/// Returns a BOLT12 offer for the given amount, if specified. +/// +/// See more: +/// - +/// - +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Bolt12ReceiveRequest { + /// An optional description to attach along with the offer. + /// Will be set in the description field of the encoded offer. + #[prost(string, tag="1")] + pub description: ::prost::alloc::string::String, + /// The amount in millisatoshi to send. If unset, a "zero-amount" or variable-amount offer is returned. + #[prost(uint64, optional, tag="2")] + pub amount_msat: ::core::option::Option, + /// Offer expiry time in seconds. + #[prost(uint32, optional, tag="3")] + pub expiry_secs: ::core::option::Option, + /// If set, it represents the number of items requested, can only be set for fixed-amount offers. + #[prost(uint64, optional, tag="4")] + pub quantity: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Bolt12ReceiveResponse { + /// An offer for a payment within the Lightning Network. + /// With the details of the offer, the sender has all the data necessary to send a payment + /// to the recipient. + #[prost(string, tag="1")] + pub offer: ::prost::alloc::string::String, +} +/// Send a payment for a BOLT12 offer. +/// See more: +/// - +/// - +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Bolt12SendRequest { + /// An offer for a payment within the Lightning Network. + #[prost(string, tag="1")] + pub offer: ::prost::alloc::string::String, + /// Set this field when paying a so-called "zero-amount" offer, i.e., an offer that leaves the + /// amount paid to be determined by the user. + /// This operation will fail if the amount specified is less than the value required by the given offer. + #[prost(uint64, optional, tag="2")] + pub amount_msat: ::core::option::Option, + /// If set, it represents the number of items requested. + #[prost(uint64, optional, tag="3")] + pub quantity: ::core::option::Option, + /// If set, it will be seen by the recipient and reflected back in the invoice. + #[prost(string, optional, tag="4")] + pub payer_note: ::core::option::Option<::prost::alloc::string::String>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Bolt12SendResponse { + /// An identifier used to uniquely identify a payment. + #[prost(bytes="bytes", tag="1")] + pub payment_id: ::prost::bytes::Bytes, +} +/// Creates a new outbound channel to the given remote node. +/// See more: +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct OpenChannelRequest { + /// The hex-encoded public key of the node to open a channel with. + #[prost(string, tag="1")] + pub node_pubkey: ::prost::alloc::string::String, + /// An address which can be used to connect to a remote peer. + /// It can be of type IPv4:port, IPv6:port, OnionV3:port or hostname:port + #[prost(string, tag="2")] + pub address: ::prost::alloc::string::String, + /// The amount of satoshis the caller is willing to commit to the channel. + #[prost(uint64, tag="3")] + pub channel_amount_sats: u64, + /// The amount of satoshis to push to the remote side as part of the initial commitment state. + #[prost(uint64, optional, tag="4")] + pub push_to_counterparty_msat: ::core::option::Option, + /// The channel configuration to be used for opening this channel. If unset, default ChannelConfig is used. + #[prost(message, optional, tag="5")] + pub channel_config: ::core::option::Option, + /// Whether the channel should be public. + #[prost(bool, tag="6")] + pub announce_channel: bool, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct OpenChannelResponse { + /// The channel id of the created channel that user can use to refer to channel. + #[prost(bytes="bytes", tag="1")] + pub user_channel_id: ::prost::bytes::Bytes, +} +/// Update the config for a previously opened channel. +/// See more: +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct UpdateChannelConfigRequest { + /// The hex-encoded local `user_channel_id` of this channel. + #[prost(string, tag="1")] + pub user_channel_id: ::prost::alloc::string::String, + /// The hex-encoded public key of the counterparty node to update channel config with. + #[prost(string, tag="2")] + pub counterparty_node_id: ::prost::alloc::string::String, + /// The updated channel configuration settings for a channel. + #[prost(message, optional, tag="3")] + pub channel_config: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct UpdateChannelConfigResponse { +} +/// Closes the channel specified by given request. +/// See more: +/// - +/// - +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CloseChannelRequest { + /// The channel id of the created channel that user can use to refer to channel. + #[prost(bytes="bytes", tag="1")] + pub user_channel_id: ::prost::bytes::Bytes, + /// The hex-encoded public key of the node to close a channel with. + #[prost(string, tag="2")] + pub counterparty_node_id: ::prost::alloc::string::String, + /// Whether to force close the specified channel. + #[prost(bool, optional, tag="3")] + pub force_close: ::core::option::Option, + /// The reason for force-closing, can only be set while force closing a channel. + #[prost(string, optional, tag="4")] + pub force_close_reason: ::core::option::Option<::prost::alloc::string::String>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CloseChannelResponse { +} +/// Returns a list of known channels. +/// See more: +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ListChannelsRequest { +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ListChannelsResponse { + /// List of channels. + #[prost(message, repeated, tag="1")] + pub channels: ::prost::alloc::vec::Vec, +} +/// Returns payment details for a given payment_id. +/// See more: +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetPaymentDetailsRequest { + /// An identifier used to uniquely identify a payment in hex-encoded form. + #[prost(string, tag="1")] + pub payment_id: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetPaymentDetailsResponse { + /// Represents a payment. + /// Will be `None` if payment doesn't exist. + #[prost(message, optional, tag="1")] + pub payment: ::core::option::Option, +} +/// Retrieves list of all payments. +/// See more: +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ListPaymentsRequest { +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ListPaymentsResponse { + /// List of payments. + #[prost(message, repeated, tag="1")] + pub payments: ::prost::alloc::vec::Vec, +} diff --git a/protos/src/error.rs b/protos/src/error.rs new file mode 100644 index 0000000..5a274f1 --- /dev/null +++ b/protos/src/error.rs @@ -0,0 +1,142 @@ +/// When HttpStatusCode is not ok (200), the response `content` contains a serialized `ErrorResponse` +/// with the relevant ErrorCode and `message` +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ErrorResponse { + /// The error message containing a generic description of the error condition in English. + /// It is intended for a human audience only and should not be parsed to extract any information + /// programmatically. Client-side code may use it for logging only. + #[prost(string, tag="1")] + pub message: ::prost::alloc::string::String, + /// The error code uniquely identifying an error condition. + /// It is meant to be read and understood programmatically by code that detects/handles errors by + /// type. + /// + /// **Caution**: If a new type of `error_code` is introduced in oneof, `error_code` field will be unset. + /// If unset, it should be treated as `UnknownError`, it will not be set as `UnknownError`. + #[prost(oneof="error_response::ErrorCode", tags="2, 3, 4, 5, 6")] + pub error_code: ::core::option::Option, +} +/// Nested message and enum types in `ErrorResponse`. +pub mod error_response { + /// The error code uniquely identifying an error condition. + /// It is meant to be read and understood programmatically by code that detects/handles errors by + /// type. + /// + /// **Caution**: If a new type of `error_code` is introduced in oneof, `error_code` field will be unset. + /// If unset, it should be treated as `UnknownError`, it will not be set as `UnknownError`. + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum ErrorCode { + /// Will neve be used as `error_code` by server. + #[prost(message, tag="2")] + UnknownError(super::UnknownError), + /// Used in the following cases: + /// - The request was missing a required argument. + /// - The specified argument was invalid, incomplete or in the wrong format. + /// - The request body of api cannot be deserialized into corresponding protobuf object. + /// - The request does not follow api contract. + #[prost(message, tag="3")] + InvalidRequestError(super::InvalidRequestError), + /// Used when authentication fails or in case of an unauthorized request. + #[prost(message, tag="4")] + AuthError(super::AuthError), + /// Used to represent an Error while doing Lightning operation. Contains `LightningErrorCode` for further details. + #[prost(message, tag="5")] + LightningError(super::LightningError), + /// Used when an internal server error occurred, client is probably at no fault and can safely retry + /// this error with exponential backoff. + #[prost(message, tag="6")] + InternalServerError(super::InternalServerError), + } +} +/// Will neve be used as `error_code` by server. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct UnknownError { +} +/// Used in the following cases: +/// - The request was missing a required argument. +/// - The specified argument was invalid, incomplete or in the wrong format. +/// - The request body of api cannot be deserialized into corresponding protobuf object. +/// - The request does not follow api contract. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct InvalidRequestError { +} +/// Used when authentication fails or in case of an unauthorized request. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct AuthError { +} +/// Used to represent an Error while doing Lightning operation. Contains `LightningErrorCode` for further details. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct LightningError { + #[prost(enumeration="LightningErrorCode", tag="1")] + pub lightning_error_code: i32, +} +/// Used when an internal server error occurred, client is probably at no fault and can safely retry +/// this error with exponential backoff. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct InternalServerError { +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum LightningErrorCode { + /// Default protobuf Enum value. Will not be used as `LightningErrorCode` by server. + /// **Caution**: If a new Enum value is introduced, it will be seen as `UNKNOWN_LIGHTNING_ERROR` by code using earlier + /// versions of protobuf definition for deserialization. + UnknownLightningError = 0, + /// The requested operation failed, such as invoice creation failed, refund creation failed etc. + OperationFailed = 1, + /// There was a timeout during the requested operation. + OperationTimedOut = 2, + /// Sending a payment has failed. + PaymentSendingFailed = 3, + /// The available funds are insufficient to complete the given operation. + InsufficientFunds = 4, + /// A payment failed since it has already been initiated. + DuplicatePayment = 5, + /// A liquidity request operation failed. + LiquidityRequestFailed = 6, + /// The given operation failed due to the required liquidity source being unavailable. + LiquiditySourceUnavailable = 7, + /// The given operation failed due to the LSP's required opening fee being too high. + LiquidityFeeHigh = 8, +} +impl LightningErrorCode { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + LightningErrorCode::UnknownLightningError => "UNKNOWN_LIGHTNING_ERROR", + LightningErrorCode::OperationFailed => "OPERATION_FAILED", + LightningErrorCode::OperationTimedOut => "OPERATION_TIMED_OUT", + LightningErrorCode::PaymentSendingFailed => "PAYMENT_SENDING_FAILED", + LightningErrorCode::InsufficientFunds => "INSUFFICIENT_FUNDS", + LightningErrorCode::DuplicatePayment => "DUPLICATE_PAYMENT", + LightningErrorCode::LiquidityRequestFailed => "LIQUIDITY_REQUEST_FAILED", + LightningErrorCode::LiquiditySourceUnavailable => "LIQUIDITY_SOURCE_UNAVAILABLE", + LightningErrorCode::LiquidityFeeHigh => "LIQUIDITY_FEE_HIGH", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "UNKNOWN_LIGHTNING_ERROR" => Some(Self::UnknownLightningError), + "OPERATION_FAILED" => Some(Self::OperationFailed), + "OPERATION_TIMED_OUT" => Some(Self::OperationTimedOut), + "PAYMENT_SENDING_FAILED" => Some(Self::PaymentSendingFailed), + "INSUFFICIENT_FUNDS" => Some(Self::InsufficientFunds), + "DUPLICATE_PAYMENT" => Some(Self::DuplicatePayment), + "LIQUIDITY_REQUEST_FAILED" => Some(Self::LiquidityRequestFailed), + "LIQUIDITY_SOURCE_UNAVAILABLE" => Some(Self::LiquiditySourceUnavailable), + "LIQUIDITY_FEE_HIGH" => Some(Self::LiquidityFeeHigh), + _ => None, + } + } +} diff --git a/protos/src/lib.rs b/protos/src/lib.rs index 87af55e..ef33bab 100644 --- a/protos/src/lib.rs +++ b/protos/src/lib.rs @@ -1,751 +1,3 @@ -/// Retrieve the latest node info like `node_id`, `current_best_block` etc. -/// See more: -/// - -/// - -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct GetNodeInfoRequest {} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct GetNodeInfoResponse { - /// The hex-encoded `node-id` or public key for our own lightning node. - #[prost(string, tag = "1")] - pub node_id: ::prost::alloc::string::String, - /// The best block to which our Lightning wallet is currently synced. - /// - /// Should be always set, will never be `None`. - #[prost(message, optional, tag = "3")] - pub current_best_block: ::core::option::Option, - /// The timestamp, in seconds since start of the UNIX epoch, when we last successfully synced our Lightning wallet to - /// the chain tip. - /// - /// Will be `None` if the wallet hasn't been synced yet. - #[prost(uint64, optional, tag = "4")] - pub latest_lightning_wallet_sync_timestamp: ::core::option::Option, - /// The timestamp, in seconds since start of the UNIX epoch, when we last successfully synced our on-chain - /// wallet to the chain tip. - /// - /// Will be `None` if the wallet hasn’t been synced since the node was initialized. - #[prost(uint64, optional, tag = "5")] - pub latest_onchain_wallet_sync_timestamp: ::core::option::Option, - /// The timestamp, in seconds since start of the UNIX epoch, when we last successfully update our fee rate cache. - /// - /// Will be `None` if the cache hasn’t been updated since the node was initialized. - #[prost(uint64, optional, tag = "6")] - pub latest_fee_rate_cache_update_timestamp: ::core::option::Option, - /// The timestamp, in seconds since start of the UNIX epoch, when the last rapid gossip sync (RGS) snapshot we - /// successfully applied was generated. - /// - /// Will be `None` if RGS isn’t configured or the snapshot hasn’t been updated since the node was initialized. - #[prost(uint64, optional, tag = "7")] - pub latest_rgs_snapshot_timestamp: ::core::option::Option, - /// The timestamp, in seconds since start of the UNIX epoch, when we last broadcasted a node announcement. - /// - /// Will be `None` if we have no public channels or we haven’t broadcasted since the node was initialized. - #[prost(uint64, optional, tag = "8")] - pub latest_node_announcement_broadcast_timestamp: ::core::option::Option, -} -/// Retrieve a new on-chain funding address. -/// See more: -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct OnchainReceiveRequest {} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct OnchainReceiveResponse { - /// A Bitcoin on-chain address. - #[prost(string, tag = "1")] - pub address: ::prost::alloc::string::String, -} -/// Send an on-chain payment to the given address. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct OnchainSendRequest { - /// The address to send coins to. - #[prost(string, tag = "1")] - pub address: ::prost::alloc::string::String, - /// The amount in satoshis to send. - /// While sending the specified amount, we will respect any on-chain reserve we need to keep, - /// i.e., won't allow to cut into `total_anchor_channels_reserve_sats`. - /// See more: - #[prost(uint64, optional, tag = "2")] - pub amount_sats: ::core::option::Option, - /// If set, the amount_sats field should be unset. - /// It indicates that node will send full balance to the specified address. - /// - /// Please note that when send_all is used this operation will **not** retain any on-chain reserves, - /// which might be potentially dangerous if you have open Anchor channels for which you can't trust - /// the counterparty to spend the Anchor output after channel closure. - /// See more: - #[prost(bool, optional, tag = "3")] - pub send_all: ::core::option::Option, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct OnchainSendResponse { - /// The transaction ID of the broadcasted transaction. - #[prost(string, tag = "1")] - pub txid: ::prost::alloc::string::String, -} -/// Return a BOLT11 payable invoice that can be used to request and receive a payment -/// for the given amount, if specified. -/// The inbound payment will be automatically claimed upon arrival. -/// See more: -/// - -/// - -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Bolt11ReceiveRequest { - /// The amount in millisatoshi to send. If unset, a "zero-amount" or variable-amount invoice is returned. - #[prost(uint64, optional, tag = "1")] - pub amount_msat: ::core::option::Option, - /// An optional description to attach along with the invoice. - /// Will be set in the description field of the encoded payment request. - #[prost(string, tag = "2")] - pub description: ::prost::alloc::string::String, - /// Invoice expiry time in seconds. - #[prost(uint32, tag = "3")] - pub expiry_secs: u32, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Bolt11ReceiveResponse { - /// An invoice for a payment within the Lightning Network. - /// With the details of the invoice, the sender has all the data necessary to send a payment - /// to the recipient. - #[prost(string, tag = "1")] - pub invoice: ::prost::alloc::string::String, -} -/// Send a payment for a BOLT11 invoice. -/// See more: -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Bolt11SendRequest { - /// An invoice for a payment within the Lightning Network. - #[prost(string, tag = "1")] - pub invoice: ::prost::alloc::string::String, - /// Set this field when paying a so-called "zero-amount" invoice, i.e., an invoice that leaves the - /// amount paid to be determined by the user. - /// This operation will fail if the amount specified is less than the value required by the given invoice. - #[prost(uint64, optional, tag = "2")] - pub amount_msat: ::core::option::Option, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Bolt11SendResponse { - /// An identifier used to uniquely identify a payment. - #[prost(bytes = "bytes", tag = "1")] - pub payment_id: ::prost::bytes::Bytes, -} -/// Returns a BOLT12 offer for the given amount, if specified. -/// -/// See more: -/// - -/// - -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Bolt12ReceiveRequest { - /// An optional description to attach along with the offer. - /// Will be set in the description field of the encoded offer. - #[prost(string, tag = "1")] - pub description: ::prost::alloc::string::String, - /// The amount in millisatoshi to send. If unset, a "zero-amount" or variable-amount offer is returned. - #[prost(uint64, optional, tag = "2")] - pub amount_msat: ::core::option::Option, - /// Offer expiry time in seconds. - #[prost(uint32, optional, tag = "3")] - pub expiry_secs: ::core::option::Option, - /// If set, it represents the number of items requested, can only be set for fixed-amount offers. - #[prost(uint64, optional, tag = "4")] - pub quantity: ::core::option::Option, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Bolt12ReceiveResponse { - /// An offer for a payment within the Lightning Network. - /// With the details of the offer, the sender has all the data necessary to send a payment - /// to the recipient. - #[prost(string, tag = "1")] - pub offer: ::prost::alloc::string::String, -} -/// Send a payment for a BOLT12 offer. -/// See more: -/// - -/// - -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Bolt12SendRequest { - /// An offer for a payment within the Lightning Network. - #[prost(string, tag = "1")] - pub offer: ::prost::alloc::string::String, - /// Set this field when paying a so-called "zero-amount" offer, i.e., an offer that leaves the - /// amount paid to be determined by the user. - /// This operation will fail if the amount specified is less than the value required by the given offer. - #[prost(uint64, optional, tag = "2")] - pub amount_msat: ::core::option::Option, - /// If set, it represents the number of items requested. - #[prost(uint64, optional, tag = "3")] - pub quantity: ::core::option::Option, - /// If set, it will be seen by the recipient and reflected back in the invoice. - #[prost(string, optional, tag = "4")] - pub payer_note: ::core::option::Option<::prost::alloc::string::String>, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Bolt12SendResponse { - /// An identifier used to uniquely identify a payment. - #[prost(bytes = "bytes", tag = "1")] - pub payment_id: ::prost::bytes::Bytes, -} -/// Creates a new outbound channel to the given remote node. -/// See more: -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct OpenChannelRequest { - /// The hex-encoded public key of the node to open a channel with. - #[prost(string, tag = "1")] - pub node_pubkey: ::prost::alloc::string::String, - /// An address which can be used to connect to a remote peer. - /// It can be of type IPv4:port, IPv6:port, OnionV3:port or hostname:port - #[prost(string, tag = "2")] - pub address: ::prost::alloc::string::String, - /// The amount of satoshis the caller is willing to commit to the channel. - #[prost(uint64, tag = "3")] - pub channel_amount_sats: u64, - /// The amount of satoshis to push to the remote side as part of the initial commitment state. - #[prost(uint64, optional, tag = "4")] - pub push_to_counterparty_msat: ::core::option::Option, - /// The channel configuration to be used for opening this channel. If unset, default ChannelConfig is used. - #[prost(message, optional, tag = "5")] - pub channel_config: ::core::option::Option, - /// Whether the channel should be public. - #[prost(bool, tag = "6")] - pub announce_channel: bool, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct OpenChannelResponse { - /// The channel id of the created channel that user can use to refer to channel. - #[prost(bytes = "bytes", tag = "1")] - pub user_channel_id: ::prost::bytes::Bytes, -} -/// Update the config for a previously opened channel. -/// See more: -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct UpdateChannelConfigRequest { - /// The hex-encoded local `user_channel_id` of this channel. - #[prost(string, tag = "1")] - pub user_channel_id: ::prost::alloc::string::String, - /// The hex-encoded public key of the counterparty node to update channel config with. - #[prost(string, tag = "2")] - pub counterparty_node_id: ::prost::alloc::string::String, - /// The updated channel configuration settings for a channel. - #[prost(message, optional, tag = "3")] - pub channel_config: ::core::option::Option, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct UpdateChannelConfigResponse {} -/// ChannelConfig represents the configuration settings for a channel in a Lightning Network node. -/// See more: -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ChannelConfig { - /// Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound - /// over the channel. - /// See more: - #[prost(uint32, optional, tag = "1")] - pub forwarding_fee_proportional_millionths: ::core::option::Option, - /// Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, - /// in excess of forwarding_fee_proportional_millionths. - /// See more: - #[prost(uint32, optional, tag = "2")] - pub forwarding_fee_base_msat: ::core::option::Option, - /// The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded - /// over the channel this config applies to. - /// See more: - #[prost(uint32, optional, tag = "3")] - pub cltv_expiry_delta: ::core::option::Option, - /// The maximum additional fee we’re willing to pay to avoid waiting for the counterparty’s - /// to_self_delay to reclaim funds. - /// See more: - #[prost(uint64, optional, tag = "4")] - pub force_close_avoidance_max_fee_satoshis: ::core::option::Option, - /// If set, allows this channel’s counterparty to skim an additional fee off this node’s - /// inbound HTLCs. Useful for liquidity providers to offload on-chain channel costs to end users. - /// See more: - #[prost(bool, optional, tag = "5")] - pub accept_underpaying_htlcs: ::core::option::Option, - /// Limit our total exposure to potential loss to on-chain fees on close, including - /// in-flight HTLCs which are burned to fees as they are too small to claim on-chain - /// and fees on commitment transaction(s) broadcasted by our counterparty in excess of - /// our own fee estimate. - /// See more: - #[prost(oneof = "channel_config::MaxDustHtlcExposure", tags = "6, 7")] - pub max_dust_htlc_exposure: ::core::option::Option, -} -/// Nested message and enum types in `ChannelConfig`. -pub mod channel_config { - /// Limit our total exposure to potential loss to on-chain fees on close, including - /// in-flight HTLCs which are burned to fees as they are too small to claim on-chain - /// and fees on commitment transaction(s) broadcasted by our counterparty in excess of - /// our own fee estimate. - /// See more: - #[allow(clippy::derive_partial_eq_without_eq)] - #[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum MaxDustHtlcExposure { - /// This sets a fixed limit on the total dust exposure in millisatoshis. - /// See more: - #[prost(uint64, tag = "6")] - FixedLimitMsat(u64), - /// This sets a multiplier on the ConfirmationTarget::OnChainSweep feerate (in sats/KW) to determine the maximum allowed dust exposure. - /// See more: - #[prost(uint64, tag = "7")] - FeeRateMultiplier(u64), - } -} -/// Closes the channel specified by given request. -/// See more: -/// - -/// - -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct CloseChannelRequest { - /// The channel id of the created channel that user can use to refer to channel. - #[prost(bytes = "bytes", tag = "1")] - pub user_channel_id: ::prost::bytes::Bytes, - /// The hex-encoded public key of the node to close a channel with. - #[prost(string, tag = "2")] - pub counterparty_node_id: ::prost::alloc::string::String, - /// Whether to force close the specified channel. - #[prost(bool, optional, tag = "3")] - pub force_close: ::core::option::Option, - /// The reason for force-closing, can only be set while force closing a channel. - #[prost(string, optional, tag = "4")] - pub force_close_reason: ::core::option::Option<::prost::alloc::string::String>, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct CloseChannelResponse {} -/// Returns a list of known channels. -/// See more: -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ListChannelsRequest {} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ListChannelsResponse { - /// List of channels. - #[prost(message, repeated, tag = "1")] - pub channels: ::prost::alloc::vec::Vec, -} -/// Returns payment details for a given payment_id. -/// See more: -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct GetPaymentDetailsRequest { - /// An identifier used to uniquely identify a payment in hex-encoded form. - #[prost(string, tag = "1")] - pub payment_id: ::prost::alloc::string::String, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct GetPaymentDetailsResponse { - /// Represents a payment. - /// Will be `None` if payment doesn't exist. - #[prost(message, optional, tag = "1")] - pub payment: ::core::option::Option, -} -/// Retrieves list of all payments. -/// See more: -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ListPaymentsRequest {} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ListPaymentsResponse { - /// List of payments. - #[prost(message, repeated, tag = "1")] - pub payments: ::prost::alloc::vec::Vec, -} -/// Represents a payment. -/// See more: -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Payment { - /// An identifier used to uniquely identify a payment in hex-encoded form. - #[prost(string, tag = "1")] - pub id: ::prost::alloc::string::String, - /// The kind of the payment. - #[prost(message, optional, tag = "2")] - pub kind: ::core::option::Option, - /// The amount transferred. - #[prost(uint64, optional, tag = "3")] - pub amount_msat: ::core::option::Option, - /// The direction of the payment. - #[prost(enumeration = "PaymentDirection", tag = "4")] - pub direction: i32, - /// The status of the payment. - #[prost(enumeration = "PaymentStatus", tag = "5")] - pub status: i32, - /// The timestamp, in seconds since start of the UNIX epoch, when this entry was last updated. - #[prost(uint64, tag = "6")] - pub latest_update_timestamp: u64, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct PaymentKind { - #[prost(oneof = "payment_kind::Kind", tags = "1, 2, 3, 4, 5, 6")] - pub kind: ::core::option::Option, -} -/// Nested message and enum types in `PaymentKind`. -pub mod payment_kind { - #[allow(clippy::derive_partial_eq_without_eq)] - #[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum Kind { - #[prost(message, tag = "1")] - Onchain(super::Onchain), - #[prost(message, tag = "2")] - Bolt11(super::Bolt11), - #[prost(message, tag = "3")] - Bolt11Jit(super::Bolt11Jit), - #[prost(message, tag = "4")] - Bolt12Offer(super::Bolt12Offer), - #[prost(message, tag = "5")] - Bolt12Refund(super::Bolt12Refund), - #[prost(message, tag = "6")] - Spontaneous(super::Spontaneous), - } -} -/// Represents an on-chain payment. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Onchain {} -/// Represents a BOLT 11 payment. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Bolt11 { - /// The payment hash, i.e., the hash of the preimage. - #[prost(string, tag = "1")] - pub hash: ::prost::alloc::string::String, - /// The pre-image used by the payment. - #[prost(string, optional, tag = "2")] - pub preimage: ::core::option::Option<::prost::alloc::string::String>, - /// The secret used by the payment. - #[prost(bytes = "bytes", optional, tag = "3")] - pub secret: ::core::option::Option<::prost::bytes::Bytes>, -} -/// Represents a BOLT 11 payment intended to open an LSPS 2 just-in-time channel. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Bolt11Jit { - /// The payment hash, i.e., the hash of the preimage. - #[prost(string, tag = "1")] - pub hash: ::prost::alloc::string::String, - /// The pre-image used by the payment. - #[prost(string, optional, tag = "2")] - pub preimage: ::core::option::Option<::prost::alloc::string::String>, - /// The secret used by the payment. - #[prost(bytes = "bytes", optional, tag = "3")] - pub secret: ::core::option::Option<::prost::bytes::Bytes>, - /// Limits applying to how much fee we allow an LSP to deduct from the payment amount. - /// - /// Allowing them to deduct this fee from the first inbound payment will pay for the LSP’s channel opening fees. - /// - /// See \[`LdkChannelConfig::accept_underpaying_htlcs`\]() - /// for more information. - #[prost(message, optional, tag = "4")] - pub lsp_fee_limits: ::core::option::Option, -} -/// Represents a BOLT 12 ‘offer’ payment, i.e., a payment for an Offer. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Bolt12Offer { - /// The payment hash, i.e., the hash of the preimage. - #[prost(string, optional, tag = "1")] - pub hash: ::core::option::Option<::prost::alloc::string::String>, - /// The pre-image used by the payment. - #[prost(string, optional, tag = "2")] - pub preimage: ::core::option::Option<::prost::alloc::string::String>, - /// The secret used by the payment. - #[prost(bytes = "bytes", optional, tag = "3")] - pub secret: ::core::option::Option<::prost::bytes::Bytes>, - /// The hex-encoded ID of the offer this payment is for. - #[prost(string, tag = "4")] - pub offer_id: ::prost::alloc::string::String, - /// The payer's note for the payment. - /// Truncated to \[PAYER_NOTE_LIMIT\](). - /// - /// **Caution**: The `payer_note` field may come from an untrusted source. To prevent potential misuse, - /// all non-printable characters will be sanitized and replaced with safe characters. - #[prost(string, optional, tag = "5")] - pub payer_note: ::core::option::Option<::prost::alloc::string::String>, - /// The quantity of an item requested in the offer. - #[prost(uint64, optional, tag = "6")] - pub quantity: ::core::option::Option, -} -/// Represents a BOLT 12 ‘refund’ payment, i.e., a payment for a Refund. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Bolt12Refund { - /// The payment hash, i.e., the hash of the preimage. - #[prost(string, optional, tag = "1")] - pub hash: ::core::option::Option<::prost::alloc::string::String>, - /// The pre-image used by the payment. - #[prost(string, optional, tag = "2")] - pub preimage: ::core::option::Option<::prost::alloc::string::String>, - /// The secret used by the payment. - #[prost(bytes = "bytes", optional, tag = "3")] - pub secret: ::core::option::Option<::prost::bytes::Bytes>, - /// The payer's note for the payment. - /// Truncated to \[PAYER_NOTE_LIMIT\](). - /// - /// **Caution**: The `payer_note` field may come from an untrusted source. To prevent potential misuse, - /// all non-printable characters will be sanitized and replaced with safe characters. - #[prost(string, optional, tag = "5")] - pub payer_note: ::core::option::Option<::prost::alloc::string::String>, - /// The quantity of an item requested in the offer. - #[prost(uint64, optional, tag = "6")] - pub quantity: ::core::option::Option, -} -/// Represents a spontaneous (“keysend”) payment. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Spontaneous { - /// The payment hash, i.e., the hash of the preimage. - #[prost(string, tag = "1")] - pub hash: ::prost::alloc::string::String, - /// The pre-image used by the payment. - #[prost(string, optional, tag = "2")] - pub preimage: ::core::option::Option<::prost::alloc::string::String>, -} -/// Limits applying to how much fee we allow an LSP to deduct from the payment amount. -/// See \[`LdkChannelConfig::accept_underpaying_htlcs`\] for more information. -/// -/// \[`LdkChannelConfig::accept_underpaying_htlcs`\]: lightning::util::config::ChannelConfig::accept_underpaying_htlcs -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct LspFeeLimits { - /// The maximal total amount we allow any configured LSP withhold from us when forwarding the - /// payment. - #[prost(uint64, optional, tag = "1")] - pub max_total_opening_fee_msat: ::core::option::Option, - /// The maximal proportional fee, in parts-per-million millisatoshi, we allow any configured - /// LSP withhold from us when forwarding the payment. - #[prost(uint64, optional, tag = "2")] - pub max_proportional_opening_fee_ppm_msat: ::core::option::Option, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Channel { - /// The channel ID (prior to funding transaction generation, this is a random 32-byte - /// identifier, afterwards this is the transaction ID of the funding transaction XOR the - /// funding transaction output). - /// - /// Note that this means this value is *not* persistent - it can change once during the - /// lifetime of the channel. - #[prost(string, tag = "1")] - pub channel_id: ::prost::alloc::string::String, - /// The node ID of our the channel's remote counterparty. - #[prost(string, tag = "2")] - pub counterparty_node_id: ::prost::alloc::string::String, - /// The channel's funding transaction output, if we've negotiated the funding transaction with - /// our counterparty already. - #[prost(message, optional, tag = "3")] - pub funding_txo: ::core::option::Option, - /// The hex-encoded local `user_channel_id` of this channel. - #[prost(string, tag = "4")] - pub user_channel_id: ::prost::alloc::string::String, - /// The value, in satoshis, that must always be held as a reserve in the channel for us. This - /// value ensures that if we broadcast a revoked state, our counterparty can punish us by - /// claiming at least this value on chain. - /// - /// This value is not included in \[`outbound_capacity_msat`\] as it can never be spent. - /// - /// This value will be `None` for outbound channels until the counterparty accepts the channel. - #[prost(uint64, optional, tag = "5")] - pub unspendable_punishment_reserve: ::core::option::Option, - /// The value, in satoshis, of this channel as it appears in the funding output. - #[prost(uint64, tag = "6")] - pub channel_value_sats: u64, - /// The currently negotiated fee rate denominated in satoshi per 1000 weight units, - /// which is applied to commitment and HTLC transactions. - #[prost(uint32, tag = "7")] - pub feerate_sat_per_1000_weight: u32, - /// The available outbound capacity for sending HTLCs to the remote peer. - /// - /// The amount does not include any pending HTLCs which are not yet resolved (and, thus, whose - /// balance is not available for inclusion in new outbound HTLCs). This further does not include - /// any pending outgoing HTLCs which are awaiting some other resolution to be sent. - #[prost(uint64, tag = "8")] - pub outbound_capacity_msat: u64, - /// The available outbound capacity for sending HTLCs to the remote peer. - /// - /// The amount does not include any pending HTLCs which are not yet resolved - /// (and, thus, whose balance is not available for inclusion in new inbound HTLCs). This further - /// does not include any pending outgoing HTLCs which are awaiting some other resolution to be - /// sent. - #[prost(uint64, tag = "9")] - pub inbound_capacity_msat: u64, - /// The number of required confirmations on the funding transactions before the funding is - /// considered "locked". The amount is selected by the channel fundee. - /// - /// The value will be `None` for outbound channels until the counterparty accepts the channel. - #[prost(uint32, optional, tag = "10")] - pub confirmations_required: ::core::option::Option, - /// The current number of confirmations on the funding transaction. - #[prost(uint32, optional, tag = "11")] - pub confirmations: ::core::option::Option, - /// Is `true` if the channel was initiated (and therefore funded) by us. - #[prost(bool, tag = "12")] - pub is_outbound: bool, - /// Is `true` if both parties have exchanged `channel_ready` messages, and the channel is - /// not currently being shut down. Both parties exchange `channel_ready` messages upon - /// independently verifying that the required confirmations count provided by - /// `confirmations_required` has been reached. - #[prost(bool, tag = "13")] - pub is_channel_ready: bool, - /// Is `true` if the channel (a) `channel_ready` messages have been exchanged, (b) the - /// peer is connected, and (c) the channel is not currently negotiating shutdown. - /// - /// This is a strict superset of `is_channel_ready`. - #[prost(bool, tag = "14")] - pub is_usable: bool, - /// Is `true` if this channel is (or will be) publicly-announced - #[prost(bool, tag = "15")] - pub is_announced: bool, - /// Set of configurable parameters set by self that affect channel operation. - #[prost(message, optional, tag = "16")] - pub channel_config: ::core::option::Option, - /// The available outbound capacity for sending a single HTLC to the remote peer. This is - /// similar to `outbound_capacity_msat` but it may be further restricted by - /// the current state and per-HTLC limit(s). This is intended for use when routing, allowing us - /// to use a limit as close as possible to the HTLC limit we can currently send. - #[prost(uint64, tag = "17")] - pub next_outbound_htlc_limit_msat: u64, - /// The minimum value for sending a single HTLC to the remote peer. This is the equivalent of - /// `next_outbound_htlc_limit_msat` but represents a lower-bound, rather than - /// an upper-bound. This is intended for use when routing, allowing us to ensure we pick a - /// route which is valid. - #[prost(uint64, tag = "18")] - pub next_outbound_htlc_minimum_msat: u64, - /// The number of blocks (after our commitment transaction confirms) that we will need to wait - /// until we can claim our funds after we force-close the channel. During this time our - /// counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty - /// force-closes the channel and broadcasts a commitment transaction we do not have to wait any - /// time to claim our non-HTLC-encumbered funds. - /// - /// This value will be `None` for outbound channels until the counterparty accepts the channel. - #[prost(uint32, optional, tag = "19")] - pub force_close_spend_delay: ::core::option::Option, - /// The smallest value HTLC (in msat) the remote peer will accept, for this channel. - /// - /// This field is only `None` before we have received either the `OpenChannel` or - /// `AcceptChannel` message from the remote peer. - #[prost(uint64, optional, tag = "20")] - pub counterparty_outbound_htlc_minimum_msat: ::core::option::Option, - /// The largest value HTLC (in msat) the remote peer currently will accept, for this channel. - #[prost(uint64, optional, tag = "21")] - pub counterparty_outbound_htlc_maximum_msat: ::core::option::Option, - /// The value, in satoshis, that must always be held in the channel for our counterparty. This - /// value ensures that if our counterparty broadcasts a revoked state, we can punish them by - /// claiming at least this value on chain. - /// - /// This value is not included in `inbound_capacity_msat` as it can never be spent. - #[prost(uint64, tag = "22")] - pub counterparty_unspendable_punishment_reserve: u64, - /// Base routing fee in millisatoshis. - #[prost(uint32, optional, tag = "23")] - pub counterparty_forwarding_info_fee_base_msat: ::core::option::Option, - /// Proportional fee, in millionths of a satoshi the channel will charge per transferred satoshi. - #[prost(uint32, optional, tag = "24")] - pub counterparty_forwarding_info_fee_proportional_millionths: ::core::option::Option, - /// The minimum difference in CLTV expiry between an ingoing HTLC and its outgoing counterpart, - /// such that the outgoing HTLC is forwardable to this counterparty. - #[prost(uint32, optional, tag = "25")] - pub counterparty_forwarding_info_cltv_expiry_delta: ::core::option::Option, -} -/// Represent a transaction outpoint. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct OutPoint { - /// The referenced transaction's txid. - #[prost(string, tag = "1")] - pub txid: ::prost::alloc::string::String, - /// The index of the referenced output in its transaction's vout. - #[prost(uint32, tag = "2")] - pub vout: u32, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct BestBlock { - /// The block’s hash - #[prost(string, tag = "1")] - pub block_hash: ::prost::alloc::string::String, - /// The height at which the block was confirmed. - #[prost(uint32, tag = "2")] - pub height: u32, -} -/// Represents the direction of a payment. -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] -#[repr(i32)] -pub enum PaymentDirection { - /// The payment is inbound. - Inbound = 0, - /// The payment is outbound. - Outbound = 1, -} -impl PaymentDirection { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - PaymentDirection::Inbound => "INBOUND", - PaymentDirection::Outbound => "OUTBOUND", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "INBOUND" => Some(Self::Inbound), - "OUTBOUND" => Some(Self::Outbound), - _ => None, - } - } -} -/// Represents the current status of a payment. -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] -#[repr(i32)] -pub enum PaymentStatus { - /// The payment is still pending. - Pending = 0, - /// The payment succeeded. - Succeeded = 1, - /// The payment failed. - Failed = 2, -} -impl PaymentStatus { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - PaymentStatus::Pending => "PENDING", - PaymentStatus::Succeeded => "SUCCEEDED", - PaymentStatus::Failed => "FAILED", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "PENDING" => Some(Self::Pending), - "SUCCEEDED" => Some(Self::Succeeded), - "FAILED" => Some(Self::Failed), - _ => None, - } - } -} +pub mod api; +pub mod types; +pub mod error; diff --git a/protos/src/proto/api.proto b/protos/src/proto/api.proto new file mode 100644 index 0000000..f3ddd83 --- /dev/null +++ b/protos/src/proto/api.proto @@ -0,0 +1,295 @@ +syntax = "proto3"; +package api; + +import 'types.proto'; + +// Retrieve the latest node info like `node_id`, `current_best_block` etc. +// See more: +// - https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.node_id +// - https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.status +message GetNodeInfoRequest { +} + +message GetNodeInfoResponse { + + // The hex-encoded `node-id` or public key for our own lightning node. + string node_id = 1; + + // The best block to which our Lightning wallet is currently synced. + // + // Should be always set, will never be `None`. + types.BestBlock current_best_block = 3; + + // The timestamp, in seconds since start of the UNIX epoch, when we last successfully synced our Lightning wallet to + // the chain tip. + // + // Will be `None` if the wallet hasn't been synced yet. + optional uint64 latest_lightning_wallet_sync_timestamp = 4; + + // The timestamp, in seconds since start of the UNIX epoch, when we last successfully synced our on-chain + // wallet to the chain tip. + // + // Will be `None` if the wallet hasn’t been synced since the node was initialized. + optional uint64 latest_onchain_wallet_sync_timestamp = 5; + + // The timestamp, in seconds since start of the UNIX epoch, when we last successfully update our fee rate cache. + // + // Will be `None` if the cache hasn’t been updated since the node was initialized. + optional uint64 latest_fee_rate_cache_update_timestamp = 6; + + // The timestamp, in seconds since start of the UNIX epoch, when the last rapid gossip sync (RGS) snapshot we + // successfully applied was generated. + // + // Will be `None` if RGS isn’t configured or the snapshot hasn’t been updated since the node was initialized. + optional uint64 latest_rgs_snapshot_timestamp = 7; + + // The timestamp, in seconds since start of the UNIX epoch, when we last broadcasted a node announcement. + // + // Will be `None` if we have no public channels or we haven’t broadcasted since the node was initialized. + optional uint64 latest_node_announcement_broadcast_timestamp = 8; +} + +// Retrieve a new on-chain funding address. +// See more: https://docs.rs/ldk-node/latest/ldk_node/payment/struct.OnchainPayment.html#method.new_address +message OnchainReceiveRequest { +} + +message OnchainReceiveResponse { + + // A Bitcoin on-chain address. + string address = 1; +} + +// Send an on-chain payment to the given address. +message OnchainSendRequest { + + // The address to send coins to. + string address = 1; + + // The amount in satoshis to send. + // While sending the specified amount, we will respect any on-chain reserve we need to keep, + // i.e., won't allow to cut into `total_anchor_channels_reserve_sats`. + // See more: https://docs.rs/ldk-node/latest/ldk_node/payment/struct.OnchainPayment.html#method.send_to_address + optional uint64 amount_sats = 2; + + // If set, the amount_sats field should be unset. + // It indicates that node will send full balance to the specified address. + // + // Please note that when send_all is used this operation will **not** retain any on-chain reserves, + // which might be potentially dangerous if you have open Anchor channels for which you can't trust + // the counterparty to spend the Anchor output after channel closure. + // See more: https://docs.rs/ldk-node/latest/ldk_node/payment/struct.OnchainPayment.html#method.send_all_to_address + optional bool send_all = 3; +} + +message OnchainSendResponse { + + // The transaction ID of the broadcasted transaction. + string txid = 1; +} + +// Return a BOLT11 payable invoice that can be used to request and receive a payment +// for the given amount, if specified. +// The inbound payment will be automatically claimed upon arrival. +// See more: +// - https://docs.rs/ldk-node/latest/ldk_node/payment/struct.Bolt11Payment.html#method.receive +// - https://docs.rs/ldk-node/latest/ldk_node/payment/struct.Bolt11Payment.html#method.receive_variable_amount +message Bolt11ReceiveRequest { + + // The amount in millisatoshi to send. If unset, a "zero-amount" or variable-amount invoice is returned. + optional uint64 amount_msat = 1; + + // An optional description to attach along with the invoice. + // Will be set in the description field of the encoded payment request. + string description = 2; + + // Invoice expiry time in seconds. + uint32 expiry_secs = 3; +} + + +message Bolt11ReceiveResponse { + + // An invoice for a payment within the Lightning Network. + // With the details of the invoice, the sender has all the data necessary to send a payment + // to the recipient. + string invoice = 1; +} + +// Send a payment for a BOLT11 invoice. +// See more: https://docs.rs/ldk-node/latest/ldk_node/payment/struct.Bolt11Payment.html#method.send +message Bolt11SendRequest { + + // An invoice for a payment within the Lightning Network. + string invoice = 1; + + // Set this field when paying a so-called "zero-amount" invoice, i.e., an invoice that leaves the + // amount paid to be determined by the user. + // This operation will fail if the amount specified is less than the value required by the given invoice. + optional uint64 amount_msat = 2; + +} + +message Bolt11SendResponse { + + // An identifier used to uniquely identify a payment. + bytes payment_id = 1; +} + +// Returns a BOLT12 offer for the given amount, if specified. +// +// See more: +// - https://docs.rs/ldk-node/latest/ldk_node/payment/struct.Bolt12Payment.html#method.receive +// - https://docs.rs/ldk-node/latest/ldk_node/payment/struct.Bolt12Payment.html#method.receive_variable_amount +message Bolt12ReceiveRequest { + + // An optional description to attach along with the offer. + // Will be set in the description field of the encoded offer. + string description = 1; + + // The amount in millisatoshi to send. If unset, a "zero-amount" or variable-amount offer is returned. + optional uint64 amount_msat = 2; + + // Offer expiry time in seconds. + optional uint32 expiry_secs = 3; + + // If set, it represents the number of items requested, can only be set for fixed-amount offers. + optional uint64 quantity = 4; +} + +message Bolt12ReceiveResponse { + + // An offer for a payment within the Lightning Network. + // With the details of the offer, the sender has all the data necessary to send a payment + // to the recipient. + string offer = 1; +} + +// Send a payment for a BOLT12 offer. +// See more: +// - https://docs.rs/ldk-node/latest/ldk_node/payment/struct.Bolt12Payment.html#method.send +// - https://docs.rs/ldk-node/latest/ldk_node/payment/struct.Bolt12Payment.html#method.send_using_amount +message Bolt12SendRequest { + + // An offer for a payment within the Lightning Network. + string offer = 1; + + // Set this field when paying a so-called "zero-amount" offer, i.e., an offer that leaves the + // amount paid to be determined by the user. + // This operation will fail if the amount specified is less than the value required by the given offer. + optional uint64 amount_msat = 2; + + // If set, it represents the number of items requested. + optional uint64 quantity = 3; + + // If set, it will be seen by the recipient and reflected back in the invoice. + optional string payer_note = 4; +} + +message Bolt12SendResponse { + + // An identifier used to uniquely identify a payment. + bytes payment_id = 1; +} + +// Creates a new outbound channel to the given remote node. +// See more: https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.connect_open_channel +message OpenChannelRequest { + + // The hex-encoded public key of the node to open a channel with. + string node_pubkey = 1; + + // An address which can be used to connect to a remote peer. + // It can be of type IPv4:port, IPv6:port, OnionV3:port or hostname:port + string address = 2; + + // The amount of satoshis the caller is willing to commit to the channel. + uint64 channel_amount_sats = 3; + + // The amount of satoshis to push to the remote side as part of the initial commitment state. + optional uint64 push_to_counterparty_msat = 4; + + // The channel configuration to be used for opening this channel. If unset, default ChannelConfig is used. + optional types.ChannelConfig channel_config = 5; + + // Whether the channel should be public. + bool announce_channel = 6; +} + +message OpenChannelResponse { + + // The channel id of the created channel that user can use to refer to channel. + bytes user_channel_id = 1; +} + +// Update the config for a previously opened channel. +// See more: https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.update_channel_config +message UpdateChannelConfigRequest { + + // The hex-encoded local `user_channel_id` of this channel. + string user_channel_id = 1; + + // The hex-encoded public key of the counterparty node to update channel config with. + string counterparty_node_id = 2; + + // The updated channel configuration settings for a channel. + types.ChannelConfig channel_config = 3; +} + +message UpdateChannelConfigResponse { +} + +// Closes the channel specified by given request. +// See more: +// - https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.close_channel +// - https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.force_close_channel +message CloseChannelRequest { + + // The channel id of the created channel that user can use to refer to channel. + bytes user_channel_id = 1; + + // The hex-encoded public key of the node to close a channel with. + string counterparty_node_id = 2; + + // Whether to force close the specified channel. + optional bool force_close = 3; + + // The reason for force-closing, can only be set while force closing a channel. + optional string force_close_reason = 4; +} + +message CloseChannelResponse { + +} + +// Returns a list of known channels. +// See more: https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.list_channels +message ListChannelsRequest {} + +message ListChannelsResponse { + + // List of channels. + repeated types.Channel channels = 1; +} + +// Returns payment details for a given payment_id. +// See more: https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.payment +message GetPaymentDetailsRequest { + // An identifier used to uniquely identify a payment in hex-encoded form. + string payment_id = 1; +} + +message GetPaymentDetailsResponse { + // Represents a payment. + // Will be `None` if payment doesn't exist. + types.Payment payment = 1; +} + +// Retrieves list of all payments. +// See more: https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.list_payments +message ListPaymentsRequest {} + +message ListPaymentsResponse { + // List of payments. + repeated types.Payment payments = 1; +} diff --git a/protos/src/proto/error.proto b/protos/src/proto/error.proto new file mode 100644 index 0000000..6593eae --- /dev/null +++ b/protos/src/proto/error.proto @@ -0,0 +1,93 @@ +syntax = "proto3"; +package error; + +// When HttpStatusCode is not ok (200), the response `content` contains a serialized `ErrorResponse` +// with the relevant ErrorCode and `message` +message ErrorResponse { + + // The error message containing a generic description of the error condition in English. + // It is intended for a human audience only and should not be parsed to extract any information + // programmatically. Client-side code may use it for logging only. + string message = 1; + + // The error code uniquely identifying an error condition. + // It is meant to be read and understood programmatically by code that detects/handles errors by + // type. + // + // **Caution**: If a new type of `error_code` is introduced in oneof, `error_code` field will be unset. + // If unset, it should be treated as `UnknownError`, it will not be set as `UnknownError`. + oneof error_code { + // Will neve be used as `error_code` by server. + UnknownError unknown_error = 2; + + // Used in the following cases: + // - The request was missing a required argument. + // - The specified argument was invalid, incomplete or in the wrong format. + // - The request body of api cannot be deserialized into corresponding protobuf object. + // - The request does not follow api contract. + InvalidRequestError invalid_request_error = 3; + + // Used when authentication fails or in case of an unauthorized request. + AuthError auth_error = 4; + + // Used to represent an Error while doing Lightning operation. Contains `LightningErrorCode` for further details. + LightningError lightning_error = 5; + + // Used when an internal server error occurred, client is probably at no fault and can safely retry + // this error with exponential backoff. + InternalServerError internal_server_error = 6; + } +} + +// Will neve be used as `error_code` by server. +message UnknownError {} + +// Used in the following cases: +// - The request was missing a required argument. +// - The specified argument was invalid, incomplete or in the wrong format. +// - The request body of api cannot be deserialized into corresponding protobuf object. +// - The request does not follow api contract. +message InvalidRequestError {} + +// Used when authentication fails or in case of an unauthorized request. +message AuthError {} + +// Used to represent an Error while doing Lightning operation. Contains `LightningErrorCode` for further details. +message LightningError { + LightningErrorCode lightning_error_code = 1; +} + +// Used when an internal server error occurred, client is probably at no fault and can safely retry +// this error with exponential backoff. +message InternalServerError {} + +enum LightningErrorCode { + // Default protobuf Enum value. Will not be used as `LightningErrorCode` by server. + // **Caution**: If a new Enum value is introduced, it will be seen as `UNKNOWN_LIGHTNING_ERROR` by code using earlier + // versions of protobuf definition for deserialization. + UNKNOWN_LIGHTNING_ERROR = 0; + + // The requested operation failed, such as invoice creation failed, refund creation failed etc. + OPERATION_FAILED = 1; + + // There was a timeout during the requested operation. + OPERATION_TIMED_OUT = 2; + + // Sending a payment has failed. + PAYMENT_SENDING_FAILED = 3; + + // The available funds are insufficient to complete the given operation. + INSUFFICIENT_FUNDS = 4; + + // A payment failed since it has already been initiated. + DUPLICATE_PAYMENT = 5; + + // A liquidity request operation failed. + LIQUIDITY_REQUEST_FAILED = 6; + + // The given operation failed due to the required liquidity source being unavailable. + LIQUIDITY_SOURCE_UNAVAILABLE = 7; + + // The given operation failed due to the LSP's required opening fee being too high. + LIQUIDITY_FEE_HIGH = 8; +} diff --git a/protos/src/proto/ldk_node_server.proto b/protos/src/proto/types.proto similarity index 58% rename from protos/src/proto/ldk_node_server.proto rename to protos/src/proto/types.proto index 342f704..82eeee8 100644 --- a/protos/src/proto/ldk_node_server.proto +++ b/protos/src/proto/types.proto @@ -1,341 +1,5 @@ syntax = "proto3"; -package ldk_node_server; - -// Retrieve the latest node info like `node_id`, `current_best_block` etc. -// See more: -// - https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.node_id -// - https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.status -message GetNodeInfoRequest { -} - -message GetNodeInfoResponse { - - // The hex-encoded `node-id` or public key for our own lightning node. - string node_id = 1; - - // The best block to which our Lightning wallet is currently synced. - // - // Should be always set, will never be `None`. - BestBlock current_best_block = 3; - - // The timestamp, in seconds since start of the UNIX epoch, when we last successfully synced our Lightning wallet to - // the chain tip. - // - // Will be `None` if the wallet hasn't been synced yet. - optional uint64 latest_lightning_wallet_sync_timestamp = 4; - - // The timestamp, in seconds since start of the UNIX epoch, when we last successfully synced our on-chain - // wallet to the chain tip. - // - // Will be `None` if the wallet hasn’t been synced since the node was initialized. - optional uint64 latest_onchain_wallet_sync_timestamp = 5; - - // The timestamp, in seconds since start of the UNIX epoch, when we last successfully update our fee rate cache. - // - // Will be `None` if the cache hasn’t been updated since the node was initialized. - optional uint64 latest_fee_rate_cache_update_timestamp = 6; - - // The timestamp, in seconds since start of the UNIX epoch, when the last rapid gossip sync (RGS) snapshot we - // successfully applied was generated. - // - // Will be `None` if RGS isn’t configured or the snapshot hasn’t been updated since the node was initialized. - optional uint64 latest_rgs_snapshot_timestamp = 7; - - // The timestamp, in seconds since start of the UNIX epoch, when we last broadcasted a node announcement. - // - // Will be `None` if we have no public channels or we haven’t broadcasted since the node was initialized. - optional uint64 latest_node_announcement_broadcast_timestamp = 8; -} - -// Retrieve a new on-chain funding address. -// See more: https://docs.rs/ldk-node/latest/ldk_node/payment/struct.OnchainPayment.html#method.new_address -message OnchainReceiveRequest { -} - -message OnchainReceiveResponse { - - // A Bitcoin on-chain address. - string address = 1; -} - -// Send an on-chain payment to the given address. -message OnchainSendRequest { - - // The address to send coins to. - string address = 1; - - // The amount in satoshis to send. - // While sending the specified amount, we will respect any on-chain reserve we need to keep, - // i.e., won't allow to cut into `total_anchor_channels_reserve_sats`. - // See more: https://docs.rs/ldk-node/latest/ldk_node/payment/struct.OnchainPayment.html#method.send_to_address - optional uint64 amount_sats = 2; - - // If set, the amount_sats field should be unset. - // It indicates that node will send full balance to the specified address. - // - // Please note that when send_all is used this operation will **not** retain any on-chain reserves, - // which might be potentially dangerous if you have open Anchor channels for which you can't trust - // the counterparty to spend the Anchor output after channel closure. - // See more: https://docs.rs/ldk-node/latest/ldk_node/payment/struct.OnchainPayment.html#method.send_all_to_address - optional bool send_all = 3; -} - -message OnchainSendResponse { - - // The transaction ID of the broadcasted transaction. - string txid = 1; -} - -// Return a BOLT11 payable invoice that can be used to request and receive a payment -// for the given amount, if specified. -// The inbound payment will be automatically claimed upon arrival. -// See more: -// - https://docs.rs/ldk-node/latest/ldk_node/payment/struct.Bolt11Payment.html#method.receive -// - https://docs.rs/ldk-node/latest/ldk_node/payment/struct.Bolt11Payment.html#method.receive_variable_amount -message Bolt11ReceiveRequest { - - // The amount in millisatoshi to send. If unset, a "zero-amount" or variable-amount invoice is returned. - optional uint64 amount_msat = 1; - - // An optional description to attach along with the invoice. - // Will be set in the description field of the encoded payment request. - string description = 2; - - // Invoice expiry time in seconds. - uint32 expiry_secs = 3; -} - - -message Bolt11ReceiveResponse { - - // An invoice for a payment within the Lightning Network. - // With the details of the invoice, the sender has all the data necessary to send a payment - // to the recipient. - string invoice = 1; -} - -// Send a payment for a BOLT11 invoice. -// See more: https://docs.rs/ldk-node/latest/ldk_node/payment/struct.Bolt11Payment.html#method.send -message Bolt11SendRequest { - - // An invoice for a payment within the Lightning Network. - string invoice = 1; - - // Set this field when paying a so-called "zero-amount" invoice, i.e., an invoice that leaves the - // amount paid to be determined by the user. - // This operation will fail if the amount specified is less than the value required by the given invoice. - optional uint64 amount_msat = 2; - -} - -message Bolt11SendResponse { - - // An identifier used to uniquely identify a payment. - bytes payment_id = 1; -} - -// Returns a BOLT12 offer for the given amount, if specified. -// -// See more: -// - https://docs.rs/ldk-node/latest/ldk_node/payment/struct.Bolt12Payment.html#method.receive -// - https://docs.rs/ldk-node/latest/ldk_node/payment/struct.Bolt12Payment.html#method.receive_variable_amount -message Bolt12ReceiveRequest { - - // An optional description to attach along with the offer. - // Will be set in the description field of the encoded offer. - string description = 1; - - // The amount in millisatoshi to send. If unset, a "zero-amount" or variable-amount offer is returned. - optional uint64 amount_msat = 2; - - // Offer expiry time in seconds. - optional uint32 expiry_secs = 3; - - // If set, it represents the number of items requested, can only be set for fixed-amount offers. - optional uint64 quantity = 4; -} - -message Bolt12ReceiveResponse { - - // An offer for a payment within the Lightning Network. - // With the details of the offer, the sender has all the data necessary to send a payment - // to the recipient. - string offer = 1; -} - -// Send a payment for a BOLT12 offer. -// See more: -// - https://docs.rs/ldk-node/latest/ldk_node/payment/struct.Bolt12Payment.html#method.send -// - https://docs.rs/ldk-node/latest/ldk_node/payment/struct.Bolt12Payment.html#method.send_using_amount -message Bolt12SendRequest { - - // An offer for a payment within the Lightning Network. - string offer = 1; - - // Set this field when paying a so-called "zero-amount" offer, i.e., an offer that leaves the - // amount paid to be determined by the user. - // This operation will fail if the amount specified is less than the value required by the given offer. - optional uint64 amount_msat = 2; - - // If set, it represents the number of items requested. - optional uint64 quantity = 3; - - // If set, it will be seen by the recipient and reflected back in the invoice. - optional string payer_note = 4; -} - -message Bolt12SendResponse { - - // An identifier used to uniquely identify a payment. - bytes payment_id = 1; -} - -// Creates a new outbound channel to the given remote node. -// See more: https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.connect_open_channel -message OpenChannelRequest { - - // The hex-encoded public key of the node to open a channel with. - string node_pubkey = 1; - - // An address which can be used to connect to a remote peer. - // It can be of type IPv4:port, IPv6:port, OnionV3:port or hostname:port - string address = 2; - - // The amount of satoshis the caller is willing to commit to the channel. - uint64 channel_amount_sats = 3; - - // The amount of satoshis to push to the remote side as part of the initial commitment state. - optional uint64 push_to_counterparty_msat = 4; - - // The channel configuration to be used for opening this channel. If unset, default ChannelConfig is used. - optional ChannelConfig channel_config = 5; - - // Whether the channel should be public. - bool announce_channel = 6; -} - -message OpenChannelResponse { - - // The channel id of the created channel that user can use to refer to channel. - bytes user_channel_id = 1; -} - -// Update the config for a previously opened channel. -// See more: https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.update_channel_config -message UpdateChannelConfigRequest { - - // The hex-encoded local `user_channel_id` of this channel. - string user_channel_id = 1; - - // The hex-encoded public key of the counterparty node to update channel config with. - string counterparty_node_id = 2; - - // The updated channel configuration settings for a channel. - ChannelConfig channel_config = 3; -} - -message UpdateChannelConfigResponse { -} - -// ChannelConfig represents the configuration settings for a channel in a Lightning Network node. -// See more: https://docs.rs/lightning/latest/lightning/util/config/struct.ChannelConfig.html -message ChannelConfig { - // Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound - // over the channel. - // See more: https://docs.rs/lightning/latest/lightning/util/config/struct.ChannelConfig.html#structfield.forwarding_fee_proportional_millionths - optional uint32 forwarding_fee_proportional_millionths = 1; - - // Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, - // in excess of forwarding_fee_proportional_millionths. - // See more: https://docs.rs/lightning/latest/lightning/util/config/struct.ChannelConfig.html#structfield.forwarding_fee_base_msat - optional uint32 forwarding_fee_base_msat = 2; - - // The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded - // over the channel this config applies to. - // See more: https://docs.rs/lightning/latest/lightning/util/config/struct.ChannelConfig.html#structfield.cltv_expiry_delta - optional uint32 cltv_expiry_delta = 3; - - // The maximum additional fee we’re willing to pay to avoid waiting for the counterparty’s - // to_self_delay to reclaim funds. - // See more: https://docs.rs/lightning/latest/lightning/util/config/struct.ChannelConfig.html#structfield.force_close_avoidance_max_fee_satoshis - optional uint64 force_close_avoidance_max_fee_satoshis = 4; - - // If set, allows this channel’s counterparty to skim an additional fee off this node’s - // inbound HTLCs. Useful for liquidity providers to offload on-chain channel costs to end users. - // See more: https://docs.rs/lightning/latest/lightning/util/config/struct.ChannelConfig.html#structfield.accept_underpaying_htlcs - optional bool accept_underpaying_htlcs = 5; - - // Limit our total exposure to potential loss to on-chain fees on close, including - // in-flight HTLCs which are burned to fees as they are too small to claim on-chain - // and fees on commitment transaction(s) broadcasted by our counterparty in excess of - // our own fee estimate. - // See more: https://docs.rs/lightning/latest/lightning/util/config/struct.ChannelConfig.html#structfield.max_dust_htlc_exposure - oneof max_dust_htlc_exposure { - - // This sets a fixed limit on the total dust exposure in millisatoshis. - // See more: https://docs.rs/lightning/latest/lightning/util/config/enum.MaxDustHTLCExposure.html#variant.FixedLimitMsat - uint64 fixed_limit_msat = 6; - - // This sets a multiplier on the ConfirmationTarget::OnChainSweep feerate (in sats/KW) to determine the maximum allowed dust exposure. - // See more: https://docs.rs/lightning/latest/lightning/util/config/enum.MaxDustHTLCExposure.html#variant.FeeRateMultiplier - uint64 fee_rate_multiplier = 7; - } -} - -// Closes the channel specified by given request. -// See more: -// - https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.close_channel -// - https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.force_close_channel -message CloseChannelRequest { - - // The channel id of the created channel that user can use to refer to channel. - bytes user_channel_id = 1; - - // The hex-encoded public key of the node to close a channel with. - string counterparty_node_id = 2; - - // Whether to force close the specified channel. - optional bool force_close = 3; - - // The reason for force-closing, can only be set while force closing a channel. - optional string force_close_reason = 4; -} - -message CloseChannelResponse { - -} - -// Returns a list of known channels. -// See more: https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.list_channels -message ListChannelsRequest {} - -message ListChannelsResponse { - - // List of channels. - repeated Channel channels = 1; -} - -// Returns payment details for a given payment_id. -// See more: https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.payment -message GetPaymentDetailsRequest { - // An identifier used to uniquely identify a payment in hex-encoded form. - string payment_id = 1; -} - -message GetPaymentDetailsResponse { - // Represents a payment. - // Will be `None` if payment doesn't exist. - Payment payment = 1; -} - -// Retrieves list of all payments. -// See more: https://docs.rs/ldk-node/latest/ldk_node/struct.Node.html#method.list_payments -message ListPaymentsRequest {} - -message ListPaymentsResponse { - // List of payments. - repeated Payment payments = 1; -} +package types; // Represents a payment. // See more: https://docs.rs/ldk-node/latest/ldk_node/payment/struct.PaymentDetails.html @@ -625,6 +289,51 @@ message Channel { optional uint32 counterparty_forwarding_info_cltv_expiry_delta = 25; } +// ChannelConfig represents the configuration settings for a channel in a Lightning Network node. +// See more: https://docs.rs/lightning/latest/lightning/util/config/struct.ChannelConfig.html +message ChannelConfig { + // Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound + // over the channel. + // See more: https://docs.rs/lightning/latest/lightning/util/config/struct.ChannelConfig.html#structfield.forwarding_fee_proportional_millionths + optional uint32 forwarding_fee_proportional_millionths = 1; + + // Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, + // in excess of forwarding_fee_proportional_millionths. + // See more: https://docs.rs/lightning/latest/lightning/util/config/struct.ChannelConfig.html#structfield.forwarding_fee_base_msat + optional uint32 forwarding_fee_base_msat = 2; + + // The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded + // over the channel this config applies to. + // See more: https://docs.rs/lightning/latest/lightning/util/config/struct.ChannelConfig.html#structfield.cltv_expiry_delta + optional uint32 cltv_expiry_delta = 3; + + // The maximum additional fee we’re willing to pay to avoid waiting for the counterparty’s + // to_self_delay to reclaim funds. + // See more: https://docs.rs/lightning/latest/lightning/util/config/struct.ChannelConfig.html#structfield.force_close_avoidance_max_fee_satoshis + optional uint64 force_close_avoidance_max_fee_satoshis = 4; + + // If set, allows this channel’s counterparty to skim an additional fee off this node’s + // inbound HTLCs. Useful for liquidity providers to offload on-chain channel costs to end users. + // See more: https://docs.rs/lightning/latest/lightning/util/config/struct.ChannelConfig.html#structfield.accept_underpaying_htlcs + optional bool accept_underpaying_htlcs = 5; + + // Limit our total exposure to potential loss to on-chain fees on close, including + // in-flight HTLCs which are burned to fees as they are too small to claim on-chain + // and fees on commitment transaction(s) broadcasted by our counterparty in excess of + // our own fee estimate. + // See more: https://docs.rs/lightning/latest/lightning/util/config/struct.ChannelConfig.html#structfield.max_dust_htlc_exposure + oneof max_dust_htlc_exposure { + + // This sets a fixed limit on the total dust exposure in millisatoshis. + // See more: https://docs.rs/lightning/latest/lightning/util/config/enum.MaxDustHTLCExposure.html#variant.FixedLimitMsat + uint64 fixed_limit_msat = 6; + + // This sets a multiplier on the ConfirmationTarget::OnChainSweep feerate (in sats/KW) to determine the maximum allowed dust exposure. + // See more: https://docs.rs/lightning/latest/lightning/util/config/enum.MaxDustHTLCExposure.html#variant.FeeRateMultiplier + uint64 fee_rate_multiplier = 7; + } +} + // Represent a transaction outpoint. message OutPoint { // The referenced transaction's txid. diff --git a/protos/src/types.rs b/protos/src/types.rs new file mode 100644 index 0000000..42e2495 --- /dev/null +++ b/protos/src/types.rs @@ -0,0 +1,439 @@ +/// Represents a payment. +/// See more: +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Payment { + /// An identifier used to uniquely identify a payment in hex-encoded form. + #[prost(string, tag="1")] + pub id: ::prost::alloc::string::String, + /// The kind of the payment. + #[prost(message, optional, tag="2")] + pub kind: ::core::option::Option, + /// The amount transferred. + #[prost(uint64, optional, tag="3")] + pub amount_msat: ::core::option::Option, + /// The direction of the payment. + #[prost(enumeration="PaymentDirection", tag="4")] + pub direction: i32, + /// The status of the payment. + #[prost(enumeration="PaymentStatus", tag="5")] + pub status: i32, + /// The timestamp, in seconds since start of the UNIX epoch, when this entry was last updated. + #[prost(uint64, tag="6")] + pub latest_update_timestamp: u64, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PaymentKind { + #[prost(oneof="payment_kind::Kind", tags="1, 2, 3, 4, 5, 6")] + pub kind: ::core::option::Option, +} +/// Nested message and enum types in `PaymentKind`. +pub mod payment_kind { + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Kind { + #[prost(message, tag="1")] + Onchain(super::Onchain), + #[prost(message, tag="2")] + Bolt11(super::Bolt11), + #[prost(message, tag="3")] + Bolt11Jit(super::Bolt11Jit), + #[prost(message, tag="4")] + Bolt12Offer(super::Bolt12Offer), + #[prost(message, tag="5")] + Bolt12Refund(super::Bolt12Refund), + #[prost(message, tag="6")] + Spontaneous(super::Spontaneous), + } +} +/// Represents an on-chain payment. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Onchain { +} +/// Represents a BOLT 11 payment. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Bolt11 { + /// The payment hash, i.e., the hash of the preimage. + #[prost(string, tag="1")] + pub hash: ::prost::alloc::string::String, + /// The pre-image used by the payment. + #[prost(string, optional, tag="2")] + pub preimage: ::core::option::Option<::prost::alloc::string::String>, + /// The secret used by the payment. + #[prost(bytes="bytes", optional, tag="3")] + pub secret: ::core::option::Option<::prost::bytes::Bytes>, +} +/// Represents a BOLT 11 payment intended to open an LSPS 2 just-in-time channel. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Bolt11Jit { + /// The payment hash, i.e., the hash of the preimage. + #[prost(string, tag="1")] + pub hash: ::prost::alloc::string::String, + /// The pre-image used by the payment. + #[prost(string, optional, tag="2")] + pub preimage: ::core::option::Option<::prost::alloc::string::String>, + /// The secret used by the payment. + #[prost(bytes="bytes", optional, tag="3")] + pub secret: ::core::option::Option<::prost::bytes::Bytes>, + /// Limits applying to how much fee we allow an LSP to deduct from the payment amount. + /// + /// Allowing them to deduct this fee from the first inbound payment will pay for the LSP’s channel opening fees. + /// + /// See \[`LdkChannelConfig::accept_underpaying_htlcs`\]() + /// for more information. + #[prost(message, optional, tag="4")] + pub lsp_fee_limits: ::core::option::Option, +} +/// Represents a BOLT 12 ‘offer’ payment, i.e., a payment for an Offer. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Bolt12Offer { + /// The payment hash, i.e., the hash of the preimage. + #[prost(string, optional, tag="1")] + pub hash: ::core::option::Option<::prost::alloc::string::String>, + /// The pre-image used by the payment. + #[prost(string, optional, tag="2")] + pub preimage: ::core::option::Option<::prost::alloc::string::String>, + /// The secret used by the payment. + #[prost(bytes="bytes", optional, tag="3")] + pub secret: ::core::option::Option<::prost::bytes::Bytes>, + /// The hex-encoded ID of the offer this payment is for. + #[prost(string, tag="4")] + pub offer_id: ::prost::alloc::string::String, + /// The payer's note for the payment. + /// Truncated to \[PAYER_NOTE_LIMIT\](). + /// + /// **Caution**: The `payer_note` field may come from an untrusted source. To prevent potential misuse, + /// all non-printable characters will be sanitized and replaced with safe characters. + #[prost(string, optional, tag="5")] + pub payer_note: ::core::option::Option<::prost::alloc::string::String>, + /// The quantity of an item requested in the offer. + #[prost(uint64, optional, tag="6")] + pub quantity: ::core::option::Option, +} +/// Represents a BOLT 12 ‘refund’ payment, i.e., a payment for a Refund. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Bolt12Refund { + /// The payment hash, i.e., the hash of the preimage. + #[prost(string, optional, tag="1")] + pub hash: ::core::option::Option<::prost::alloc::string::String>, + /// The pre-image used by the payment. + #[prost(string, optional, tag="2")] + pub preimage: ::core::option::Option<::prost::alloc::string::String>, + /// The secret used by the payment. + #[prost(bytes="bytes", optional, tag="3")] + pub secret: ::core::option::Option<::prost::bytes::Bytes>, + /// The payer's note for the payment. + /// Truncated to \[PAYER_NOTE_LIMIT\](). + /// + /// **Caution**: The `payer_note` field may come from an untrusted source. To prevent potential misuse, + /// all non-printable characters will be sanitized and replaced with safe characters. + #[prost(string, optional, tag="5")] + pub payer_note: ::core::option::Option<::prost::alloc::string::String>, + /// The quantity of an item requested in the offer. + #[prost(uint64, optional, tag="6")] + pub quantity: ::core::option::Option, +} +/// Represents a spontaneous (“keysend”) payment. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Spontaneous { + /// The payment hash, i.e., the hash of the preimage. + #[prost(string, tag="1")] + pub hash: ::prost::alloc::string::String, + /// The pre-image used by the payment. + #[prost(string, optional, tag="2")] + pub preimage: ::core::option::Option<::prost::alloc::string::String>, +} +/// Limits applying to how much fee we allow an LSP to deduct from the payment amount. +/// See \[`LdkChannelConfig::accept_underpaying_htlcs`\] for more information. +/// +/// \[`LdkChannelConfig::accept_underpaying_htlcs`\]: lightning::util::config::ChannelConfig::accept_underpaying_htlcs +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct LspFeeLimits { + /// The maximal total amount we allow any configured LSP withhold from us when forwarding the + /// payment. + #[prost(uint64, optional, tag="1")] + pub max_total_opening_fee_msat: ::core::option::Option, + /// The maximal proportional fee, in parts-per-million millisatoshi, we allow any configured + /// LSP withhold from us when forwarding the payment. + #[prost(uint64, optional, tag="2")] + pub max_proportional_opening_fee_ppm_msat: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Channel { + /// The channel ID (prior to funding transaction generation, this is a random 32-byte + /// identifier, afterwards this is the transaction ID of the funding transaction XOR the + /// funding transaction output). + /// + /// Note that this means this value is *not* persistent - it can change once during the + /// lifetime of the channel. + #[prost(string, tag="1")] + pub channel_id: ::prost::alloc::string::String, + /// The node ID of our the channel's remote counterparty. + #[prost(string, tag="2")] + pub counterparty_node_id: ::prost::alloc::string::String, + /// The channel's funding transaction output, if we've negotiated the funding transaction with + /// our counterparty already. + #[prost(message, optional, tag="3")] + pub funding_txo: ::core::option::Option, + /// The hex-encoded local `user_channel_id` of this channel. + #[prost(string, tag="4")] + pub user_channel_id: ::prost::alloc::string::String, + /// The value, in satoshis, that must always be held as a reserve in the channel for us. This + /// value ensures that if we broadcast a revoked state, our counterparty can punish us by + /// claiming at least this value on chain. + /// + /// This value is not included in \[`outbound_capacity_msat`\] as it can never be spent. + /// + /// This value will be `None` for outbound channels until the counterparty accepts the channel. + #[prost(uint64, optional, tag="5")] + pub unspendable_punishment_reserve: ::core::option::Option, + /// The value, in satoshis, of this channel as it appears in the funding output. + #[prost(uint64, tag="6")] + pub channel_value_sats: u64, + /// The currently negotiated fee rate denominated in satoshi per 1000 weight units, + /// which is applied to commitment and HTLC transactions. + #[prost(uint32, tag="7")] + pub feerate_sat_per_1000_weight: u32, + /// The available outbound capacity for sending HTLCs to the remote peer. + /// + /// The amount does not include any pending HTLCs which are not yet resolved (and, thus, whose + /// balance is not available for inclusion in new outbound HTLCs). This further does not include + /// any pending outgoing HTLCs which are awaiting some other resolution to be sent. + #[prost(uint64, tag="8")] + pub outbound_capacity_msat: u64, + /// The available outbound capacity for sending HTLCs to the remote peer. + /// + /// The amount does not include any pending HTLCs which are not yet resolved + /// (and, thus, whose balance is not available for inclusion in new inbound HTLCs). This further + /// does not include any pending outgoing HTLCs which are awaiting some other resolution to be + /// sent. + #[prost(uint64, tag="9")] + pub inbound_capacity_msat: u64, + /// The number of required confirmations on the funding transactions before the funding is + /// considered "locked". The amount is selected by the channel fundee. + /// + /// The value will be `None` for outbound channels until the counterparty accepts the channel. + #[prost(uint32, optional, tag="10")] + pub confirmations_required: ::core::option::Option, + /// The current number of confirmations on the funding transaction. + #[prost(uint32, optional, tag="11")] + pub confirmations: ::core::option::Option, + /// Is `true` if the channel was initiated (and therefore funded) by us. + #[prost(bool, tag="12")] + pub is_outbound: bool, + /// Is `true` if both parties have exchanged `channel_ready` messages, and the channel is + /// not currently being shut down. Both parties exchange `channel_ready` messages upon + /// independently verifying that the required confirmations count provided by + /// `confirmations_required` has been reached. + #[prost(bool, tag="13")] + pub is_channel_ready: bool, + /// Is `true` if the channel (a) `channel_ready` messages have been exchanged, (b) the + /// peer is connected, and (c) the channel is not currently negotiating shutdown. + /// + /// This is a strict superset of `is_channel_ready`. + #[prost(bool, tag="14")] + pub is_usable: bool, + /// Is `true` if this channel is (or will be) publicly-announced + #[prost(bool, tag="15")] + pub is_announced: bool, + /// Set of configurable parameters set by self that affect channel operation. + #[prost(message, optional, tag="16")] + pub channel_config: ::core::option::Option, + /// The available outbound capacity for sending a single HTLC to the remote peer. This is + /// similar to `outbound_capacity_msat` but it may be further restricted by + /// the current state and per-HTLC limit(s). This is intended for use when routing, allowing us + /// to use a limit as close as possible to the HTLC limit we can currently send. + #[prost(uint64, tag="17")] + pub next_outbound_htlc_limit_msat: u64, + /// The minimum value for sending a single HTLC to the remote peer. This is the equivalent of + /// `next_outbound_htlc_limit_msat` but represents a lower-bound, rather than + /// an upper-bound. This is intended for use when routing, allowing us to ensure we pick a + /// route which is valid. + #[prost(uint64, tag="18")] + pub next_outbound_htlc_minimum_msat: u64, + /// The number of blocks (after our commitment transaction confirms) that we will need to wait + /// until we can claim our funds after we force-close the channel. During this time our + /// counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty + /// force-closes the channel and broadcasts a commitment transaction we do not have to wait any + /// time to claim our non-HTLC-encumbered funds. + /// + /// This value will be `None` for outbound channels until the counterparty accepts the channel. + #[prost(uint32, optional, tag="19")] + pub force_close_spend_delay: ::core::option::Option, + /// The smallest value HTLC (in msat) the remote peer will accept, for this channel. + /// + /// This field is only `None` before we have received either the `OpenChannel` or + /// `AcceptChannel` message from the remote peer. + #[prost(uint64, optional, tag="20")] + pub counterparty_outbound_htlc_minimum_msat: ::core::option::Option, + /// The largest value HTLC (in msat) the remote peer currently will accept, for this channel. + #[prost(uint64, optional, tag="21")] + pub counterparty_outbound_htlc_maximum_msat: ::core::option::Option, + /// The value, in satoshis, that must always be held in the channel for our counterparty. This + /// value ensures that if our counterparty broadcasts a revoked state, we can punish them by + /// claiming at least this value on chain. + /// + /// This value is not included in `inbound_capacity_msat` as it can never be spent. + #[prost(uint64, tag="22")] + pub counterparty_unspendable_punishment_reserve: u64, + /// Base routing fee in millisatoshis. + #[prost(uint32, optional, tag="23")] + pub counterparty_forwarding_info_fee_base_msat: ::core::option::Option, + /// Proportional fee, in millionths of a satoshi the channel will charge per transferred satoshi. + #[prost(uint32, optional, tag="24")] + pub counterparty_forwarding_info_fee_proportional_millionths: ::core::option::Option, + /// The minimum difference in CLTV expiry between an ingoing HTLC and its outgoing counterpart, + /// such that the outgoing HTLC is forwardable to this counterparty. + #[prost(uint32, optional, tag="25")] + pub counterparty_forwarding_info_cltv_expiry_delta: ::core::option::Option, +} +/// ChannelConfig represents the configuration settings for a channel in a Lightning Network node. +/// See more: +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ChannelConfig { + /// Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound + /// over the channel. + /// See more: + #[prost(uint32, optional, tag="1")] + pub forwarding_fee_proportional_millionths: ::core::option::Option, + /// Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, + /// in excess of forwarding_fee_proportional_millionths. + /// See more: + #[prost(uint32, optional, tag="2")] + pub forwarding_fee_base_msat: ::core::option::Option, + /// The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded + /// over the channel this config applies to. + /// See more: + #[prost(uint32, optional, tag="3")] + pub cltv_expiry_delta: ::core::option::Option, + /// The maximum additional fee we’re willing to pay to avoid waiting for the counterparty’s + /// to_self_delay to reclaim funds. + /// See more: + #[prost(uint64, optional, tag="4")] + pub force_close_avoidance_max_fee_satoshis: ::core::option::Option, + /// If set, allows this channel’s counterparty to skim an additional fee off this node’s + /// inbound HTLCs. Useful for liquidity providers to offload on-chain channel costs to end users. + /// See more: + #[prost(bool, optional, tag="5")] + pub accept_underpaying_htlcs: ::core::option::Option, + /// Limit our total exposure to potential loss to on-chain fees on close, including + /// in-flight HTLCs which are burned to fees as they are too small to claim on-chain + /// and fees on commitment transaction(s) broadcasted by our counterparty in excess of + /// our own fee estimate. + /// See more: + #[prost(oneof="channel_config::MaxDustHtlcExposure", tags="6, 7")] + pub max_dust_htlc_exposure: ::core::option::Option, +} +/// Nested message and enum types in `ChannelConfig`. +pub mod channel_config { + /// Limit our total exposure to potential loss to on-chain fees on close, including + /// in-flight HTLCs which are burned to fees as they are too small to claim on-chain + /// and fees on commitment transaction(s) broadcasted by our counterparty in excess of + /// our own fee estimate. + /// See more: + #[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum MaxDustHtlcExposure { + /// This sets a fixed limit on the total dust exposure in millisatoshis. + /// See more: + #[prost(uint64, tag="6")] + FixedLimitMsat(u64), + /// This sets a multiplier on the ConfirmationTarget::OnChainSweep feerate (in sats/KW) to determine the maximum allowed dust exposure. + /// See more: + #[prost(uint64, tag="7")] + FeeRateMultiplier(u64), + } +} +/// Represent a transaction outpoint. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct OutPoint { + /// The referenced transaction's txid. + #[prost(string, tag="1")] + pub txid: ::prost::alloc::string::String, + /// The index of the referenced output in its transaction's vout. + #[prost(uint32, tag="2")] + pub vout: u32, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct BestBlock { + /// The block’s hash + #[prost(string, tag="1")] + pub block_hash: ::prost::alloc::string::String, + /// The height at which the block was confirmed. + #[prost(uint32, tag="2")] + pub height: u32, +} +/// Represents the direction of a payment. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum PaymentDirection { + /// The payment is inbound. + Inbound = 0, + /// The payment is outbound. + Outbound = 1, +} +impl PaymentDirection { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + PaymentDirection::Inbound => "INBOUND", + PaymentDirection::Outbound => "OUTBOUND", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "INBOUND" => Some(Self::Inbound), + "OUTBOUND" => Some(Self::Outbound), + _ => None, + } + } +} +/// Represents the current status of a payment. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum PaymentStatus { + /// The payment is still pending. + Pending = 0, + /// The payment succeeded. + Succeeded = 1, + /// The payment failed. + Failed = 2, +} +impl PaymentStatus { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + PaymentStatus::Pending => "PENDING", + PaymentStatus::Succeeded => "SUCCEEDED", + PaymentStatus::Failed => "FAILED", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "PENDING" => Some(Self::Pending), + "SUCCEEDED" => Some(Self::Succeeded), + "FAILED" => Some(Self::Failed), + _ => None, + } + } +} diff --git a/server/src/api/bolt11_receive.rs b/server/src/api/bolt11_receive.rs index 8778c67..7c8ef29 100644 --- a/server/src/api/bolt11_receive.rs +++ b/server/src/api/bolt11_receive.rs @@ -1,5 +1,5 @@ use ldk_node::Node; -use protos::{Bolt11ReceiveRequest, Bolt11ReceiveResponse}; +use protos::api::{Bolt11ReceiveRequest, Bolt11ReceiveResponse}; use std::sync::Arc; pub(crate) const BOLT11_RECEIVE_PATH: &str = "Bolt11Receive"; diff --git a/server/src/api/bolt11_send.rs b/server/src/api/bolt11_send.rs index fc3e09b..2376f16 100644 --- a/server/src/api/bolt11_send.rs +++ b/server/src/api/bolt11_send.rs @@ -1,7 +1,7 @@ use bytes::Bytes; use ldk_node::lightning_invoice::Bolt11Invoice; use ldk_node::Node; -use protos::{Bolt11SendRequest, Bolt11SendResponse}; +use protos::api::{Bolt11SendRequest, Bolt11SendResponse}; use std::str::FromStr; use std::sync::Arc; diff --git a/server/src/api/bolt12_receive.rs b/server/src/api/bolt12_receive.rs index 203a81f..5d49531 100644 --- a/server/src/api/bolt12_receive.rs +++ b/server/src/api/bolt12_receive.rs @@ -1,5 +1,5 @@ use ldk_node::Node; -use protos::{Bolt12ReceiveRequest, Bolt12ReceiveResponse}; +use protos::api::{Bolt12ReceiveRequest, Bolt12ReceiveResponse}; use std::sync::Arc; pub(crate) const BOLT12_RECEIVE_PATH: &str = "Bolt12Receive"; diff --git a/server/src/api/bolt12_send.rs b/server/src/api/bolt12_send.rs index 8a09823..423c579 100644 --- a/server/src/api/bolt12_send.rs +++ b/server/src/api/bolt12_send.rs @@ -1,7 +1,7 @@ use bytes::Bytes; use ldk_node::lightning::offers::offer::Offer; use ldk_node::Node; -use protos::{Bolt12SendRequest, Bolt12SendResponse}; +use protos::api::{Bolt12SendRequest, Bolt12SendResponse}; use std::str::FromStr; use std::sync::Arc; diff --git a/server/src/api/close_channel.rs b/server/src/api/close_channel.rs index 2d58bc1..e9f6e3d 100644 --- a/server/src/api/close_channel.rs +++ b/server/src/api/close_channel.rs @@ -1,6 +1,6 @@ use ldk_node::bitcoin::secp256k1::PublicKey; use ldk_node::{Node, UserChannelId}; -use protos::{CloseChannelRequest, CloseChannelResponse}; +use protos::api::{CloseChannelRequest, CloseChannelResponse}; use std::str::FromStr; use std::sync::Arc; diff --git a/server/src/api/error.rs b/server/src/api/error.rs new file mode 100644 index 0000000..b7432bc --- /dev/null +++ b/server/src/api/error.rs @@ -0,0 +1,48 @@ + +pub(crate) struct LdkServerError { + // The error message containing a generic description of the error condition in English. + // It is intended for a human audience only and should not be parsed to extract any information + // programmatically. Client-side code may use it for logging only. + pub(crate) message: String, + + // The error code uniquely identifying an error condition. + // It is meant to be read and understood programmatically by code that detects/handles errors by + // type. + pub(crate) error_code: LdkServerErrorCode, + + + // The `sub_error_code` used to represent further details of `Error` while doing Lightning operation. + // It is only set when `error_code` is set to `LightningError`. + pub(crate) sub_error_code: Option +} + +pub(crate) enum LdkServerErrorCode { + /// Please refer to [`protos::error::InvalidRequestError`]. + InvalidRequestError, + + /// Please refer to [`protos::error::AuthError`]. + AuthError, + + /// Please refer to [`protos::error::LightningError`]. + LightningError, + + /// Please refer to [`protos::error::InternalServerError`]. + InternalServerError, + + /// There is an unknown error, it could be a client-side bug, unrecognized error-code, network error + /// or something else. + InternalError, +} + +// TODO: Add docs. +pub(crate) enum LightningErrorCode { + UnknownLightningError, + OperationFailed, + OperationTimedOut, + PaymentSendingFailed, + InsufficientFunds, + DuplicatePayment, + LiquidityRequestFailed, + LiquiditySourceUnavailable, + LiquidityFeeHigh, +} diff --git a/server/src/api/get_node_info.rs b/server/src/api/get_node_info.rs index c221c9d..eabc25e 100644 --- a/server/src/api/get_node_info.rs +++ b/server/src/api/get_node_info.rs @@ -1,5 +1,6 @@ use ldk_node::Node; -use protos::{BestBlock, GetNodeInfoRequest, GetNodeInfoResponse}; +use protos::api::{GetNodeInfoRequest, GetNodeInfoResponse}; +use protos::types::BestBlock; use std::sync::Arc; pub(crate) const GET_NODE_INFO: &str = "GetNodeInfo"; diff --git a/server/src/api/get_payment_details.rs b/server/src/api/get_payment_details.rs index 52008a3..d1f2734 100644 --- a/server/src/api/get_payment_details.rs +++ b/server/src/api/get_payment_details.rs @@ -2,7 +2,7 @@ use crate::util::proto_adapter::payment_to_proto; use hex::FromHex; use ldk_node::lightning::ln::channelmanager::PaymentId; use ldk_node::Node; -use protos::{GetPaymentDetailsRequest, GetPaymentDetailsResponse}; +use protos::api::{GetPaymentDetailsRequest, GetPaymentDetailsResponse}; use std::sync::Arc; pub(crate) const GET_PAYMENT_DETAILS_PATH: &str = "GetPaymentDetails"; diff --git a/server/src/api/list_channels.rs b/server/src/api/list_channels.rs index 32688d6..90520c5 100644 --- a/server/src/api/list_channels.rs +++ b/server/src/api/list_channels.rs @@ -1,6 +1,6 @@ use crate::util::proto_adapter::channel_to_proto; use ldk_node::Node; -use protos::{ListChannelsRequest, ListChannelsResponse}; +use protos::api::{ListChannelsRequest, ListChannelsResponse}; use std::sync::Arc; pub(crate) const LIST_CHANNELS_PATH: &str = "ListChannels"; diff --git a/server/src/api/list_payments.rs b/server/src/api/list_payments.rs index 2667d58..671741d 100644 --- a/server/src/api/list_payments.rs +++ b/server/src/api/list_payments.rs @@ -1,6 +1,6 @@ use crate::util::proto_adapter::payment_to_proto; use ldk_node::Node; -use protos::{ListPaymentsRequest, ListPaymentsResponse}; +use protos::api::{ListPaymentsRequest, ListPaymentsResponse}; use std::sync::Arc; pub(crate) const LIST_PAYMENTS_PATH: &str = "ListPayments"; diff --git a/server/src/api/mod.rs b/server/src/api/mod.rs index e7561fd..cd1e0da 100644 --- a/server/src/api/mod.rs +++ b/server/src/api/mod.rs @@ -3,6 +3,7 @@ pub(crate) mod bolt11_send; pub(crate) mod bolt12_receive; pub(crate) mod bolt12_send; pub(crate) mod close_channel; +pub(crate) mod error; pub(crate) mod get_node_info; pub(crate) mod get_payment_details; pub(crate) mod list_channels; diff --git a/server/src/api/onchain_receive.rs b/server/src/api/onchain_receive.rs index 565bfd9..884552f 100644 --- a/server/src/api/onchain_receive.rs +++ b/server/src/api/onchain_receive.rs @@ -1,5 +1,5 @@ use ldk_node::Node; -use protos::{OnchainReceiveRequest, OnchainReceiveResponse}; +use protos::api::{OnchainReceiveRequest, OnchainReceiveResponse}; use std::sync::Arc; pub(crate) const ONCHAIN_RECEIVE_PATH: &str = "OnchainReceive"; diff --git a/server/src/api/onchain_send.rs b/server/src/api/onchain_send.rs index 0e40d63..7d9348f 100644 --- a/server/src/api/onchain_send.rs +++ b/server/src/api/onchain_send.rs @@ -1,6 +1,6 @@ use ldk_node::bitcoin::Address; use ldk_node::Node; -use protos::{OnchainSendRequest, OnchainSendResponse}; +use protos::api::{OnchainSendRequest, OnchainSendResponse}; use std::str::FromStr; use std::sync::Arc; diff --git a/server/src/api/open_channel.rs b/server/src/api/open_channel.rs index 0f74459..214746d 100644 --- a/server/src/api/open_channel.rs +++ b/server/src/api/open_channel.rs @@ -2,7 +2,7 @@ use bytes::Bytes; use ldk_node::bitcoin::secp256k1::PublicKey; use ldk_node::lightning::ln::msgs::SocketAddress; use ldk_node::Node; -use protos::{OpenChannelRequest, OpenChannelResponse}; +use protos::api::{OpenChannelRequest, OpenChannelResponse}; use std::str::FromStr; use std::sync::Arc; diff --git a/server/src/api/update_channel_config.rs b/server/src/api/update_channel_config.rs index 1f8cec2..306cdbb 100644 --- a/server/src/api/update_channel_config.rs +++ b/server/src/api/update_channel_config.rs @@ -1,8 +1,8 @@ use ldk_node::bitcoin::secp256k1::PublicKey; use ldk_node::config::{ChannelConfig, MaxDustHTLCExposure}; use ldk_node::{Node, UserChannelId}; -use protos::channel_config::MaxDustHtlcExposure; -use protos::{UpdateChannelConfigRequest, UpdateChannelConfigResponse}; +use protos::api::{UpdateChannelConfigRequest, UpdateChannelConfigResponse}; +use protos::types::channel_config::MaxDustHtlcExposure; use std::str::FromStr; use std::sync::Arc; @@ -38,7 +38,7 @@ pub(crate) fn handle_update_channel_config_request( } fn build_updated_channel_config( - current_config: ChannelConfig, proto_channel_config: protos::ChannelConfig, + current_config: ChannelConfig, proto_channel_config: protos::types::ChannelConfig, ) -> ChannelConfig { let max_dust_htlc_exposure = proto_channel_config .max_dust_htlc_exposure @@ -53,7 +53,8 @@ fn build_updated_channel_config( .unwrap_or(current_config.max_dust_htlc_exposure); let cltv_expiry_delta = proto_channel_config - .cltv_expiry_delta.map(|c| u16::try_from(c).unwrap()) + .cltv_expiry_delta + .map(|c| u16::try_from(c).unwrap()) .unwrap_or(current_config.cltv_expiry_delta); ChannelConfig { diff --git a/server/src/util/proto_adapter.rs b/server/src/util/proto_adapter.rs index 9f9efe7..e785564 100644 --- a/server/src/util/proto_adapter.rs +++ b/server/src/util/proto_adapter.rs @@ -3,10 +3,10 @@ use hex::prelude::*; use ldk_node::config::{ChannelConfig, MaxDustHTLCExposure}; use ldk_node::payment::{PaymentDetails, PaymentDirection, PaymentKind, PaymentStatus}; use ldk_node::ChannelDetails; -use protos::payment_kind::Kind::{ +use protos::types::payment_kind::Kind::{ Bolt11, Bolt11Jit, Bolt12Offer, Bolt12Refund, Onchain, Spontaneous, }; -use protos::{Channel, LspFeeLimits, OutPoint, Payment}; +use protos::types::{Channel, LspFeeLimits, OutPoint, Payment}; pub(crate) fn channel_to_proto(channel: ChannelDetails) -> Channel { Channel { @@ -45,8 +45,10 @@ pub(crate) fn channel_to_proto(channel: ChannelDetails) -> Channel { } } -pub(crate) fn channel_config_to_proto(channel_config: ChannelConfig) -> protos::ChannelConfig { - protos::ChannelConfig { +pub(crate) fn channel_config_to_proto( + channel_config: ChannelConfig, +) -> protos::types::ChannelConfig { + protos::types::ChannelConfig { forwarding_fee_proportional_millionths: Some( channel_config.forwarding_fee_proportional_millionths, ), @@ -58,11 +60,11 @@ pub(crate) fn channel_config_to_proto(channel_config: ChannelConfig) -> protos:: accept_underpaying_htlcs: Some(channel_config.accept_underpaying_htlcs), max_dust_htlc_exposure: match channel_config.max_dust_htlc_exposure { MaxDustHTLCExposure::FixedLimit { limit_msat } => { - Some(protos::channel_config::MaxDustHtlcExposure::FixedLimitMsat(limit_msat)) - }, - MaxDustHTLCExposure::FeeRateMultiplier { multiplier } => { - Some(protos::channel_config::MaxDustHtlcExposure::FeeRateMultiplier(multiplier)) + Some(protos::types::channel_config::MaxDustHtlcExposure::FixedLimitMsat(limit_msat)) }, + MaxDustHTLCExposure::FeeRateMultiplier { multiplier } => Some( + protos::types::channel_config::MaxDustHtlcExposure::FeeRateMultiplier(multiplier), + ), }, } } @@ -73,43 +75,47 @@ pub(crate) fn payment_to_proto(payment: PaymentDetails) -> Payment { kind: Some(payment_kind_to_proto(payment.kind)), amount_msat: payment.amount_msat, direction: match payment.direction { - PaymentDirection::Inbound => protos::PaymentDirection::Inbound.into(), - PaymentDirection::Outbound => protos::PaymentDirection::Outbound.into(), + PaymentDirection::Inbound => protos::types::PaymentDirection::Inbound.into(), + PaymentDirection::Outbound => protos::types::PaymentDirection::Outbound.into(), }, status: match payment.status { - PaymentStatus::Pending => protos::PaymentStatus::Pending.into(), - PaymentStatus::Succeeded => protos::PaymentStatus::Succeeded.into(), - PaymentStatus::Failed => protos::PaymentStatus::Failed.into(), + PaymentStatus::Pending => protos::types::PaymentStatus::Pending.into(), + PaymentStatus::Succeeded => protos::types::PaymentStatus::Succeeded.into(), + PaymentStatus::Failed => protos::types::PaymentStatus::Failed.into(), }, latest_update_timestamp: payment.latest_update_timestamp, } } -pub(crate) fn payment_kind_to_proto(payment_kind: PaymentKind) -> protos::PaymentKind { +pub(crate) fn payment_kind_to_proto(payment_kind: PaymentKind) -> protos::types::PaymentKind { match payment_kind { - PaymentKind::Onchain => protos::PaymentKind { kind: Some(Onchain(protos::Onchain {})) }, - PaymentKind::Bolt11 { hash, preimage, secret } => protos::PaymentKind { - kind: Some(Bolt11(protos::Bolt11 { - hash: hash.to_string(), - preimage: preimage.map(|p| p.to_string()), - secret: secret.map(|s| Bytes::copy_from_slice(&s.0)), - })), + PaymentKind::Onchain => { + protos::types::PaymentKind { kind: Some(Onchain(protos::types::Onchain {})) } }, - PaymentKind::Bolt11Jit { hash, preimage, secret, lsp_fee_limits } => protos::PaymentKind { - kind: Some(Bolt11Jit(protos::Bolt11Jit { + PaymentKind::Bolt11 { hash, preimage, secret } => protos::types::PaymentKind { + kind: Some(Bolt11(protos::types::Bolt11 { hash: hash.to_string(), preimage: preimage.map(|p| p.to_string()), secret: secret.map(|s| Bytes::copy_from_slice(&s.0)), - lsp_fee_limits: Some(LspFeeLimits { - max_total_opening_fee_msat: lsp_fee_limits.max_total_opening_fee_msat, - max_proportional_opening_fee_ppm_msat: lsp_fee_limits - .max_proportional_opening_fee_ppm_msat, - }), })), }, + PaymentKind::Bolt11Jit { hash, preimage, secret, lsp_fee_limits } => { + protos::types::PaymentKind { + kind: Some(Bolt11Jit(protos::types::Bolt11Jit { + hash: hash.to_string(), + preimage: preimage.map(|p| p.to_string()), + secret: secret.map(|s| Bytes::copy_from_slice(&s.0)), + lsp_fee_limits: Some(LspFeeLimits { + max_total_opening_fee_msat: lsp_fee_limits.max_total_opening_fee_msat, + max_proportional_opening_fee_ppm_msat: lsp_fee_limits + .max_proportional_opening_fee_ppm_msat, + }), + })), + } + }, PaymentKind::Bolt12Offer { hash, preimage, secret, offer_id, payer_note, quantity } => { - protos::PaymentKind { - kind: Some(Bolt12Offer(protos::Bolt12Offer { + protos::types::PaymentKind { + kind: Some(Bolt12Offer(protos::types::Bolt12Offer { hash: hash.map(|h| h.to_string()), preimage: preimage.map(|p| p.to_string()), secret: secret.map(|s| Bytes::copy_from_slice(&s.0)), @@ -120,8 +126,8 @@ pub(crate) fn payment_kind_to_proto(payment_kind: PaymentKind) -> protos::Paymen } }, PaymentKind::Bolt12Refund { hash, preimage, secret, payer_note, quantity } => { - protos::PaymentKind { - kind: Some(Bolt12Refund(protos::Bolt12Refund { + protos::types::PaymentKind { + kind: Some(Bolt12Refund(protos::types::Bolt12Refund { hash: hash.map(|h| h.to_string()), preimage: preimage.map(|p| p.to_string()), secret: secret.map(|s| Bytes::copy_from_slice(&s.0)), @@ -130,8 +136,8 @@ pub(crate) fn payment_kind_to_proto(payment_kind: PaymentKind) -> protos::Paymen })), } }, - PaymentKind::Spontaneous { hash, preimage } => protos::PaymentKind { - kind: Some(Spontaneous(protos::Spontaneous { + PaymentKind::Spontaneous { hash, preimage } => protos::types::PaymentKind { + kind: Some(Spontaneous(protos::types::Spontaneous { hash: hash.to_string(), preimage: preimage.map(|p| p.to_string()), })),