use std::sync::Arc;
use bsv::services::overlay_tools::LookupResolver;
use bsv::wallet::cached_key_deriver::CachedKeyDeriver;
use serde::{Deserialize, Serialize};
use crate::tables::ProvenTx;
use crate::services::traits::WalletServices;
use crate::storage::manager::WalletStorageManager;
use crate::types::Chain;
use super::privileged::PrivilegedKeyManager;
use super::settings::WalletSettingsManager;
pub use crate::signer::types::PendingSignAction;
pub struct WalletArgs {
pub chain: Chain,
pub key_deriver: Arc<CachedKeyDeriver>,
pub storage: Arc<WalletStorageManager>,
pub services: Option<Arc<dyn WalletServices>>,
pub monitor: Option<Arc<crate::monitor::Monitor>>,
pub privileged_key_manager: Option<Arc<dyn PrivilegedKeyManager>>,
pub settings_manager: Option<WalletSettingsManager>,
pub lookup_resolver: Option<Arc<LookupResolver>>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AuthId {
pub identity_key: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub user_id: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub is_active: Option<bool>,
}
#[derive(Debug, Clone)]
pub struct KeyPair {
pub private_key: String,
pub public_key: String,
}
#[derive(Debug, Clone)]
pub struct StorageIdentity {
pub storage_identity_key: String,
pub storage_name: String,
}
pub const SPEC_OP_THROW_REVIEW_ACTIONS: &str =
"a496e747fc3ad5fabdd4ae8f91184e71f87539bd3d962aa2548942faaaf0047a";
pub const SPEC_OP_WALLET_BALANCE: &str =
"893b7646de0e1c9f741bd6e9169b76a8847ae34adef7bef1e6a285371206d2e8";
pub const SPEC_OP_INVALID_CHANGE: &str =
"5a76fd430a311f8bc0553859061710a4475c19fed46e2ff95969aa918e612e57";
pub const SPEC_OP_SET_WALLET_CHANGE_PARAMS: &str =
"a4979d28ced8581e9c1c92f1001cc7cb3aabf8ea32e10888ad898f0a509a3929";
pub const SPEC_OP_NO_SEND_ACTIONS: &str =
"ac6b20a3bb320adafecd637b25c84b792ad828d3aa510d05dc841481f664277d";
pub const SPEC_OP_FAILED_ACTIONS: &str =
"97d4eb1e49215e3374cc2c1939a7c43a55e95c7427bf2d45ed63e3b4e0c88153";
pub fn is_spec_op_basket(basket: &str) -> bool {
matches!(
basket,
SPEC_OP_WALLET_BALANCE | SPEC_OP_INVALID_CHANGE | SPEC_OP_SET_WALLET_CHANGE_PARAMS
)
}
pub fn is_spec_op_label(label: &str) -> bool {
matches!(label, SPEC_OP_NO_SEND_ACTIONS | SPEC_OP_FAILED_ACTIONS)
}
pub fn is_spec_op_throw_label(label: &str) -> bool {
label == SPEC_OP_THROW_REVIEW_ACTIONS
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct WalletBalance {
pub total: u64,
pub utxos: Vec<UtxoInfo>,
}
#[derive(Debug, Clone, Serialize)]
pub struct UtxoInfo {
pub satoshis: u64,
pub outpoint: String,
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct AdminStatsResult {
pub requested_by: String,
pub when: String,
pub users_day: u64,
pub users_week: u64,
pub users_month: u64,
pub users_total: u64,
pub transactions_day: u64,
pub transactions_week: u64,
pub transactions_month: u64,
pub transactions_total: u64,
pub tx_completed_day: u64,
pub tx_completed_week: u64,
pub tx_completed_month: u64,
pub tx_completed_total: u64,
pub tx_failed_day: u64,
pub tx_failed_week: u64,
pub tx_failed_month: u64,
pub tx_failed_total: u64,
pub tx_unprocessed_day: u64,
pub tx_unprocessed_week: u64,
pub tx_unprocessed_month: u64,
pub tx_unprocessed_total: u64,
pub tx_sending_day: u64,
pub tx_sending_week: u64,
pub tx_sending_month: u64,
pub tx_sending_total: u64,
pub tx_unproven_day: u64,
pub tx_unproven_week: u64,
pub tx_unproven_month: u64,
pub tx_unproven_total: u64,
pub tx_unsigned_day: u64,
pub tx_unsigned_week: u64,
pub tx_unsigned_month: u64,
pub tx_unsigned_total: u64,
pub tx_nosend_day: u64,
pub tx_nosend_week: u64,
pub tx_nosend_month: u64,
pub tx_nosend_total: u64,
pub tx_nonfinal_day: u64,
pub tx_nonfinal_week: u64,
pub tx_nonfinal_month: u64,
pub tx_nonfinal_total: u64,
pub tx_unfail_day: u64,
pub tx_unfail_week: u64,
pub tx_unfail_month: u64,
pub tx_unfail_total: u64,
pub satoshis_default_day: u64,
pub satoshis_default_week: u64,
pub satoshis_default_month: u64,
pub satoshis_default_total: u64,
pub satoshis_other_day: u64,
pub satoshis_other_week: u64,
pub satoshis_other_month: u64,
pub satoshis_other_total: u64,
pub baskets_day: u64,
pub baskets_week: u64,
pub baskets_month: u64,
pub baskets_total: u64,
pub labels_day: u64,
pub labels_week: u64,
pub labels_month: u64,
pub labels_total: u64,
pub tags_day: u64,
pub tags_week: u64,
pub tags_month: u64,
pub tags_total: u64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ReproveProvenUpdate {
pub update: ProvenTx,
pub log_update: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ReproveProvenResult {
pub updated: Option<ReproveProvenUpdate>,
pub unchanged: bool,
pub unavailable: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ReproveHeaderResult {
pub updated: Vec<ProvenTx>,
pub unchanged: Vec<ProvenTx>,
pub unavailable: Vec<ProvenTx>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct WalletStorageInfo {
pub storage_identity_key: String,
pub storage_name: String,
pub user_id: Option<i64>,
pub is_active: bool,
pub is_enabled: bool,
pub is_backup: bool,
pub is_conflicting: bool,
pub endpoint_url: Option<String>,
}