Пример #1
0
        /// <summary>
        /// Get DApp info
        /// </summary>
        /// <param name="req">request content</param>
        /// <param name="url">interface address</param>
        /// <param name="certPath">https cert path</param>
        /// <returns></returns>
        public static Tuple <bool, string, AppInfoResBody> GetAppInfo(AppSetting config)
        {
            try
            {
                //Get the unsigned signature of DApp
                NodeApiReq req = new NodeApiReq()
                {
                    header = new ReqHeader()
                    {
                        userCode = config.userCode,
                        appCode  = config.appInfo.AppCode
                    }
                };
                NodeApiResBody <AppInfoResBody> res = SendHelper.SendPost <NodeApiResBody <AppInfoResBody> >(config.reqUrl + appInfoUrl, JsonConvert.SerializeObject(req), config.httpsCert);

                if (res != null)
                {
                    //Check the status codes in turn
                    if (res.header.code != 0)
                    {
                        return(new Tuple <bool, string, AppInfoResBody>(false, res.header.msg, null));
                    }

                    return(new Tuple <bool, string, AppInfoResBody>(true, null, res.body));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(new Tuple <bool, string, AppInfoResBody>(false, "failed to get DApp info", null));
        }
Пример #2
0
        /// <summary>
        /// get character string of to get the block infomation to sign verification
        /// </summary>
        /// <param name="res"></param>
        /// <returns></returns>
        public static string GetFiscoBlockInfoResMac(NodeApiResBody <FiscoBlockData> res)
        {
            //assemble the original string to verify
            StringBuilder strRes = new StringBuilder();

            strRes.Append(GetResHeaderMac(res.header))
            .Append(res.body.BlockHash)
            .Append(res.body.BlockNumber)
            .Append(res.body.ParentBlockHash)
            .Append(res.body.BlockSize)
            .Append(res.body.BlockTime)
            .Append(res.body.Author);
            if (res.body.Transactions != null && res.body.Transactions.Count > 0)
            {
                string transMac = string.Empty;
                foreach (FiscoTransactionData t in res.body.Transactions)
                {
                    transMac += t.TxId;
                    transMac += t.BlockHash;
                    transMac += t.BlockNumber;
                    transMac += t.GasUsed;
                    transMac += t.From;
                    transMac += t.To;
                    transMac += t.Value;
                    transMac += t.Input;
                }
                strRes.Append(transMac);
            }
            return(strRes.ToString());
        }
Пример #3
0
        /// <summary>
        /// get character string of to get the block infomation to sign verification
        /// </summary>
        /// <param name="res"></param>
        /// <returns></returns>
        public static string GetCitaBlockInfoResMac(NodeApiResBody <CitaBlockData> res)
        {
            //assemble the original string to verify
            StringBuilder strRes = new StringBuilder();

            strRes.Append(GetResHeaderMac(res.header))
            .Append(res.body.BlockHash)
            .Append(res.body.BlockNumber)
            .Append(res.body.PrevBlockHash)
            .Append(res.body.BlockTime)
            .Append(res.body.QuotaUsed)
            .Append(res.body.TransactionsRoot)
            .Append(res.body.StateRoot)
            .Append(res.body.ReceiptsRoot);
            if (res.body.Transactions != null && res.body.Transactions.Count > 0)
            {
                string transMac = string.Empty;
                foreach (CitaTransactionData t in res.body.Transactions)
                {
                    transMac += t.TxHash;
                    transMac += t.Data;
                    transMac += t.ChainId;
                    transMac += t.Quota;
                    transMac += t.From;
                    transMac += t.To;
                    transMac += t.Nonce;
                    transMac += t.ValidUntilBlock;
                    transMac += t.Version;
                }
                strRes.Append(transMac);
            }
            return(strRes.ToString());
        }
Пример #4
0
        /// <summary>
        /// character string of event query to sign verification
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public static string EventQueryResMac(NodeApiResBody <List <EventQueryResBody> > res)
        {
            //assemble the original string to verify
            StringBuilder strBuilder = new StringBuilder();

            strBuilder.Append(GetResHeaderMac(res.header));
            if (res.body != null && res.body.Count > 0)
            {
                string strmac = string.Empty;
                foreach (var s in res.body)
                {
                    strmac += s.eventId;
                    strmac += s.eventKey;
                    strmac += s.notifyUrl;
                    strmac += s.attachArgs;
                    strmac += s.createTime;
                    strmac += s.orgCode;
                    strmac += s.userCode;
                    strmac += s.appCode;
                    strmac += s.chainCode;
                }
                strBuilder.Append(strmac);
            }
            return(strBuilder.ToString());
        }
Пример #5
0
        /// <summary>
        /// character string to sign verification to get the block information
        /// </summary>
        /// <param name="res"></param>
        /// <returns></returns>
        public static string GetBlockInfoResMac(NodeApiResBody <GetBlockResBody> res)
        {
            //assemble the original string to verify
            StringBuilder strBuilder = new StringBuilder();

            strBuilder.Append(GetResHeaderMac(res.header))
            .Append(res.body.blockHash)
            .Append(res.body.blockNumber)
            .Append(res.body.preBlockHash)
            .Append(res.body.blockSize)
            .Append(res.body.blockTxCount);
            if (res.body.transactions != null && res.body.transactions.Count > 0)
            {
                string transMac = string.Empty;
                foreach (TransactionData t in res.body.transactions)
                {
                    transMac += t.txId;
                    transMac += t.status;
                    transMac += t.createName;
                    transMac += t.timeSpanSec;
                    transMac += t.timeSpanNsec;
                }
                strBuilder.Append(transMac);
            }
            return(strBuilder.ToString());
        }
Пример #6
0
        /// <summary>
        /// character string to sign verification to get the transaction information
        /// </summary>
        /// <param name="res"></param>
        /// <returns></returns>
        public static string GetTxInfoResMac(NodeApiResBody <XuperchainTransaction> res)
        {
            //assemble the original string to verify
            StringBuilder strBuilder = new StringBuilder();

            strBuilder.Append(GetResHeaderMac(res.header))
            .Append(res.body.TxId)
            .Append(res.body.BlockId)
            .Append(res.body.Version);

            string contact = string.Empty;

            if (res.body.ContractRequests != null && res.body.ContractRequests.Count > 0)
            {
                foreach (var c in res.body.ContractRequests)
                {
                    contact += c.ContractName;
                    contact += c.MethodName;
                    contact += c.Args;
                }
                strBuilder.Append(contact);
            }
            strBuilder.Append(res.body.ReceivedTimestamp);
            return(strBuilder.ToString());
        }
Пример #7
0
        /// <summary>
        /// character string of user cert request to sign verification
        /// </summary>
        /// <param name="res"></param>
        /// <returns></returns>
        public static string GetEnrollUserResMac(NodeApiResBody <EnrollUserResBody> res)
        {
            //assemble the original string to verify
            StringBuilder strBuilder = new StringBuilder();

            strBuilder.Append(GetResHeaderMac(res.header))
            .Append(res.body.cert);
            return(strBuilder.ToString());
        }
Пример #8
0
        /// <summary>
        /// get character string of get the block heioght to sign verification
        /// </summary>
        /// <param name="res"></param>
        /// <returns></returns>
        public static string GetBlockHeightResMac(NodeApiResBody <CitaBlockHeightResBody> res)
        {
            //assemble the original string to verify
            StringBuilder strRes = new StringBuilder();

            strRes.Append(GetResHeaderMac(res.header))
            .Append(res.body.Data);
            return(strRes.ToString());
        }
Пример #9
0
        /// <summary>
        /// character string to sign verification to get the event registered
        /// </summary>
        /// <param name="res"></param>
        /// <returns></returns>
        public static string GetCitaEventRegisterResMac(NodeApiResBody <CitaRegisterEventResData> res)
        {
            //assemble the original string to verify
            StringBuilder strRes = new StringBuilder();

            strRes.Append(GetResHeaderMac(res.header))
            .Append(res.body.EventId);
            return(strRes.ToString());
        }
Пример #10
0
        /// <summary>
        /// character string to sign verification to register event
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public static string EventRegisterResMac(NodeApiResBody <EventRegisterResBody> res)
        {
            //assemble the orginal string to verify
            StringBuilder strBuilder = new StringBuilder();

            strBuilder.Append(GetResHeaderMac(res.header))
            .Append(res.body.eventId);
            return(strBuilder.ToString());
        }
Пример #11
0
        /// <summary>
        /// get character string of to get the transaction receipt to sign verification
        /// </summary>
        /// <param name="res"></param>
        /// <returns></returns>
        public static string GetCitaTxReceiptResMac(NodeApiResBody <CitaTxReceiptResBody> res)
        {
            //assemble the original string to verify
            StringBuilder strRes = new StringBuilder();

            strRes.Append(GetResHeaderMac(res.header))
            .Append(res.body.TransactionHash)
            .Append(res.body.TransactionIndex)
            .Append(res.body.BlockHash)
            .Append(res.body.BlockNumber)
            .Append(res.body.CumulativeGasUsed)
            .Append(res.body.CumulativeQuotaUsed)
            .Append(res.body.GasUsed)
            .Append(res.body.QuotaUsed)
            .Append(res.body.ContractAddress)
            .Append(res.body.Root)
            .Append(res.body.Status)
            .Append(res.body.From)
            .Append(res.body.To)
            .Append(res.body.LogsBloom)
            .Append(res.body.ErrorMessage)
            .Append(res.body.TransactionIndexRaw)
            .Append(res.body.BlockNumberRaw)
            .Append(res.body.CumulativeGasUsedRaw)
            .Append(res.body.CumulativeQuotaUsedRaw)
            .Append(res.body.GasUsedRaw)
            .Append(res.body.QuotaUsedRaw);
            if (res.body.Logs != null && res.body.Logs.Count > 0)
            {
                string transMac = string.Empty;
                foreach (CitaTranReceiptLogData t in res.body.Logs)
                {
                    transMac += t.Removed;
                    transMac += t.LogIndex;
                    transMac += t.TransactionIndex;
                    transMac += t.TransactionHash;
                    transMac += t.BlockHash;
                    transMac += t.BlockNumber;
                    transMac += t.Address;
                    transMac += t.Data;
                    transMac += t.TransactionLogIndex;
                    transMac += t.TransactionIndexRaw;
                    transMac += t.BlockNumberRaw;
                    transMac += t.LogIndexRaw;
                    if (t.Topics != null && t.Topics.Count > 0)
                    {
                        foreach (string ts in t.Topics)
                        {
                            transMac += ts;
                        }
                    }
                }
                strRes.Append(transMac);
            }
            return(strRes.ToString());
        }
Пример #12
0
        /// <summary>
        /// get character string of user registration to sign verification
        /// </summary>
        /// <param name="res"></param>
        /// <returns></returns>
        public static string GetRegisterUserResMac(NodeApiResBody <RegisterUserResBody> res)
        {
            //assemble the original string to verify
            StringBuilder strRes = new StringBuilder();

            strRes.Append(GetResHeaderMac(res.header))
            .Append(res.body.name)
            .Append(res.body.secret);
            return(strRes.ToString());
        }
Пример #13
0
        /// <summary>
        /// character string to sign verification to get the transaction data
        /// </summary>
        /// <param name="res"></param>
        /// <returns></returns>
        public static string GetTransactionDataResMac(NodeApiResBody <GetTransDataResBody> res)
        {
            //assemble the original string to verify
            StringBuilder strBuilder = new StringBuilder();

            strBuilder.Append(GetResHeaderMac(res.header))
            .Append(res.body.txId)
            .Append(res.body.transData);
            return(strBuilder.ToString());
        }
Пример #14
0
        /// <summary>
        /// character string to sign verification of transaction processing under key trust mode
        /// </summary>
        /// <param name="res"></param>
        /// <returns></returns>
        public static string GetCitaTransactionResMac(NodeApiResBody <CitaTransResBody> res)
        {
            //assemble the original string to verify
            StringBuilder strRes = new StringBuilder();

            strRes.Append(GetResHeaderMac(res.header))
            .Append(res.body.TxId)
            .Append(res.body.Status)
            .Append(res.body.Data);
            return(strRes.ToString());
        }
Пример #15
0
        /// <summary>
        /// character string to sign verification of transaction processing under key trust mode
        /// </summary>
        /// <param name="res"></param>
        /// <returns></returns>
        public static string ReqChainCodeResMac(NodeApiResBody <CallContractResDataBody> res)
        {
            //assemble the original string to verify
            StringBuilder strBuilder = new StringBuilder();

            strBuilder.Append(GetResHeaderMac(res.header))
            .Append(res.body.TxId)
            .Append(res.body.QueryInfo);

            return(strBuilder.ToString());
        }
Пример #16
0
        /// <summary>
        /// character string to sign verification to get the ledger information
        /// </summary>
        /// <param name="res"></param>
        /// <returns></returns>
        public static string GetLedgerInfoResMac(NodeApiResBody <GetLedgerResBody> res)
        {
            //assemble the orginal string to verify
            StringBuilder strBuilder = new StringBuilder();

            strBuilder.Append(GetResHeaderMac(res.header))
            .Append(res.body.blockHash)
            .Append(res.body.height)
            .Append(res.body.preBlockHash);

            return(strBuilder.ToString());
        }
Пример #17
0
        /// <summary>
        /// character string to sign verification to get the block information
        /// </summary>
        /// <param name="res"></param>
        /// <returns></returns>
        public static string GetBlockDataResMac(NodeApiResBody <GetBlockDataResBody> res)
        {
            //assemble the original string to verify
            StringBuilder strBuilder = new StringBuilder();

            strBuilder.Append(GetResHeaderMac(res.header))
            .Append(res.body.blockHash)
            .Append(res.body.blockNumber)
            .Append(res.body.preBlockHash)
            .Append(res.body.blockData);

            return(strBuilder.ToString());
        }
Пример #18
0
        /// <summary>
        /// character string to sign verification to get the transaction information
        /// </summary>
        /// <param name="res"></param>
        /// <returns></returns>
        public static string GetTransactionResMac(NodeApiResBody <GetTransResBody> res)
        {
            //assemble the original string to verify
            StringBuilder strBuilder = new StringBuilder();

            strBuilder.Append(GetResHeaderMac(res.header))
            .Append(res.body.blockHash)
            .Append(res.body.blockNumber)
            .Append(res.body.status)
            .Append(res.body.createName)
            .Append(res.body.timeSpanSec)
            .Append(res.body.timeSpanNsec);
            return(strBuilder.ToString());
        }
Пример #19
0
        /// <summary>
        /// get character string of to get the transaction receipt to sign verification
        /// </summary>
        /// <param name="res"></param>
        /// <returns></returns>
        public static string GetFiscoTxReceiptResMac(NodeApiResBody <FiscoTxReceiptResBody> res)
        {
            //assemble the original string to verify
            StringBuilder strRes = new StringBuilder();

            strRes.Append(GetResHeaderMac(res.header))
            .Append(res.body.TxId)
            .Append(res.body.BlockHash)
            .Append(res.body.BlockNumber)
            .Append(res.body.GasUsed)
            .Append(res.body.From)
            .Append(res.body.To)
            .Append(res.body.ContractAddress);
            return(strRes.ToString());
        }
Пример #20
0
        /// <summary>
        /// get character string of to get the transaction infomation to sign verification
        /// </summary>
        /// <param name="res"></param>
        /// <returns></returns>
        public static string GetFiscoTxInfoResMac(NodeApiResBody <FiscoTransactionData> res)
        {
            //assemble the original string to verify
            StringBuilder strRes = new StringBuilder();

            strRes.Append(GetResHeaderMac(res.header))
            .Append(res.body.TxId)
            .Append(res.body.BlockHash)
            .Append(res.body.BlockNumber)
            .Append(res.body.GasUsed)
            .Append(res.body.From)
            .Append(res.body.To)
            .Append(res.body.Value)
            .Append(res.body.Input);
            return(strRes.ToString());
        }
Пример #21
0
        /// <summary>
        /// get character string of to get the transaction infomation to sign verification
        /// </summary>
        /// <param name="res"></param>
        /// <returns></returns>
        public static string GetCitaTxInfoResMac(NodeApiResBody <CitaTransactionData> res)
        {
            //assemble the original string to verify
            StringBuilder strRes = new StringBuilder();

            strRes.Append(GetResHeaderMac(res.header))
            .Append(res.body.TxHash)
            .Append(res.body.Data)
            .Append(res.body.ChainId)
            .Append(res.body.Quota)
            .Append(res.body.From)
            .Append(res.body.To)
            .Append(res.body.Nonce)
            .Append(res.body.ValidUntilBlock)
            .Append(res.body.Version);
            return(strRes.ToString());
        }
Пример #22
0
        /// <summary>
        /// character string to sign verification of transaction processing under key trust mode
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public static string ReqChainCodeResMac(NodeApiResBody <ReqChainCodeResBody> res)
        {
            //assemble the original string to verify
            StringBuilder strBuilder = new StringBuilder();

            strBuilder.Append(GetResHeaderMac(res.header));
            if (res.body.blockInfo != null)
            {
                strBuilder.Append(res.body.blockInfo.txId)
                .Append(res.body.blockInfo.blockHash)
                .Append(res.body.blockInfo.status);
            }
            if (res.body.ccRes != null)
            {
                strBuilder.Append(res.body.ccRes.ccCode)
                .Append(res.body.ccRes.ccData);
            }
            return(strBuilder.ToString());
        }
Пример #23
0
        /// <summary>
        /// character string to sign verification of transaction processing
        /// </summary>
        /// <param name="res"></param>
        /// <returns></returns>
        public static string GetFiscoTransactionResMac(NodeApiResBody <FiscoTransResBody> res)
        {
            //assemble the original string to verify
            StringBuilder strRes = new StringBuilder();

            strRes.Append(GetResHeaderMac(res.header))
            .Append(res.body.Constant.ToString().ToLower())
            .Append(res.body.QueryInfo)
            .Append(res.body.TxId)
            .Append(res.body.BlockHash)
            .Append(res.body.BlockNumber)
            .Append(res.body.GasUsed)
            .Append(res.body.Status)
            .Append(res.body.From)
            .Append(res.body.To)
            .Append(res.body.Input)
            .Append(res.body.Output)
            .Append(res.body.Logs);
            return(strRes.ToString());
        }
Пример #24
0
        /// <summary>
        /// character string to sign verification to get the event removed
        /// </summary>
        /// <param name="res"></param>
        /// <returns></returns>
        public static string GetCitaQueryEventResMac(NodeApiResBody <CitaQueryEventResData> res)
        {
            //assemble the original string to verify
            StringBuilder strRes = new StringBuilder();

            strRes.Append(GetResHeaderMac(res.header));

            if (res.body.BlockEvent != null && res.body.BlockEvent.Count > 0)
            {
                string eventMac = string.Empty;
                foreach (Event t in res.body.BlockEvent)
                {
                    eventMac += t.EventId;
                    eventMac += t.AppCode;
                    eventMac += t.UserCode;
                    eventMac += t.NotifyUrl;
                    eventMac += t.AttachArgs;
                    eventMac += t.CreateTime;
                }
                strRes.Append(eventMac);
            }
            if (res.body.ContractEvent != null && res.body.ContractEvent.Count > 0)
            {
                string eventMac = string.Empty;
                foreach (ContractEvent t in res.body.ContractEvent)
                {
                    eventMac += t.EventId;
                    eventMac += t.AppCode;
                    eventMac += t.UserCode;
                    eventMac += t.NotifyUrl;
                    eventMac += t.AttachArgs;
                    eventMac += t.CreateTime;
                    eventMac += t.ContractAddress;
                }
                strRes.Append(eventMac);
            }
            return(strRes.ToString());
        }
Пример #25
0
        /// <summary>
        /// character string to sign verification to get the block information
        /// </summary>
        /// <param name="res"></param>
        /// <returns></returns>
        public static string GetBlockInfoResMac(NodeApiResBody <XuperchainBlock> res)
        {
            //assemble the original string to verify
            StringBuilder strBuilder = new StringBuilder();

            strBuilder.Append(GetResHeaderMac(res.header))
            .Append(res.body.Version)
            .Append(res.body.BlockId)
            .Append(res.body.PreHash)
            .Append(res.body.Height)
            .Append(res.body.Timestamp);
            if (res.body.Transactions != null && res.body.Transactions.Count > 0)
            {
                string transMac = string.Empty;
                foreach (XuperchainTransaction t in res.body.Transactions)
                {
                    transMac += t.TxId;
                    transMac += t.BlockId;
                    transMac += t.Version;
                    string contact = string.Empty;
                    if (t.ContractRequests != null && t.ContractRequests.Count > 0)
                    {
                        foreach (var c in t.ContractRequests)
                        {
                            contact += c.ContractName;
                            contact += c.MethodName;
                            contact += c.Args;
                        }
                        transMac += contact;
                    }
                    transMac += t.ReceivedTimestamp;
                }
                strBuilder.Append(transMac);
            }
            strBuilder.Append(res.body.TxCount)
            .Append(res.body.NextHash);
            return(strBuilder.ToString());
        }