public static bool VerifyFormattedAddress(string formattedAddress) { if (string.IsNullOrEmpty(formattedAddress)) { return(false); } return(Base58CheckEncoding.Verify(formattedAddress)); }
public string GetFormatted() { if (_formatted != null) { return(_formatted); } return(_formatted = (TypeConsts.AElfAddressPrefix + "_") + Address.GetFormatted() + ("_" + Base58CheckEncoding.Encode(ChainId.DumpByteArray()))); }
public static int ConvertBase58ToChainId(string base58String) { // Use int type to save chain id (4 base58 chars, default is 3 bytes) var bytes = Base58CheckEncoding.DecodePlain(base58String); if (bytes.Length < 4) { Array.Resize(ref bytes, 4); } return(bytes.ToInt32(false)); }
public static ChainAddress Parse(string str) { var arr = str.Split('_'); if (arr[0] != TypeConsts.AElfAddressPrefix) { throw new ArgumentException("invalid chain address", nameof(str)); } var address = Address.Parse(arr[1]); var chainId = BitConverter.ToInt32(Base58CheckEncoding.Decode(arr[2]), 0); return(new ChainAddress(address, chainId)); }
public string GetFormatted() { if (_formattedAddress != null) { return(_formattedAddress); } if (Value.Length != TypeConsts.AddressHashLength) { throw new ArgumentOutOfRangeException( $"Serialized value does not represent a valid address. The input is {Value.Length} bytes long."); } var pubKeyHash = Base58CheckEncoding.Encode(Value.ToByteArray()); return(_formattedAddress = pubKeyHash); }
public static byte[] DecodeBase58(this string value) { return(Base58CheckEncoding.DecodePlain(value)); }
public static string ToPlainBase58(this byte[] value) { return(Base58CheckEncoding.EncodePlain(value)); }
public static Address Base58StringToAddress(string inputStr) { return(Address.FromBytes(Base58CheckEncoding.Decode(inputStr))); }
public static Address Parse(string inputStr) { return(new Address(Base58CheckEncoding.Decode(inputStr))); }