Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions lightspark/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,11 +470,10 @@ impl<K: OperationSigningKey> LightsparkClient<K> {
}

fn get_node_signing_key(&self, node_id: &str) -> Result<K, Error> {
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(
Expand Down
43 changes: 37 additions & 6 deletions lightspark/src/objects/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -807,11 +808,13 @@ impl Account {
lightning_node_id: Option<String>,
statuses: Option<Vec<TransactionStatus>>,
exclude_failures: Option<TransactionFailures>,
max_amount: Option<CurrencyAmountInput>,
min_amount: Option<CurrencyAmountInput>,
) -> Result<AccountToTransactionsConnection, Error> {
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) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a syntax error in the GraphQL query - an extra comma appears after transactions(. The comma should be removed to make this valid GraphQL syntax.

Spotted by Graphite Reviewer

Is this helpful? React 👍 or 👎 to let us know.

__typename
account_to_transactions_connection_count: count
account_to_transactions_connection_page_info: page_info {
Expand Down Expand Up @@ -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?;
Expand All @@ -1431,11 +1442,13 @@ impl Account {
before_date: Option<DateTime<Utc>>,
bitcoin_network: Option<BitcoinNetwork>,
lightning_node_id: Option<String>,
max_amount: Option<CurrencyAmountInput>,
min_amount: Option<CurrencyAmountInput>,
) -> Result<AccountToPaymentRequestsConnection, Error> {
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 {
Expand Down Expand Up @@ -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?;
Expand All @@ -1788,11 +1809,13 @@ impl Account {
idempotency_keys: Option<Vec<String>>,
after_date: Option<DateTime<Utc>>,
before_date: Option<DateTime<Utc>>,
max_amount: Option<CurrencyAmountInput>,
min_amount: Option<CurrencyAmountInput>,
) -> Result<AccountToWithdrawalRequestsConnection, Error> {
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 {
Expand Down Expand Up @@ -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?;
Expand Down
4 changes: 4 additions & 0 deletions lightspark/src/objects/create_test_mode_invoice_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,

/// The type of invoice to create.
pub invoice_type: Option<InvoiceType>,
}
10 changes: 10 additions & 0 deletions lightspark/src/objects/currency_amount_input.rs
Original file line number Diff line number Diff line change
@@ -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,
}
2 changes: 2 additions & 0 deletions lightspark/src/objects/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
27 changes: 27 additions & 0 deletions lightspark/src/objects/pay_test_mode_invoice_input.rs
Original file line number Diff line number Diff line change
@@ -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<PaymentFailureReason>,

/// 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<i64>,

/// The idempotency key of the request. The same result will be returned for the same idempotency key.
pub idempotency_key: Option<String>,
}
Loading