Example #1
0
        /// <inheritdoc/>
        protected override void Dispose(bool disposing)
        {
            try
            {
                if (disposing)
                {
                    if (InnerTransaction != null)
                    {
                        if (OwnedTransaction)
                        {
                            InnerTransaction.Dispose();
                        }

                        InnerTransaction = null;
                    }

                    if (InnerConnection != null)
                    {
                        InnerConnection.Close();
                        InnerConnection = null;
                    }
                }
            }
            finally
            {
                base.Dispose(disposing);
            }
        }
 public TransactionResponse(string hash, uint ledger, string createdAt, string sourceAccount, string feeAccount, bool successful,
                            string pagingToken, long sourceAccountSequence, long maxFee, long feeCharged, int operationCount, string envelopeXdr,
                            string resultXdr, string resultMetaXdr, Memo memo, List <String> signatures,
                            FeeBumpTransaction feeBumpTransaction, InnerTransaction innerTransaction, TransactionResponseLinks links)
 {
     Hash                  = hash;
     Ledger                = ledger;
     CreatedAt             = createdAt;
     SourceAccount         = sourceAccount;
     FeeAccount            = feeAccount;
     Successful            = successful;
     PagingToken           = pagingToken;
     SourceAccountSequence = sourceAccountSequence;
     MaxFee                = maxFee;
     FeeCharged            = feeCharged;
     OperationCount        = operationCount;
     EnvelopeXdr           = envelopeXdr;
     ResultXdr             = resultXdr;
     ResultMetaXdr         = resultMetaXdr;
     Memo                  = memo;
     Signatures            = signatures;
     FeeBumpTx             = feeBumpTransaction;
     InnerTx               = innerTransaction;
     Links                 = links;
 }
Example #3
0
        public DocumentsTransaction BeginAsyncCommitAndStartNewTransaction()
        {
            _replaced = true;
            var tx = InnerTransaction.BeginAsyncCommitAndStartNewTransaction();

            return(new DocumentsTransaction(_context, tx, _changes));
        }
Example #4
0
        internal override byte[] GenerateBytes()
        {
            var innerTransactionBytes = InnerTransaction.GenerateBytes();
            var builder          = new FlatBufferBuilder(1);
            var signer           = MultisigTransactionBuffer.CreatePublicKeyVector(builder, GetSigner());
            var innerTransaction = MultisigTransactionBuffer.CreateInnerTransactionBytesVector(builder, innerTransactionBytes);

            MultisigTransactionBuffer.StartMultisigTransactionBuffer(builder);

            MultisigTransactionBuffer.AddTransactionType(builder, TransactionType.GetValue());
            MultisigTransactionBuffer.AddVersion(builder, BitConverter.ToInt16(new byte[] { ExtractVersion(Version), 0 }, 0));
            MultisigTransactionBuffer.AddNetwork(builder, BitConverter.ToInt16(new byte[] { 0, NetworkType.GetNetwork() }, 0));
            MultisigTransactionBuffer.AddTimestamp(builder, NetworkTime.EpochTimeInMilliSeconds());
            MultisigTransactionBuffer.AddPublicKeyLen(builder, 32);
            MultisigTransactionBuffer.AddPublicKey(builder, signer);
            MultisigTransactionBuffer.AddFee(builder, Fee);
            MultisigTransactionBuffer.AddDeadline(builder, Deadline.Ticks);
            MultisigTransactionBuffer.AddInnerTransactionLength(builder, innerTransactionBytes.Length);
            MultisigTransactionBuffer.AddInnerTransactionBytes(builder, innerTransaction);

            var codedTransfer = MultisigTransactionBuffer.EndMultisigTransactionBuffer(builder);

            builder.Finish(codedTransfer.Value);

            return(new MultisigTransactionSchema().Serialize(builder.SizedByteArray()));
        }
Example #5
0
        public DocumentsTransaction BeginAsyncCommitAndStartNewTransaction(DocumentsOperationContext context)
        {
            _replaced = true;
            var tx = InnerTransaction.BeginAsyncCommitAndStartNewTransaction(context.PersistentContext);

            return(new DocumentsTransaction(context, tx, _changes));
        }
Example #6
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         InnerTransaction.Dispose();
     }
     base.Dispose(disposing);
 }
Example #7
0
 public void ForgetAbout(Document doc)
 {
     if (doc == null)
     {
         return;
     }
     InnerTransaction.ForgetAbout(doc.StorageId);
 }
Example #8
0
        /// <summary>
        /// Rolls back the open transaction.
        /// </summary>
        public void Rollback()
        {
            if (InnerTransaction == null)
            {
                throw new InvalidOperationException("A transaction has not been created for this connection");
            }

            InnerTransaction.Rollback();
        }
Example #9
0
 protected override void Dispose(bool disposing)
 {
     _profiler.TransactionDisposing(InnerTransaction, NHProfilerContextProvider.GetLoggedDbTransaction(InnerTransaction, _connectionId));
     if (disposing && InnerTransaction != null)
     {
         InnerTransaction.Dispose();
     }
     InnerTransaction = null;
     _connection      = null;
     base.Dispose(disposing);
 }
        public override void Rollback()
        {
            InnerTransaction.Rollback();

            if (MessageBroker != null && TimerStrategy != null)
            {
                MessageBroker.Publish(
                    new TransactionRollbackMessage(InnerConnection.ConnectionId, TransactionId)
                    .AsTimedMessage(TimerStrategy.Stop(timerTimeSpan)));
            }
        }
Example #11
0
        public void Insert(InnerTransaction innertransaction)
        {
            var param = new List <SqlParameter>
            {
                new SqlParameter("ID", innertransaction.ID),
                new SqlParameter("@WarehouseID ", innertransaction.WarehouseID),
                new SqlParameter("@UserID", innertransaction.UserID),
                new SqlParameter("@DeliveryDate", innertransaction.@DeliveryDate),
            };

            Insert(param.ToArray());
        }
        private InnerTransaction CreateInnerTransaction(Transaction source)
        {
            var result = new InnerTransaction
            {
                UserId = source.UserId,
                AssociatedTransactionId = source.TxKey,
                FromType        = source.Symbol,
                FromValue       = source.Amount,
                ToValue         = source.Amount,
                TokenMultiplier = _tokenMultiplierRate,
            };

            return(result);
        }
Example #13
0
        // disposing: true if Dispose() was called, false
        // if being finalized by the garbage collector
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                // Close the transaction before closing the lock
                if (InnerTransaction != null)
                {
                    InnerTransaction.Dispose();
                    InnerTransaction = null;
                }
            }

            base.Dispose(disposing);
        }
        private async Task <InnerTransaction> ProcessAndInsertInnerTransactionAsync(InnerTransaction transaction)
        {
            transaction.ToValue *= _tokenMultiplierRate;
            switch (transaction.FromType)
            {
            case ("BTC"):
                transaction.TypeToTokenConversationRate = _btcToTokenRate;
                transaction.ToValue *= _btcToTokenRate;
                break;

            case ("ETH"):
                transaction.TypeToTokenConversationRate = _ethToTokenRate;
                transaction.ToValue *= _ethToTokenRate;
                break;

            default:
                throw new ArgumentException("Invalid transaction adapter: " + transaction.FromType);
            }
            await _usersService.IncreaseUserBalance(transaction.UserId, transaction.ToValue);

            transaction = await _innerTransactionsRepository.InsertAsync(transaction);

            return(transaction);
        }
        private async Task <bool> PayToAffiliatorAsync(int userId, decimal userPaymentValue, InnerTransaction transaction)
        {
            var affiliatorUser = await _usersService.GetAffiliatorOfUser(userId);

            if (affiliatorUser == null)
            {
                return(false);
            }
            var affiliatorPaybackValue = userPaymentValue * _affiliationPaybackMultiplierRate;
            await _usersService.IncreaseUserBalance(affiliatorUser.Id, affiliatorPaybackValue);

            await _affiliatePayoffsRepository.InsertAsync(new AffiliatePayoff
            {
                AffiliatePayoffMultiplier = _affiliationPaybackMultiplierRate,
                AffiliateUserId           = affiliatorUser.Id,
                InnerTransactionId        = transaction.Id,
                PayingUserId     = userId,
                TransactionValue = transaction.ToValue,
                PayoffValue      = affiliatorPaybackValue
            });

            return(true);
        }
 public override void Commit()
 {
     InnerTransaction.Commit();
     Stats.TransactionCommit(InnerConnection.ConnectionId, TransactionId);
 }
 public override void Rollback()
 {
     InnerTransaction.Rollback();
     Stats.TransactionRolledBack(InnerConnection.ConnectionId, TransactionId);
 }
 public override void Rollback()
 {
     InnerTransaction.Rollback();
 }
 public override void Commit()
 {
     InnerTransaction.Commit();
 }
Example #20
0
 public void Insert(InnerTransaction innerTransaction)
 {
     _repository.Insert(innerTransaction);
 }
 public override void Commit()
 {
     _retryPolicy.Execute(() => InnerTransaction.Commit());
 }
Example #22
0
        /// <summary>
        /// Signs the MultisigTransaction with a KeyPair and sets the inner transaction signer.
        /// </summary>
        /// <param name="cosignatory">The cosignatory.</param>
        /// <param name="multisigAccount">The multisig account.</param>
        /// <returns>SignedMultisigTransaction.</returns>
        /// <exception cref="System.ArgumentNullException">
        /// cosignatory
        /// or
        /// multisigAccount
        /// </exception>
        public SignedMultisigTransaction SignWith(KeyPair cosignatory, PublicAccount multisigAccount)
        {
            if (cosignatory == null)
            {
                throw new ArgumentNullException(nameof(cosignatory));
            }
            if (multisigAccount == null)
            {
                throw new ArgumentNullException(nameof(multisigAccount));
            }

            Signer = PublicAccount.CreateFromPublicKey(cosignatory.PublicKeyString, NetworkType);
            InnerTransaction.Signer = multisigAccount;
            Bytes = GenerateBytes();
            var sig = TransactionExtensions.SignTransaction(cosignatory, Bytes);

            return(SignedMultisigTransaction.Create(Bytes, sig, TransactionExtensions.Hasher(Bytes), InnerTransaction.CreateTransactionHash().FromHex(), cosignatory.PublicKey, TransactionType));
        }
Example #23
0
 public override void Rollback()
 {
     _profiler.TransactionRolledBack(InnerTransaction, NHProfilerContextProvider.GetLoggedDbTransaction(InnerTransaction, _connectionId));
     InnerTransaction.Rollback();
 }
Example #24
0
 public override void Commit()
 {
     _profiler.TransactionCommitted(InnerTransaction, NHProfilerContextProvider.GetLoggedDbTransaction(InnerTransaction, _connectionId));
     InnerTransaction.Commit();
 }
 public override void Rollback()
 {
     _retryPolicy.Execute(() => InnerTransaction.Rollback());
 }