spark_rust/wallet/internal_handlers/traits/
cooperative_exit.rs1use std::collections::HashMap;
2
3use super::transfer::LeafKeyTweak;
4use crate::{error::SparkSdkError, signer::traits::SparkSigner};
5use bitcoin::{secp256k1::PublicKey, OutPoint, Transaction};
6use frost_secp256k1_tr_unofficial::round1::SigningCommitments;
7use spark_protos::spark::{LeafRefundTxSigningJob, Transfer};
8use tonic::async_trait;
9
10#[async_trait]
11pub(crate) trait CooperativeExitInternalHandlers<S: SparkSigner + Send + Sync> {
12 async fn get_connector_refund_signatures(
13 &self,
14 leaves: &Vec<LeafKeyTweak>,
15 exit_txid: &Vec<u8>,
16 connector_outputs: &Vec<OutPoint>,
17 receiver_pubkey: &PublicKey,
18 expiry_time: u64,
19 ) -> Result<(Transfer, HashMap<String, Vec<u8>>), SparkSdkError>;
20
21 fn create_connector_refund_transaction_signing_job(
22 &self,
23 leaf_id: &str,
24 signing_pubkey: &Vec<u8>,
25 commitment: &SigningCommitments,
26 refund_tx: &Transaction,
27 ) -> Result<LeafRefundTxSigningJob, SparkSdkError>;
28
29 async fn sign_coop_exit_refunds(
30 &self,
31 leaves: &Vec<LeafKeyTweak>,
32 exit_txid: &Vec<u8>,
33 connector_outputs: &Vec<OutPoint>,
34 receiver_pubkey: &PublicKey,
35 expiry_time: u64,
36 ) -> Result<(Transfer, HashMap<String, Vec<u8>>), SparkSdkError>;
37}