diff --git a/Cargo.toml b/Cargo.toml index beb6d12..6b4e807 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,5 +5,5 @@ resolver = "2" members = [ "lightspark", "lightspark-remote-signing", - "examples/*", + "examples/lightspark-remote-signing-server", ] \ No newline at end of file diff --git a/lightspark/CHANGELOG.md b/lightspark/CHANGELOG.md index cad455b..e550764 100644 --- a/lightspark/CHANGELOG.md +++ b/lightspark/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +# v0.9.0 +- Update API objects. + # v0.8.1 - Remove openssl dependency from reqwest. diff --git a/lightspark/Cargo.toml b/lightspark/Cargo.toml index a443a17..0f986a6 100644 --- a/lightspark/Cargo.toml +++ b/lightspark/Cargo.toml @@ -2,7 +2,7 @@ name = "lightspark" description = "Lightspark Rust SDK" authors = ["Lightspark Group, Inc. "] -version = "0.8.2" +version = "0.9.0" edition = "2021" documentation = "https://docs.lightspark.com/lightspark-sdk/getting-started?language=Rust" homepage = "https://www.lightspark.com/" diff --git a/lightspark/README.md b/lightspark/README.md index 709ad89..5e30b38 100644 --- a/lightspark/README.md +++ b/lightspark/README.md @@ -1,8 +1,8 @@ -# Lightspark Rust SDK - v0.8.2 +# Lightspark Rust SDK - v0.9.0 The Lightspark Rust SDK provides a convenient way to interact with the Lightspark services from applications written in the Rust language. -***WARNING: This SDK is in version 0.8.1 (active development). It means that its APIs may not be fully stable. Please expect that changes to the APIs may happen until we move to v1.0.0.*** +***WARNING: This SDK is in version 0.9.0 (active development). It means that its APIs may not be fully stable. Please expect that changes to the APIs may happen until we move to v1.0.0.*** ## Documentation diff --git a/lightspark/examples/example.rs b/lightspark/examples/example.rs index 5548efc..cf4acb7 100644 --- a/lightspark/examples/example.rs +++ b/lightspark/examples/example.rs @@ -557,7 +557,7 @@ async fn main() { } }; if let Ok(channels_connection) = node - .get_channels(&client.requester, Some(10), None, None) + .get_channels(&client.requester, Some(10), None, None, None, None) .await { println!( diff --git a/lightspark/examples/two_node_example.rs b/lightspark/examples/two_node_example.rs index 8add817..4ecb7ad 100644 --- a/lightspark/examples/two_node_example.rs +++ b/lightspark/examples/two_node_example.rs @@ -527,7 +527,7 @@ async fn main() { } }; if let Ok(channels_connection) = node - .get_channels(&client.requester, Some(10), None, None) + .get_channels(&client.requester, Some(10), None, None, None, None) .await { println!("{} has {} channel(s):", node_1, channels_connection.count); diff --git a/lightspark/src/objects/account.rs b/lightspark/src/objects/account.rs index cffafb5..2231196 100644 --- a/lightspark/src/objects/account.rs +++ b/lightspark/src/objects/account.rs @@ -132,6 +132,7 @@ impl Account { api_token_client_id: client_id api_token_name: name api_token_permissions: permissions + api_token_is_deleted: is_deleted } } } @@ -958,6 +959,7 @@ impl Account { currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } incoming_payment_transaction_hash: transaction_hash + incoming_payment_is_uma: is_uma incoming_payment_destination: destination { id } @@ -976,6 +978,7 @@ impl Account { currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } } + incoming_payment_is_internal_payment: is_internal_payment } ... on OutgoingPayment { __typename @@ -993,6 +996,7 @@ impl Account { currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } outgoing_payment_transaction_hash: transaction_hash + outgoing_payment_is_uma: is_uma outgoing_payment_origin: origin { id } @@ -1319,6 +1323,8 @@ impl Account { } } outgoing_payment_payment_preimage: payment_preimage + outgoing_payment_is_internal_payment: is_internal_payment + outgoing_payment_idempotency_key: idempotency_key } ... on RoutingTransaction { __typename @@ -1777,13 +1783,14 @@ impl Account { bitcoin_networks: Option>, statuses: Option>, node_ids: Option>, + idempotency_keys: Option>, after_date: Option>, before_date: Option>, ) -> Result { - let query = "query FetchAccountToWithdrawalRequestsConnection($entity_id: ID!, $first: Int, $after: String, $bitcoin_networks: [BitcoinNetwork!], $statuses: [WithdrawalRequestStatus!], $node_ids: [ID!], $after_date: DateTime, $before_date: DateTime) { + let query = "query FetchAccountToWithdrawalRequestsConnection($entity_id: ID!, $first: Int, $after: String, $bitcoin_networks: [BitcoinNetwork!], $statuses: [WithdrawalRequestStatus!], $node_ids: [ID!], $idempotency_keys: [String!], $after_date: DateTime, $before_date: DateTime) { entity(id: $entity_id) { ... on Account { - withdrawal_requests(, first: $first, after: $after, bitcoin_networks: $bitcoin_networks, statuses: $statuses, node_ids: $node_ids, after_date: $after_date, before_date: $before_date) { + withdrawal_requests(, first: $first, after: $after, bitcoin_networks: $bitcoin_networks, statuses: $statuses, node_ids: $node_ids, idempotency_keys: $idempotency_keys, after_date: $after_date, before_date: $before_date) { __typename account_to_withdrawal_requests_connection_count: count account_to_withdrawal_requests_connection_page_info: page_info { @@ -1830,6 +1837,14 @@ impl Account { currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } + withdrawal_request_total_fees: total_fees { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } withdrawal_request_bitcoin_address: bitcoin_address withdrawal_request_withdrawal_mode: withdrawal_mode withdrawal_request_status: status @@ -1837,6 +1852,7 @@ impl Account { withdrawal_request_withdrawal: withdrawal { id } + withdrawal_request_idempotency_key: idempotency_key } } } @@ -1849,6 +1865,7 @@ impl Account { variables.insert("bitcoin_networks", bitcoin_networks.into()); variables.insert("statuses", statuses.into()); variables.insert("node_ids", node_ids.into()); + variables.insert("idempotency_keys", idempotency_keys.into()); variables.insert("after_date", after_date.map(|dt| dt.to_rfc3339()).into()); variables.insert("before_date", before_date.map(|dt| dt.to_rfc3339()).into()); diff --git a/lightspark/src/objects/account_to_nodes_connection.rs b/lightspark/src/objects/account_to_nodes_connection.rs index f627e8a..f973d30 100644 --- a/lightspark/src/objects/account_to_nodes_connection.rs +++ b/lightspark/src/objects/account_to_nodes_connection.rs @@ -3,6 +3,7 @@ use crate::objects::connection::Connection; use crate::objects::lightspark_node::LightsparkNodeEnum; use crate::objects::page_info::PageInfo; use serde::{Deserialize, Serialize}; + use std::vec::Vec; /// A connection between an account and the nodes it manages. diff --git a/lightspark/src/objects/account_to_payment_requests_connection.rs b/lightspark/src/objects/account_to_payment_requests_connection.rs index 44a9c22..0e6dad2 100644 --- a/lightspark/src/objects/account_to_payment_requests_connection.rs +++ b/lightspark/src/objects/account_to_payment_requests_connection.rs @@ -1,10 +1,10 @@ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::objects::payment_request::PaymentRequestEnum; use serde::{Deserialize, Serialize}; -use std::vec::Vec; use crate::objects::connection::Connection; use crate::objects::page_info::PageInfo; -use crate::objects::payment_request::PaymentRequestEnum; +use std::vec::Vec; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct AccountToPaymentRequestsConnection { diff --git a/lightspark/src/objects/account_to_transactions_connection.rs b/lightspark/src/objects/account_to_transactions_connection.rs index 2fa1974..4adcfb4 100644 --- a/lightspark/src/objects/account_to_transactions_connection.rs +++ b/lightspark/src/objects/account_to_transactions_connection.rs @@ -1,11 +1,11 @@ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use crate::objects::transaction::TransactionEnum; use serde::{Deserialize, Serialize}; -use std::vec::Vec; use crate::objects::connection::Connection; use crate::objects::currency_amount::CurrencyAmount; use crate::objects::page_info::PageInfo; +use crate::objects::transaction::TransactionEnum; +use std::vec::Vec; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct AccountToTransactionsConnection { diff --git a/lightspark/src/objects/api_token.rs b/lightspark/src/objects/api_token.rs index e8b35a4..0439ebc 100644 --- a/lightspark/src/objects/api_token.rs +++ b/lightspark/src/objects/api_token.rs @@ -1,4 +1,5 @@ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::objects::audit_log_actor::AuditLogActor; use crate::objects::entity::Entity; use crate::objects::permission::Permission; use crate::types::custom_date_formats::custom_date_format; @@ -34,11 +35,21 @@ pub struct ApiToken { #[serde(rename = "api_token_permissions")] pub permissions: Vec, + /// Whether the api token has been deleted. + #[serde(rename = "api_token_is_deleted")] + pub is_deleted: bool, + /// The typename of the object #[serde(rename = "__typename")] pub typename: String, } +impl AuditLogActor for ApiToken { + fn type_name(&self) -> &'static str { + "ApiToken" + } +} + impl Entity for ApiToken { /// The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string. fn get_id(&self) -> String { @@ -87,5 +98,6 @@ fragment ApiTokenFragment on ApiToken { api_token_client_id: client_id api_token_name: name api_token_permissions: permissions + api_token_is_deleted: is_deleted } "; diff --git a/lightspark/src/objects/audit_log_actor.rs b/lightspark/src/objects/audit_log_actor.rs new file mode 100644 index 0000000..7379df1 --- /dev/null +++ b/lightspark/src/objects/audit_log_actor.rs @@ -0,0 +1,40 @@ +// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use super::api_token::ApiToken; +use crate::objects::entity::Entity; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_json::Value; + +pub trait AuditLogActor: Entity { + fn type_name(&self) -> &'static str; +} + +#[allow(clippy::large_enum_variant)] +#[derive(Debug, Clone, Serialize)] +pub enum AuditLogActorEnum { + ApiToken(ApiToken), +} + +impl<'de> Deserialize<'de> for AuditLogActorEnum { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let value = Value::deserialize(deserializer)?; + if let Some(typename) = value.get("__typename").and_then(Value::as_str) { + match typename { + "ApiToken" => { + let obj = ApiToken::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; + Ok(AuditLogActorEnum::ApiToken(obj)) + } + + _ => Err(serde::de::Error::custom("unknown typename")), + } + } else { + Err(serde::de::Error::custom( + "missing __typename field on AuditLogActor", + )) + } + } +} diff --git a/lightspark/src/objects/cancel_invoice_input.rs b/lightspark/src/objects/cancel_invoice_input.rs index 35c33be..1cf4f24 100644 --- a/lightspark/src/objects/cancel_invoice_input.rs +++ b/lightspark/src/objects/cancel_invoice_input.rs @@ -1,6 +1,7 @@ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; +/// The unique identifier of the Invoice that should be cancelled. The invoice is supposed to be open, not settled and not expired. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct CancelInvoiceInput { pub invoice_id: String, diff --git a/lightspark/src/objects/cancel_invoice_output.rs b/lightspark/src/objects/cancel_invoice_output.rs index e72c10c..ddcf827 100644 --- a/lightspark/src/objects/cancel_invoice_output.rs +++ b/lightspark/src/objects/cancel_invoice_output.rs @@ -2,6 +2,7 @@ use crate::types::entity_wrapper::EntityWrapper; use serde::{Deserialize, Serialize}; +/// The Invoice that was cancelled. If the invoice was already cancelled, the same invoice is returned. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct CancelInvoiceOutput { #[serde(rename = "cancel_invoice_output_invoice")] diff --git a/lightspark/src/objects/channel_closing_transaction.rs b/lightspark/src/objects/channel_closing_transaction.rs index efae612..de3a582 100644 --- a/lightspark/src/objects/channel_closing_transaction.rs +++ b/lightspark/src/objects/channel_closing_transaction.rs @@ -52,7 +52,7 @@ pub struct ChannelClosingTransaction { #[serde(rename = "channel_closing_transaction_transaction_hash")] pub transaction_hash: Option, - /// The fees that were paid by the wallet sending the transaction to commit it to the Bitcoin blockchain. + /// The fees that were paid by the node for this transaction. #[serde(rename = "channel_closing_transaction_fees")] pub fees: Option, @@ -82,7 +82,7 @@ pub struct ChannelClosingTransaction { } impl OnChainTransaction for ChannelClosingTransaction { - /// The fees that were paid by the wallet sending the transaction to commit it to the Bitcoin blockchain. + /// The fees that were paid by the node for this transaction. fn get_fees(&self) -> Option { self.fees.clone() } diff --git a/lightspark/src/objects/channel_opening_transaction.rs b/lightspark/src/objects/channel_opening_transaction.rs index d82f2b5..70215e4 100644 --- a/lightspark/src/objects/channel_opening_transaction.rs +++ b/lightspark/src/objects/channel_opening_transaction.rs @@ -52,7 +52,7 @@ pub struct ChannelOpeningTransaction { #[serde(rename = "channel_opening_transaction_transaction_hash")] pub transaction_hash: Option, - /// The fees that were paid by the wallet sending the transaction to commit it to the Bitcoin blockchain. + /// The fees that were paid by the node for this transaction. #[serde(rename = "channel_opening_transaction_fees")] pub fees: Option, @@ -82,7 +82,7 @@ pub struct ChannelOpeningTransaction { } impl OnChainTransaction for ChannelOpeningTransaction { - /// The fees that were paid by the wallet sending the transaction to commit it to the Bitcoin blockchain. + /// The fees that were paid by the node for this transaction. fn get_fees(&self) -> Option { self.fees.clone() } diff --git a/lightspark/src/objects/channel_snapshot.rs b/lightspark/src/objects/channel_snapshot.rs index f00c2df..dbbff21 100644 --- a/lightspark/src/objects/channel_snapshot.rs +++ b/lightspark/src/objects/channel_snapshot.rs @@ -1,17 +1,25 @@ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use crate::objects::currency_amount::CurrencyAmount; +use crate::objects::entity::Entity; use crate::types::custom_date_formats::custom_date_format; use crate::types::entity_wrapper::EntityWrapper; +use crate::types::get_entity::GetEntity; use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct ChannelSnapshot { - #[serde(rename = "channel_snapshot_channel")] - pub channel: EntityWrapper, + /// The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string. + #[serde(rename = "channel_snapshot_id")] + pub id: String, - #[serde(with = "custom_date_format", rename = "channel_snapshot_timestamp")] - pub timestamp: DateTime, + /// The date and time when the entity was first created. + #[serde(with = "custom_date_format", rename = "channel_snapshot_created_at")] + pub created_at: DateTime, + + /// The date and time when the entity was last updated. + #[serde(with = "custom_date_format", rename = "channel_snapshot_updated_at")] + pub updated_at: DateTime, #[serde(rename = "channel_snapshot_local_balance")] pub local_balance: Option, @@ -19,23 +27,75 @@ pub struct ChannelSnapshot { #[serde(rename = "channel_snapshot_local_unsettled_balance")] pub local_unsettled_balance: Option, - #[serde(rename = "channel_snapshot_local_channel_reserve")] - pub local_channel_reserve: Option, - #[serde(rename = "channel_snapshot_remote_balance")] pub remote_balance: Option, #[serde(rename = "channel_snapshot_remote_unsettled_balance")] pub remote_unsettled_balance: Option, + + #[serde(rename = "channel_snapshot_status")] + pub status: Option, + + #[serde(rename = "channel_snapshot_channel")] + pub channel: EntityWrapper, + + #[serde(rename = "channel_snapshot_local_channel_reserve")] + pub local_channel_reserve: Option, + + /// The timestamp that was used to query the snapshot of the channel + #[serde(with = "custom_date_format", rename = "channel_snapshot_timestamp")] + pub timestamp: DateTime, + + /// The typename of the object + #[serde(rename = "__typename")] + pub typename: String, +} + +impl Entity for ChannelSnapshot { + /// The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string. + fn get_id(&self) -> String { + self.id.clone() + } + + /// The date and time when the entity was first created. + fn get_created_at(&self) -> DateTime { + self.created_at + } + + /// The date and time when the entity was last updated. + fn get_updated_at(&self) -> DateTime { + self.updated_at + } + + fn type_name(&self) -> &'static str { + "ChannelSnapshot" + } +} + +impl GetEntity for ChannelSnapshot { + fn get_entity_query() -> String { + format!( + " + query GetEntity($id: ID!) {{ + entity(id: $id) {{ + ... on ChannelSnapshot {{ + ... ChannelSnapshotFragment + }} + }} + }} + + {}", + FRAGMENT + ) + } } pub const FRAGMENT: &str = " fragment ChannelSnapshotFragment on ChannelSnapshot { __typename - channel_snapshot_channel: channel { - id - } - channel_snapshot_timestamp: timestamp + channel_snapshot_id: id + channel_snapshot_created_at: created_at + channel_snapshot_updated_at: updated_at channel_snapshot_local_balance: local_balance { __typename currency_amount_original_value: original_value @@ -52,7 +112,7 @@ fragment ChannelSnapshotFragment on ChannelSnapshot { currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } - channel_snapshot_local_channel_reserve: local_channel_reserve { + channel_snapshot_remote_balance: remote_balance { __typename currency_amount_original_value: original_value currency_amount_original_unit: original_unit @@ -60,7 +120,7 @@ fragment ChannelSnapshotFragment on ChannelSnapshot { currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } - channel_snapshot_remote_balance: remote_balance { + channel_snapshot_remote_unsettled_balance: remote_unsettled_balance { __typename currency_amount_original_value: original_value currency_amount_original_unit: original_unit @@ -68,7 +128,11 @@ fragment ChannelSnapshotFragment on ChannelSnapshot { currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } - channel_snapshot_remote_unsettled_balance: remote_unsettled_balance { + channel_snapshot_status: status + channel_snapshot_channel: channel { + id + } + channel_snapshot_local_channel_reserve: local_channel_reserve { __typename currency_amount_original_value: original_value currency_amount_original_unit: original_unit @@ -76,5 +140,6 @@ fragment ChannelSnapshotFragment on ChannelSnapshot { currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } + channel_snapshot_timestamp: timestamp } "; diff --git a/lightspark/src/objects/claim_uma_invitation_input.rs b/lightspark/src/objects/claim_uma_invitation_input.rs index 17b133c..160b71a 100644 --- a/lightspark/src/objects/claim_uma_invitation_input.rs +++ b/lightspark/src/objects/claim_uma_invitation_input.rs @@ -3,7 +3,9 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct ClaimUmaInvitationInput { + /// The unique code that identifies this invitation and was shared by the inviter. pub invitation_code: String, + /// The UMA of the user claiming the invitation. It will be sent to the inviter so that they can start transacting with the invitee. pub invitee_uma: String, } diff --git a/lightspark/src/objects/claim_uma_invitation_output.rs b/lightspark/src/objects/claim_uma_invitation_output.rs index 6253ba8..2fc5f5a 100644 --- a/lightspark/src/objects/claim_uma_invitation_output.rs +++ b/lightspark/src/objects/claim_uma_invitation_output.rs @@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct ClaimUmaInvitationOutput { + /// An UMA.ME invitation object. #[serde(rename = "claim_uma_invitation_output_invitation")] pub invitation: EntityWrapper, } diff --git a/lightspark/src/objects/claim_uma_invitation_with_incentives_input.rs b/lightspark/src/objects/claim_uma_invitation_with_incentives_input.rs index 420fdef..0971e8e 100644 --- a/lightspark/src/objects/claim_uma_invitation_with_incentives_input.rs +++ b/lightspark/src/objects/claim_uma_invitation_with_incentives_input.rs @@ -4,11 +4,15 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct ClaimUmaInvitationWithIncentivesInput { + /// The unique code that identifies this invitation and was shared by the inviter. pub invitation_code: String, + /// The UMA of the user claiming the invitation. It will be sent to the inviter so that they can start transacting with the invitee. pub invitee_uma: String, + /// The phone hash of the user getting the invitation. pub invitee_phone_hash: String, + /// The region of the user getting the invitation. pub invitee_region: RegionCode, } diff --git a/lightspark/src/objects/claim_uma_invitation_with_incentives_output.rs b/lightspark/src/objects/claim_uma_invitation_with_incentives_output.rs index 7da6e76..6a058e2 100644 --- a/lightspark/src/objects/claim_uma_invitation_with_incentives_output.rs +++ b/lightspark/src/objects/claim_uma_invitation_with_incentives_output.rs @@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct ClaimUmaInvitationWithIncentivesOutput { + /// An UMA.ME invitation object. #[serde(rename = "claim_uma_invitation_with_incentives_output_invitation")] pub invitation: EntityWrapper, } diff --git a/lightspark/src/objects/connection.rs b/lightspark/src/objects/connection.rs index 41d57c7..668be65 100644 --- a/lightspark/src/objects/connection.rs +++ b/lightspark/src/objects/connection.rs @@ -14,6 +14,8 @@ use super::outgoing_payment_to_attempts_connection::OutgoingPaymentToAttemptsCon use super::wallet_to_payment_requests_connection::WalletToPaymentRequestsConnection; use super::wallet_to_transactions_connection::WalletToTransactionsConnection; use super::wallet_to_withdrawal_requests_connection::WalletToWithdrawalRequestsConnection; +use super::withdrawal_request_to_channel_closing_transactions_connection::WithdrawalRequestToChannelClosingTransactionsConnection; +use super::withdrawal_request_to_channel_opening_transactions_connection::WithdrawalRequestToChannelOpeningTransactionsConnection; use crate::objects::page_info::PageInfo; use serde::{Deserialize, Deserializer, Serialize}; use serde_json::Value; @@ -45,6 +47,12 @@ pub enum ConnectionEnum { WalletToPaymentRequestsConnection(WalletToPaymentRequestsConnection), WalletToTransactionsConnection(WalletToTransactionsConnection), WalletToWithdrawalRequestsConnection(WalletToWithdrawalRequestsConnection), + WithdrawalRequestToChannelClosingTransactionsConnection( + WithdrawalRequestToChannelClosingTransactionsConnection, + ), + WithdrawalRequestToChannelOpeningTransactionsConnection( + WithdrawalRequestToChannelOpeningTransactionsConnection, + ), } impl<'de> Deserialize<'de> for ConnectionEnum { @@ -146,6 +154,30 @@ impl<'de> Deserialize<'de> for ConnectionEnum { )?; Ok(ConnectionEnum::WalletToWithdrawalRequestsConnection(obj)) } + "WithdrawalRequestToChannelClosingTransactionsConnection" => { + let obj = + WithdrawalRequestToChannelClosingTransactionsConnection::deserialize(value) + .map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; + Ok( + ConnectionEnum::WithdrawalRequestToChannelClosingTransactionsConnection( + obj, + ), + ) + } + "WithdrawalRequestToChannelOpeningTransactionsConnection" => { + let obj = + WithdrawalRequestToChannelOpeningTransactionsConnection::deserialize(value) + .map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; + Ok( + ConnectionEnum::WithdrawalRequestToChannelOpeningTransactionsConnection( + obj, + ), + ) + } _ => Err(serde::de::Error::custom("unknown typename")), } diff --git a/lightspark/src/objects/create_api_token_output.rs b/lightspark/src/objects/create_api_token_output.rs index 841c9ed..2cbf1df 100644 --- a/lightspark/src/objects/create_api_token_output.rs +++ b/lightspark/src/objects/create_api_token_output.rs @@ -25,6 +25,7 @@ fragment CreateApiTokenOutputFragment on CreateApiTokenOutput { api_token_client_id: client_id api_token_name: name api_token_permissions: permissions + api_token_is_deleted: is_deleted } create_api_token_output_client_secret: client_secret } diff --git a/lightspark/src/objects/create_invitation_with_incentives_input.rs b/lightspark/src/objects/create_invitation_with_incentives_input.rs index 5007a15..f6d6bd9 100644 --- a/lightspark/src/objects/create_invitation_with_incentives_input.rs +++ b/lightspark/src/objects/create_invitation_with_incentives_input.rs @@ -4,9 +4,12 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct CreateInvitationWithIncentivesInput { + /// The UMA of the user creating the invitation. It will be used to identify the inviter when receiving the invitation. pub inviter_uma: String, + /// The phone hash of the user creating the invitation. pub inviter_phone_hash: String, + /// The region of the user creating the invitation. pub inviter_region: RegionCode, } diff --git a/lightspark/src/objects/create_invitation_with_incentives_output.rs b/lightspark/src/objects/create_invitation_with_incentives_output.rs index c073e8e..d136323 100644 --- a/lightspark/src/objects/create_invitation_with_incentives_output.rs +++ b/lightspark/src/objects/create_invitation_with_incentives_output.rs @@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct CreateInvitationWithIncentivesOutput { + /// The created invitation in the form of a string identifier. #[serde(rename = "create_invitation_with_incentives_output_invitation")] pub invitation: EntityWrapper, } diff --git a/lightspark/src/objects/create_invoice_input.rs b/lightspark/src/objects/create_invoice_input.rs index 2af3b2f..7287726 100644 --- a/lightspark/src/objects/create_invoice_input.rs +++ b/lightspark/src/objects/create_invoice_input.rs @@ -7,7 +7,7 @@ pub struct CreateInvoiceInput { /// The node from which to create the invoice. pub node_id: String, - /// The amount for which the invoice should be created, in millisatoshis. + /// The amount for which the invoice should be created, in millisatoshis. Setting the amount to 0 will allow the payer to specify an amount. pub amount_msats: i64, pub memo: Option, diff --git a/lightspark/src/objects/create_node_wallet_address_output.rs b/lightspark/src/objects/create_node_wallet_address_output.rs index 5e8cfe9..a943dd4 100644 --- a/lightspark/src/objects/create_node_wallet_address_output.rs +++ b/lightspark/src/objects/create_node_wallet_address_output.rs @@ -1,4 +1,5 @@ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::objects::multi_sig_address_validation_parameters::MultiSigAddressValidationParameters; use crate::types::entity_wrapper::EntityWrapper; use serde::{Deserialize, Serialize}; @@ -9,6 +10,12 @@ pub struct CreateNodeWalletAddressOutput { #[serde(rename = "create_node_wallet_address_output_wallet_address")] pub wallet_address: String, + + /// Vaildation parameters for the 2-of-2 multisig address. None if the address is not a 2-of-2 multisig address. + #[serde( + rename = "create_node_wallet_address_output_multisig_wallet_address_validation_parameters" + )] + pub multisig_wallet_address_validation_parameters: Option, } pub const FRAGMENT: &str = " @@ -18,5 +25,10 @@ fragment CreateNodeWalletAddressOutputFragment on CreateNodeWalletAddressOutput id } create_node_wallet_address_output_wallet_address: wallet_address + create_node_wallet_address_output_multisig_wallet_address_validation_parameters: multisig_wallet_address_validation_parameters { + __typename + multi_sig_address_validation_parameters_counterparty_funding_pubkey: counterparty_funding_pubkey + multi_sig_address_validation_parameters_funding_pubkey_derivation_path: funding_pubkey_derivation_path + } } "; diff --git a/lightspark/src/objects/create_uma_invitation_input.rs b/lightspark/src/objects/create_uma_invitation_input.rs index 304216f..52b3041 100644 --- a/lightspark/src/objects/create_uma_invitation_input.rs +++ b/lightspark/src/objects/create_uma_invitation_input.rs @@ -3,5 +3,6 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct CreateUmaInvitationInput { + /// The UMA of the user creating the invitation. It will be used to identify the inviter when receiving the invitation. pub inviter_uma: String, } diff --git a/lightspark/src/objects/create_uma_invitation_output.rs b/lightspark/src/objects/create_uma_invitation_output.rs index 392e8be..cbdc14f 100644 --- a/lightspark/src/objects/create_uma_invitation_output.rs +++ b/lightspark/src/objects/create_uma_invitation_output.rs @@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct CreateUmaInvitationOutput { + /// The created invitation in the form of a string identifier. #[serde(rename = "create_uma_invitation_output_invitation")] pub invitation: EntityWrapper, } diff --git a/lightspark/src/objects/deposit.rs b/lightspark/src/objects/deposit.rs index f1e9f3e..b295be9 100644 --- a/lightspark/src/objects/deposit.rs +++ b/lightspark/src/objects/deposit.rs @@ -43,7 +43,7 @@ pub struct Deposit { #[serde(rename = "deposit_transaction_hash")] pub transaction_hash: Option, - /// The fees that were paid by the wallet sending the transaction to commit it to the Bitcoin blockchain. + /// The fees that were paid by the node for this transaction. #[serde(rename = "deposit_fees")] pub fees: Option, @@ -73,7 +73,7 @@ pub struct Deposit { } impl OnChainTransaction for Deposit { - /// The fees that were paid by the wallet sending the transaction to commit it to the Bitcoin blockchain. + /// The fees that were paid by the node for this transaction. fn get_fees(&self) -> Option { self.fees.clone() } diff --git a/lightspark/src/objects/entity.rs b/lightspark/src/objects/entity.rs index 4bd9bf1..b00c3ef 100644 --- a/lightspark/src/objects/entity.rs +++ b/lightspark/src/objects/entity.rs @@ -5,6 +5,7 @@ use super::api_token::ApiToken; use super::channel::Channel; use super::channel_closing_transaction::ChannelClosingTransaction; use super::channel_opening_transaction::ChannelOpeningTransaction; +use super::channel_snapshot::ChannelSnapshot; use super::deposit::Deposit; use super::graph_node::GraphNode; use super::hop::Hop; @@ -47,6 +48,7 @@ pub enum EntityEnum { Channel(Channel), ChannelClosingTransaction(ChannelClosingTransaction), ChannelOpeningTransaction(ChannelOpeningTransaction), + ChannelSnapshot(ChannelSnapshot), Deposit(Deposit), GraphNode(GraphNode), Hop(Hop), @@ -104,6 +106,12 @@ impl<'de> Deserialize<'de> for EntityEnum { })?; Ok(EntityEnum::ChannelOpeningTransaction(obj)) } + "ChannelSnapshot" => { + let obj = ChannelSnapshot::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; + Ok(EntityEnum::ChannelSnapshot(obj)) + } "Deposit" => { let obj = Deposit::deserialize(value).map_err(|err| { serde::de::Error::custom(format!("Serde JSON Error {}", err)) diff --git a/lightspark/src/objects/fail_htlcs_input.rs b/lightspark/src/objects/fail_htlcs_input.rs new file mode 100644 index 0000000..5a05798 --- /dev/null +++ b/lightspark/src/objects/fail_htlcs_input.rs @@ -0,0 +1,11 @@ +// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct FailHtlcsInput { + /// The id of invoice which the pending HTLCs that need to be failed are paying for. + pub invoice_id: String, + + /// Whether the invoice needs to be canceled after failing the htlcs. If yes, the invoice cannot be paid anymore. + pub cancel_invoice: bool, +} diff --git a/lightspark/src/objects/fail_htlcs_output.rs b/lightspark/src/objects/fail_htlcs_output.rs new file mode 100644 index 0000000..66c79fb --- /dev/null +++ b/lightspark/src/objects/fail_htlcs_output.rs @@ -0,0 +1,18 @@ +// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::types::entity_wrapper::EntityWrapper; +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct FailHtlcsOutput { + #[serde(rename = "fail_htlcs_output_invoice")] + pub invoice: EntityWrapper, +} + +pub const FRAGMENT: &str = " +fragment FailHtlcsOutputFragment on FailHtlcsOutput { + __typename + fail_htlcs_output_invoice: invoice { + id + } +} +"; diff --git a/lightspark/src/objects/incoming_payment.rs b/lightspark/src/objects/incoming_payment.rs index 7bd65d8..df01baf 100644 --- a/lightspark/src/objects/incoming_payment.rs +++ b/lightspark/src/objects/incoming_payment.rs @@ -53,6 +53,10 @@ pub struct IncomingPayment { #[serde(rename = "incoming_payment_transaction_hash")] pub transaction_hash: Option, + /// Whether this payment is an UMA payment or not. NOTE: this field is only set if the invoice that is being paid has been created using the recommended `create_uma_invoice` function. + #[serde(rename = "incoming_payment_is_uma")] + pub is_uma: bool, + /// The recipient Lightspark node this payment was sent to. #[serde(rename = "incoming_payment_destination")] pub destination: EntityWrapper, @@ -65,6 +69,10 @@ pub struct IncomingPayment { #[serde(rename = "incoming_payment_uma_post_transaction_data")] pub uma_post_transaction_data: Option>, + /// Whether the payment is made from the same node. + #[serde(rename = "incoming_payment_is_internal_payment")] + pub is_internal_payment: bool, + /// The typename of the object #[serde(rename = "__typename")] pub typename: String, @@ -158,6 +166,7 @@ fragment IncomingPaymentFragment on IncomingPayment { currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } incoming_payment_transaction_hash: transaction_hash + incoming_payment_is_uma: is_uma incoming_payment_destination: destination { id } @@ -176,6 +185,7 @@ fragment IncomingPaymentFragment on IncomingPayment { currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } } + incoming_payment_is_internal_payment: is_internal_payment } "; diff --git a/lightspark/src/objects/incoming_payments_for_invoice_query_input.rs b/lightspark/src/objects/incoming_payments_for_invoice_query_input.rs new file mode 100644 index 0000000..ded744d --- /dev/null +++ b/lightspark/src/objects/incoming_payments_for_invoice_query_input.rs @@ -0,0 +1,12 @@ +// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::objects::transaction_status::TransactionStatus; +use serde::{Deserialize, Serialize}; +use std::vec::Vec; + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct IncomingPaymentsForInvoiceQueryInput { + pub invoice_id: String, + + /// An optional filter to only query outgoing payments of given statuses. + pub statuses: Option>, +} diff --git a/lightspark/src/objects/incoming_payments_for_invoice_query_output.rs b/lightspark/src/objects/incoming_payments_for_invoice_query_output.rs new file mode 100644 index 0000000..0573e5c --- /dev/null +++ b/lightspark/src/objects/incoming_payments_for_invoice_query_output.rs @@ -0,0 +1,53 @@ +// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::objects::incoming_payment::IncomingPayment; +use serde::{Deserialize, Serialize}; +use std::vec::Vec; + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct IncomingPaymentsForInvoiceQueryOutput { + #[serde(rename = "incoming_payments_for_invoice_query_output_payments")] + pub payments: Vec, +} + +pub const FRAGMENT: &str = " +fragment IncomingPaymentsForInvoiceQueryOutputFragment on IncomingPaymentsForInvoiceQueryOutput { + __typename + incoming_payments_for_invoice_query_output_payments: payments { + __typename + incoming_payment_id: id + incoming_payment_created_at: created_at + incoming_payment_updated_at: updated_at + incoming_payment_status: status + incoming_payment_resolved_at: resolved_at + incoming_payment_amount: amount { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + incoming_payment_transaction_hash: transaction_hash + incoming_payment_is_uma: is_uma + incoming_payment_destination: destination { + id + } + incoming_payment_payment_request: payment_request { + id + } + incoming_payment_uma_post_transaction_data: uma_post_transaction_data { + __typename + post_transaction_data_utxo: utxo + post_transaction_data_amount: amount { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + } + incoming_payment_is_internal_payment: is_internal_payment + } +} +"; diff --git a/lightspark/src/objects/invoice_data.rs b/lightspark/src/objects/invoice_data.rs index 27635d4..614f6da 100644 --- a/lightspark/src/objects/invoice_data.rs +++ b/lightspark/src/objects/invoice_data.rs @@ -1,12 +1,12 @@ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use crate::objects::bitcoin_network::BitcoinNetwork; -use crate::objects::node::NodeEnum; use crate::objects::payment_request_data::PaymentRequestData; -use crate::types::custom_date_formats::custom_date_format; -use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use crate::objects::currency_amount::CurrencyAmount; +use crate::objects::node::NodeEnum; +use crate::types::custom_date_formats::custom_date_format; +use chrono::{DateTime, Utc}; /// This object represents the data associated with a BOLT #11 invoice. You can retrieve this object to receive the relevant data associated with a specific invoice. #[derive(Debug, Clone, Deserialize, Serialize)] diff --git a/lightspark/src/objects/invoice_for_payment_hash_input.rs b/lightspark/src/objects/invoice_for_payment_hash_input.rs new file mode 100644 index 0000000..d460cc7 --- /dev/null +++ b/lightspark/src/objects/invoice_for_payment_hash_input.rs @@ -0,0 +1,8 @@ +// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct InvoiceForPaymentHashInput { + /// The 32-byte hash of the payment preimage for which to fetch an invoice. + pub payment_hash: String, +} diff --git a/lightspark/src/objects/invoice_for_payment_hash_output.rs b/lightspark/src/objects/invoice_for_payment_hash_output.rs new file mode 100644 index 0000000..8e4f814 --- /dev/null +++ b/lightspark/src/objects/invoice_for_payment_hash_output.rs @@ -0,0 +1,18 @@ +// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::types::entity_wrapper::EntityWrapper; +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct InvoiceForPaymentHashOutput { + #[serde(rename = "invoice_for_payment_hash_output_invoice")] + pub invoice: Option, +} + +pub const FRAGMENT: &str = " +fragment InvoiceForPaymentHashOutputFragment on InvoiceForPaymentHashOutput { + __typename + invoice_for_payment_hash_output_invoice: invoice { + id + } +} +"; diff --git a/lightspark/src/objects/lightspark_node.rs b/lightspark/src/objects/lightspark_node.rs index 917a15a..dffa629 100644 --- a/lightspark/src/objects/lightspark_node.rs +++ b/lightspark/src/objects/lightspark_node.rs @@ -1,17 +1,17 @@ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use super::lightspark_node_with_o_s_k::LightsparkNodeWithOSK; use crate::objects::entity::Entity; use crate::objects::node::Node; -use serde::{Deserialize, Deserializer, Serialize}; -use std::vec::Vec; +use super::lightspark_node_with_o_s_k::LightsparkNodeWithOSK; use super::lightspark_node_with_remote_signing::LightsparkNodeWithRemoteSigning; use crate::objects::balances::Balances; use crate::objects::blockchain_balance::BlockchainBalance; use crate::objects::currency_amount::CurrencyAmount; use crate::objects::lightspark_node_status::LightsparkNodeStatus; use crate::types::entity_wrapper::EntityWrapper; +use serde::{Deserialize, Deserializer, Serialize}; use serde_json::Value; +use std::vec::Vec; pub trait LightsparkNode: Node + Entity { /// The owner of this LightsparkNode. diff --git a/lightspark/src/objects/lightspark_node_with_o_s_k.rs b/lightspark/src/objects/lightspark_node_with_o_s_k.rs index 042a59a..22ec9be 100644 --- a/lightspark/src/objects/lightspark_node_with_o_s_k.rs +++ b/lightspark/src/objects/lightspark_node_with_o_s_k.rs @@ -1,30 +1,30 @@ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use crate::error::Error; -use crate::objects::blockchain_balance::BlockchainBalance; +use crate::objects::balances::Balances; use crate::objects::channel_status::ChannelStatus; -use crate::objects::currency_amount::CurrencyAmount; -use crate::objects::node::Node; +use crate::objects::lightning_payment_direction::LightningPaymentDirection; +use crate::objects::lightspark_node::LightsparkNode; +use crate::objects::lightspark_node_status::LightsparkNodeStatus; +use crate::objects::lightspark_node_to_channels_connection::LightsparkNodeToChannelsConnection; +use crate::objects::node_address_type::NodeAddressType; use crate::types::custom_date_formats::custom_date_format; -use crate::types::entity_wrapper::EntityWrapper; use crate::types::get_entity::GetEntity; use crate::types::graphql_requester::GraphQLRequester; +use chrono::NaiveDate; use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; -use std::collections::HashMap; -use crate::objects::balances::Balances; use crate::objects::bitcoin_network::BitcoinNetwork; +use crate::objects::blockchain_balance::BlockchainBalance; +use crate::objects::currency_amount::CurrencyAmount; use crate::objects::entity::Entity; -use crate::objects::lightning_payment_direction::LightningPaymentDirection; -use crate::objects::lightspark_node::LightsparkNode; -use crate::objects::lightspark_node_status::LightsparkNodeStatus; -use crate::objects::lightspark_node_to_channels_connection::LightsparkNodeToChannelsConnection; use crate::objects::lightspark_node_to_daily_liquidity_forecasts_connection::LightsparkNodeToDailyLiquidityForecastsConnection; -use crate::objects::node_address_type::NodeAddressType; +use crate::objects::node::Node; use crate::objects::node_to_addresses_connection::NodeToAddressesConnection; use crate::objects::secret::Secret; -use chrono::NaiveDate; +use crate::types::entity_wrapper::EntityWrapper; use serde_json::Value; +use std::collections::HashMap; use std::vec::Vec; /// This is a Lightspark node with OSK. @@ -416,13 +416,15 @@ impl LightsparkNodeWithOSK { &self, requester: &impl GraphQLRequester, first: Option, - statuses: Option>, after: Option, + before_date: Option>, + after_date: Option>, + statuses: Option>, ) -> Result { - let query = "query FetchLightsparkNodeToChannelsConnection($entity_id: ID!, $first: Int, $statuses: [ChannelStatus!], $after: String) { + let query = "query FetchLightsparkNodeToChannelsConnection($entity_id: ID!, $first: Int, $after: String, $before_date: DateTime, $after_date: DateTime, $statuses: [ChannelStatus!]) { entity(id: $entity_id) { ... on LightsparkNodeWithOSK { - channels(, first: $first, statuses: $statuses, after: $after) { + channels(, first: $first, after: $after, before_date: $before_date, after_date: $after_date, statuses: $statuses) { __typename lightspark_node_to_channels_connection_count: count lightspark_node_to_channels_connection_page_info: page_info { @@ -533,8 +535,10 @@ impl LightsparkNodeWithOSK { let mut variables: HashMap<&str, Value> = HashMap::new(); variables.insert("entity_id", self.id.clone().into()); variables.insert("first", first.into()); - variables.insert("statuses", statuses.into()); variables.insert("after", after.into()); + variables.insert("before_date", before_date.map(|dt| dt.to_rfc3339()).into()); + variables.insert("after_date", after_date.map(|dt| dt.to_rfc3339()).into()); + variables.insert("statuses", statuses.into()); let value = serde_json::to_value(variables).map_err(Error::ConversionError)?; let result = requester.execute_graphql(query, Some(value)).await?; diff --git a/lightspark/src/objects/lightspark_node_with_remote_signing.rs b/lightspark/src/objects/lightspark_node_with_remote_signing.rs index 71789e6..5cb11f2 100644 --- a/lightspark/src/objects/lightspark_node_with_remote_signing.rs +++ b/lightspark/src/objects/lightspark_node_with_remote_signing.rs @@ -1,29 +1,29 @@ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use crate::error::Error; -use crate::objects::blockchain_balance::BlockchainBalance; +use crate::objects::balances::Balances; use crate::objects::channel_status::ChannelStatus; -use crate::objects::currency_amount::CurrencyAmount; -use crate::objects::node::Node; +use crate::objects::lightning_payment_direction::LightningPaymentDirection; +use crate::objects::lightspark_node::LightsparkNode; +use crate::objects::lightspark_node_status::LightsparkNodeStatus; +use crate::objects::lightspark_node_to_channels_connection::LightsparkNodeToChannelsConnection; +use crate::objects::node_address_type::NodeAddressType; use crate::types::custom_date_formats::custom_date_format; -use crate::types::entity_wrapper::EntityWrapper; use crate::types::get_entity::GetEntity; use crate::types::graphql_requester::GraphQLRequester; +use chrono::NaiveDate; use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; -use std::collections::HashMap; -use crate::objects::balances::Balances; use crate::objects::bitcoin_network::BitcoinNetwork; +use crate::objects::blockchain_balance::BlockchainBalance; +use crate::objects::currency_amount::CurrencyAmount; use crate::objects::entity::Entity; -use crate::objects::lightning_payment_direction::LightningPaymentDirection; -use crate::objects::lightspark_node::LightsparkNode; -use crate::objects::lightspark_node_status::LightsparkNodeStatus; -use crate::objects::lightspark_node_to_channels_connection::LightsparkNodeToChannelsConnection; use crate::objects::lightspark_node_to_daily_liquidity_forecasts_connection::LightsparkNodeToDailyLiquidityForecastsConnection; -use crate::objects::node_address_type::NodeAddressType; +use crate::objects::node::Node; use crate::objects::node_to_addresses_connection::NodeToAddressesConnection; -use chrono::NaiveDate; +use crate::types::entity_wrapper::EntityWrapper; use serde_json::Value; +use std::collections::HashMap; use std::vec::Vec; /// This is a Lightspark node with remote signing. @@ -406,13 +406,15 @@ impl LightsparkNodeWithRemoteSigning { &self, requester: &impl GraphQLRequester, first: Option, - statuses: Option>, after: Option, + before_date: Option>, + after_date: Option>, + statuses: Option>, ) -> Result { - let query = "query FetchLightsparkNodeToChannelsConnection($entity_id: ID!, $first: Int, $statuses: [ChannelStatus!], $after: String) { + let query = "query FetchLightsparkNodeToChannelsConnection($entity_id: ID!, $first: Int, $after: String, $before_date: DateTime, $after_date: DateTime, $statuses: [ChannelStatus!]) { entity(id: $entity_id) { ... on LightsparkNodeWithRemoteSigning { - channels(, first: $first, statuses: $statuses, after: $after) { + channels(, first: $first, after: $after, before_date: $before_date, after_date: $after_date, statuses: $statuses) { __typename lightspark_node_to_channels_connection_count: count lightspark_node_to_channels_connection_page_info: page_info { @@ -523,8 +525,10 @@ impl LightsparkNodeWithRemoteSigning { let mut variables: HashMap<&str, Value> = HashMap::new(); variables.insert("entity_id", self.id.clone().into()); variables.insert("first", first.into()); - variables.insert("statuses", statuses.into()); variables.insert("after", after.into()); + variables.insert("before_date", before_date.map(|dt| dt.to_rfc3339()).into()); + variables.insert("after_date", after_date.map(|dt| dt.to_rfc3339()).into()); + variables.insert("statuses", statuses.into()); let value = serde_json::to_value(variables).map_err(Error::ConversionError)?; let result = requester.execute_graphql(query, Some(value)).await?; diff --git a/lightspark/src/objects/mod.rs b/lightspark/src/objects/mod.rs index a57837c..a61784d 100644 --- a/lightspark/src/objects/mod.rs +++ b/lightspark/src/objects/mod.rs @@ -9,6 +9,7 @@ pub mod account_to_transactions_connection; pub mod account_to_wallets_connection; pub mod account_to_withdrawal_requests_connection; pub mod api_token; +pub mod audit_log_actor; pub mod balances; pub mod bitcoin_network; pub mod blockchain_balance; @@ -52,6 +53,8 @@ pub mod delete_api_token_input; pub mod delete_api_token_output; pub mod deposit; pub mod entity; +pub mod fail_htlcs_input; +pub mod fail_htlcs_output; pub mod fee_estimate; pub mod fund_node_input; pub mod fund_node_output; @@ -65,8 +68,12 @@ pub mod incoming_payment; pub mod incoming_payment_attempt; pub mod incoming_payment_attempt_status; pub mod incoming_payment_to_attempts_connection; +pub mod incoming_payments_for_invoice_query_input; +pub mod incoming_payments_for_invoice_query_output; pub mod invoice; pub mod invoice_data; +pub mod invoice_for_payment_hash_input; +pub mod invoice_for_payment_hash_output; pub mod invoice_type; pub mod lightning_fee_estimate_for_invoice_input; pub mod lightning_fee_estimate_for_node_input; @@ -80,18 +87,24 @@ pub mod lightspark_node_to_channels_connection; pub mod lightspark_node_to_daily_liquidity_forecasts_connection; pub mod lightspark_node_with_o_s_k; pub mod lightspark_node_with_remote_signing; +pub mod multi_sig_address_validation_parameters; pub mod node; pub mod node_address; pub mod node_address_type; pub mod node_to_addresses_connection; +pub mod on_chain_fee_target; pub mod on_chain_transaction; pub mod outgoing_payment; pub mod outgoing_payment_attempt; pub mod outgoing_payment_attempt_status; pub mod outgoing_payment_attempt_to_hops_connection; +pub mod outgoing_payment_for_idempotency_key_input; +pub mod outgoing_payment_for_idempotency_key_output; pub mod outgoing_payment_to_attempts_connection; pub mod outgoing_payments_for_invoice_query_input; pub mod outgoing_payments_for_invoice_query_output; +pub mod outgoing_payments_for_payment_hash_query_input; +pub mod outgoing_payments_for_payment_hash_query_output; pub mod page_info; pub mod pay_invoice_input; pub mod pay_invoice_output; @@ -154,3 +167,4 @@ pub mod withdrawal_request; pub mod withdrawal_request_status; pub mod withdrawal_request_to_channel_closing_transactions_connection; pub mod withdrawal_request_to_channel_opening_transactions_connection; +pub mod withdrawal_request_to_withdrawals_connection; diff --git a/lightspark/src/objects/multi_sig_address_validation_parameters.rs b/lightspark/src/objects/multi_sig_address_validation_parameters.rs new file mode 100644 index 0000000..60e579b --- /dev/null +++ b/lightspark/src/objects/multi_sig_address_validation_parameters.rs @@ -0,0 +1,21 @@ +// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct MultiSigAddressValidationParameters { + /// The counterparty funding public key used to create the 2-of-2 multisig for the address. + #[serde(rename = "multi_sig_address_validation_parameters_counterparty_funding_pubkey")] + pub counterparty_funding_pubkey: String, + + /// The derivation path used to derive the funding public key for the 2-of-2 multisig address. + #[serde(rename = "multi_sig_address_validation_parameters_funding_pubkey_derivation_path")] + pub funding_pubkey_derivation_path: String, +} + +pub const FRAGMENT: &str = " +fragment MultiSigAddressValidationParametersFragment on MultiSigAddressValidationParameters { + __typename + multi_sig_address_validation_parameters_counterparty_funding_pubkey: counterparty_funding_pubkey + multi_sig_address_validation_parameters_funding_pubkey_derivation_path: funding_pubkey_derivation_path +} +"; diff --git a/lightspark/src/objects/on_chain_fee_target.rs b/lightspark/src/objects/on_chain_fee_target.rs new file mode 100644 index 0000000..70239ae --- /dev/null +++ b/lightspark/src/objects/on_chain_fee_target.rs @@ -0,0 +1,41 @@ +// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use serde::{Deserialize, Serialize}; +use serde_json::Value; +use std::fmt; + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub enum OnChainFeeTarget { + /// Transaction expected to be confirmed within 2 blocks. + + #[serde(rename = "HIGH")] + High, + /// Transaction expected to be confirmed within 6 blocks. + + #[serde(rename = "MEDIUM")] + Medium, + /// Transaction expected to be confirmed within 18 blocks. + + #[serde(rename = "LOW")] + Low, + /// Transaction expected to be confirmed within 50 blocks. + + #[serde(rename = "BACKGROUND")] + Background, +} + +impl From for Value { + fn from(val: OnChainFeeTarget) -> Self { + Value::from(val.to_string()) + } +} + +impl fmt::Display for OnChainFeeTarget { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + Self::High => write!(f, "HIGH"), + Self::Medium => write!(f, "MEDIUM"), + Self::Low => write!(f, "LOW"), + Self::Background => write!(f, "BACKGROUND"), + } + } +} diff --git a/lightspark/src/objects/on_chain_transaction.rs b/lightspark/src/objects/on_chain_transaction.rs index ee301bc..884726e 100644 --- a/lightspark/src/objects/on_chain_transaction.rs +++ b/lightspark/src/objects/on_chain_transaction.rs @@ -11,7 +11,7 @@ use serde_json::Value; use std::vec::Vec; pub trait OnChainTransaction: Transaction + Entity { - /// The fees that were paid by the wallet sending the transaction to commit it to the Bitcoin blockchain. + /// The fees that were paid by the node for this transaction. fn get_fees(&self) -> Option; /// The hash of the block that included this transaction. This will be null for unconfirmed transactions. diff --git a/lightspark/src/objects/outgoing_payment.rs b/lightspark/src/objects/outgoing_payment.rs index d38bc13..cf65665 100644 --- a/lightspark/src/objects/outgoing_payment.rs +++ b/lightspark/src/objects/outgoing_payment.rs @@ -1,25 +1,25 @@ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use crate::error::Error; -use crate::objects::currency_amount::CurrencyAmount; use crate::objects::outgoing_payment_to_attempts_connection::OutgoingPaymentToAttemptsConnection; -use crate::objects::payment_failure_reason::PaymentFailureReason; -use crate::types::custom_date_formats::custom_date_format; -use crate::types::entity_wrapper::EntityWrapper; -use crate::types::get_entity::GetEntity; +use crate::types::custom_date_formats::custom_date_format_option; use crate::types::graphql_requester::GraphQLRequester; -use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; -use std::collections::HashMap; +use crate::error::Error; +use crate::objects::currency_amount::CurrencyAmount; use crate::objects::entity::Entity; use crate::objects::lightning_transaction::LightningTransaction; +use crate::objects::payment_failure_reason::PaymentFailureReason; use crate::objects::payment_request_data::PaymentRequestDataEnum; use crate::objects::post_transaction_data::PostTransactionData; use crate::objects::rich_text::RichText; use crate::objects::transaction::Transaction; use crate::objects::transaction_status::TransactionStatus; -use crate::types::custom_date_formats::custom_date_format_option; +use crate::types::custom_date_formats::custom_date_format; +use crate::types::entity_wrapper::EntityWrapper; +use crate::types::get_entity::GetEntity; +use chrono::{DateTime, Utc}; use serde_json::Value; +use std::collections::HashMap; use std::vec::Vec; /// This object represents a Lightning Network payment sent from a Lightspark Node. You can retrieve this object to receive payment related information about any payment sent from your Lightspark Node on the Lightning Network. @@ -56,6 +56,10 @@ pub struct OutgoingPayment { #[serde(rename = "outgoing_payment_transaction_hash")] pub transaction_hash: Option, + /// Whether this payment is an UMA payment or not. NOTE: this field is only set if the payment has been sent using the recommended `pay_uma_invoice` function. + #[serde(rename = "outgoing_payment_is_uma")] + pub is_uma: bool, + /// The Lightspark node this payment originated from. #[serde(rename = "outgoing_payment_origin")] pub origin: EntityWrapper, @@ -88,6 +92,14 @@ pub struct OutgoingPayment { #[serde(rename = "outgoing_payment_payment_preimage")] pub payment_preimage: Option, + /// Whether the payment is made to the same node. + #[serde(rename = "outgoing_payment_is_internal_payment")] + pub is_internal_payment: bool, + + /// The idempotency key of the payment. + #[serde(rename = "outgoing_payment_idempotency_key")] + pub idempotency_key: Option, + /// The typename of the object #[serde(rename = "__typename")] pub typename: String, @@ -181,6 +193,7 @@ fragment OutgoingPaymentFragment on OutgoingPayment { currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } outgoing_payment_transaction_hash: transaction_hash + outgoing_payment_is_uma: is_uma outgoing_payment_origin: origin { id } @@ -507,6 +520,8 @@ fragment OutgoingPaymentFragment on OutgoingPayment { } } outgoing_payment_payment_preimage: payment_preimage + outgoing_payment_is_internal_payment: is_internal_payment + outgoing_payment_idempotency_key: idempotency_key } "; @@ -560,51 +575,7 @@ impl OutgoingPayment { id } outgoing_payment_attempt_channel_snapshot: channel_snapshot { - __typename - channel_snapshot_channel: channel { - id - } - channel_snapshot_timestamp: timestamp - channel_snapshot_local_balance: local_balance { - __typename - currency_amount_original_value: original_value - currency_amount_original_unit: original_unit - currency_amount_preferred_currency_unit: preferred_currency_unit - currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded - currency_amount_preferred_currency_value_approx: preferred_currency_value_approx - } - channel_snapshot_local_unsettled_balance: local_unsettled_balance { - __typename - currency_amount_original_value: original_value - currency_amount_original_unit: original_unit - currency_amount_preferred_currency_unit: preferred_currency_unit - currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded - currency_amount_preferred_currency_value_approx: preferred_currency_value_approx - } - channel_snapshot_local_channel_reserve: local_channel_reserve { - __typename - currency_amount_original_value: original_value - currency_amount_original_unit: original_unit - currency_amount_preferred_currency_unit: preferred_currency_unit - currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded - currency_amount_preferred_currency_value_approx: preferred_currency_value_approx - } - channel_snapshot_remote_balance: remote_balance { - __typename - currency_amount_original_value: original_value - currency_amount_original_unit: original_unit - currency_amount_preferred_currency_unit: preferred_currency_unit - currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded - currency_amount_preferred_currency_value_approx: preferred_currency_value_approx - } - channel_snapshot_remote_unsettled_balance: remote_unsettled_balance { - __typename - currency_amount_original_value: original_value - currency_amount_original_unit: original_unit - currency_amount_preferred_currency_unit: preferred_currency_unit - currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded - currency_amount_preferred_currency_value_approx: preferred_currency_value_approx - } + id } } } diff --git a/lightspark/src/objects/outgoing_payment_attempt.rs b/lightspark/src/objects/outgoing_payment_attempt.rs index 5eb8a99..450a2d4 100644 --- a/lightspark/src/objects/outgoing_payment_attempt.rs +++ b/lightspark/src/objects/outgoing_payment_attempt.rs @@ -1,6 +1,5 @@ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use crate::error::Error; -use crate::objects::channel_snapshot::ChannelSnapshot; use crate::objects::currency_amount::CurrencyAmount; use crate::objects::entity::Entity; use crate::objects::htlc_attempt_failure_code::HtlcAttemptFailureCode; @@ -77,7 +76,7 @@ pub struct OutgoingPaymentAttempt { /// The channel snapshot at the time the outgoing payment attempt was made. #[serde(rename = "outgoing_payment_attempt_channel_snapshot")] - pub channel_snapshot: Option, + pub channel_snapshot: Option, /// The typename of the object #[serde(rename = "__typename")] @@ -154,51 +153,7 @@ fragment OutgoingPaymentAttemptFragment on OutgoingPaymentAttempt { id } outgoing_payment_attempt_channel_snapshot: channel_snapshot { - __typename - channel_snapshot_channel: channel { - id - } - channel_snapshot_timestamp: timestamp - channel_snapshot_local_balance: local_balance { - __typename - currency_amount_original_value: original_value - currency_amount_original_unit: original_unit - currency_amount_preferred_currency_unit: preferred_currency_unit - currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded - currency_amount_preferred_currency_value_approx: preferred_currency_value_approx - } - channel_snapshot_local_unsettled_balance: local_unsettled_balance { - __typename - currency_amount_original_value: original_value - currency_amount_original_unit: original_unit - currency_amount_preferred_currency_unit: preferred_currency_unit - currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded - currency_amount_preferred_currency_value_approx: preferred_currency_value_approx - } - channel_snapshot_local_channel_reserve: local_channel_reserve { - __typename - currency_amount_original_value: original_value - currency_amount_original_unit: original_unit - currency_amount_preferred_currency_unit: preferred_currency_unit - currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded - currency_amount_preferred_currency_value_approx: preferred_currency_value_approx - } - channel_snapshot_remote_balance: remote_balance { - __typename - currency_amount_original_value: original_value - currency_amount_original_unit: original_unit - currency_amount_preferred_currency_unit: preferred_currency_unit - currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded - currency_amount_preferred_currency_value_approx: preferred_currency_value_approx - } - channel_snapshot_remote_unsettled_balance: remote_unsettled_balance { - __typename - currency_amount_original_value: original_value - currency_amount_original_unit: original_unit - currency_amount_preferred_currency_unit: preferred_currency_unit - currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded - currency_amount_preferred_currency_value_approx: preferred_currency_value_approx - } + id } } "; diff --git a/lightspark/src/objects/outgoing_payment_for_idempotency_key_input.rs b/lightspark/src/objects/outgoing_payment_for_idempotency_key_input.rs new file mode 100644 index 0000000..a708a4b --- /dev/null +++ b/lightspark/src/objects/outgoing_payment_for_idempotency_key_input.rs @@ -0,0 +1,7 @@ +// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct OutgoingPaymentForIdempotencyKeyInput { + pub idempotency_key: String, +} diff --git a/lightspark/src/objects/outgoing_payment_for_idempotency_key_output.rs b/lightspark/src/objects/outgoing_payment_for_idempotency_key_output.rs new file mode 100644 index 0000000..9211c96 --- /dev/null +++ b/lightspark/src/objects/outgoing_payment_for_idempotency_key_output.rs @@ -0,0 +1,18 @@ +// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::types::entity_wrapper::EntityWrapper; +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct OutgoingPaymentForIdempotencyKeyOutput { + #[serde(rename = "outgoing_payment_for_idempotency_key_output_payment")] + pub payment: Option, +} + +pub const FRAGMENT: &str = " +fragment OutgoingPaymentForIdempotencyKeyOutputFragment on OutgoingPaymentForIdempotencyKeyOutput { + __typename + outgoing_payment_for_idempotency_key_output_payment: payment { + id + } +} +"; diff --git a/lightspark/src/objects/outgoing_payments_for_invoice_query_output.rs b/lightspark/src/objects/outgoing_payments_for_invoice_query_output.rs index d9f28ec..6d8a48e 100644 --- a/lightspark/src/objects/outgoing_payments_for_invoice_query_output.rs +++ b/lightspark/src/objects/outgoing_payments_for_invoice_query_output.rs @@ -13,7 +13,350 @@ pub const FRAGMENT: &str = " fragment OutgoingPaymentsForInvoiceQueryOutputFragment on OutgoingPaymentsForInvoiceQueryOutput { __typename outgoing_payments_for_invoice_query_output_payments: payments { - id + __typename + outgoing_payment_id: id + outgoing_payment_created_at: created_at + outgoing_payment_updated_at: updated_at + outgoing_payment_status: status + outgoing_payment_resolved_at: resolved_at + outgoing_payment_amount: amount { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + outgoing_payment_transaction_hash: transaction_hash + outgoing_payment_is_uma: is_uma + outgoing_payment_origin: origin { + id + } + outgoing_payment_destination: destination { + id + } + outgoing_payment_fees: fees { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + outgoing_payment_payment_request_data: payment_request_data { + __typename + ... on InvoiceData { + __typename + invoice_data_encoded_payment_request: encoded_payment_request + invoice_data_bitcoin_network: bitcoin_network + invoice_data_payment_hash: payment_hash + invoice_data_amount: amount { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + invoice_data_created_at: created_at + invoice_data_expires_at: expires_at + invoice_data_memo: memo + invoice_data_destination: destination { + __typename + ... on GraphNode { + __typename + graph_node_id: id + graph_node_created_at: created_at + graph_node_updated_at: updated_at + graph_node_alias: alias + graph_node_bitcoin_network: bitcoin_network + graph_node_color: color + graph_node_conductivity: conductivity + graph_node_display_name: display_name + graph_node_public_key: public_key + } + ... on LightsparkNodeWithOSK { + __typename + lightspark_node_with_o_s_k_id: id + lightspark_node_with_o_s_k_created_at: created_at + lightspark_node_with_o_s_k_updated_at: updated_at + lightspark_node_with_o_s_k_alias: alias + lightspark_node_with_o_s_k_bitcoin_network: bitcoin_network + lightspark_node_with_o_s_k_color: color + lightspark_node_with_o_s_k_conductivity: conductivity + lightspark_node_with_o_s_k_display_name: display_name + lightspark_node_with_o_s_k_public_key: public_key + lightspark_node_with_o_s_k_owner: owner { + id + } + lightspark_node_with_o_s_k_status: status + lightspark_node_with_o_s_k_total_balance: total_balance { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + lightspark_node_with_o_s_k_total_local_balance: total_local_balance { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + lightspark_node_with_o_s_k_local_balance: local_balance { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + lightspark_node_with_o_s_k_remote_balance: remote_balance { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + lightspark_node_with_o_s_k_blockchain_balance: blockchain_balance { + __typename + blockchain_balance_total_balance: total_balance { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + blockchain_balance_confirmed_balance: confirmed_balance { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + blockchain_balance_unconfirmed_balance: unconfirmed_balance { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + blockchain_balance_locked_balance: locked_balance { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + blockchain_balance_required_reserve: required_reserve { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + blockchain_balance_available_balance: available_balance { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + } + lightspark_node_with_o_s_k_uma_prescreening_utxos: uma_prescreening_utxos + lightspark_node_with_o_s_k_balances: balances { + __typename + balances_owned_balance: owned_balance { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + balances_available_to_send_balance: available_to_send_balance { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + balances_available_to_withdraw_balance: available_to_withdraw_balance { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + } + lightspark_node_with_o_s_k_encrypted_signing_private_key: encrypted_signing_private_key { + __typename + secret_encrypted_value: encrypted_value + secret_cipher: cipher + } + } + ... on LightsparkNodeWithRemoteSigning { + __typename + lightspark_node_with_remote_signing_id: id + lightspark_node_with_remote_signing_created_at: created_at + lightspark_node_with_remote_signing_updated_at: updated_at + lightspark_node_with_remote_signing_alias: alias + lightspark_node_with_remote_signing_bitcoin_network: bitcoin_network + lightspark_node_with_remote_signing_color: color + lightspark_node_with_remote_signing_conductivity: conductivity + lightspark_node_with_remote_signing_display_name: display_name + lightspark_node_with_remote_signing_public_key: public_key + lightspark_node_with_remote_signing_owner: owner { + id + } + lightspark_node_with_remote_signing_status: status + lightspark_node_with_remote_signing_total_balance: total_balance { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + lightspark_node_with_remote_signing_total_local_balance: total_local_balance { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + lightspark_node_with_remote_signing_local_balance: local_balance { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + lightspark_node_with_remote_signing_remote_balance: remote_balance { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + lightspark_node_with_remote_signing_blockchain_balance: blockchain_balance { + __typename + blockchain_balance_total_balance: total_balance { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + blockchain_balance_confirmed_balance: confirmed_balance { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + blockchain_balance_unconfirmed_balance: unconfirmed_balance { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + blockchain_balance_locked_balance: locked_balance { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + blockchain_balance_required_reserve: required_reserve { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + blockchain_balance_available_balance: available_balance { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + } + lightspark_node_with_remote_signing_uma_prescreening_utxos: uma_prescreening_utxos + lightspark_node_with_remote_signing_balances: balances { + __typename + balances_owned_balance: owned_balance { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + balances_available_to_send_balance: available_to_send_balance { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + balances_available_to_withdraw_balance: available_to_withdraw_balance { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + } + } + } + } + } + outgoing_payment_failure_reason: failure_reason + outgoing_payment_failure_message: failure_message { + __typename + rich_text_text: text + } + outgoing_payment_uma_post_transaction_data: uma_post_transaction_data { + __typename + post_transaction_data_utxo: utxo + post_transaction_data_amount: amount { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + } + outgoing_payment_payment_preimage: payment_preimage + outgoing_payment_is_internal_payment: is_internal_payment + outgoing_payment_idempotency_key: idempotency_key } } "; diff --git a/lightspark/src/objects/outgoing_payments_for_payment_hash_query_input.rs b/lightspark/src/objects/outgoing_payments_for_payment_hash_query_input.rs new file mode 100644 index 0000000..78afcb6 --- /dev/null +++ b/lightspark/src/objects/outgoing_payments_for_payment_hash_query_input.rs @@ -0,0 +1,13 @@ +// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::objects::transaction_status::TransactionStatus; +use serde::{Deserialize, Serialize}; +use std::vec::Vec; + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct OutgoingPaymentsForPaymentHashQueryInput { + /// The 32-byte hash of the payment preimage for which to fetch payments + pub payment_hash: String, + + /// An optional filter to only query outgoing payments of given statuses. + pub statuses: Option>, +} diff --git a/lightspark/src/objects/outgoing_payments_for_payment_hash_query_output.rs b/lightspark/src/objects/outgoing_payments_for_payment_hash_query_output.rs new file mode 100644 index 0000000..60f7c21 --- /dev/null +++ b/lightspark/src/objects/outgoing_payments_for_payment_hash_query_output.rs @@ -0,0 +1,19 @@ +// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::objects::outgoing_payment::OutgoingPayment; +use serde::{Deserialize, Serialize}; +use std::vec::Vec; + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct OutgoingPaymentsForPaymentHashQueryOutput { + #[serde(rename = "outgoing_payments_for_payment_hash_query_output_payments")] + pub payments: Vec, +} + +pub const FRAGMENT: &str = " +fragment OutgoingPaymentsForPaymentHashQueryOutputFragment on OutgoingPaymentsForPaymentHashQueryOutput { + __typename + outgoing_payments_for_payment_hash_query_output_payments: payments { + id + } +} +"; diff --git a/lightspark/src/objects/pay_invoice_input.rs b/lightspark/src/objects/pay_invoice_input.rs index 8fc7e8d..6bb1c89 100644 --- a/lightspark/src/objects/pay_invoice_input.rs +++ b/lightspark/src/objects/pay_invoice_input.rs @@ -17,4 +17,7 @@ pub struct PayInvoiceInput { /// The amount you will pay for this invoice, expressed in msats. It should ONLY be set when the invoice amount is zero. pub amount_msats: Option, + + /// The idempotency key of the request. The same result will be returned for the same idempotency key. + pub idempotency_key: Option, } diff --git a/lightspark/src/objects/pay_uma_invoice_input.rs b/lightspark/src/objects/pay_uma_invoice_input.rs index d80872a..22fd92c 100644 --- a/lightspark/src/objects/pay_uma_invoice_input.rs +++ b/lightspark/src/objects/pay_uma_invoice_input.rs @@ -12,4 +12,6 @@ pub struct PayUmaInvoiceInput { pub maximum_fees_msats: i64, pub amount_msats: Option, + + pub idempotency_key: Option, } diff --git a/lightspark/src/objects/payment_failure_reason.rs b/lightspark/src/objects/payment_failure_reason.rs index 7018b43..585e8c6 100644 --- a/lightspark/src/objects/payment_failure_reason.rs +++ b/lightspark/src/objects/payment_failure_reason.rs @@ -33,8 +33,14 @@ pub enum PaymentFailureReason { #[serde(rename = "INVOICE_EXPIRED")] InvoiceExpired, + #[serde(rename = "INVOICE_CANCELLED")] + InvoiceCancelled, + #[serde(rename = "RISK_SCREENING_FAILED")] RiskScreeningFailed, + + #[serde(rename = "INSUFFICIENT_BALANCE_ON_SINGLE_PATH_INVOICE")] + InsufficientBalanceOnSinglePathInvoice, } impl From for Value { @@ -55,7 +61,11 @@ impl fmt::Display for PaymentFailureReason { Self::InvoiceAlreadyPaid => write!(f, "INVOICE_ALREADY_PAID"), Self::SelfPayment => write!(f, "SELF_PAYMENT"), Self::InvoiceExpired => write!(f, "INVOICE_EXPIRED"), + Self::InvoiceCancelled => write!(f, "INVOICE_CANCELLED"), Self::RiskScreeningFailed => write!(f, "RISK_SCREENING_FAILED"), + Self::InsufficientBalanceOnSinglePathInvoice => { + write!(f, "INSUFFICIENT_BALANCE_ON_SINGLE_PATH_INVOICE") + } } } } diff --git a/lightspark/src/objects/remote_signing_sub_event_type.rs b/lightspark/src/objects/remote_signing_sub_event_type.rs index 5825552..061735c 100644 --- a/lightspark/src/objects/remote_signing_sub_event_type.rs +++ b/lightspark/src/objects/remote_signing_sub_event_type.rs @@ -29,6 +29,9 @@ pub enum RemoteSigningSubEventType { #[serde(rename = "REVEAL_COUNTERPARTY_PER_COMMITMENT_SECRET")] RevealCounterpartyPerCommitmentSecret, + + #[serde(rename = "VLS_MESSAGE")] + VlsMessage, } impl From for Value { @@ -50,6 +53,7 @@ impl fmt::Display for RemoteSigningSubEventType { Self::RevealCounterpartyPerCommitmentSecret => { write!(f, "REVEAL_COUNTERPARTY_PER_COMMITMENT_SECRET") } + Self::VlsMessage => write!(f, "VLS_MESSAGE"), } } } diff --git a/lightspark/src/objects/request_withdrawal_input.rs b/lightspark/src/objects/request_withdrawal_input.rs index 1d34a39..75b2970 100644 --- a/lightspark/src/objects/request_withdrawal_input.rs +++ b/lightspark/src/objects/request_withdrawal_input.rs @@ -1,4 +1,5 @@ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::objects::on_chain_fee_target::OnChainFeeTarget; use crate::objects::withdrawal_mode::WithdrawalMode; use serde::{Deserialize, Serialize}; @@ -15,4 +16,13 @@ pub struct RequestWithdrawalInput { /// The strategy that should be used to withdraw the funds from this node. pub withdrawal_mode: WithdrawalMode, + + /// The idempotency key of the request. The same result will be returned for the same idempotency key. + pub idempotency_key: Option, + + /// The target of the fee that should be used when crafting the L1 transaction. You should only set `fee_target` or `sats_per_vbyte`. If neither of them is set, default value of MEDIUM will be used as `fee_target`. + pub fee_target: Option, + + /// A manual fee rate set in sat/vbyte that should be used when crafting the L1 transaction. You should only set `fee_target` or `sats_per_vbyte` + pub sats_per_vbyte: Option, } diff --git a/lightspark/src/objects/send_payment_input.rs b/lightspark/src/objects/send_payment_input.rs index 5dfd511..de81135 100644 --- a/lightspark/src/objects/send_payment_input.rs +++ b/lightspark/src/objects/send_payment_input.rs @@ -17,4 +17,7 @@ pub struct SendPaymentInput { /// The maximum amount of fees that you want to pay for this payment to be sent, expressed in msats. pub maximum_fees_msats: i64, + + /// The idempotency key of the request. The same result will be returned for the same idempotency key. + pub idempotency_key: Option, } diff --git a/lightspark/src/objects/transaction_status.rs b/lightspark/src/objects/transaction_status.rs index a353729..30b863d 100644 --- a/lightspark/src/objects/transaction_status.rs +++ b/lightspark/src/objects/transaction_status.rs @@ -6,7 +6,7 @@ use std::fmt; /// This is an enum of the potential statuses a transaction associated with your Lightspark Node can take. #[derive(Debug, Clone, Deserialize, Serialize)] pub enum TransactionStatus { - /// Transaction succeeded.. + /// Transaction succeeded. #[serde(rename = "SUCCESS")] Success, diff --git a/lightspark/src/objects/wallet.rs b/lightspark/src/objects/wallet.rs index 8cf8424..6e10061 100644 --- a/lightspark/src/objects/wallet.rs +++ b/lightspark/src/objects/wallet.rs @@ -288,6 +288,7 @@ impl Wallet { currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } incoming_payment_transaction_hash: transaction_hash + incoming_payment_is_uma: is_uma incoming_payment_destination: destination { id } @@ -306,6 +307,7 @@ impl Wallet { currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } } + incoming_payment_is_internal_payment: is_internal_payment } ... on OutgoingPayment { __typename @@ -323,6 +325,7 @@ impl Wallet { currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } outgoing_payment_transaction_hash: transaction_hash + outgoing_payment_is_uma: is_uma outgoing_payment_origin: origin { id } @@ -649,6 +652,8 @@ impl Wallet { } } outgoing_payment_payment_preimage: payment_preimage + outgoing_payment_is_internal_payment: is_internal_payment + outgoing_payment_idempotency_key: idempotency_key } ... on RoutingTransaction { __typename @@ -1196,6 +1201,14 @@ impl Wallet { currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } + withdrawal_request_total_fees: total_fees { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } withdrawal_request_bitcoin_address: bitcoin_address withdrawal_request_withdrawal_mode: withdrawal_mode withdrawal_request_status: status @@ -1203,6 +1216,7 @@ impl Wallet { withdrawal_request_withdrawal: withdrawal { id } + withdrawal_request_idempotency_key: idempotency_key } } } diff --git a/lightspark/src/objects/wallet_to_payment_requests_connection.rs b/lightspark/src/objects/wallet_to_payment_requests_connection.rs index 3936fba..60a3535 100644 --- a/lightspark/src/objects/wallet_to_payment_requests_connection.rs +++ b/lightspark/src/objects/wallet_to_payment_requests_connection.rs @@ -1,10 +1,10 @@ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::objects::payment_request::PaymentRequestEnum; use serde::{Deserialize, Serialize}; -use std::vec::Vec; use crate::objects::connection::Connection; use crate::objects::page_info::PageInfo; -use crate::objects::payment_request::PaymentRequestEnum; +use std::vec::Vec; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct WalletToPaymentRequestsConnection { diff --git a/lightspark/src/objects/wallet_to_transactions_connection.rs b/lightspark/src/objects/wallet_to_transactions_connection.rs index e5f1893..a39e4cf 100644 --- a/lightspark/src/objects/wallet_to_transactions_connection.rs +++ b/lightspark/src/objects/wallet_to_transactions_connection.rs @@ -1,10 +1,10 @@ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use crate::objects::transaction::TransactionEnum; use serde::{Deserialize, Serialize}; -use std::vec::Vec; use crate::objects::connection::Connection; use crate::objects::page_info::PageInfo; +use crate::objects::transaction::TransactionEnum; +use std::vec::Vec; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct WalletToTransactionsConnection { diff --git a/lightspark/src/objects/webhook_event_type.rs b/lightspark/src/objects/webhook_event_type.rs index d52e934..e5242ea 100644 --- a/lightspark/src/objects/webhook_event_type.rs +++ b/lightspark/src/objects/webhook_event_type.rs @@ -44,6 +44,9 @@ pub enum WebhookEventType { #[serde(rename = "LOW_BALANCE")] LowBalance, + + #[serde(rename = "HIGH_BALANCE")] + HighBalance, } impl From for Value { @@ -68,6 +71,7 @@ impl fmt::Display for WebhookEventType { Self::WalletFundsReceived => write!(f, "WALLET_FUNDS_RECEIVED"), Self::RemoteSigning => write!(f, "REMOTE_SIGNING"), Self::LowBalance => write!(f, "LOW_BALANCE"), + Self::HighBalance => write!(f, "HIGH_BALANCE"), } } } diff --git a/lightspark/src/objects/withdrawal.rs b/lightspark/src/objects/withdrawal.rs index 2291c8b..3ad012b 100644 --- a/lightspark/src/objects/withdrawal.rs +++ b/lightspark/src/objects/withdrawal.rs @@ -43,7 +43,7 @@ pub struct Withdrawal { #[serde(rename = "withdrawal_transaction_hash")] pub transaction_hash: Option, - /// The fees that were paid by the wallet sending the transaction to commit it to the Bitcoin blockchain. + /// The fees that were paid by the node for this transaction. #[serde(rename = "withdrawal_fees")] pub fees: Option, @@ -73,7 +73,7 @@ pub struct Withdrawal { } impl OnChainTransaction for Withdrawal { - /// The fees that were paid by the wallet sending the transaction to commit it to the Bitcoin blockchain. + /// The fees that were paid by the node for this transaction. fn get_fees(&self) -> Option { self.fees.clone() } diff --git a/lightspark/src/objects/withdrawal_request.rs b/lightspark/src/objects/withdrawal_request.rs index 236b802..c4ace3c 100644 --- a/lightspark/src/objects/withdrawal_request.rs +++ b/lightspark/src/objects/withdrawal_request.rs @@ -6,6 +6,7 @@ use crate::objects::withdrawal_mode::WithdrawalMode; use crate::objects::withdrawal_request_status::WithdrawalRequestStatus; use crate::objects::withdrawal_request_to_channel_closing_transactions_connection::WithdrawalRequestToChannelClosingTransactionsConnection; use crate::objects::withdrawal_request_to_channel_opening_transactions_connection::WithdrawalRequestToChannelOpeningTransactionsConnection; +use crate::objects::withdrawal_request_to_withdrawals_connection::WithdrawalRequestToWithdrawalsConnection; use crate::types::custom_date_formats::custom_date_format; use crate::types::custom_date_formats::custom_date_format_option; use crate::types::entity_wrapper::EntityWrapper; @@ -43,10 +44,14 @@ pub struct WithdrawalRequest { #[serde(rename = "withdrawal_request_estimated_amount")] pub estimated_amount: Option, - /// The actual amount that is withdrawn. It will be set once the request is completed. + /// The actual amount that is withdrawn to the bitcoin address. It will be set once the request is completed. #[serde(rename = "withdrawal_request_amount_withdrawn")] pub amount_withdrawn: Option, + /// The total fees the node paid for the withdrawal. It will be set once the request is completed. + #[serde(rename = "withdrawal_request_total_fees")] + pub total_fees: Option, + /// The bitcoin address where the funds should be sent. #[serde(rename = "withdrawal_request_bitcoin_address")] pub bitcoin_address: String, @@ -70,6 +75,10 @@ pub struct WithdrawalRequest { #[serde(rename = "withdrawal_request_withdrawal")] pub withdrawal: Option, + /// The idempotency key of the withdrawal request. + #[serde(rename = "withdrawal_request_idempotency_key")] + pub idempotency_key: Option, + /// The typename of the object #[serde(rename = "__typename")] pub typename: String, @@ -152,6 +161,14 @@ fragment WithdrawalRequestFragment on WithdrawalRequest { currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } + withdrawal_request_total_fees: total_fees { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } withdrawal_request_bitcoin_address: bitcoin_address withdrawal_request_withdrawal_mode: withdrawal_mode withdrawal_request_status: status @@ -159,6 +176,7 @@ fragment WithdrawalRequestFragment on WithdrawalRequest { withdrawal_request_withdrawal: withdrawal { id } + withdrawal_request_idempotency_key: idempotency_key } "; @@ -167,12 +185,14 @@ impl WithdrawalRequest { &self, requester: &impl GraphQLRequester, first: Option, + after: Option, ) -> Result { - let query = "query FetchWithdrawalRequestToChannelClosingTransactionsConnection($entity_id: ID!, $first: Int) { + let query = "query FetchWithdrawalRequestToChannelClosingTransactionsConnection($entity_id: ID!, $first: Int, $after: String) { entity(id: $entity_id) { ... on WithdrawalRequest { - channel_closing_transactions(, first: $first) { + channel_closing_transactions(, first: $first, after: $after) { __typename + withdrawal_request_to_channel_closing_transactions_connection_count: count withdrawal_request_to_channel_closing_transactions_connection_page_info: page_info { __typename page_info_has_next_page: has_next_page @@ -180,7 +200,6 @@ impl WithdrawalRequest { page_info_start_cursor: start_cursor page_info_end_cursor: end_cursor } - withdrawal_request_to_channel_closing_transactions_connection_count: count withdrawal_request_to_channel_closing_transactions_connection_entities: entities { __typename channel_closing_transaction_id: id @@ -220,6 +239,7 @@ impl WithdrawalRequest { let mut variables: HashMap<&str, Value> = HashMap::new(); variables.insert("entity_id", self.id.clone().into()); variables.insert("first", first.into()); + variables.insert("after", after.into()); let value = serde_json::to_value(variables).map_err(Error::ConversionError)?; let result = requester.execute_graphql(query, Some(value)).await?; @@ -232,12 +252,14 @@ impl WithdrawalRequest { &self, requester: &impl GraphQLRequester, first: Option, + after: Option, ) -> Result { - let query = "query FetchWithdrawalRequestToChannelOpeningTransactionsConnection($entity_id: ID!, $first: Int) { + let query = "query FetchWithdrawalRequestToChannelOpeningTransactionsConnection($entity_id: ID!, $first: Int, $after: String) { entity(id: $entity_id) { ... on WithdrawalRequest { - channel_opening_transactions(, first: $first) { + channel_opening_transactions(, first: $first, after: $after) { __typename + withdrawal_request_to_channel_opening_transactions_connection_count: count withdrawal_request_to_channel_opening_transactions_connection_page_info: page_info { __typename page_info_has_next_page: has_next_page @@ -245,7 +267,6 @@ impl WithdrawalRequest { page_info_start_cursor: start_cursor page_info_end_cursor: end_cursor } - withdrawal_request_to_channel_opening_transactions_connection_count: count withdrawal_request_to_channel_opening_transactions_connection_entities: entities { __typename channel_opening_transaction_id: id @@ -285,6 +306,7 @@ impl WithdrawalRequest { let mut variables: HashMap<&str, Value> = HashMap::new(); variables.insert("entity_id", self.id.clone().into()); variables.insert("first", first.into()); + variables.insert("after", after.into()); let value = serde_json::to_value(variables).map_err(Error::ConversionError)?; let result = requester.execute_graphql(query, Some(value)).await?; @@ -292,4 +314,62 @@ impl WithdrawalRequest { let result = serde_json::from_value(json).map_err(Error::JsonError)?; Ok(result) } + + pub async fn get_withdrawals( + &self, + requester: &impl GraphQLRequester, + first: Option, + ) -> Result { + let query = "query FetchWithdrawalRequestToWithdrawalsConnection($entity_id: ID!, $first: Int) { + entity(id: $entity_id) { + ... on WithdrawalRequest { + withdrawals(, first: $first) { + __typename + withdrawal_request_to_withdrawals_connection_count: count + withdrawal_request_to_withdrawals_connection_entities: entities { + __typename + withdrawal_id: id + withdrawal_created_at: created_at + withdrawal_updated_at: updated_at + withdrawal_status: status + withdrawal_resolved_at: resolved_at + withdrawal_amount: amount { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + withdrawal_transaction_hash: transaction_hash + withdrawal_fees: fees { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + withdrawal_block_hash: block_hash + withdrawal_block_height: block_height + withdrawal_destination_addresses: destination_addresses + withdrawal_num_confirmations: num_confirmations + withdrawal_origin: origin { + id + } + } + } + } + } +}"; + let mut variables: HashMap<&str, Value> = HashMap::new(); + variables.insert("entity_id", self.id.clone().into()); + variables.insert("first", first.into()); + + let value = serde_json::to_value(variables).map_err(Error::ConversionError)?; + let result = requester.execute_graphql(query, Some(value)).await?; + let json = result["entity"]["withdrawals"].clone(); + let result = serde_json::from_value(json).map_err(Error::JsonError)?; + Ok(result) + } } diff --git a/lightspark/src/objects/withdrawal_request_status.rs b/lightspark/src/objects/withdrawal_request_status.rs index 2728fc1..70c4cf9 100644 --- a/lightspark/src/objects/withdrawal_request_status.rs +++ b/lightspark/src/objects/withdrawal_request_status.rs @@ -6,6 +6,9 @@ use std::fmt; /// This is an enum of the potential statuses that a Withdrawal can take. #[derive(Debug, Clone, Deserialize, Serialize)] pub enum WithdrawalRequestStatus { + #[serde(rename = "CREATING")] + Creating, + #[serde(rename = "CREATED")] Created, @@ -17,6 +20,9 @@ pub enum WithdrawalRequestStatus { #[serde(rename = "SUCCESSFUL")] Successful, + + #[serde(rename = "PARTIALLY_SUCCESSFUL")] + PartiallySuccessful, } impl From for Value { @@ -28,10 +34,12 @@ impl From for Value { impl fmt::Display for WithdrawalRequestStatus { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { + Self::Creating => write!(f, "CREATING"), Self::Created => write!(f, "CREATED"), Self::Failed => write!(f, "FAILED"), Self::InProgress => write!(f, "IN_PROGRESS"), Self::Successful => write!(f, "SUCCESSFUL"), + Self::PartiallySuccessful => write!(f, "PARTIALLY_SUCCESSFUL"), } } } diff --git a/lightspark/src/objects/withdrawal_request_to_channel_closing_transactions_connection.rs b/lightspark/src/objects/withdrawal_request_to_channel_closing_transactions_connection.rs index 3911eb6..4fdc6eb 100644 --- a/lightspark/src/objects/withdrawal_request_to_channel_closing_transactions_connection.rs +++ b/lightspark/src/objects/withdrawal_request_to_channel_closing_transactions_connection.rs @@ -1,27 +1,49 @@ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use crate::objects::channel_closing_transaction::ChannelClosingTransaction; +use crate::objects::connection::Connection; use crate::objects::page_info::PageInfo; use serde::{Deserialize, Serialize}; use std::vec::Vec; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct WithdrawalRequestToChannelClosingTransactionsConnection { - /// An object that holds pagination information about the objects in this connection. - #[serde(rename = "withdrawal_request_to_channel_closing_transactions_connection_page_info")] - pub page_info: PageInfo, - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). #[serde(rename = "withdrawal_request_to_channel_closing_transactions_connection_count")] pub count: i64, + /// An object that holds pagination information about the objects in this connection. + #[serde(rename = "withdrawal_request_to_channel_closing_transactions_connection_page_info")] + pub page_info: PageInfo, + /// The channel closing transactions for the current page of this connection. #[serde(rename = "withdrawal_request_to_channel_closing_transactions_connection_entities")] pub entities: Vec, + + /// The typename of the object + #[serde(rename = "__typename")] + pub typename: String, +} + +impl Connection for WithdrawalRequestToChannelClosingTransactionsConnection { + /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). + fn get_count(&self) -> i64 { + self.count + } + + /// An object that holds pagination information about the objects in this connection. + fn get_page_info(&self) -> PageInfo { + self.page_info.clone() + } + + fn type_name(&self) -> &'static str { + "WithdrawalRequestToChannelClosingTransactionsConnection" + } } pub const FRAGMENT: &str = " fragment WithdrawalRequestToChannelClosingTransactionsConnectionFragment on WithdrawalRequestToChannelClosingTransactionsConnection { __typename + withdrawal_request_to_channel_closing_transactions_connection_count: count withdrawal_request_to_channel_closing_transactions_connection_page_info: page_info { __typename page_info_has_next_page: has_next_page @@ -29,7 +51,6 @@ fragment WithdrawalRequestToChannelClosingTransactionsConnectionFragment on With page_info_start_cursor: start_cursor page_info_end_cursor: end_cursor } - withdrawal_request_to_channel_closing_transactions_connection_count: count withdrawal_request_to_channel_closing_transactions_connection_entities: entities { id } diff --git a/lightspark/src/objects/withdrawal_request_to_channel_opening_transactions_connection.rs b/lightspark/src/objects/withdrawal_request_to_channel_opening_transactions_connection.rs index c9e9716..63ab6e8 100644 --- a/lightspark/src/objects/withdrawal_request_to_channel_opening_transactions_connection.rs +++ b/lightspark/src/objects/withdrawal_request_to_channel_opening_transactions_connection.rs @@ -1,27 +1,49 @@ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use crate::objects::channel_opening_transaction::ChannelOpeningTransaction; +use crate::objects::connection::Connection; use crate::objects::page_info::PageInfo; use serde::{Deserialize, Serialize}; use std::vec::Vec; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct WithdrawalRequestToChannelOpeningTransactionsConnection { - /// An object that holds pagination information about the objects in this connection. - #[serde(rename = "withdrawal_request_to_channel_opening_transactions_connection_page_info")] - pub page_info: PageInfo, - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). #[serde(rename = "withdrawal_request_to_channel_opening_transactions_connection_count")] pub count: i64, + /// An object that holds pagination information about the objects in this connection. + #[serde(rename = "withdrawal_request_to_channel_opening_transactions_connection_page_info")] + pub page_info: PageInfo, + /// The channel opening transactions for the current page of this connection. #[serde(rename = "withdrawal_request_to_channel_opening_transactions_connection_entities")] pub entities: Vec, + + /// The typename of the object + #[serde(rename = "__typename")] + pub typename: String, +} + +impl Connection for WithdrawalRequestToChannelOpeningTransactionsConnection { + /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). + fn get_count(&self) -> i64 { + self.count + } + + /// An object that holds pagination information about the objects in this connection. + fn get_page_info(&self) -> PageInfo { + self.page_info.clone() + } + + fn type_name(&self) -> &'static str { + "WithdrawalRequestToChannelOpeningTransactionsConnection" + } } pub const FRAGMENT: &str = " fragment WithdrawalRequestToChannelOpeningTransactionsConnectionFragment on WithdrawalRequestToChannelOpeningTransactionsConnection { __typename + withdrawal_request_to_channel_opening_transactions_connection_count: count withdrawal_request_to_channel_opening_transactions_connection_page_info: page_info { __typename page_info_has_next_page: has_next_page @@ -29,7 +51,6 @@ fragment WithdrawalRequestToChannelOpeningTransactionsConnectionFragment on With page_info_start_cursor: start_cursor page_info_end_cursor: end_cursor } - withdrawal_request_to_channel_opening_transactions_connection_count: count withdrawal_request_to_channel_opening_transactions_connection_entities: entities { id } diff --git a/lightspark/src/objects/withdrawal_request_to_withdrawals_connection.rs b/lightspark/src/objects/withdrawal_request_to_withdrawals_connection.rs new file mode 100644 index 0000000..e0349f3 --- /dev/null +++ b/lightspark/src/objects/withdrawal_request_to_withdrawals_connection.rs @@ -0,0 +1,25 @@ +// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::objects::withdrawal::Withdrawal; +use serde::{Deserialize, Serialize}; +use std::vec::Vec; + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct WithdrawalRequestToWithdrawalsConnection { + /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). + #[serde(rename = "withdrawal_request_to_withdrawals_connection_count")] + pub count: i64, + + /// The withdrawals for the current page of this connection. + #[serde(rename = "withdrawal_request_to_withdrawals_connection_entities")] + pub entities: Vec, +} + +pub const FRAGMENT: &str = " +fragment WithdrawalRequestToWithdrawalsConnectionFragment on WithdrawalRequestToWithdrawalsConnection { + __typename + withdrawal_request_to_withdrawals_connection_count: count + withdrawal_request_to_withdrawals_connection_entities: entities { + id + } +} +"; diff --git a/lightspark/src/request/requester.rs b/lightspark/src/request/requester.rs index c543698..3e93e45 100644 --- a/lightspark/src/request/requester.rs +++ b/lightspark/src/request/requester.rs @@ -172,7 +172,7 @@ impl Requester { if let Some(key) = signing_key { let signing = key - .sign_payload(&json_string.as_bytes()) + .sign_payload(json_string.as_bytes()) .map_err(Error::CryptoError)?; headers.insert( "X-Lightspark-Signing",