public void SetHexAmount(string hexAmount) { if (!StringUtils.IsHex(hexAmount)) { throw ClientArgumentException.Exception("setHexValue argument hex value."); } string noPrefixAmount = StringUtils.SanitizeHex(hexAmount); Value = BlockchainUtils.Amount(noPrefixAmount, (int)Token.Precision, (int)Token.Scale); }
/// <summary> /// Get transaction receipt /// </summary> /// <param name="txId"> /// txId hex string start with "0x" </param> /// <param name="revision"> /// <seealso cref="Revision"/> </param> /// <returns> <seealso cref="Receipt"/> return Receipt . </returns> /// <exception cref="ClientIOException"> </exception> public static Receipt GetTransactionReceipt(string txId, Revision revision) { if (!BlockchainUtils.IsId(txId)) { throw ClientArgumentException.Exception("Tx id is invalid"); } var currRevision = revision ?? Revision.BEST; var uriParams = Parameters(new string[] { "id" }, new string[] { txId }); var queryParams = Parameters(new string[] { "revision" }, new string[] { currRevision.ToString() }); return(SendGetRequest <Receipt>(Path.GetTransactionReceipt, uriParams, queryParams)); }
/// <summary> /// Get transaction by transaction Id. /// </summary> /// <param name="txId"> /// required transaction id . </param> /// <param name="isRaw"> /// is response raw transaction. </param> /// <param name="revision"> /// <seealso cref="Revision"/> revision. </param> /// <returns> Transaction <seealso cref="Transaction"/> </returns> /// <exception cref="ClientIOException"> </exception> public static Transaction GetTransaction(string txId, bool isRaw, Revision revision) { if (!BlockchainUtils.IsId(txId)) { throw ClientArgumentException.Exception("Tx id is invalid"); } var currRevision = revision ?? Revision.BEST; var uriParams = Parameters(new string[] { "id" }, new string[] { txId }); var queryParams = Parameters(new string[] { "revision", "raw" }, new string[] { currRevision.ToString(), isRaw.ToString() }); return(SendGetRequest <Transaction>(AbstractClient.Path.GetTransactionPath, uriParams, queryParams)); }
public static Address FromHexString(string hexAddress) { if (string.IsNullOrWhiteSpace(hexAddress)) { throw ClientArgumentException.Exception("Address.fromHexString hexAddress is blank string"); } if (!BlockchainUtils.IsAddress(hexAddress)) { throw ClientArgumentException.Exception("Address.fromHexString hexAddress is not hex format "); } string sanitizeHexStr = StringUtils.SanitizeHex(hexAddress); return(new Address(sanitizeHexStr)); }
public static Revision Create(string blockId) { if (blockId.Equals("best", StringComparison.InvariantCultureIgnoreCase)) { return(BEST); } if (!BlockchainUtils.IsId(blockId)) { throw ClientArgumentException.Exception("create revision from blockId invalid"); } var revision = new Revision { _revision = blockId }; return(revision); }
public static byte GetChainTag() { var genesisBlock = BlockClient.GetBlock(Revision.Create(0)); if (genesisBlock == null) { throw new Exception("Get Genesis block error"); } string hexId = genesisBlock.Id; if (!BlockchainUtils.IsId(hexId)) { throw new Exception("Genesis block id is invalid"); } var bytesId = ByteUtils.ToByteArray(hexId); if (bytesId == null || bytesId.Length != 32) { throw new Exception("Genesis block id converted error"); } return(bytesId[31]); }
public virtual byte[] ToByteArray() { return(BlockchainUtils.ByteArrayAmount(Value, (int)Token.Precision)); }