diff --git a/lightspark-remote-signing/src/handler.rs b/lightspark-remote-signing/src/handler.rs index f87cc73..72fb969 100644 --- a/lightspark-remote-signing/src/handler.rs +++ b/lightspark-remote-signing/src/handler.rs @@ -62,7 +62,7 @@ impl Handler { SigningRequest::ReleaseCounterpartyPerCommitmentSecretRequest(_) => None, }; - Ok(response.map(|r| Some(r.graphql_response())).flatten()) + Ok(response.map(|r| r.graphql_response())) } } diff --git a/lightspark/src/objects/account.rs b/lightspark/src/objects/account.rs index a6d8366..163b841 100644 --- a/lightspark/src/objects/account.rs +++ b/lightspark/src/objects/account.rs @@ -1752,6 +1752,8 @@ impl Account { currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } + invoice_is_uma: is_uma + invoice_is_lnurl: is_lnurl } } } diff --git a/lightspark/src/objects/account_to_nodes_connection.rs b/lightspark/src/objects/account_to_nodes_connection.rs index fbcba0e..f627e8a 100644 --- a/lightspark/src/objects/account_to_nodes_connection.rs +++ b/lightspark/src/objects/account_to_nodes_connection.rs @@ -1,11 +1,10 @@ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +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; -use crate::objects::connection::Connection; - /// A connection between an account and the nodes it manages. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct AccountToNodesConnection { diff --git a/lightspark/src/objects/account_to_payment_requests_connection.rs b/lightspark/src/objects/account_to_payment_requests_connection.rs index b61bf12..d43c3c9 100644 --- a/lightspark/src/objects/account_to_payment_requests_connection.rs +++ b/lightspark/src/objects/account_to_payment_requests_connection.rs @@ -1,9 +1,8 @@ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::objects::connection::Connection; use crate::objects::page_info::PageInfo; use crate::objects::payment_request::PaymentRequestEnum; use serde::{Deserialize, Serialize}; - -use crate::objects::connection::Connection; use std::vec::Vec; #[derive(Debug, Clone, Deserialize, Serialize)] diff --git a/lightspark/src/objects/account_to_transactions_connection.rs b/lightspark/src/objects/account_to_transactions_connection.rs index 9b8acc6..3e1416d 100644 --- a/lightspark/src/objects/account_to_transactions_connection.rs +++ b/lightspark/src/objects/account_to_transactions_connection.rs @@ -1,10 +1,9 @@ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::objects::connection::Connection; use crate::objects::currency_amount::CurrencyAmount; use crate::objects::page_info::PageInfo; use crate::objects::transaction::TransactionEnum; use serde::{Deserialize, Serialize}; - -use crate::objects::connection::Connection; use std::vec::Vec; #[derive(Debug, Clone, Deserialize, Serialize)] diff --git a/lightspark/src/objects/create_uma_invoice_input.rs b/lightspark/src/objects/create_uma_invoice_input.rs index fffbd9f..d00eacb 100644 --- a/lightspark/src/objects/create_uma_invoice_input.rs +++ b/lightspark/src/objects/create_uma_invoice_input.rs @@ -3,13 +3,18 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct CreateUmaInvoiceInput { + /// The node from which to create the invoice. pub node_id: String, + /// The amount for which the invoice should be created, in millisatoshis. pub amount_msats: i64, + /// The SHA256 hash of the UMA metadata payload. This will be present in the h-tag (SHA256 purpose of payment) of the resulting Bolt 11 invoice. pub metadata_hash: String, + /// The expiry of the invoice in seconds. Default value is 86400 (1 day). pub expiry_secs: Option, + /// An optional, monthly-rotated, unique hashed identifier corresponding to the receiver of the payment. pub receiver_hash: Option, } diff --git a/lightspark/src/objects/currency_unit.rs b/lightspark/src/objects/currency_unit.rs index 8ade2bc..5c96fd5 100644 --- a/lightspark/src/objects/currency_unit.rs +++ b/lightspark/src/objects/currency_unit.rs @@ -22,6 +22,10 @@ pub enum CurrencyUnit { #[serde(rename = "USD")] Usd, + /// Mexican Peso. + + #[serde(rename = "MXN")] + Mxn, /// 0.000000001 (10e-9) Bitcoin or a billionth of a Bitcoin. We recommend using the Satoshi unit instead when possible. #[serde(rename = "NANOBITCOIN")] @@ -49,6 +53,7 @@ impl fmt::Display for CurrencyUnit { Self::Satoshi => write!(f, "SATOSHI"), Self::Millisatoshi => write!(f, "MILLISATOSHI"), Self::Usd => write!(f, "USD"), + Self::Mxn => write!(f, "MXN"), Self::Nanobitcoin => write!(f, "NANOBITCOIN"), Self::Microbitcoin => write!(f, "MICROBITCOIN"), Self::Millibitcoin => write!(f, "MILLIBITCOIN"), diff --git a/lightspark/src/objects/fund_node_input.rs b/lightspark/src/objects/fund_node_input.rs index a9e4443..5c4ed5f 100644 --- a/lightspark/src/objects/fund_node_input.rs +++ b/lightspark/src/objects/fund_node_input.rs @@ -6,4 +6,6 @@ pub struct FundNodeInput { pub node_id: String, pub amount_sats: Option, + + pub funding_address: Option, } diff --git a/lightspark/src/objects/incoming_payments_for_payment_hash_query_input.rs b/lightspark/src/objects/incoming_payments_for_payment_hash_query_input.rs new file mode 100644 index 0000000..0fdb899 --- /dev/null +++ b/lightspark/src/objects/incoming_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 IncomingPaymentsForPaymentHashQueryInput { + /// The 32-byte hash of the payment preimage for which to fetch payments + pub payment_hash: String, + + /// An optional filter to only query incoming payments of given statuses. + pub statuses: Option>, +} diff --git a/lightspark/src/objects/incoming_payments_for_payment_hash_query_output.rs b/lightspark/src/objects/incoming_payments_for_payment_hash_query_output.rs new file mode 100644 index 0000000..7993c76 --- /dev/null +++ b/lightspark/src/objects/incoming_payments_for_payment_hash_query_output.rs @@ -0,0 +1,19 @@ +// 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 IncomingPaymentsForPaymentHashQueryOutput { + #[serde(rename = "incoming_payments_for_payment_hash_query_output_payments")] + pub payments: Vec, +} + +pub const FRAGMENT: &str = " +fragment IncomingPaymentsForPaymentHashQueryOutputFragment on IncomingPaymentsForPaymentHashQueryOutput { + __typename + incoming_payments_for_payment_hash_query_output_payments: payments { + id + } +} +"; diff --git a/lightspark/src/objects/invoice.rs b/lightspark/src/objects/invoice.rs index 0fcc672..fd80bef 100644 --- a/lightspark/src/objects/invoice.rs +++ b/lightspark/src/objects/invoice.rs @@ -37,6 +37,14 @@ pub struct Invoice { #[serde(rename = "invoice_amount_paid")] pub amount_paid: Option, + /// Whether this invoice is an UMA invoice or not. NOTE: this field is only set if the invoice was created using the recommended `create_uma_invoice` function. + #[serde(rename = "invoice_is_uma")] + pub is_uma: Option, + + /// Whether this invoice is an LNURL invoice or not. NOTE: this field is only set if the invoice was created using the recommended `create_lnurl_invoice` function. + #[serde(rename = "invoice_is_lnurl")] + pub is_lnurl: Option, + /// The typename of the object #[serde(rename = "__typename")] pub typename: String, @@ -403,5 +411,7 @@ fragment InvoiceFragment on Invoice { currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } + invoice_is_uma: is_uma + invoice_is_lnurl: is_lnurl } "; diff --git a/lightspark/src/objects/invoice_data.rs b/lightspark/src/objects/invoice_data.rs index a4063c0..d906ccf 100644 --- a/lightspark/src/objects/invoice_data.rs +++ b/lightspark/src/objects/invoice_data.rs @@ -4,9 +4,8 @@ use crate::objects::currency_amount::CurrencyAmount; use crate::objects::node::NodeEnum; use crate::objects::payment_request_data::PaymentRequestData; use crate::types::custom_date_formats::custom_date_format; -use serde::{Deserialize, Serialize}; - use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; /// 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/lightspark_node.rs b/lightspark/src/objects/lightspark_node.rs index 6a19bbe..5721546 100644 --- a/lightspark/src/objects/lightspark_node.rs +++ b/lightspark/src/objects/lightspark_node.rs @@ -1,16 +1,15 @@ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use super::lightspark_node_with_o_s_k::LightsparkNodeWithOSK; -use crate::objects::balances::Balances; -use crate::objects::entity::Entity; -use crate::objects::node::Node; -use serde_json::Value; - 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::entity::Entity; use crate::objects::lightspark_node_status::LightsparkNodeStatus; +use crate::objects::node::Node; use crate::types::entity_wrapper::EntityWrapper; use serde::{Deserialize, Deserializer, Serialize}; +use serde_json::Value; use std::vec::Vec; pub trait LightsparkNode: Node + Entity { 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 89c88ed..19e51b2 100644 --- a/lightspark/src/objects/lightspark_node_with_o_s_k.rs +++ b/lightspark/src/objects/lightspark_node_with_o_s_k.rs @@ -1,4 +1,5 @@ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::error::Error; use crate::objects::balances::Balances; use crate::objects::bitcoin_network::BitcoinNetwork; use crate::objects::blockchain_balance::BlockchainBalance; @@ -10,6 +11,7 @@ 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::Node; use crate::objects::node_address_type::NodeAddressType; use crate::objects::node_to_addresses_connection::NodeToAddressesConnection; use crate::objects::secret::Secret; @@ -24,9 +26,6 @@ use serde_json::Value; use std::collections::HashMap; use std::vec::Vec; -use crate::error::Error; -use crate::objects::node::Node; - /// This is a Lightspark node with OSK. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct LightsparkNodeWithOSK { diff --git a/lightspark/src/objects/lightspark_node_with_remote_signing.rs b/lightspark/src/objects/lightspark_node_with_remote_signing.rs index 30fe42f..346440b 100644 --- a/lightspark/src/objects/lightspark_node_with_remote_signing.rs +++ b/lightspark/src/objects/lightspark_node_with_remote_signing.rs @@ -1,4 +1,5 @@ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::error::Error; use crate::objects::balances::Balances; use crate::objects::bitcoin_network::BitcoinNetwork; use crate::objects::blockchain_balance::BlockchainBalance; @@ -10,6 +11,7 @@ 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::Node; use crate::objects::node_address_type::NodeAddressType; use crate::objects::node_to_addresses_connection::NodeToAddressesConnection; use crate::types::custom_date_formats::custom_date_format; @@ -23,9 +25,6 @@ use serde_json::Value; use std::collections::HashMap; use std::vec::Vec; -use crate::error::Error; -use crate::objects::node::Node; - /// This is a Lightspark node with remote signing. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct LightsparkNodeWithRemoteSigning { diff --git a/lightspark/src/objects/mod.rs b/lightspark/src/objects/mod.rs index 47610e7..c8e4320 100644 --- a/lightspark/src/objects/mod.rs +++ b/lightspark/src/objects/mod.rs @@ -70,6 +70,8 @@ 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 incoming_payments_for_payment_hash_query_input; +pub mod incoming_payments_for_payment_hash_query_output; pub mod invoice; pub mod invoice_data; pub mod invoice_for_payment_hash_input; diff --git a/lightspark/src/objects/outgoing_payment.rs b/lightspark/src/objects/outgoing_payment.rs index bf92593..a8d187a 100644 --- a/lightspark/src/objects/outgoing_payment.rs +++ b/lightspark/src/objects/outgoing_payment.rs @@ -1,11 +1,14 @@ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::error::Error; use crate::objects::currency_amount::CurrencyAmount; use crate::objects::entity::Entity; use crate::objects::lightning_transaction::LightningTransaction; use crate::objects::outgoing_payment_to_attempts_connection::OutgoingPaymentToAttemptsConnection; 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; use crate::types::custom_date_formats::custom_date_format_option; @@ -18,10 +21,6 @@ use serde_json::Value; use std::collections::HashMap; use std::vec::Vec; -use crate::error::Error; -use crate::objects::post_transaction_data::PostTransactionData; -use crate::objects::transaction::Transaction; - /// 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. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct OutgoingPayment { diff --git a/lightspark/src/objects/region_code.rs b/lightspark/src/objects/region_code.rs index 631dce4..4a34761 100644 --- a/lightspark/src/objects/region_code.rs +++ b/lightspark/src/objects/region_code.rs @@ -1002,6 +1002,10 @@ pub enum RegionCode { #[serde(rename = "ZW")] Zw, + /// The code representing a fake region for testing. + + #[serde(rename = "NN")] + Nn, } impl From for Value { @@ -1262,6 +1266,7 @@ impl fmt::Display for RegionCode { Self::Ye => write!(f, "YE"), Self::Zm => write!(f, "ZM"), Self::Zw => write!(f, "ZW"), + Self::Nn => write!(f, "NN"), } } } diff --git a/lightspark/src/objects/wallet.rs b/lightspark/src/objects/wallet.rs index 18b70c4..35bee3d 100644 --- a/lightspark/src/objects/wallet.rs +++ b/lightspark/src/objects/wallet.rs @@ -1078,6 +1078,8 @@ impl Wallet { currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } + invoice_is_uma: is_uma + invoice_is_lnurl: is_lnurl } } } diff --git a/lightspark/src/objects/wallet_to_payment_requests_connection.rs b/lightspark/src/objects/wallet_to_payment_requests_connection.rs index 6b91d17..2ed09ed 100644 --- a/lightspark/src/objects/wallet_to_payment_requests_connection.rs +++ b/lightspark/src/objects/wallet_to_payment_requests_connection.rs @@ -1,9 +1,8 @@ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::objects::connection::Connection; use crate::objects::page_info::PageInfo; use crate::objects::payment_request::PaymentRequestEnum; use serde::{Deserialize, Serialize}; - -use crate::objects::connection::Connection; use std::vec::Vec; #[derive(Debug, Clone, Deserialize, Serialize)] diff --git a/lightspark/src/objects/wallet_to_transactions_connection.rs b/lightspark/src/objects/wallet_to_transactions_connection.rs index 09d14b9..483e78b 100644 --- a/lightspark/src/objects/wallet_to_transactions_connection.rs +++ b/lightspark/src/objects/wallet_to_transactions_connection.rs @@ -1,9 +1,8 @@ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::objects::connection::Connection; use crate::objects::page_info::PageInfo; use crate::objects::transaction::TransactionEnum; use serde::{Deserialize, Serialize}; - -use crate::objects::connection::Connection; use std::vec::Vec; #[derive(Debug, Clone, Deserialize, Serialize)] diff --git a/lightspark/src/objects/webhook_event_type.rs b/lightspark/src/objects/webhook_event_type.rs index e5242ea..ba1dedb 100644 --- a/lightspark/src/objects/webhook_event_type.rs +++ b/lightspark/src/objects/webhook_event_type.rs @@ -47,6 +47,9 @@ pub enum WebhookEventType { #[serde(rename = "HIGH_BALANCE")] HighBalance, + + #[serde(rename = "CHANNEL_OPENING_FEES")] + ChannelOpeningFees, } impl From for Value { @@ -72,6 +75,7 @@ impl fmt::Display for WebhookEventType { Self::RemoteSigning => write!(f, "REMOTE_SIGNING"), Self::LowBalance => write!(f, "LOW_BALANCE"), Self::HighBalance => write!(f, "HIGH_BALANCE"), + Self::ChannelOpeningFees => write!(f, "CHANNEL_OPENING_FEES"), } } } diff --git a/lightspark/src/utils.rs b/lightspark/src/utils.rs index eef41bf..2b32f9f 100644 --- a/lightspark/src/utils.rs +++ b/lightspark/src/utils.rs @@ -8,6 +8,7 @@ pub fn value_millisatoshi(amount: &CurrencyAmount) -> Result { crate::objects::currency_unit::CurrencyUnit::Satoshi => Ok(amount.original_value * 1000), crate::objects::currency_unit::CurrencyUnit::Millisatoshi => Ok(amount.original_value), crate::objects::currency_unit::CurrencyUnit::Usd => Err(Error::InvalidCurrencyConversion), + crate::objects::currency_unit::CurrencyUnit::Mxn => Err(Error::InvalidCurrencyConversion), crate::objects::currency_unit::CurrencyUnit::Nanobitcoin => Ok(amount.original_value * 100), crate::objects::currency_unit::CurrencyUnit::Microbitcoin => { Ok(amount.original_value * 100_000)