spark_sdk/wallet/internal_handlers/traits/
ssp.rs1use crate::{error::SparkSdkError, signer::traits::SparkSigner, SparkNetwork};
2use bitcoin::Network;
3use serde::{Deserialize, Serialize};
4use tonic::async_trait;
5
6#[derive(Debug, Serialize, Deserialize)]
7pub(crate) struct SwapLeaf {
8 pub leaf_id: String,
9 pub raw_unsigned_refund_transaction: String,
10 pub adaptor_added_signature: String,
11}
12
13#[derive(Debug, Serialize, Deserialize)]
14pub(crate) struct CreateInvoiceVariables {
15 network: String,
16 amount_sats: u64,
17 payment_hash: String,
18 memo: String,
19 expiry_secs: u64,
20}
21
22#[async_trait]
23pub(crate) trait SspInternalHandlers<S: SparkSigner + Send + Sync> {
24 async fn ping_ssp(&self) -> Result<bool, SparkSdkError>;
25
26 async fn create_invoice_with_ssp(
27 &self,
28 amount_sats: i64,
29 payment_hash: String,
30 expiry_secs: Option<i32>,
31 memo: Option<String>,
32 network: Network,
33 ) -> Result<(String, i64), SparkSdkError>;
34
35 async fn pay_invoice_with_ssp(&self, invoice: String) -> Result<String, SparkSdkError>;
36
37 async fn request_swap_leaves_with_ssp(
38 &self,
39 adaptor_pubkey: String,
40 total_amount_sats: u64,
41 target_amount_sats: u64,
42 fee_sats: u64,
43 network: SparkNetwork,
44 user_leaves: Vec<SwapLeaf>,
45 ) -> Result<(String, Vec<SwapLeaf>), SparkSdkError>;
46
47 async fn complete_leaves_swap_with_ssp(
48 &self,
49 adaptor_secret_key: String,
50 user_outbound_transfer_external_id: String,
51 leaves_swap_request_id: String,
52 ) -> Result<String, SparkSdkError>;
53
54 async fn initiate_cooperative_exit_with_ssp(
55 &self,
56 leaf_external_ids: Vec<String>,
57 address: String,
58 ) -> Result<(String, Vec<u8>, bitcoin::Transaction), SparkSdkError>;
59
60 async fn complete_cooperative_exit_with_ssp(
61 &self,
62 user_outbound_transfer_external_id: String,
63 coop_exit_request_id: String,
64 ) -> Result<String, SparkSdkError>;
65
66 async fn request_lightning_send_with_ssp(
67 &self,
68 encoded_invoice: String,
69 idompotency_key: String,
70 ) -> Result<String, SparkSdkError>;
71}