Exemple #1
0
 public OperationExecutionAggregate ToDomain()
 {
     return(OperationExecutionAggregate.Restore(
                ETag,
                State,
                Result,
                StartMoment,
                ActiveTransactionIdGenerationMoment,
                ActiveTransactionStartMoment,
                TransactionExecutionRepeatRequestMoment,
                ActiveTransactionClearingMoment,
                TransactionFinishMoment,
                FinishMoment,
                OperationId,
                FromAddress,
                Outputs
                .Select(x => x.ToDomain())
                .ToArray(),
                AssetId,
                IncludeFee,
                BlockchainType,
                BlockchainAssetId,
                EndpointsConfiguration,
                ActiveTransactionId,
                ActiveTransactionNumber,
                TransactionOutputs?
                .Select(o => o.ToDomain())
                .ToArray(),
                TransactionBlock,
                TransactionFee,
                TransactionHash,
                Error,
                RebuildConfirmationResult));
 }
        /// <summary>
        /// Processing Transaction In Miner
        /// </summary>
        /// <param name="checkGenesis">A function That returns whether a transaction is Genesis or not.</param>
        /// <param name="chechBlockReward">A function that indicate if Transaction is a Block Reward.</param>
        /// <param name="checkForUTXOs">check if transaction inputs are valide in network.</param>
        /// <param name="cleaningUTXOs">clearing old inputs and adding new ones in network UTXOs and update UTXOs.</param>
        /// <returns></returns>
        public bool Process(
            Func <Transaction, bool> checkGenesis,
            Func <Transaction, bool> checkBlockReward,
            Func <List <TransactionInput>, bool> checkForUTXOs,
            Func <List <TransactionInput>, List <TransactionOutput>, bool> cleaningUTXOs
            )
        {
            if (!IsSignatureVerified)
            {
                return(false);
            }
            //check if Transaction Reward Or Genesis
            if (TransactionInputs == null)
            {
                if (!string.IsNullOrEmpty(TransactionHash))
                {
                    var res = checkGenesis(this);
                    if (res)
                    {
                        return(cleaningUTXOs(null, TransactionOutputs));
                    }
                    else
                    {
                        return(res);
                    }
                }
                var resBR = checkBlockReward(this);
                if (resBR)
                {
                    return(cleaningUTXOs(null, TransactionOutputs));
                }
                else
                {
                    return(resBR);
                }
            }
            if (!checkForUTXOs(TransactionInputs))
            {
                return(false);
            }
            var Change = InputsBalance - Amount;

            TransactionHash = GetHashString();
            TransactionOutputs.Add(new TransactionOutput(Reciepient, Amount, TransactionHash));
            TransactionOutputs.Add(new TransactionOutput(Issuer, Change, TransactionHash));
            return(cleaningUTXOs(TransactionInputs, TransactionOutputs));
        }
Exemple #3
0
 public TransactionExecutionAggregate ToDomain([CanBeNull] TransactionExecutionBlobEntity blobData)
 {
     return(TransactionExecutionAggregate.Restore(
                ETag,
                State,
                Result,
                StartMoment,
                SourceAddressLockingMoment,
                BuildingMoment,
                SigningMoment,
                BroadcastingMoment,
                FinishMoment,
                SourceAddressReleaseMoment,
                ClearedMoment,
                BuildingFailureMoment,
                BroadcastinFailureMoment,
                WaitingForEndingStartMoment,
                WaitingForEndingFailureMoment,
                OperationId,
                TransactionId,
                TransactionNumber,
                BlockchainType,
                FromAddress,
                FromAddressContext,
                Outputs
                .Select(x => x.ToDomain())
                .ToArray(),
                AssetId,
                IncludeFee,
                blobData?.TransactionContext,
                BlockchainAssetId,
                blobData?.SignedTransaction,
                TransactionOutputs?
                .Select(o => o.ToDomain())
                .ToArray(),
                Block,
                Fee,
                Hash,
                Error));
 }