コード例 #1
0
        private async Task <Sp8deTransaction> CreateTransaction(int secret, Sp8deTransactionType type, string dependsOn = null)
        {
            var innerItems = new List <InternalTransaction>();

            for (int i = 0; i < keys.Length; i++)
            {
                var key = keys[i];

                var internalTx = new InternalTransaction()
                {
                    Nonce = ((secret + i) * 3).ToString(),
                    From  = key.PublicAddress,
                    Data  = (secret / (i + 3) + i).ToString()
                };

                internalTx.Sign = cryptoService.SignMessage(internalTx.GetDataForSign(), key.PrivateKey);

                switch (type)
                {
                case Sp8deTransactionType.AggregatedCommit:
                    internalTx.Type = Sp8deTransactionType.InternalContributor + i;
                    internalTx.Data = null;     //cleanup secret data
                    break;

                case Sp8deTransactionType.AggregatedReveal:
                    internalTx.Type = Sp8deTransactionType.InternalContributor + i;
                    break;

                default:
                    throw new ArgumentException(nameof(type));
                }

                innerItems.Add(internalTx);
            }

            var tx = await transactionService.AddTransaction(new CreateTransactionRequest()
            {
                DependsOn         = dependsOn,
                InnerTransactions = innerItems,
                Type = type
            });

            return(tx);
        }