spark_sdk/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::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 ) -> Result<(Transfer, HashMap<String, Vec<u8>>), SparkSdkError>;
19
20 fn create_connector_refund_transaction_signing_job(
21 &self,
22 leaf_id: &str,
23 signing_pubkey: &Vec<u8>,
24 commitment: &SigningCommitments,
25 refund_tx: &Transaction,
26 ) -> Result<LeafRefundTxSigningJob, SparkSdkError>;
27
28 async fn sign_coop_exit_refunds(
29 &self,
30 leaves: &Vec<LeafKeyTweak>,
31 exit_txid: &Vec<u8>,
32 connector_outputs: &Vec<OutPoint>,
33 receiver_pubkey: &PublicKey,
34 ) -> Result<(Transfer, HashMap<String, Vec<u8>>), SparkSdkError>;
35}