diff --git a/lightspark/src/client.rs b/lightspark/src/client.rs index 8f81ebc..9ec2528 100644 --- a/lightspark/src/client.rs +++ b/lightspark/src/client.rs @@ -470,11 +470,10 @@ impl LightsparkClient { } fn get_node_signing_key(&self, node_id: &str) -> Result { - return self - .signing_keys + self.signing_keys .get(node_id) .cloned() - .ok_or(Error::SigningKeyNotFound); + .ok_or(Error::SigningKeyNotFound) } pub async fn get_decoded_payment_request( diff --git a/lightspark/src/objects/account.rs b/lightspark/src/objects/account.rs index 163b841..eb32bcf 100644 --- a/lightspark/src/objects/account.rs +++ b/lightspark/src/objects/account.rs @@ -10,6 +10,7 @@ use crate::objects::account_to_withdrawal_requests_connection::AccountToWithdraw use crate::objects::bitcoin_network::BitcoinNetwork; use crate::objects::blockchain_balance::BlockchainBalance; use crate::objects::currency_amount::CurrencyAmount; +use crate::objects::currency_amount_input::CurrencyAmountInput; use crate::objects::entity::Entity; use crate::objects::lightspark_node_owner::LightsparkNodeOwner; use crate::objects::transaction_failures::TransactionFailures; @@ -807,11 +808,13 @@ impl Account { lightning_node_id: Option, statuses: Option>, exclude_failures: Option, + max_amount: Option, + min_amount: Option, ) -> Result { - let query = "query FetchAccountToTransactionsConnection($entity_id: ID!, $first: Int, $after: String, $types: [TransactionType!], $after_date: DateTime, $before_date: DateTime, $bitcoin_network: BitcoinNetwork, $lightning_node_id: ID, $statuses: [TransactionStatus!], $exclude_failures: TransactionFailures) { + let query = "query FetchAccountToTransactionsConnection($entity_id: ID!, $first: Int, $after: String, $types: [TransactionType!], $after_date: DateTime, $before_date: DateTime, $bitcoin_network: BitcoinNetwork, $lightning_node_id: ID, $statuses: [TransactionStatus!], $exclude_failures: TransactionFailures, $max_amount: CurrencyAmountInput, $min_amount: CurrencyAmountInput) { entity(id: $entity_id) { ... on Account { - transactions(, first: $first, after: $after, types: $types, after_date: $after_date, before_date: $before_date, bitcoin_network: $bitcoin_network, lightning_node_id: $lightning_node_id, statuses: $statuses, exclude_failures: $exclude_failures) { + transactions(, first: $first, after: $after, types: $types, after_date: $after_date, before_date: $before_date, bitcoin_network: $bitcoin_network, lightning_node_id: $lightning_node_id, statuses: $statuses, exclude_failures: $exclude_failures, max_amount: $max_amount, min_amount: $min_amount) { __typename account_to_transactions_connection_count: count account_to_transactions_connection_page_info: page_info { @@ -1413,6 +1416,14 @@ impl Account { "exclude_failures", serde_json::to_value(&exclude_failures).map_err(Error::ConversionError)?, ); + variables.insert( + "max_amount", + serde_json::to_value(&max_amount).map_err(Error::ConversionError)?, + ); + variables.insert( + "min_amount", + serde_json::to_value(&min_amount).map_err(Error::ConversionError)?, + ); let value = serde_json::to_value(variables).map_err(Error::ConversionError)?; let result = requester.execute_graphql(query, Some(value)).await?; @@ -1431,11 +1442,13 @@ impl Account { before_date: Option>, bitcoin_network: Option, lightning_node_id: Option, + max_amount: Option, + min_amount: Option, ) -> Result { - let query = "query FetchAccountToPaymentRequestsConnection($entity_id: ID!, $first: Int, $after: String, $after_date: DateTime, $before_date: DateTime, $bitcoin_network: BitcoinNetwork, $lightning_node_id: ID) { + let query = "query FetchAccountToPaymentRequestsConnection($entity_id: ID!, $first: Int, $after: String, $after_date: DateTime, $before_date: DateTime, $bitcoin_network: BitcoinNetwork, $lightning_node_id: ID, $max_amount: CurrencyAmountInput, $min_amount: CurrencyAmountInput) { entity(id: $entity_id) { ... on Account { - payment_requests(, first: $first, after: $after, after_date: $after_date, before_date: $before_date, bitcoin_network: $bitcoin_network, lightning_node_id: $lightning_node_id) { + payment_requests(, first: $first, after: $after, after_date: $after_date, before_date: $before_date, bitcoin_network: $bitcoin_network, lightning_node_id: $lightning_node_id, max_amount: $max_amount, min_amount: $min_amount) { __typename account_to_payment_requests_connection_count: count account_to_payment_requests_connection_page_info: page_info { @@ -1768,6 +1781,14 @@ impl Account { variables.insert("before_date", before_date.map(|dt| dt.to_rfc3339()).into()); variables.insert("bitcoin_network", bitcoin_network.into()); variables.insert("lightning_node_id", lightning_node_id.into()); + variables.insert( + "max_amount", + serde_json::to_value(&max_amount).map_err(Error::ConversionError)?, + ); + variables.insert( + "min_amount", + serde_json::to_value(&min_amount).map_err(Error::ConversionError)?, + ); let value = serde_json::to_value(variables).map_err(Error::ConversionError)?; let result = requester.execute_graphql(query, Some(value)).await?; @@ -1788,11 +1809,13 @@ impl Account { idempotency_keys: Option>, after_date: Option>, before_date: Option>, + max_amount: Option, + min_amount: Option, ) -> Result { - 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) { + 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, $max_amount: CurrencyAmountInput, $min_amount: CurrencyAmountInput) { entity(id: $entity_id) { ... on Account { - 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) { + 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, max_amount: $max_amount, min_amount: $min_amount) { __typename account_to_withdrawal_requests_connection_count: count account_to_withdrawal_requests_connection_page_info: page_info { @@ -1871,6 +1894,14 @@ impl Account { 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()); + variables.insert( + "max_amount", + serde_json::to_value(&max_amount).map_err(Error::ConversionError)?, + ); + variables.insert( + "min_amount", + serde_json::to_value(&min_amount).map_err(Error::ConversionError)?, + ); 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/create_test_mode_invoice_input.rs b/lightspark/src/objects/create_test_mode_invoice_input.rs index 4f6cbdb..7563235 100644 --- a/lightspark/src/objects/create_test_mode_invoice_input.rs +++ b/lightspark/src/objects/create_test_mode_invoice_input.rs @@ -4,11 +4,15 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct CreateTestModeInvoiceInput { + /// The local node from which to create the invoice. pub local_node_id: String, + /// 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, + /// An optional memo to include in the invoice. pub memo: Option, + /// The type of invoice to create. pub invoice_type: Option, } diff --git a/lightspark/src/objects/currency_amount_input.rs b/lightspark/src/objects/currency_amount_input.rs new file mode 100644 index 0000000..7bcd025 --- /dev/null +++ b/lightspark/src/objects/currency_amount_input.rs @@ -0,0 +1,10 @@ +// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::objects::currency_unit::CurrencyUnit; +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct CurrencyAmountInput { + pub value: i64, + + pub unit: CurrencyUnit, +} diff --git a/lightspark/src/objects/mod.rs b/lightspark/src/objects/mod.rs index c8e4320..0877467 100644 --- a/lightspark/src/objects/mod.rs +++ b/lightspark/src/objects/mod.rs @@ -45,6 +45,7 @@ pub mod create_uma_invitation_input; pub mod create_uma_invitation_output; pub mod create_uma_invoice_input; pub mod currency_amount; +pub mod currency_amount_input; pub mod currency_unit; pub mod daily_liquidity_forecast; pub mod decline_to_sign_messages_input; @@ -110,6 +111,7 @@ pub mod outgoing_payments_for_payment_hash_query_output; pub mod page_info; pub mod pay_invoice_input; pub mod pay_invoice_output; +pub mod pay_test_mode_invoice_input; pub mod pay_uma_invoice_input; pub mod payment_direction; pub mod payment_failure_reason; diff --git a/lightspark/src/objects/pay_test_mode_invoice_input.rs b/lightspark/src/objects/pay_test_mode_invoice_input.rs new file mode 100644 index 0000000..8192587 --- /dev/null +++ b/lightspark/src/objects/pay_test_mode_invoice_input.rs @@ -0,0 +1,27 @@ +// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::objects::payment_failure_reason::PaymentFailureReason; +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct PayTestModeInvoiceInput { + /// The node from where you want to send the payment. + pub node_id: String, + + /// The invoice you want to pay (as defined by the BOLT11 standard). + pub encoded_invoice: String, + + /// The timeout in seconds that we will try to make the payment. + pub timeout_secs: i64, + + /// 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 failure reason to trigger for the payment. If not set, pay_invoice will be called. + pub failure_reason: Option, + + /// 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, +}