コード例 #1
0
    private bool IsTransactionPendingOnThisCard()
    {
        CraftingManager manager = CraftingManager.Get();

        if (manager == null)
        {
            return(false);
        }
        PendingTransaction pendingTransaction = manager.GetPendingTransaction();

        if (pendingTransaction == null)
        {
            return(false);
        }
        EntityDef entityDef = this.m_actor.GetEntityDef();

        if (entityDef == null)
        {
            return(false);
        }
        if (pendingTransaction.CardID != entityDef.GetCardId())
        {
            return(false);
        }
        if (pendingTransaction.cardFlair != this.m_actor.GetCardFlair())
        {
            return(false);
        }
        return(true);
    }
コード例 #2
0
        public static async Task <Activity> CompletePendingTransaction(Activity message)
        {
            //get pending transaction
            StateClient stateClient = message.GetStateClient();
            BotData     userData    = await stateClient.BotState.GetUserDataAsync(message.ChannelId, message.From.Id);

            PendingTransaction transaction = userData.GetProperty <PendingTransaction>("PendingTransaction");

            //clear pending data
            userData.SetProperty <PendingTransaction>("PendingTransaction", null);
            userData.SetProperty <string>("Pending", null);
            await stateClient.BotState.SetUserDataAsync(message.ChannelId, message.From.Id, userData);

            if (message.Text.ToLower().Trim() == "confirm")
            {
                //ensure nothing changed before confirmation
                if (transaction.amount > transaction.From.Balance)
                {
                    return(message.CreateReply(string.Format("Insufficient funds $ {0:F2}, to pay $ {1:F2}", transaction.From.Balance, transaction.amount)));
                }

                await AzureManager.AzureManagerInstance.MakeTransaction(transaction.amount, transaction.To, transaction.From);

                Activity response = message.CreateReply("Transaction successful!");
                response.Attachments = new List <Attachment> {
                    TransactionCompleteCard(transaction)
                };
                return(response);
            }
            else
            {
                return(message.CreateReply("Transaction canceled"));
            }
        }
コード例 #3
0
        private static Attachment TransactionConfirmationCard(PendingTransaction transaction)
        {
            List <CardAction> buttons = new List <CardAction>
            {
                new CardAction
                {
                    Title = "Confirm",
                    Type  = "imBack",
                    Value = "confirm"
                },
                new CardAction
                {
                    Title = "Cancel",
                    Type  = "imBack",
                    Value = "deny"
                }
            };

            return(new HeroCard
            {
                Title = "Confirm transaction",
                Text = $"Amount: NZD {transaction.amount.ToString("F2")}  \nFrom: {AccountNumberFormat(transaction.From.AccountNumber)}  \nTo: {AccountNumberFormat(transaction.To.AccountNumber)}",
                Images = new List <CardImage>
                {
                    new CardImage
                    {
                        Url = "https://jw-contoso.azurewebsites.net/img/logoCarousel512.png",
                        Alt = "Contoso Bank Logo"
                    }
                },
                Buttons = buttons
            }.ToAttachment());
        }
コード例 #4
0
        /// <summary>
        ///		Get transaction scope reusing pending transaction if already pending.
        /// </summary>
        /// <param name="lazy">
        ///		Whether the scope needs to be lazy or eager.
        /// </param>
        /// <returns>
        ///		New scope.
        /// </returns>
        /// <remarks>
        ///		Eager scope is for complete units of work such as <see cref="IRepositoryWriter.Flush()"/>.
        ///		Lazy scope is for the methods which need to take part in external [long] transactions but do not represent units of
        ///		work themselves, such as <see cref="IRepositoryWriter.Write(IDataItem)"/>
        ///		Pending transaction is registered and subscribed to only first time when returned scope is not owning the transaction
        /// </remarks>
        private StorageTransactionScope GetTransactionScope(bool lazy)
        {
            CheckNotDisposed();

            StorageTransactionScope scope;

            if (lazy)
            {
                scope = StorageTransactionScope.CreateLazy(Repository, PendingTransaction);
            }
            else
            {
                scope = StorageTransactionScope.Create(Repository, PendingTransaction);
            }

            if (!scope.IsNullScope && !scope.IsTransactionOwner && PendingTransaction == null)
            {
                PendingTransaction = scope.UnderlyingTransaction;
                if (_subscriber != null)
                {
                    PendingTransaction.Subscribe(_subscriber);
                }
                PendingTransaction.Subscribe((ITransactionNotification)this);
                Check.Ensure(!scope.ToBeDisposed, "Pending transaction must not be disposed - we need to keep the single instance of slave pending transaction");
            }
            return(scope);
        }
コード例 #5
0
        public static bool IsValidSignature(this PendingTransaction transaction)
        {
            var dataForSign = transaction.From + transaction.To + transaction.Amount;

            return(Crypto.Crypto.VerifySignature(transaction.SenderPublickKey, dataForSign,
                                                 transaction.SenderSignature));
        }
コード例 #6
0
        public async Task <object> Send([FromBody] PendingTransactionRequest tr)
        {
            var transaction = new PendingTransaction(tr.Hash, tr.From, tr.To, tr.Amount, tr.SenderPublickKey, tr.SenderSignature);
            var isAccepted  = await _transactionService.AddPendingTransaction(transaction);

            return(new { Accepted = isAccepted });
        }
コード例 #7
0
        /// <summary>
        /// Adds a new pending transaction to the mempool.
        /// </summary>
        /// <param name="ptx">The transaction to add.</param>
        /// <param name="needSave">If true, the database will be saved immediately.</param>
        /// <remarks>
        /// In scenarios when there are multiple calls to this method,
        /// passing false to <paramref name="needSave"/> and then calling
        /// <see cref="Save"/> in the end would be a more efficient approach.
        /// </remarks>
        public void AddPendingTransaction(PendingTransaction ptx, bool needSave = true)
        {
            _pendingTransactions.Add(ptx);

            if (needSave)
            {
                Save();
            }
        }
コード例 #8
0
        public List <PendingTransaction> GetTableRecords(string fileLocation, string table, bool isManuallImport = false)
        {
            var transactions     = new List <PendingTransaction>();
            var connectionString = string.Format(_connectionString, fileLocation);
            PendingTransaction _pendingTransaction = new PendingTransaction();

            try
            {
                using (oledbConnection = new OleDbConnection(connectionString))
                {
                    oledbConnection.Open();
                    if (!string.IsNullOrEmpty(table))
                    {
                        var sql = "SELECT * From[" + table + "] WHERE OpenClosedFlag = 'O'";
                        oledbCommand = new OleDbCommand(sql, oledbConnection);
                        oledbReader  = oledbCommand.ExecuteReader();
                        while (oledbReader.Read())
                        {
                            if (isManuallImport)
                            {
                                _pendingTransaction = MapAceesDataManual(oledbReader);
                            }
                            else
                            {
                                _pendingTransaction = MapAceesData(oledbReader);
                            }
                            transactions.Add(_pendingTransaction);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (oledbConnection != null && oledbConnection.State == ConnectionState.Open)
                {
                    oledbConnection.Close();
                }
                if (oledbReader != null)
                {
                    oledbReader.Close();
                }
                if (oledbCommand != null)
                {
                    oledbCommand.Dispose();
                }
                if (oledbConnection != null)
                {
                    oledbConnection.Dispose();
                }
            }
            return(transactions);
        }
コード例 #9
0
        /// <inheritdoc />
        public async Task <FaucetDrip> OpenAsync(IPAddress ipAddress, INetworkAccount recipient, INetworkBlockHeader networkBlockHeader, CancellationToken cancellationToken)
        {
            const string sourceName = @"Test Network Faucet";

            if (!this._faucetContract.Addresses.TryGetValue(key: recipient.Network, out ContractAddress? faucetContractAddress))
            {
                this._logger.LogCritical($"{recipient.Network.Name}: Cannot issue {recipient.Network.NativeCurrency} from faucet. Faucet not available on network");

                throw new InsufficientTokenException();
            }

            INetworkSigningAccount networkSigningAccount = this._ethereumAccountManager.GetAccount(network: recipient.Network);

            (EthereumAmount sourceAccountBalance, EthereumAmount recipientEthBalance) = await this.GetNativeCurrencyBalancesAsync(
                recipient : recipient,
                faucetContractAddress : faucetContractAddress,
                networkBlockHeader : networkBlockHeader,
                cancellationToken : cancellationToken);

            (Token sourceBalanceForToken, Token recipientBalanceForToken) =
                await this.GetTokenBalancesAsync(recipient : recipient, networkBlockHeader : networkBlockHeader, faucetContractAddress : faucetContractAddress, cancellationToken : cancellationToken);

            (EthereumAmount nativeCurrencyAmount, Token tokenAmount) = this.CalculateFundsToIssue(recipient: recipient,
                                                                                                  recipientNativeCurrencyBalance: recipientEthBalance,
                                                                                                  recipientTokenBalance: recipientBalanceForToken,
                                                                                                  faucetNativeCurrencyBalance: sourceAccountBalance,
                                                                                                  faucetTokenBalance: sourceBalanceForToken);

            if (!await this.IsAllowedToIssueFromFaucetAsync(ipAddress: ipAddress, recipientAddress: recipient.Address))
            {
                throw new TooFrequentTokenException();
            }

            Issuance issuance =
                new(recipient : recipient, ethToIssue : nativeCurrencyAmount, tokenToIssue : tokenAmount, sourceAccountBalance : sourceAccountBalance, sourceTokenBalance : sourceBalanceForToken, sourceName
                    : sourceName, new NetworkContract(network : recipient.Network, contractAddress : faucetContractAddress), contractInfo : this._faucetContract);

            try
            {
                PendingTransaction tx = await this.IssueFundsAsync(networkSigningAccount : networkSigningAccount,
                                                                   issuance : issuance,
                                                                   new TransactionContext(contextType : WellKnownContracts.Faucet, recipient.Address.ToString()));

                await this.RecordSuccessfulFaucetDripAsync(recipient : recipient, nativeCurrencyAmount : nativeCurrencyAmount, tokenAmount : tokenAmount, ipAddress : ipAddress);

                return(new FaucetDrip(transaction: tx, ethAmount: nativeCurrencyAmount, tokenAmount: tokenAmount));
            }
            catch (TransactionWillAlwaysFailException exception)
            {
                this._logger.LogCritical(new EventId(exception.HResult),
                                         exception: exception,
                                         $"{issuance.Recipient.Network.Name}: Cannot issue {this._tokenContract.Symbol} from faucet: {exception.Message}");

                throw new InsufficientTokenException(message: "Could not request funds from faucet", innerException: exception);
            }
        }
コード例 #10
0
        public async Task <bool> AddPendingTransaction(PendingTransaction transaction)
        {
            if (_blockchainInstance.Blockchain.AddPending(transaction))
            {
                await _mediator.Publish(new TransactionNotify(transaction));

                return(true);
            }

            return(false);
        }
コード例 #11
0
        public static async Task <Activity> HandleTransaction(Activity message, LUISQueryResult LUISResult)
        {
            StateClient stateClient = message.GetStateClient();
            BotData     userData    = await stateClient.BotState.GetUserDataAsync(message.ChannelId, message.From.Id);

            //check query included required paramaters
            if (!(LUISResult.parameters.ContainsKey("AccountNumber") && VerifyAccountNumber(LUISResult.parameters["AccountNumber"])))
            {
                return(message.CreateReply("To make a transaction, you must include a valid account number"));
            }
            if (!LUISResult.parameters.ContainsKey("Money"))
            {
                return(message.CreateReply("To make a transaction, you must include an amount to send"));
            }

            Account From = await AzureManager.AzureManagerInstance.GetAccountByNumber(userData.GetProperty <string>("AccountNumber"));

            Account To = await AzureManager.AzureManagerInstance.GetAccountByNumber(AccountNumberStrip(LUISResult.parameters["AccountNumber"]));

            double amount = double.TryParse(ExtractNum.Replace(FindNum.Match(LUISResult.parameters["Money"]).Value, ""), out amount) ? amount : 0.0;

            //check particulars are valid
            if (amount <= 0)
            {
                return(message.CreateReply("Cannot send a non-positive amount of money"));
            }
            if (To == null)
            {
                return(message.CreateReply("Recipient account not found"));
            }
            if (amount > From.Balance)
            {
                return(message.CreateReply(string.Format("Insufficient funds $ {0:F2}, to pay $ {1:F2}", From.Balance, amount)));
            }

            //setup transaction, pending confirmation
            PendingTransaction transaction = new PendingTransaction
            {
                From   = From,
                To     = To,
                amount = amount
            };

            userData.SetProperty("Pending", "Transaction");
            userData.SetProperty("PendingTransaction", transaction);
            await stateClient.BotState.SetUserDataAsync(message.ChannelId, message.From.Id, userData);

            Activity response = message.CreateReply("Please confirm or cancel transaction:");

            response.Attachments = new List <Attachment> {
                TransactionConfirmationCard(transaction)
            };
            return(response);
        }
コード例 #12
0
        /// <summary>
        /// Wraps execution of a pending transaction so that the database servers
        /// can be load-balanced.
        /// </summary>
        /// <param name="transaction"></param>
        public void ExecuteTransaction(PendingTransaction transaction)
        {
            Validation.IsNotNull(transaction, "transaction");

            var server = _serverContext.NextServer;

            if (server == null)
            {
                throw new GeneralException(Resources.ERR_DB_SERVER_NOT_FOUND, transaction.TransactionId);
            }

            server.ExecuteTransaction(transaction);
        }
コード例 #13
0
ファイル: Blockchain.cs プロジェクト: alex687/BlockchainTech
        public bool AddPending(PendingTransaction transaction)
        {
            var pendingTransactions = _pendingTransactionRepository.GetPending().ToList();

            pendingTransactions.Add(transaction);

            if (_transactionValidator.PendingTransactionsValidate(pendingTransactions))
            {
                return(_pendingTransactionRepository.AddPending(transaction));
            }

            return(false);
        }
コード例 #14
0
    /// <summary>
    /// Starts a new pending transaction.
    /// </summary>
    /// <param name="ethTransactionPromise"> The transaction promise returning the result of the transaction. </param>
    /// <param name="txHash"> The transaction hash of the transaction. </param>
    /// <param name="addressFrom"> The address the transaction was sent from. </param>
    /// <param name="message"> The message representing the transaction. </param>
    public void StartNewPendingTransaction(EthTransactionPromise ethTransactionPromise, string txHash, string addressFrom, string message)
    {
        addressFrom = addressFrom.ToLower();
        txHash      = txHash.ToLower();

        var pendingTransaction = new PendingTransaction(addressFrom, txHash, message);

        transactionsByAddress.AddOrReplace(addressFrom, pendingTransaction);
        transactionsByHash.AddOrReplace(txHash, pendingTransaction);

        OnNewTransactionPending?.Invoke(txHash, message);

        ethTransactionPromise.OnSuccess(_ => PendingTransactionSuccessful(txHash)).OnError(_ => PendingTransactionUnsuccessful(txHash));
    }
コード例 #15
0
        public bool RequestPayment(PaymentRequest request)
        {
            var validator = new RequestPaymentValidator();

            var valResults = validator.Validate(request);

            if (!valResults.IsValid)
            {
                throw new ArgumentException($"Failed payment request validation. {valResults.ToString()}");
            }

            // Check if pending need to be paid first
            if (request.SendByDate.Date > DateTime.Today.Date)
            {
                var pendingPayment = new PendingTransaction()
                {
                    AccountId         = request.AccountId,
                    TransactionTypeId = 1,
                    Amount            = request.Amount,
                    PayDate           = request.SendByDate,
                    Description       = request.Description
                };

                _pursueContext.PendingTransactions.Add(pendingPayment);

                _pursueContext.SaveChanges();
            }
            else
            {
                // If today payment substract payment amount from account balance
                // then take that balance amount and insert transaction record
                var account = _pursueContext.Accounts.Where(a => a.Id == request.AccountId).Single();

                account.Balance = account.Balance - request.Amount;
                _pursueContext.Transactions.Add(new Transaction()
                {
                    AccountId          = account.Id,
                    Amount             = request.Amount,
                    TransactionBalance = account.Balance,
                    TransactionTypeId  = 1,
                    Description        = request.Description,
                    WhenTransacted     = DateTime.Now
                });

                _pursueContext.SaveChanges();
            }

            return(true);
        }
コード例 #16
0
        private PendingTransaction Create(TransactionRequestModel tranRM)
        {
            var newTransaction = new PendingTransaction
            {
                From            = tranRM.From,
                To              = tranRM.To,
                SenderPublicKey = tranRM.SenderPubKey,
                Value           = tranRM.Value,
                Fee             = tranRM.Fee,
                DateCreated     = tranRM.DateCreated,
                SenderSignature = tranRM.SenderSignature
            };

            return(newTransaction);
        }
コード例 #17
0
        private void Validate(PendingTransaction currentTransaction)
        {
            if (pendingTransactions.Any(t => t.Hash == currentTransaction.Hash))
            {
                throw new Exception("Transaction is already added.");
            }

            if (!Crypto.IsSignatureValid(currentTransaction))
            {
                throw new Exception("Transaction signature is not valid.");
            }

            //Check for missing / invalid fields
            //Check for correct balances?
        }
コード例 #18
0
 private static Attachment TransactionCompleteCard(PendingTransaction transaction)
 {
     return(new HeroCard
     {
         Title = "Transaction confirmed!",
         Text = $"Amount: NZD {transaction.amount.ToString("F2")}  \nFrom: {AccountNumberFormat(transaction.From.AccountNumber)}  \nTo: {AccountNumberFormat(transaction.To.AccountNumber)}",
         Images = new List <CardImage>
         {
             new CardImage
             {
                 Url = "https://jw-contoso.azurewebsites.net/img/logoCarousel512.png",
                 Alt = "Contoso Bank Logo"
             }
         }
     }.ToAttachment());
 }
コード例 #19
0
        public async Task SellItem(params string[] indexXamount)
        {
            Player player = Context.Player;

            if (!player.IsEncounter("npc"))
            {
                await ReplyAsync("You must be in an interaction with a n NPC to Sell. Find NPCs by exploring in towns");
            }
            else
            {
                PendingTransaction transaction = new PendingTransaction(
                    player, indexXamount, PendingTransaction.Transaction.Sell);

                await transaction.SendTransaction(player, Context.Channel);
            }
        }
コード例 #20
0
        public void PublishTransaction(PendingTransaction transaction)
        {
            var transactionRequest = new PendingTransactionRequest
            {
                Amount           = transaction.Amount,
                From             = transaction.From,
                Hash             = transaction.Hash,
                SenderPublickKey = transaction.SenderPublickKey,
                SenderSignature  = transaction.SenderSignature,
                To = transaction.To
            };

            foreach (var peer in _peers.GetAll())
            {
                peer.Address.AppendPathSegments("api", "transactions")
                .PostJsonAsync(transactionRequest);
            }
        }
コード例 #21
0
        /// <inheritdoc />
        public async Task StartGameAsync(INetworkSigningAccount account, ContractAddress gameContract, INetworkBlockHeader networkBlockHeader, CancellationToken cancellationToken)
        {
            if (!this._lowBalanceWatcher.DoesAccountHaveEnoughBalance(account))
            {
                this._logger.LogWarning($"{account.Network.Name}: There was no enough {account.Network.NativeCurrency} for house address {account.Address} to create a game");

                return;
            }

            if (!this._gameManager.Addresses.TryGetValue(key: account.Network, out ContractAddress? gameManagerContract))
            {
                return;
            }

            GameRoundId gameRoundId = new(bytes : this._randomSource.Generate(count : GameRoundId.RequiredByteLength));

            // The commit that's public is generated by using the one way hash from the reveal.
            Seed seedReveal = new(bytes : this._randomSource.Generate(count : Seed.RequiredByteLength));
            Seed seedCommit = new(this._hasher.Hash(seedReveal.ToSpan()));

            StartGameRoundInput input = new(roundId : gameRoundId, gameAddress : gameContract, entropyCommit : seedCommit);

            PendingTransaction pendingTransaction = await this._transactionService.SubmitAsync(account : account,
                                                                                               transactionContext : new TransactionContext(contextType: @"GAMEROUND", gameRoundId.ToString()),
                                                                                               input : input,
                                                                                               cancellationToken : cancellationToken);

            this._logger.LogInformation($"{pendingTransaction.Network.Name}: Created game {gameRoundId} tx {pendingTransaction.TransactionHash}");

            await this._gameRoundDataManager.SaveStartRoundAsync(gameRoundId : gameRoundId,
                                                                 createdByAccount : account.Address,
                                                                 network : account.Network,
                                                                 gameContract : gameContract,
                                                                 gameManagerContract : gameManagerContract,
                                                                 seedCommit : seedCommit,
                                                                 seedReveal : seedReveal,
                                                                 roundDuration : GameRoundParameters.RoundDuration,
                                                                 bettingCloseDuration : GameRoundParameters.BettingCloseDuration,
                                                                 roundTimeoutDuration : GameRoundParameters.RoundTimeoutDuration,
                                                                 blockNumberCreated : networkBlockHeader.Number,
                                                                 transactionHash : pendingTransaction.TransactionHash);

            await this._gameStatisticsPublisher.GameRoundStartingAsync(network : account.Network, gameRoundId : gameRoundId, transactionHash : pendingTransaction.TransactionHash);
        }
コード例 #22
0
        public static bool IsSignatureValid(PendingTransaction transaction)
        {
            ECPoint               publicKeyPoint      = GetECPublicKeyPoint(transaction.SenderPublicKey);
            ECDomainParameters    ecSpec              = new ECDomainParameters(curve.Curve, curve.G, curve.N, curve.H);
            ECPublicKeyParameters publicKeyParameters = new ECPublicKeyParameters(publicKeyPoint, ecSpec);

            IDsaKCalculator kCalculator = new HMacDsaKCalculator(new Sha256Digest());
            ECDsaSigner     signer      = new ECDsaSigner(kCalculator);

            signer.Init(false, publicKeyParameters);

            byte[]     tranHashWithoutSignature = CalculateSHA256(transaction.AsJsonWithoutSignatureAndHash());
            BigInteger signatureR = new BigInteger(transaction.SenderSignature[0], 16);
            BigInteger signatureS = new BigInteger(transaction.SenderSignature[1], 16);

            bool isValid = signer.VerifySignature(tranHashWithoutSignature, signatureR, signatureS);

            return(isValid);
        }
        /// <inheritdoc />
        public async Task <PendingTransaction> SubmitAsync <TTransactionInput>(INetworkSigningAccount account,
                                                                               TTransactionInput input,
                                                                               TransactionContext transactionContext,
                                                                               CancellationToken cancellationToken)
            where TTransactionInput : TransactionParameters
        {
            this._logger.LogInformation($"{account.Network.Name}: Submit transaction: {typeof(TTransactionInput)}");
            PendingTransaction transaction = await this._contractInfo.SubmitTransactionAsync(transactionExecutorFactory : this._transactionExecutorFactory,
                                                                                             account : account,
                                                                                             input : input,
                                                                                             amountToSend : EthereumAmount.Zero,
                                                                                             priority : TransactionPriority.NORMAL,
                                                                                             context : transactionContext,
                                                                                             cancellationToken : cancellationToken);

            this._logger.LogInformation($"{account.Network.Name}: Transaction submitted: {typeof(TTransactionInput)}, hash: {transaction.TransactionHash}");

            return(transaction);
        }
コード例 #24
0
        public void AddPendingCommit(CommitLogRecord commit, long postPosition)
        {
            PendingTransaction transaction;

            if (_pendingTransactions.TryGetValue(commit.TransactionPosition, out transaction))
            {
                var newTransaction = new PendingTransaction(commit.TransactionPosition, postPosition, transaction.Prepares, commit);
                if (!_pendingTransactions.TryUpdate(commit.TransactionPosition, newTransaction, transaction))
                {
                    throw new InvalidOperationException("Failed to update pending commit");
                }
            }
            else
            {
                var pendingTransaction = new PendingTransaction(commit.TransactionPosition, postPosition, commit);
                if (!_pendingTransactions.TryAdd(commit.TransactionPosition, pendingTransaction))
                {
                    throw new InvalidOperationException("Failed to add pending commit");
                }
            }
        }
コード例 #25
0
        private PendingTransaction MapAceesData(OleDbDataReader reader)
        {
            PendingTransaction tran = new PendingTransaction();

            if (reader != null)
            {
                tran.TransactionUID                 = CheckNull.ConvertToInt32(reader["TransactionUID"]);
                tran.OpenClosedFlag                 = CheckNull.ConvertToString(reader["OpenClosedFlag"]);
                tran.TypeCode                       = CheckNull.ConvertToString(reader["TypeCode"]);
                tran.CededAssumedFlag               = CheckNull.ConvertToString(reader["CededAssumedFlag"]);
                tran.DisputedFlag                   = CheckNull.ConvertToString(reader["DisputedFlag"]);
                tran.Pre1984Flag                    = CheckNull.ConvertToString(reader["Pre1984Flag"]);
                tran.CnaReProductSw                 = CheckNull.ConvertToString(reader["CnaReProductSw"]);
                tran.ReinsurerCode                  = CheckNull.ConvertToString(reader["ReinsurerCode"]);
                tran.ContractCode                   = CheckNull.ConvertToString(reader["ContractCode"]);
                tran.SourceCode                     = CheckNull.ConvertToInt32(reader["SourceCode"]);
                tran.CompanyCode                    = CheckNull.ConvertToString(reader["CompanyCode"]);
                tran.TableUID                       = CheckNull.ConvertToShort(reader["TableUID"]);
                tran.APFlag                         = CheckNull.ConvertToString(reader["APFlag"]);
                tran.NICOOffsetFlag                 = CheckNull.ConvertToString(reader["NICOOffsetFlag"]);
                tran.OriginalReinsurerCode          = CheckNull.ConvertToString(reader["OriginalReinsurerCode"]);
                tran.ContractCodeFAC                = CheckNull.ConvertToString(reader["ContractCodeFAC"]);
                tran.ContractUnderwritingYear       = CheckNull.ConvertToShort(reader["ContractUnderwritingYear"]);
                tran.ContractLayerEffectiveDate     = CheckNull.ConvertToDateTime(reader["ContractLayerEffectiveDate"]);
                tran.ContractLayerNumber            = CheckNull.ConvertToShort(reader["ContractLayerNumber"]);
                tran.CatastropheCode                = CheckNull.ConvertToString(reader["CatastropheCode"]);
                tran.LocationCodePart6              = CheckNull.ConvertToString(reader["LocationCodePart6"]);
                tran.CollateralDeferralEndDate      = CheckNull.ConvertToDateTime(reader["CollateralDeferralEndDate"]);
                tran.CertifiedRatingEffDt           = CheckNull.ConvertToDateTime(reader["CertifiedRatingEffDt"]);
                tran.CertifiedRecoRatingCd          = CheckNull.ConvertToString(reader["CertifiedRecoRatingCd"]);
                tran.CertifiedPercent               = CheckNull.ConvertToDouble(reader["CertifiedPercent"]);
                tran.OrigReinsCollateDeferralEndDt  = CheckNull.ConvertToDateTime(reader["OrigReinsCollateDeferralEndDt"]);
                tran.OrigReinsCertifiedRatingEffDt  = CheckNull.ConvertToDateTime(reader["OrigReinsCertifiedRatingEffDt"]);
                tran.OrigReinsCertifiedRecoRatingCd = CheckNull.ConvertToString(reader["OrigReinsCertifiedRecoRatingCd"]);
                tran.OrigReinsCertifiedPercent      = CheckNull.ConvertToInt32(reader["OrigReinsCertifiedPercent"]);
                tran.MultipleBeneficiaryAmt         = CheckNull.ConvertToDecimal(reader["MultipleBeneficiaryAmt"]);
            }

            return(tran);
        }
コード例 #26
0
        public void AddPendingPrepare(PrepareLogRecord[] prepares, long postPosition)
        {
            var transactionPosition = prepares[0].TransactionPosition;
            PendingTransaction transaction;

            if (_pendingTransactions.TryGetValue(transactionPosition, out transaction))
            {
                var newTransaction = new PendingTransaction(transactionPosition, postPosition, transaction.Prepares, transaction.Commit);
                newTransaction.AddPendingPrepares(prepares);
                if (!_pendingTransactions.TryUpdate(transactionPosition, newTransaction, transaction))
                {
                    throw new InvalidOperationException("Failed to update pending prepare");
                }
            }
            else
            {
                var pendingTransaction = new PendingTransaction(transactionPosition, postPosition, prepares);
                if (!_pendingTransactions.TryAdd(transactionPosition, pendingTransaction))
                {
                    throw new InvalidOperationException("Failed to add pending prepare");
                }
            }
        }
コード例 #27
0
        public override void receivedTransactionInclusionVerificationResponse(byte[] txid, bool verified)
        {
            // TODO implement error
            // TODO implement blocknum

            ActivityStatus status = ActivityStatus.Pending;

            if (verified)
            {
                status = ActivityStatus.Final;
                PendingTransaction p_tx = PendingTransactions.getPendingTransaction(txid);
                if (p_tx != null)
                {
                    if (p_tx.messageId != null)
                    {
                        StreamProcessor.confirmMessage(p_tx.messageId);
                    }
                    PendingTransactions.remove(txid);
                }
            }

            ActivityStorage.updateStatus(txid, status, 0);
        }
コード例 #28
0
 public PendingTransactionForRpc(PendingTransaction transaction)
 {
     ResourceId  = transaction.ResourceId;
     Type        = transaction.Type;
     Transaction = new TransactionInfoForRpc(transaction.Transaction);
 }
コード例 #29
0
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="ethAmount">The amount of ETH that was issued.</param>
 /// <param name="tokenAmount">The amount of token that was issued.</param>
 /// <param name="transaction">The transaction that was issued to transfer the funds.</param>
 public FaucetDrip(EthereumAmount ethAmount, Token tokenAmount, PendingTransaction transaction)
 {
     this.EthAmount   = ethAmount;
     this.TokenAmount = tokenAmount;
     this.Transaction = transaction;
 }
コード例 #30
0
 public bool Validate(PendingTransaction transaction)
 {
     return(true);
 }