use crate::error::Error;
use crate::objects::balances::Balances;
use crate::objects::currency_amount::CurrencyAmount;
use crate::objects::entity::Entity;
use crate::objects::lightspark_node_owner::LightsparkNodeOwner;
use crate::objects::transaction_status::TransactionStatus;
use crate::objects::transaction_type::TransactionType;
use crate::objects::wallet_status::WalletStatus;
use crate::objects::wallet_to_payment_requests_connection::WalletToPaymentRequestsConnection;
use crate::objects::wallet_to_transactions_connection::WalletToTransactionsConnection;
use crate::objects::wallet_to_withdrawal_requests_connection::WalletToWithdrawalRequestsConnection;
use crate::objects::withdrawal_request_status::WithdrawalRequestStatus;
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;
use crate::types::get_entity::GetEntity;
use crate::types::graphql_requester::GraphQLRequester;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::HashMap;
use std::vec::Vec;
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct Wallet {
#[serde(rename = "wallet_id")]
pub id: String,
#[serde(with = "custom_date_format", rename = "wallet_created_at")]
pub created_at: DateTime<Utc>,
#[serde(with = "custom_date_format", rename = "wallet_updated_at")]
pub updated_at: DateTime<Utc>,
#[serde(with = "custom_date_format_option", rename = "wallet_last_login_at")]
pub last_login_at: Option<DateTime<Utc>>,
#[serde(rename = "wallet_balances")]
pub balances: Option<Balances>,
#[serde(rename = "wallet_third_party_identifier")]
pub third_party_identifier: String,
#[serde(rename = "wallet_account")]
pub account: Option<EntityWrapper>,
#[serde(rename = "wallet_status")]
pub status: WalletStatus,
#[serde(rename = "__typename")]
pub typename: String,
}
impl LightsparkNodeOwner for Wallet {
fn type_name(&self) -> &'static str {
"Wallet"
}
}
impl Entity for Wallet {
fn get_id(&self) -> String {
self.id.clone()
}
fn get_created_at(&self) -> DateTime<Utc> {
self.created_at
}
fn get_updated_at(&self) -> DateTime<Utc> {
self.updated_at
}
fn type_name(&self) -> &'static str {
"Wallet"
}
}
impl GetEntity for Wallet {
fn get_entity_query() -> String {
format!(
"
query GetEntity($id: ID!) {{
entity(id: $id) {{
... on Wallet {{
... WalletFragment
}}
}}
}}
{}",
FRAGMENT
)
}
}
pub const FRAGMENT: &str = "
fragment WalletFragment on Wallet {
__typename
wallet_id: id
wallet_created_at: created_at
wallet_updated_at: updated_at
wallet_last_login_at: last_login_at
wallet_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
}
}
wallet_third_party_identifier: third_party_identifier
wallet_account: account {
id
}
wallet_status: status
}
";
impl Wallet {
#[allow(clippy::too_many_arguments)]
pub async fn get_transactions(
&self,
requester: &impl GraphQLRequester,
first: Option<i64>,
after: Option<String>,
created_after_date: Option<DateTime<Utc>>,
created_before_date: Option<DateTime<Utc>>,
statuses: Option<Vec<TransactionStatus>>,
types: Option<Vec<TransactionType>>,
) -> Result<WalletToTransactionsConnection, Error> {
let query = "query FetchWalletToTransactionsConnection($entity_id: ID!, $first: Int, $after: ID, $created_after_date: DateTime, $created_before_date: DateTime, $statuses: [TransactionStatus!], $types: [TransactionType!]) {
entity(id: $entity_id) {
... on Wallet {
transactions(, first: $first, after: $after, created_after_date: $created_after_date, created_before_date: $created_before_date, statuses: $statuses, types: $types) {
__typename
wallet_to_transactions_connection_count: count
wallet_to_transactions_connection_page_info: page_info {
__typename
page_info_has_next_page: has_next_page
page_info_has_previous_page: has_previous_page
page_info_start_cursor: start_cursor
page_info_end_cursor: end_cursor
}
wallet_to_transactions_connection_entities: entities {
__typename
... on ChannelClosingTransaction {
__typename
channel_closing_transaction_id: id
channel_closing_transaction_created_at: created_at
channel_closing_transaction_updated_at: updated_at
channel_closing_transaction_status: status
channel_closing_transaction_resolved_at: resolved_at
channel_closing_transaction_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
}
channel_closing_transaction_transaction_hash: transaction_hash
channel_closing_transaction_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
}
channel_closing_transaction_block_hash: block_hash
channel_closing_transaction_block_height: block_height
channel_closing_transaction_destination_addresses: destination_addresses
channel_closing_transaction_num_confirmations: num_confirmations
channel_closing_transaction_channel: channel {
id
}
}
... on ChannelOpeningTransaction {
__typename
channel_opening_transaction_id: id
channel_opening_transaction_created_at: created_at
channel_opening_transaction_updated_at: updated_at
channel_opening_transaction_status: status
channel_opening_transaction_resolved_at: resolved_at
channel_opening_transaction_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
}
channel_opening_transaction_transaction_hash: transaction_hash
channel_opening_transaction_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
}
channel_opening_transaction_block_hash: block_hash
channel_opening_transaction_block_height: block_height
channel_opening_transaction_destination_addresses: destination_addresses
channel_opening_transaction_num_confirmations: num_confirmations
channel_opening_transaction_channel: channel {
id
}
}
... on Deposit {
__typename
deposit_id: id
deposit_created_at: created_at
deposit_updated_at: updated_at
deposit_status: status
deposit_resolved_at: resolved_at
deposit_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
}
deposit_transaction_hash: transaction_hash
deposit_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
}
deposit_block_hash: block_hash
deposit_block_height: block_height
deposit_destination_addresses: destination_addresses
deposit_num_confirmations: num_confirmations
deposit_destination: destination {
id
}
}
... on IncomingPayment {
__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
}
... on OutgoingPayment {
__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
}
... on RoutingTransaction {
__typename
routing_transaction_id: id
routing_transaction_created_at: created_at
routing_transaction_updated_at: updated_at
routing_transaction_status: status
routing_transaction_resolved_at: resolved_at
routing_transaction_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
}
routing_transaction_transaction_hash: transaction_hash
routing_transaction_incoming_channel: incoming_channel {
id
}
routing_transaction_outgoing_channel: outgoing_channel {
id
}
routing_transaction_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
}
routing_transaction_failure_message: failure_message {
__typename
rich_text_text: text
}
routing_transaction_failure_reason: failure_reason
}
... on Withdrawal {
__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());
variables.insert("after", after.into());
variables.insert(
"created_after_date",
created_after_date.map(|dt| dt.to_rfc3339()).into(),
);
variables.insert(
"created_before_date",
created_before_date.map(|dt| dt.to_rfc3339()).into(),
);
variables.insert("statuses", statuses.into());
variables.insert("types", types.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"]["transactions"].clone();
let result = serde_json::from_value(json).map_err(Error::JsonError)?;
Ok(result)
}
pub async fn get_payment_requests(
&self,
requester: &impl GraphQLRequester,
first: Option<i64>,
after: Option<String>,
created_after_date: Option<DateTime<Utc>>,
created_before_date: Option<DateTime<Utc>>,
) -> Result<WalletToPaymentRequestsConnection, Error> {
let query = "query FetchWalletToPaymentRequestsConnection($entity_id: ID!, $first: Int, $after: ID, $created_after_date: DateTime, $created_before_date: DateTime) {
entity(id: $entity_id) {
... on Wallet {
payment_requests(, first: $first, after: $after, created_after_date: $created_after_date, created_before_date: $created_before_date) {
__typename
wallet_to_payment_requests_connection_count: count
wallet_to_payment_requests_connection_page_info: page_info {
__typename
page_info_has_next_page: has_next_page
page_info_has_previous_page: has_previous_page
page_info_start_cursor: start_cursor
page_info_end_cursor: end_cursor
}
wallet_to_payment_requests_connection_entities: entities {
__typename
... on Invoice {
__typename
invoice_id: id
invoice_created_at: created_at
invoice_updated_at: updated_at
invoice_data: data {
__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
}
}
}
}
}
invoice_status: status
invoice_amount_paid: amount_paid {
__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_is_uma: is_uma
invoice_is_lnurl: is_lnurl
}
}
}
}
}
}";
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());
variables.insert(
"created_after_date",
created_after_date.map(|dt| dt.to_rfc3339()).into(),
);
variables.insert(
"created_before_date",
created_before_date.map(|dt| dt.to_rfc3339()).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"]["payment_requests"].clone();
let result = serde_json::from_value(json).map_err(Error::JsonError)?;
Ok(result)
}
pub async fn get_total_amount_received(
&self,
requester: &impl GraphQLRequester,
created_after_date: Option<DateTime<Utc>>,
created_before_date: Option<DateTime<Utc>>,
) -> Result<CurrencyAmount, Error> {
let query = "query FetchWalletTotalAmountReceived($entity_id: ID!, $created_after_date: DateTime, $created_before_date: DateTime) {
entity(id: $entity_id) {
... on Wallet {
total_amount_received(, created_after_date: $created_after_date, created_before_date: $created_before_date) {
__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
}
}
}
}";
let mut variables: HashMap<&str, Value> = HashMap::new();
variables.insert("entity_id", self.id.clone().into());
variables.insert(
"created_after_date",
created_after_date.map(|dt| dt.to_rfc3339()).into(),
);
variables.insert(
"created_before_date",
created_before_date.map(|dt| dt.to_rfc3339()).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"]["total_amount_received"].clone();
let result = serde_json::from_value(json).map_err(Error::JsonError)?;
Ok(result)
}
pub async fn get_withdrawal_requests(
&self,
requester: &impl GraphQLRequester,
first: Option<i64>,
after: Option<String>,
statuses: Option<Vec<WithdrawalRequestStatus>>,
created_after_date: Option<DateTime<Utc>>,
created_before_date: Option<DateTime<Utc>>,
) -> Result<WalletToWithdrawalRequestsConnection, Error> {
let query = "query FetchWalletToWithdrawalRequestsConnection($entity_id: ID!, $first: Int, $after: ID, $statuses: [WithdrawalRequestStatus!], $created_after_date: DateTime, $created_before_date: DateTime) {
entity(id: $entity_id) {
... on Wallet {
withdrawal_requests(, first: $first, after: $after, statuses: $statuses, created_after_date: $created_after_date, created_before_date: $created_before_date) {
__typename
wallet_to_withdrawal_requests_connection_count: count
wallet_to_withdrawal_requests_connection_page_info: page_info {
__typename
page_info_has_next_page: has_next_page
page_info_has_previous_page: has_previous_page
page_info_start_cursor: start_cursor
page_info_end_cursor: end_cursor
}
wallet_to_withdrawal_requests_connection_entities: entities {
__typename
withdrawal_request_id: id
withdrawal_request_created_at: created_at
withdrawal_request_updated_at: updated_at
withdrawal_request_requested_amount: requested_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_request_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_request_estimated_amount: estimated_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_request_amount_withdrawn: amount_withdrawn {
__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_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
withdrawal_request_completed_at: completed_at
withdrawal_request_withdrawal: withdrawal {
id
}
withdrawal_request_idempotency_key: idempotency_key
withdrawal_request_initiator: initiator
}
}
}
}
}";
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());
variables.insert("statuses", statuses.into());
variables.insert(
"created_after_date",
created_after_date.map(|dt| dt.to_rfc3339()).into(),
);
variables.insert(
"created_before_date",
created_before_date.map(|dt| dt.to_rfc3339()).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"]["withdrawal_requests"].clone();
let result = serde_json::from_value(json).map_err(Error::JsonError)?;
Ok(result)
}
pub async fn get_total_amount_sent(
&self,
requester: &impl GraphQLRequester,
created_after_date: Option<DateTime<Utc>>,
created_before_date: Option<DateTime<Utc>>,
) -> Result<CurrencyAmount, Error> {
let query = "query FetchWalletTotalAmountSent($entity_id: ID!, $created_after_date: DateTime, $created_before_date: DateTime) {
entity(id: $entity_id) {
... on Wallet {
total_amount_sent(, created_after_date: $created_after_date, created_before_date: $created_before_date) {
__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
}
}
}
}";
let mut variables: HashMap<&str, Value> = HashMap::new();
variables.insert("entity_id", self.id.clone().into());
variables.insert(
"created_after_date",
created_after_date.map(|dt| dt.to_rfc3339()).into(),
);
variables.insert(
"created_before_date",
created_before_date.map(|dt| dt.to_rfc3339()).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"]["total_amount_sent"].clone();
let result = serde_json::from_value(json).map_err(Error::JsonError)?;
Ok(result)
}
}