whisky_pallas/converter/tx_builder_body/
input.rs

1use whisky_common::{TxIn, WError};
2
3use crate::wrapper::transaction_body::TransactionInput;
4
5pub fn convert_inputs(inputs: &Vec<TxIn>) -> Result<Vec<TransactionInput>, WError> {
6    inputs
7        .into_iter()
8        .map(|input| {
9            let (tx_hash, tx_index) = match input {
10                TxIn::PubKeyTxIn(pub_key_tx_in) => (
11                    &pub_key_tx_in.tx_in.tx_hash,
12                    pub_key_tx_in.tx_in.tx_index.into(),
13                ),
14                TxIn::SimpleScriptTxIn(simple_script_tx_in) => (
15                    &simple_script_tx_in.tx_in.tx_hash,
16                    simple_script_tx_in.tx_in.tx_index.into(),
17                ),
18                TxIn::ScriptTxIn(script_tx_in) => (
19                    &script_tx_in.tx_in.tx_hash,
20                    script_tx_in.tx_in.tx_index.into(),
21                ),
22            };
23            TransactionInput::new(tx_hash, tx_index)
24        })
25        .collect::<Result<Vec<TransactionInput>, WError>>()
26}