/// <inheritdoc /> public Transaction Process(IContractState stateSnapshot, uint160 contractAddress, ISmartContractTransactionContext transactionContext, IList <TransferInfo> internalTransfers, bool reversionRequired) { if (reversionRequired) { // Send back funds if (transactionContext.TxOutValue > 0) { return(CreateRefundTransaction(transactionContext)); } } // If contract received no funds and made no transfers, do nothing. if (transactionContext.TxOutValue == 0 && !internalTransfers.Any(x => x.Value > 0)) // TODO: In future discern whether we should even record internal transfers of 0. { return(null); } // If contract had no balance, received funds, but made no transfers, assign the current UTXO. if (stateSnapshot.GetUnspent(contractAddress) == null && transactionContext.TxOutValue > 0 && !internalTransfers.Any()) { stateSnapshot.SetUnspent(contractAddress, new ContractUnspentOutput { Value = transactionContext.TxOutValue, Hash = transactionContext.TransactionHash, Nvout = transactionContext.Nvout }); return(null); } // All other cases we need a condensing transaction var transactionCondenser = new TransactionCondenser(contractAddress, this.loggerFactory, internalTransfers, stateSnapshot, this.network, transactionContext); return(transactionCondenser.CreateCondensingTransaction()); }