whisky_csl/tx_parser/
collaterals.rs

1use whisky_common::{PubKeyTxIn, WError};
2
3use super::{utxo_converter::utxo_to_pub_key_tx_in, CSLParser};
4
5impl CSLParser {
6    pub fn get_collaterals(&self) -> &Vec<PubKeyTxIn> {
7        &self.tx_body.collaterals
8    }
9
10    pub(super) fn extract_collaterals(&mut self) -> Result<(), WError> {
11        let collateral_inputs = self.csl_tx_body.collateral();
12        if let Some(collateral_inputs) = collateral_inputs {
13            for input in &collateral_inputs {
14                let tx_in = utxo_to_pub_key_tx_in(&input, &self.context)?;
15                self.tx_body.collaterals.push(tx_in);
16            }
17        }
18        Ok(())
19    }
20}