Exemplo n.º 1
0
        public static string FromBech32Address(string address)
        {
            Bech32Data data = Decode(address);

            if (data.hrp != HRP)
            {
                throw new Exception("Expected hrp to be zil");
            }

            List <int> bits = ConvertBits(data.data, 5, 8, false);

            byte[]
            buf = new byte[bits.Count];
            for (int i = 0; i < bits.Count; i++)
            {
                buf[i] = BitConverter.GetBytes(bits[i])[0];
            }
            if (null == buf || buf.Length == 0)
            {
                throw new Exception("Could not convert buffer to bytes");
            }

            return(Account.Account.ToCheckSumAddress(ByteUtil.ByteArrayToHexString(buf)).Replace("0x", ""));
        }
Exemplo n.º 2
0
 /**
  * Encode a Bech32 string.
  */
 public static string Encode(Bech32Data bech32)
 {
     return(Encode(bech32.hrp, bech32.data));
 }