Esempio n. 1
0
        /// <summary>
        /// Submits signed transactions and queue response utxos
        /// </summary>
        /// <returns></returns>
        public async Task ProcessTransactions()
        {
            if (CanMerge)
            {
                foreach (var transaction in Transactions)
                {
                    string             encodedTx = txEncoder.EncodeSigned(transaction).ToHex(true);
                    TransactionReceipt receipt   = await plasmaAPIService.SubmitTransaction(encodedTx);

                    if (receipt != null)
                    {
                        UTXOData utxo = new UTXOData();
                        utxo.BlkNum   = receipt.BlkNum;
                        utxo.TxIndex  = receipt.TxIndex;
                        utxo.OIndex   = 0;
                        utxo.Data     = transaction.Outputs[0].Value.ToBigIntegerFromRLPDecoded();
                        utxo.Owner    = transaction.Outputs[0].Owner;
                        utxo.Currency = transaction.Outputs[0].Currency;
                        utxo.Position = UTXOData.CalculatePosition(utxo.BlkNum, utxo.TxIndex, utxo.OIndex);
                        utxoList.Add(utxo);
                    }
                }

                Transactions.Clear();

                PrepareTransactions();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Sumbits signed transaction to child chain
        /// </summary>
        /// <param name="signedTransaction">RLP encoded signed transaction</param>
        /// <returns></returns>
        public async Task <TransactionDetails> SubmitTransaction(string signedTransaction)
        {
            var receipt = await plasmaApiService.SubmitTransaction(signedTransaction);

            if (receipt != null)
            {
                TransactionDetails transaction = null;

                // timeout
                do
                {
                    Thread.Sleep(1000);
                    transaction = await plasmaApiService.GetTransaction(receipt.TxHash.HexValue);
                } while (transaction == null);

                return(transaction);
            }
            return(null);
        }