Beispiel #1
0
        public bool Equals(TronAddress other)
        {
            if (other == null)
            {
                return(false);
            }

            if (object.ReferenceEquals(this, other))
            {
                return(true);
            }

            //то проверять на идентичность необязательно и можно переходить сразу к сравниванию полей.
            if (this.GetType() != other.GetType())
            {
                return(false);
            }

            if (string.Compare(this.AddressBase58, other.AddressBase58, StringComparison.CurrentCulture) == 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
        public static bool isBelongsPublicKeyToPrivateKey(string privateKey, string publicKey)
        {
            KeyTriple keyTriple = new KeyTriple(privateKey);

            bool isValidPublicAddress = TronAddress.ValidateAddress(publicKey);

            if (!isValidPublicAddress)
            {
                return(false);
            }

            TronAddress tronAddress = TronAddress.CreateTronAddress(publicKey);
            string      addressFromPublickKeyBase58 = tronAddress.AddressBase58;

            string addressFromPrivateKeyBase58 = Base58.Encode(keyTriple.GetAddressWallet(TypeNet.Main));

            if (addressFromPublickKeyBase58 != addressFromPrivateKeyBase58)
            {
                return(false);
            }

            return(true);
        }