pub fn transfer(
        &mut self,
        asset: &mut Asset,
        inputs: Vec<OutPoint>,
        ours: Vec<Outcoins>,
        theirs: Vec<Outcoincealed>,
    ) -> Result<Transition, ServiceErrorDomain> {
        // Collecting all input allocations
        let mut input_allocations = Vec::<Allocation>::new();
        for seal in &inputs {
            let found = asset
                .allocations(seal)
                .ok_or(format!("Unknown input {}", seal))?
                .clone();
            if found.len() == 0 {
                Err(format!("Unknown input {}", seal))?
            }
            input_allocations.extend(found);
        }
        // Computing sum of inputs
        let total_inputs = input_allocations
            .iter()
            .fold(0u64, |acc, alloc| acc + alloc.value().value);

        let metadata = type_map! {};
        let mut total_outputs = 0;
        let allocations_ours = ours
            .into_iter()
            .map(|outcoins| {
                let amount = AccountingAmount::transmutate(
                    *asset.fractional_bits(),
                    outcoins.coins,
                );
                total_outputs += amount;
                (outcoins.seal_definition(), amount)
            })
            .collect();
        let allocations_theirs = theirs
            .into_iter()
            .map(|outcoincealed| {
                let amount = AccountingAmount::transmutate(
                    *asset.fractional_bits(),
                    outcoincealed.coins,
                );
                total_outputs += amount;
                (outcoincealed.seal_confidential, amount)
            })
            .collect();

        if total_inputs != total_outputs {
            Err("Input amount is not equal to output amount".to_string())?
        }

        let input_amounts = input_allocations
            .iter()
            .map(|alloc| alloc.value().clone())
            .collect();
        let assignments = type_map! {
            OwnedRightsType::Assets =>
            Assignments::zero_balanced(input_amounts, allocations_ours, allocations_theirs)
        };

        let mut parent = ParentOwnedRights::new();
        for alloc in input_allocations {
            parent
                .entry(*alloc.node_id())
                .or_insert(bmap! {})
                .entry(*OwnedRightsType::Assets)
                .or_insert(vec![])
                .push(*alloc.index());
        }

        let transition = Transition::with(
            *TransitionType::Transfer,
            metadata.into(),
            parent,
            assignments,
            bset![],
            vec![],
        );

        Ok(transition)
    }
/// Function creates a fungible asset-specific state transition (i.e. RGB-20
/// schema-based) given an asset information, inputs and desired outputs
Function creates a fungible asset-specific state transition  given an asset information, inputs and desired outputs
Function creates a fungible asset - specific state transition given an asset information inputs and desired outputs
pub fn transfer(
        &mut self,
        asset: &mut Asset,
        inputs: Vec<OutPoint>,
        ours: Vec<Outcoins>,
        theirs: Vec<Outcoincealed>,
    ) -> Result<Transition, ServiceErrorDomain> {
        // Collecting all input allocations
        let mut input_allocations = Vec::<Allocation>::new();
        for seal in &inputs {
            let found = asset
                .allocations(seal)
                .ok_or(format!("Unknown input {}", seal))?
                .clone();
            if found.len() == 0 {
                Err(format!("Unknown input {}", seal))?
            }
            input_allocations.extend(found);
        }
        // Computing sum of inputs
        let total_inputs = input_allocations
            .iter()
            .fold(0u64, |acc, alloc| acc + alloc.value().value);
        let metadata = type_map! {};
        let mut total_outputs = 0;
        let allocations_ours = ours
            .into_iter()
            .map(|outcoins| {
                let amount = AccountingAmount::transmutate(
                    *asset.fractional_bits(),
                    outcoins.coins,
                );
                total_outputs += amount;
                (outcoins.seal_definition(), amount)
            })
            .collect();
        let allocations_theirs = theirs
            .into_iter()
            .map(|outcoincealed| {
                let amount = AccountingAmount::transmutate(
                    *asset.fractional_bits(),
                    outcoincealed.coins,
                );
                total_outputs += amount;
                (outcoincealed.seal_confidential, amount)
            })
            .collect();
        if total_inputs != total_outputs {
            Err("Input amount is not equal to output amount".to_string())?
        }
        let input_amounts = input_allocations
            .iter()
            .map(|alloc| alloc.value().clone())
            .collect();
        let assignments = type_map! {
            OwnedRightsType::Assets =>
            Assignments::zero_balanced(input_amounts, allocations_ours, allocations_theirs)
        };
        let mut parent = ParentOwnedRights::new();
        for alloc in input_allocations {
            parent
                .entry(*alloc.node_id())
                .or_insert(bmap! {})
                .entry(*OwnedRightsType::Assets)
                .or_insert(vec![])
                .push(*alloc.index());
        }
        let transition = Transition::with(
            *TransitionType::Transfer,
            metadata.into(),
            parent,
            assignments,
            bset![],
            vec![],
        );
        Ok(transition)
    }
pub fn transfer ( & mut self , asset : & mut Asset , inputs : Vec < OutPoint > , ours : Vec < Outcoins > , theirs : Vec < Outcoincealed > , ) -> Result < Transition , ServiceErrorDomain > { // Collecting all input allocations let mut input_allocations = Vec :: < Allocation > :: new ( ) ; for seal in & inputs { let found = asset . allocations ( seal ) . ok_or ( format ! ( " " seal ) ) ? . clone ( ) ; if found . len ( ) == 0 { Err ( format ! ( " " seal ) ) ? } input_allocations . extend ( found ) ; } // Computing sum of inputs let total_inputs = input_allocations . iter ( ) . fold ( 0u64 , | acc , alloc | acc + alloc . value ( ) . value ) ; let metadata = type_map ! { } ; let mut total_outputs = 0 ; let allocations_ours = ours . into_iter ( ) . map ( | outcoins | { let amount = AccountingAmount :: transmutate ( * asset . fractional_bits ( ) , outcoins . coins , ) ; total_outputs += amount ; ( outcoins . seal_definition ( ) , amount ) } ) . collect ( ) ; let allocations_theirs = theirs . into_iter ( ) . map ( | outcoincealed | { let amount = AccountingAmount :: transmutate ( * asset . fractional_bits ( ) , outcoincealed . coins , ) ; total_outputs += amount ; ( outcoincealed . seal_confidential , amount ) } ) . collect ( ) ; if total_inputs != total_outputs { Err ( " " . to_string ( ) ) ? } let input_amounts = input_allocations . iter ( ) . map ( | alloc | alloc . value ( ) . clone ( ) ) . collect ( ) ; let assignments = type_map ! { OwnedRightsType Assets Assignments zero_balanced ( input_amounts allocations_ours allocations_theirs ) } ; let mut parent = ParentOwnedRights :: new ( ) ; for alloc in input_allocations { parent . entry ( * alloc . node_id ( ) ) . or_insert ( bmap ! { } ) . entry ( * OwnedRightsType :: Assets ) . or_insert ( vec ! [ ] ) . push ( * alloc . index ( ) ) ; } let transition = Transition :: with ( * TransitionType :: Transfer , metadata . into ( ) , parent , assignments , bset ! [ ] , vec ! [ ] , ) ; Ok ( transition ) }
Function creates a fungible asset-specific state transition (i.e.
Function creates a fungible asset - specific state transition ( i . e .
&mut self
asset
&mut Asset
inputs
Vec<OutPoint>
ours
Vec<Outcoins>
theirs
Vec<Outcoincealed>
&mut self
asset
&mut Asset
inputs
Vec<OutPoint>
ours
Vec<Outcoins>
theirs
Vec<Outcoincealed>