Ejemplo n.º 1
0
        public TransactionContract GetTransactionList(SearchFilterObject SearchFilter)
        {
            TransactionContract retunrobject = new TransactionContract();

            retunrobject.TransactionList = TransactionRepo.GetTransactionList(SearchFilter);

            return(retunrobject);
        }
Ejemplo n.º 2
0
        public TransactionContract GetSalesObjectByStockID(int StockID)
        {
            TransactionContract retunrobject = new TransactionContract();

            retunrobject.SalesObject = TransactionRepo.GetSalesDetailsByStockID(StockID);

            return(retunrobject);
        }
Ejemplo n.º 3
0
        public TransactionContract GetSaleObject(int SaleID)
        {
            TransactionContract retunrobject = new TransactionContract();

            retunrobject.SalesObject = TransactionRepo.GetSalesDetails(SaleID);

            return(retunrobject);
        }
Ejemplo n.º 4
0
        public TransactionContract GetRefundObject(int RefundID)
        {
            TransactionContract retunrobject = new TransactionContract();

            retunrobject.RefundObject = TransactionRepo.GetRefundDetails(RefundID);

            return(retunrobject);
        }
Ejemplo n.º 5
0
        public TransactionContract GetPurchaseObjectByStockID(int StockID)
        {
            TransactionContract retunrobject = new TransactionContract();

            retunrobject.PurchaseObject = TransactionRepo.GetPurchaseDetailsByStockID(StockID);

            return(retunrobject);
        }
Ejemplo n.º 6
0
        public TransactionContract GetPurchaseObject(int PurchaseID)
        {
            TransactionContract retunrobject = new TransactionContract();

            retunrobject.PurchaseObject = TransactionRepo.GetPurchaseDetails(PurchaseID);

            return(retunrobject);
        }
Ejemplo n.º 7
0
 private void btn_lock_Click(object sender, EventArgs e)
 {
     using (LockUTXODialog dialog = new LockUTXODialog())
     {
         if (dialog.ShowDialog() == DialogResult.OK)
         {
             uint timestamp = dialog.GetUXTOLockTime;
             TransactionContract transactionContract = new TransactionContract();
             LockAttribute = transactionContract.MakeLockTransactionScript(timestamp);
         }
     }
 }
Ejemplo n.º 8
0
        //private string RequestRpc(string method, string kvs)
        //{
        //    string jsonRes = "";
        //    using (HttpClient client = new HttpClient())
        //    {
        //        string uri = $"{ExtensionSettings.Default.DataRPCServer.Host}/{method}?{kvs}";
        //        client.BaseAddress = new Uri(uri);
        //        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
        //        var response = client.GetAsync(uri).Result;
        //        Task<Stream> task = response.Content.ReadAsStreamAsync();
        //        Stream backStream = task.Result;
        //        StreamReader reader = new StreamReader(backStream);
        //        jsonRes = reader.ReadToEnd();
        //        reader.Close();
        //        backStream.Close();
        //    }
        //    return jsonRes;
        //}

        private Transaction MakeToColdTransaction(Coin[] coins, UInt160 outAddress, UInt256 assetId, UInt160 fee_address = null)
        {
            int         MaxInputCount = 50;
            Transaction tx            = new ContractTransaction();

            tx.Attributes = new TransactionAttribute[0];
            tx.Witnesses  = new Witness[0];

            List <CoinReference>     inputs  = new List <CoinReference>();
            List <TransactionOutput> outputs = new List <TransactionOutput>();

            Fixed8 sum = Fixed8.Zero;

            if (coins.Length < 50)
            {
                MaxInputCount = coins.Length;
            }
            for (int j = 0; j < MaxInputCount; j++)
            {
                sum += coins[j].Output.Value;
                inputs.Add(new CoinReference
                {
                    PrevHash  = coins[j].Reference.PrevHash,
                    PrevIndex = coins[j].Reference.PrevIndex
                });
            }
            tx.Inputs = inputs.ToArray();
            outputs.Add(new TransactionOutput
            {
                AssetId    = assetId,
                ScriptHash = outAddress,
                Value      = sum
            });
            if (tx.SystemFee > Fixed8.Zero)
            {
                outputs.Add(new TransactionOutput
                {
                    AssetId = Blockchain.UtilityToken.Hash,
                    Value   = tx.SystemFee
                });
            }
            tx.Outputs = outputs.ToArray();
            Fixed8 transfee = BhpTxFee.EstimateTxFee(tx, assetId);

            if (tx.Outputs[0].Value <= transfee)
            {
                return(null);
            }
            tx.Outputs[0].Value -= transfee;
            return(TransactionContract.EstimateFee(wallet, tx, null, fee_address));
        }
Ejemplo n.º 9
0
        public static Transaction Create(TransactionContract contract, Network network)
        {
            var inputs  = contract.Inputs.Select(p => InOut.Create(p, network));
            var outputs = contract.Outputs.Select(p => InOut.Create(p, network));

            var transactionInfo = NBitcoin.Transaction.Parse(contract.Hex);

            return(new Transaction
            {
                TransactionId = contract.TransactionId,
                Hex = transactionInfo.ToHex(),
                IsCoinBase = transactionInfo.IsCoinBase,
                IsColor = transactionInfo.HasValidColoredMarker(),
                Block = BlockMinInfo.Create(contract.Block),
                Fees = contract.Fees,
                TransactionsByAssets = InOutsByAsset.Create(inputs, outputs),
                InputsCount = contract.Inputs.Count(),
                OutputsCount = contract.Outputs.Count()
            });
        }
Ejemplo n.º 10
0
 /// <summary>
 /// 将钱包内的资产转账到指定地址
 /// </summary>
 /// <param name="_params[0]">收款地址</param>
 /// <param name="_params[1]">资产ID</param>
 /// <param name="_params[2]">bhp手续费地址,可选参数。(转账资产包含BHP时,此参数无效)</param>
 /// <returns>交易</returns>
 private JObject SendToCold(JArray _params)
 {
     if (wallet == null || walletTimeLock.IsLocked())
     {
         throw new RpcException(-400, "Access denied");
     }
     else
     {
         UInt160            scriptHash  = _params[0].AsString().ToScriptHash();
         UInt256            assetId     = _params.Count >= 2 ? UInt256.Parse(_params[1].AsString()) : Blockchain.GoverningToken.Hash;
         UInt160            fee_address = _params.Count >= 3 ? _params[2].AsString().ToScriptHash() : null;
         IEnumerable <Coin> allCoins    = wallet.FindUnspentCoins();
         Coin[]             coins       = TransactionContract.FindUnspentCoins(allCoins, assetId);
         Transaction        tx          = MakeToColdTransaction(coins, scriptHash, assetId, fee_address);
         if (tx == null)
         {
             throw new RpcException(-300, "Insufficient funds");
         }
         ContractParametersContext context = new ContractParametersContext(tx);
         wallet.Sign(context);
         if (context.Completed)
         {
             tx.Witnesses = context.GetWitnesses();
             if (tx.Size > Transaction.MaxTransactionSize)
             {
                 throw new RpcException(-301, "The size of the free transaction must be less than 102400 bytes");
             }
             wallet.ApplyTransaction(tx);
             system.LocalNode.Tell(new LocalNode.Relay {
                 Inventory = tx
             });
             return(tx.ToJson());
         }
         else
         {
             return(context.ToJson());
         }
     }
 }