public string PackTransactionByApiModelDelegation(RequestApiModel model)
        {
            var transac = InitTransaction(model);
            var res     = SimpleBase.Base58.Bitcoin.Encode(BCTransactionTools.CreateByteHashByTransactionDelegation(transac, model.DelegateEnable, model.DelegateDisable));

            return(res);
        }
示例#2
0
        public TransactionInfo GetTransaction(RequestTransactionApiModel model)
        {
            var response = new TransactionInfo();

            using (var client = GetClientByModel(model))
            {
                var trId  = BCTransactionTools.GetTransactionIdByStr(model.TransactionId);//GetTransactionId(id);
                var tr    = client.TransactionGet(trId);
                var tInfo = ToTransactionInfo(0, trId, tr.Transaction.Trxn);
                tInfo.Found = tr.Found;
                response    = tInfo;
            }

            return(response);
        }
示例#3
0
        public WalletDataResponseApiModel GetWalletData(RequestKeyApiModel model)
        {
            var response = new WalletDataResponseApiModel();

            using (var client = GetClientByModel(model))
            {
                var publicKeyByte = SimpleBase.Base58.Bitcoin.Decode(model.PublicKey);
                var result        = client.WalletDataGet(publicKeyByte.ToArray());


                response.Balance         = BCTransactionTools.GetDecimalByAmount(result.WalletData.Balance);
                response.LastTransaction = result.WalletData.LastTransactionId;
                var dStr = new DelegatedStructure();
                if (result.WalletData.Delegated != null)
                {
                    dStr.Incoming = BCTransactionTools.GetDecimalByAmount(result.WalletData.Delegated.Incoming);
                    dStr.Outgoing = BCTransactionTools.GetDecimalByAmount(result.WalletData.Delegated.Outgoing);
                    if (result.WalletData.Delegated.Donors != null)
                    {
                        foreach (var it in result.WalletData.Delegated.Donors)
                        {
                            var item = new DelegatedInfo();
                            item.PublicKey  = SimpleBase.Base58.Bitcoin.Encode(it.Wallet);
                            item.Sum        = BCTransactionTools.GetDecimalByAmount(it.Sum);
                            item.ValidUntil = it.ValidUntil;
                            dStr.Donors.Add(item);
                        }
                    }
                    if (result.WalletData.Delegated.Recipients != null)
                    {
                        foreach (var it in result.WalletData.Delegated.Recipients)
                        {
                            var item = new DelegatedInfo();
                            item.PublicKey  = SimpleBase.Base58.Bitcoin.Encode(it.Wallet);
                            item.Sum        = BCTransactionTools.GetDecimalByAmount(it.Sum);
                            item.ValidUntil = it.ValidUntil;
                            dStr.Recipients.Add(item);
                        }
                    }
                }
                response.Delegated = dStr;
            }

            return(response);
        }
        public API.Client GetClientByModel(AbstractRequestApiModel model)
        {
            if (!String.IsNullOrEmpty(model.NetworkIp) && !String.IsNullOrEmpty(model.NetworkPort))
            {
                return(BCTransactionTools.CreateContextBC(model.NetworkIp,
                                                          Int32.Parse(model.NetworkPort),
                                                          30000
                                                          ));
            }

            var authUser = AuthDataService.ListAuthKey.FirstOrDefault(p => p.AuthKey == model.AuthKey);

            if (authUser == null)
            {
                return(null);
            }

            return(InitContextBC(model.NetworkAlias));
        }
        public DataResponseApiModel PackTransactionByApiModel(RequestApiModel model)
        {
            var res     = new DataResponseApiModel();
            var transac = InitTransaction(model);

            byte[] byteData;

            if (!model.DelegateEnable && !model.DelegateDisable)
            {
                byteData = BCTransactionTools.CreateByteHashByTransaction(transac);
            }
            else
            {
                byteData = BCTransactionTools.CreateByteHashByTransactionDelegation(transac);
            }

            res.TransactionPackagedStr = SimpleBase.Base58.Bitcoin.Encode(byteData);
            res.RecommendedFee         = model.Fee;
            res.ActualSum = model.Amount;
            return(res);
        }
        public API.Client InitContextBC(string aliasNetwork = "MainNet", int numServer = 1)
        {
            if (String.IsNullOrEmpty(aliasNetwork))
            {
                aliasNetwork = "MainNet";
            }

            string configStr = $"ApiNode:servers:{aliasNetwork}:s{numServer}:";

            Console.WriteLine(configStr + "Port");
            //Console.WriteLine(Configuration[configStr + "Port"]);
            //Console.WriteLine(Configuration[configStr + "TimeOut"]);

            var ip      = Configuration[configStr + "Ip"];
            var port    = Configuration[configStr + "Port"];
            var timeout = Configuration[configStr + "TimeOut"];

            return(BCTransactionTools.CreateContextBC(ip,
                                                      Int32.Parse(port),
                                                      Int32.Parse(timeout)
                                                      ));
        }
        public void Crypto1Test()
        {
            var sourceStr   = "FeFjpcsfHErXPk5HkfVcwH6zYaRT2xNytDTeSjfuVywt";
            var sourceByte  = SimpleBase.Base58.Bitcoin.Decode(sourceStr).ToArray();
            var privateByte = SimpleBase.Base58.Bitcoin.Decode("ohPH5zghdzmRDxd978r7y6r8YFoTcKm1MgW2gzik3omCuZLysjwNjTd9hnGREFyQHqhShoU4ri7q748UgdwZpzA").ToArray();


            using (var _api = BCTransactionTools.CreateContextBC("165.22.220.8", 9090, 60000))
            {
                //   WalletDataGetResult WalletData = _api._connect.WalletDataGet(sourceByte);
                //   long transactionId = WalletData.WalletData.LastTransactionId + 1;
                var transactionId = _api.WalletDataGet(sourceByte).WalletData.LastTransactionId + 1;
                //     var connect = _api._connect;
                //   for (int i = 0; i <= 19; i++)
                {
                    transactionId++;
                    Transaction transac = new Transaction
                    {
                        Id     = transactionId,
                        Source = sourceByte,
                        Amount = BCTransactionTools.GetAmountByDouble_C(0.1M),
                        Fee    = BCTransactionTools.EncodeFeeFromDouble(0.1),

                        // если перевод смарта то таргет публичник смарта
                        Target = SimpleBase.Base58.Bitcoin.Decode("FY8J5uSb2D3qX3iwUSvcUSGvrBGAvsrXxKxMQdFfpdmm").ToArray(),
                        // если перевод CS - то адресат назначения.
                        //"DM79n9Lbvm3XhBf1LwyBHESaRmJEJez2YiL549ArcHDC"),
                        // UserFields = model.UserData
                    };
                    transac.UserFields = new byte[5];
                    #region ДЕПЛОЙ СМАРТА (убрать if при необходимости)
                    if (1 == 2)
                    {
                        string codeSmart  = "";
                        Byte[] byteSource = transac.Source;
                        //code
                        var byteCodes =
                            _api.SmartContractCompile(codeSmart);
                        if (byteCodes.Status.Code > 0)
                        {
                            throw new Exception(byteCodes.Status.Message);
                        }
                        foreach (var item in byteCodes.ByteCodeObjects)
                        {
                            byteSource.Concat(item.ByteCode);
                        }
                        transac.Target        = Blake2s.ComputeHash(byteSource);
                        transac.SmartContract = new SmartContractInvocation()
                        {
                            SmartContractDeploy = new SmartContractDeploy()
                            {
                                SourceCode      = codeSmart,
                                ByteCodeObjects = byteCodes.ByteCodeObjects
                            }
                        };
                    }

                    #endregion


                    #region ВЫЗОВ МЕТОДА СМАРТА (убрать if при необходимости)

                    if (1 == 2)
                    {
                        transac.SmartContract = new SmartContractInvocation()
                        {
                            Method = "transfer",
                            Params = new List <Variant>()
                            {
                                new Variant()
                                {
                                    // адресат перевода
                                    V_string = "DM79n9Lbvm3XhBf1LwyBHESaRmJEJez2YiL549ArcHDC"
                                               //      { Value = "DM79n9Lbvm3XhBf1LwyBHESaRmJEJez2YiL549ArcHDC", Key = "STRING" },
                                               //           new Credtis_Api_Connect.Model.ParamsCreateModel { Value = "0.5", Key = "STRING" }
                                },
                                new Variant()
                                {
                                    V_string = "0.5"
                                }
                            }
                        };
                    }

                    #endregion



                    transac.Currency = 1;
                    Console.WriteLine(SimpleBase.Base58.Bitcoin.Encode(BCTransactionTools.CreateByteHashByTransaction(transac)));

                    Rebex.Security.Cryptography.Ed25519 crypt = new Rebex.Security.Cryptography.Ed25519();
                    crypt.FromPrivateKey(privateByte);
                    // var b58 = new SimpleBase.Base58();


                    transac.Signature = crypt
                                        .SignMessage(BCTransactionTools.CreateByteHashByTransaction(transac));

                    Console.WriteLine();
                    Console.WriteLine(SimpleBase.Base58.Bitcoin.Encode(transac.Signature));
                    //  Console.WriteLine(BitConverter.ToString(transac.Signature)); // работает в старом вариант


                    //  var  _api1 = BCTransactionTools.CreateContextBC("165.22.220.8", 9090, 6000);
                    //   var res = _api.TransactionFlow(transac);
                    Console.WriteLine();
                    //  Console.WriteLine(BitConverter.ToString(BCTransactionTools.CreateByteHashByTransaction(transac)).Replace("-",""));
                    //      = Res1;
                }
            }
        }
示例#8
0
        public FilteredTransactionsResponseModel GetFilteredTransactions(RequestFilteredListModel model)
        {
            var res = new FilteredTransactionsResponseModel();

            using (var client = GetClientByModel(model))
            {
                var args = new API.FilteredTransactionsListGet_args();
                args.GeneralQuery         = new TransactionsQuery();
                args.GeneralQuery.Flag    = Convert.ToInt16((model.Flagg == "in") ? 1 : (model.Flagg == "out" ? 2 : 3));
                args.GeneralQuery.Queries = new List <SingleQuery>();
                foreach (var qry in model.Queries)
                {
                    //var nq = new SingleQuery();
                    var sq = new SingleQuery();
                    sq.FromId           = BCTransactionTools.GetTransactionIdByStr(qry.FromId == null ? "0.0" : qry.FromId);
                    sq.RequestedAddress = SimpleBase.Base58.Bitcoin.Decode(qry.Address).ToArray();
                    if (qry.TokenQueries != null)
                    {
                        sq.TokensList = new List <SingleTokenQuery>();
                        foreach (var tokenReq in qry.TokenQueries)
                        {
                            var sqt = new SingleTokenQuery();
                            sqt.FromId       = BCTransactionTools.GetTransactionIdByStr(tokenReq.FromId);
                            sqt.TokenAddress = SimpleBase.Base58.Bitcoin.Decode(tokenReq.TokenAddress).ToArray();
                            sq.TokensList.Add(sqt);
                        }
                    }
                    args.GeneralQuery.Queries.Add(sq);
                }

                var qResult = client.FilteredTransactionsListGet(args.GeneralQuery);
                if (model.Queries.Count() < qResult.QueryResponse.Count)
                {
                    throw new Exception("Query and response lists are not syncronized");
                }

                foreach (var qRep in qResult.QueryResponse)
                {
                    var qRes = new QueryResponseItem();
                    qRes.QueryAddress = SimpleBase.Base58.Bitcoin.Encode(qRep.RequestedAddress);
                    foreach (var tr in qRep.Transactions)
                    {
                        var newTr = new ShortTransactionInfo();
                        newTr.Amount   = BCTransactionTools.GetDecimalByAmount(tr.Amount);
                        newTr.Currency = Convert.ToUInt16(tr.Currency);
                        var feeStr = Utils.ConvertCommission(tr.Fee.Commission).Replace(",", ".");

                        var style = NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands;
                        newTr.Fee = Decimal.Parse(feeStr, style, CultureInfo.InvariantCulture);

                        if (model.Flagg == "in")
                        {
                            newTr.Source = SimpleBase.Base58.Bitcoin.Encode(tr.Source);
                        }
                        else if (model.Flagg == "out")
                        {
                            newTr.Target = SimpleBase.Base58.Bitcoin.Encode(tr.Target);
                        }
                        else
                        {
                            newTr.Source = SimpleBase.Base58.Bitcoin.Encode(tr.Source);
                            newTr.Target = SimpleBase.Base58.Bitcoin.Encode(tr.Target);
                        }
                        newTr.TimeCreation  = (new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).AddSeconds(tr.TimeCreation / 1000);
                        newTr.TransactionId = Convert.ToString(tr.Id.PoolSeq) + "." + Convert.ToString(tr.Id.Index);
                        newTr.Type          = Convert.ToByte(tr.Type);
                        newTr.UserData      = SimpleBase.Base58.Bitcoin.Encode(tr.UserFields);
                        qRes.Transactions.Add(newTr);
                    }
                    if (qRep.TransfersList != null)
                    {
                        foreach (var tokenResp in qRep.TransfersList)
                        {
                            var SingleTokenResponse = new QueryTokenResponseItem();
                            SingleTokenResponse.TokenAddress = SimpleBase.Base58.Bitcoin.Encode(tokenResp.TokenAddress);
                            SingleTokenResponse.TokenName    = tokenResp.TokenName;
                            SingleTokenResponse.TokenTiker   = tokenResp.TokenTiker;
                            if (tokenResp.Transfers != null)
                            {
                                foreach (var singleTokenTransfer in tokenResp.Transfers)
                                {
                                    var singleTokenTransferResult = new TokenTransferInfo();
                                    singleTokenTransferResult.TokenAddress      = SimpleBase.Base58.Bitcoin.Encode(singleTokenTransfer.Token);
                                    singleTokenTransferResult.Sender            = SimpleBase.Base58.Bitcoin.Encode(singleTokenTransfer.Sender);
                                    singleTokenTransferResult.Receiver          = SimpleBase.Base58.Bitcoin.Encode(singleTokenTransfer.Receiver);
                                    singleTokenTransferResult.TransferInitiator = SimpleBase.Base58.Bitcoin.Encode(singleTokenTransfer.Initiator);
                                    singleTokenTransferResult.TokenCode         = singleTokenTransfer.Code;
                                    singleTokenTransferResult.TokenAmount       = Convert.ToDecimal(singleTokenTransfer.Amount, CultureInfo.InvariantCulture);
                                    singleTokenTransferResult.TransactionID     = Convert.ToString(singleTokenTransfer.Transaction.PoolSeq) + "." + Convert.ToString(singleTokenTransfer.Transaction.Index);
                                    singleTokenTransferResult.TimeCreation      = (new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).AddSeconds(singleTokenTransfer.Time / 1000);
                                    singleTokenTransferResult.UserData          = SimpleBase.Base58.Bitcoin.Encode(singleTokenTransfer.UserFields);
                                    if (singleTokenTransfer.Fee != null)
                                    {
                                        singleTokenTransferResult.Fee = Convert.ToDecimal(Utils.FeeByIndex(singleTokenTransfer.Fee.Commission), CultureInfo.InvariantCulture);
                                    }
                                    if (singleTokenTransfer.ExtraFee != null)
                                    {
                                        foreach (var it in singleTokenTransfer.ExtraFee)
                                        {
                                            var item = new EFeeItem();
                                            item.Fee     = Convert.ToDecimal(FormatAmount(it.Sum), CultureInfo.InvariantCulture);
                                            item.Comment = it.Comment;
                                            singleTokenTransferResult.ExtraFee.Add(item);
                                        }
                                    }
                                    SingleTokenResponse.Transfers.Add(singleTokenTransferResult);
                                }
                                qRes.TransfersList.Add(SingleTokenResponse);
                            }
                        }
                    }

                    res.QuerieResponses.Add(qRes);
                }
            }
            return(res);
        }
示例#9
0
        public BalanceResponseApiModel GetBalance(RequestKeyApiModel model)
        {
            var response = new BalanceResponseApiModel();

            using (var client = GetClientByModel(model))
            {
                var publicKeyByte = SimpleBase.Base58.Bitcoin.Decode(model.PublicKey);

                var     balanceCS = client.WalletBalanceGet(publicKeyByte.ToArray());
                var     amount    = BCTransactionTools.GetDecimalByAmount(balanceCS.Balance);
                decimal delOut    = 0;
                decimal delIn     = 0;
                if (balanceCS.Delegated != null)
                {
                    if (balanceCS.Delegated.Outgoing != null)
                    {
                        delOut = BCTransactionTools.GetDecimalByAmount(balanceCS.Delegated.Outgoing);
                    }
                    if (balanceCS.Delegated.Outgoing != null)
                    {
                        delIn = BCTransactionTools.GetDecimalByAmount(balanceCS.Delegated.Incoming);
                    }
                }

                response.Balance      = amount;
                response.DelegatedOut = delOut;
                response.DelegatedIn  = delIn;

                if (balanceCS.Status.Code > 0)
                {
                    throw new Exception(balanceCS.Status.Message);
                }

                var balanceToken = client.TokenBalancesGet(publicKeyByte.ToArray());
                if (balanceToken.Status.Code > 0)
                {
                    throw new Exception(balanceToken.Status.Message);
                }

                foreach (var item in balanceToken.Balances)
                {
                    if (String.IsNullOrEmpty(item.Balance))
                    {
                        continue;
                    }

                    var item1 = new Token();
                    item1.Alias     = item.Code;
                    item1.Amount    = Decimal.Parse(item.Balance, CultureInfo.InvariantCulture);
                    item1.PublicKey = SimpleBase.Base58.Bitcoin.Encode(item.Token);
                    item1.Name      = item.Name;

                    response.Tokens.Add(
                        item1
                        );
                }
            }

            response.Success = true;
            return(response);
        }
        public Transaction InitTransaction(RequestApiModel model)
        {
            Transaction transac = new Transaction();

            using (var client = GetClientByModel(model))
            {
                // отправитель
                var sourceByte = SimpleBase.Base58.Bitcoin.Decode(model.PublicKey);
                transac.Source = sourceByte.ToArray();

                if (model.Fee == 0)
                {
                    Decimal res;
                    if (!string.IsNullOrWhiteSpace(model.FeeAsString) && Decimal.TryParse(model.FeeAsString.Replace(",", "."), NumberStyles.Any, CultureInfo.GetCultureInfo("en-US"), out res))
                    {
                        transac.Fee = BCTransactionTools.EncodeFeeFromDouble(Decimal.ToDouble(res));
                    }
                    else
                    {
                        transac.Fee = BCTransactionTools.EncodeFeeFromDouble(Decimal.ToDouble(model.Fee));
                    }
                }
                else
                {
                    transac.Fee = BCTransactionTools.EncodeFeeFromDouble(Decimal.ToDouble(model.Fee));
                }

                //transac.Fee = BCTransactionTools.EncodeFeeFromDouble(Decimal.ToDouble(model.Fee));

                transac.Currency = 1;
                // ЗАПРОС механизм присваивания транзакции
                transac.Id = client.WalletDataGet(sourceByte.ToArray()).WalletData.LastTransactionId + 1;
                if (!String.IsNullOrEmpty(model.UserData))
                {
                    transac.UserFields = SimpleBase.Base58.Bitcoin.Decode(model.UserData).ToArray();
                }
                //  transac.UserFields = Convert.FromBase64String(model.UserData);

                if (model.MethodApi == ApiMethodConstant.TransferCs)
                {
                    if (model.Amount == 0)
                    {
                        if (string.IsNullOrEmpty(model.AmountAsString))
                        {
                            transac.Amount = new Amount();
                        }
                        else
                        {
                            Decimal res;
                            if (Decimal.TryParse(model.AmountAsString.Replace(",", "."), NumberStyles.Any, CultureInfo.GetCultureInfo("en-US"), out res))
                            {
                                transac.Amount = BCTransactionTools.GetAmountByDouble_C(res);
                            }
                            else
                            {
                                transac.Amount = BCTransactionTools.GetAmountByDouble_C(model.Amount);
                            }
                        }
                    }
                    else
                    {
                        transac.Amount = BCTransactionTools.GetAmountByDouble_C(model.Amount);
                    }

                    if (model.Fee == 0)
                    {
                        var minFee = MinTransactionFee;
                        if (model.Amount - minFee >= 0.0M)
                        {
                            model.Fee    = minFee;
                            model.Amount = model.Amount - minFee;
                            //GetActualFee(RequestFeeModel)
                            //ServiceProvider.GetService<MonitorService>().GetBalance(model);

                            transac.Fee    = BCTransactionTools.EncodeFeeFromDouble(Convert.ToDouble(minFee));
                            transac.Amount = BCTransactionTools.GetAmountByDouble_C(model.Amount);
                        }
                        else
                        {
                            throw new Exception("Fee is zero and couldn't be get from transaction sum");
                        }
                    }
                    transac.Target = SimpleBase.Base58.Bitcoin.Decode(model.ReceiverPublicKey).ToArray();
                }
                else if (model.MethodApi == ApiMethodConstant.SmartDeploy)
                {
                    transac.Amount = BCTransactionTools.GetAmountByDouble_C(0);
                    //  Byte[] byteSource = sourceByte;
                    IEnumerable <Byte> sourceCodeByte = sourceByte.ToArray();

                    sourceCodeByte = sourceCodeByte.Concat(BitConverter.GetBytes(transac.Id).Take(6));
                    // ЗАПРОС
                    var byteCodes =
                        client.SmartContractCompile(model.SmartContractSource);
                    if (byteCodes.Status.Code > 0)
                    {
                        throw new Exception(byteCodes.Status.Message);
                    }
                    foreach (var item in byteCodes.ByteCodeObjects)
                    {
                        sourceCodeByte = sourceCodeByte.Concat(item.ByteCode);
                    }

                    transac.Target        = Blake2s.ComputeHash(sourceCodeByte.ToArray());
                    transac.SmartContract = new SmartContractInvocation()
                    {
                        SmartContractDeploy = new SmartContractDeploy()
                        {
                            SourceCode      = model.SmartContractSource,
                            ByteCodeObjects = byteCodes.ByteCodeObjects
                        },
                    };
                }
                else if (model.MethodApi == ApiMethodConstant.SmartMethodExecute)
                {
                    var listParam      = new List <Variant>();
                    var contractParams = new List <TokenParamsApiModel>();
                    if (model.ContractParams.Count > model.TokenParams.Count)
                    {
                        foreach (var item in model.ContractParams)
                        {
                            var param = new Variant();

                            if (item.ValBool != null)
                            {
                                param.V_boolean = item.ValBool.Value;
                            }
                            else if (item.ValDouble != null)
                            {
                                param.V_double = item.ValDouble.Value;
                            }
                            else if (item.ValInt != null)
                            {
                                param.V_int = item.ValInt.Value;
                            }
                            else if (item.ValInt != null)
                            {
                                param.V_int = item.ValInt.Value;
                            }
                            else
                            {
                                param.V_string = item.ValString;
                            }
                            listParam.Add(param);
                        }
                    }
                    else
                    {
                        foreach (var item in model.TokenParams)
                        {
                            var param = new Variant();

                            if (item.ValBool != null)
                            {
                                param.V_boolean = item.ValBool.Value;
                            }
                            else if (item.ValDouble != null)
                            {
                                param.V_double = item.ValDouble.Value;
                            }
                            else if (item.ValInt != null)
                            {
                                param.V_int = item.ValInt.Value;
                            }
                            else if (item.ValInt != null)
                            {
                                param.V_int = item.ValInt.Value;
                            }
                            else
                            {
                                param.V_string = item.ValString;
                            }
                            listParam.Add(param);
                        }
                    }


                    transac.Amount = BCTransactionTools.GetAmountByDouble_C(0); // количество токенов фиксируем в параметрах
                    if (model.ContractPublicKey == null || model.ContractPublicKey == "")
                    {
                        transac.Target = SimpleBase.Base58.Bitcoin.Decode(model.TokenPublicKey).ToArray(); // в таргет публичный ключ Token
                    }
                    else
                    {
                        transac.Target = SimpleBase.Base58.Bitcoin.Decode(model.ContractPublicKey).ToArray(); // в таргет публичный ключ Contract
                    }

                    transac.SmartContract = new SmartContractInvocation()
                    {
                        Method = (model.ContractMethod == null || model.ContractMethod == "") ? model.TokenMethod : model.ContractMethod,
                        Params = listParam
                    };
                }
                else if (model.MethodApi == ApiMethodConstant.TransferToken)
                {
                    transac.Amount        = BCTransactionTools.GetAmountByDouble_C(0);                        // количество токенов фиксируем в параметрах
                    transac.Target        = SimpleBase.Base58.Bitcoin.Decode(model.TokenPublicKey).ToArray(); // в таргет публичный ключ токена
                    transac.SmartContract = new SmartContractInvocation()
                    {
                        Method = "transfer",
                        Params = new List <Variant>()
                        {
                            new Variant()
                            {
                                // адресат перевода
                                V_string = model.ReceiverPublicKey
                            },
                            new Variant()
                            {
                                V_string = model.Amount.ToString().Replace(",", ".")
                            }
                        }
                    };
                }
            }

            return(transac);
        }
        public ResponseApiModel ExecuteTransaction(RequestApiModel request, int isDelegate = 0)
        {
            ResponseApiModel response = null;

            using (var client = GetClientByModel(request))
            {
                //снова инициируем транзакцию
                var transac = InitTransaction(request);
                transac.Signature = SimpleBase.Base58.Bitcoin.Decode(request.TransactionSignature).ToArray();

                if (request.DelegateEnable && !request.DelegateDisable)
                {
                    transac.UserFields = new byte[15] {
                        0, 1, 5, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0
                    }
                }
                ;
                else if (request.DelegateDisable && !request.DelegateEnable)
                {
                    transac.UserFields = new byte[15] {
                        0, 1, 5, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0
                    }
                }
                ;

                TransactionFlowResult result = client.TransactionFlow(transac);
                response            = new ResponseApiModel();
                response.FlowResult = result;
                if (request.MethodApi == ApiMethodConstant.SmartDeploy)
                {
                    response.DataResponse.PublicKey = SimpleBase.Base58.Bitcoin.Encode(transac.Target);
                }
                if (result.Status.Code > 0)
                {
                    response.Success = false;
                    response.Message = result.Status.Message;
                }
                else
                {
                    response.Success            = true;
                    response.TransactionInnerId = transac.Id;
                    if (result.Id != null)
                    {
                        response.TransactionId = $"{result.Id.PoolSeq}.{result.Id.Index + 1}";
                    }
                    response.DataResponse.RecommendedFee = BCTransactionTools.GetDecimalByAmount(response.FlowResult.Fee);
                    if (response.DataResponse.RecommendedFee == 0)
                    {
                        response.DataResponse.RecommendedFee = MinTransactionFee;
                    }
                    var sum = BCTransactionTools.GetDecimalByAmount(transac.Amount);
                    if (sum > 0)
                    {
                        if (response.Amount == 0)
                        {
                            response.Amount = sum;
                        }
                        if (response.ActualSum == 0)
                        {
                            response.ActualSum = sum;
                        }
                    }
                    //TODO: extract fee from node
                    if (result.Fee != null)
                    {
                        response.ActualFee = BCTransactionTools.GetDecimalByAmount(result.Fee);
                        if (response.ActualFee == 0M)
                        {
                            response.ActualFee = MinTransactionFee;
                        }
                    }

                    if (result.ExtraFee != null)
                    {
                        response.ExtraFee = new List <EFeeItem>();
                        foreach (var eFee in result.ExtraFee)
                        {
                            var feeSum = BCTransactionTools.GetDecimalByAmount(eFee.Sum);
                            response.ExtraFee.Add(new EFeeItem()
                            {
                                Fee     = feeSum,
                                Comment = eFee.Comment
                            });
                        }
                    }
                    if (request.MethodApi == ApiMethodConstant.SmartMethodExecute)
                    {
                        if (result.Smart_contract_result != null)
                        {
                            try
                            {
                                response.DataResponse.SmartContractResult = result.Smart_contract_result.ToString();
                            }
                            catch (Exception ex)
                            {
                                response.DataResponse.SmartContractResult = "";
                            }
                        }
                    }
                }
            }

            return(response);
        }
    }