public static string GetAddress(byte[] addressBytes, string hrp) { const string pbase32 = "abcdefghijklmnopqrstuvwxyz234567"; string b32 = Encoders.Base32.EncodeData(addressBytes); byte[] address32 = new byte[b32.Length]; for (int i = 0; i < b32.Length; i++) { address32[i] = (byte)pbase32.IndexOf(b32[i]); } Bech32Encoder bech32Encoder = Encoders.Bech32(hrp); return(bech32Encoder.EncodeData(address32)); }
public Wallet(Key key, BinanceDexEnvironmentData env) { EcKey = key; Env = env; Bech32Encoder bech32Encoder = Encoders.Bech32(Env.Hrp); AddressBytes = EcKey.PubKey.Hash.ToBytes(); string b32 = Encoders.Base32.EncodeData(AddressBytes); byte[] address32 = new byte[b32.Length]; for (int i = 0; i < b32.Length; i++) { address32[i] = (byte)pbase32.IndexOf(b32[i]); } Address = bech32Encoder.EncodeData(address32); byte[] pubKey = EcKey.PubKey.ToBytes(); byte[] pubKeyPrefix = MessageType.GetTransactionType(EMessageType.PubKey); PubKeyForSign = new byte[pubKey.Length + pubKeyPrefix.Length + 1]; pubKeyPrefix.CopyTo(PubKeyForSign, 0); PubKeyForSign[pubKeyPrefix.Length] = 33; pubKey.CopyTo(PubKeyForSign, pubKeyPrefix.Length + 1); client = new HttpApiClient(Env); }