Exemple #1
0
        /// <summary>
        /// Calculates Bitcoin P2PKH address given public key hash and network version bytes
        /// </summary>
        /// <param name="hash">public key hash</param>
        /// <param name="versionBytes">version bytes of network</param>
        /// <returns>base58check address</returns>
        public static string ToP2PKHAddress(this Hash160 hash, Span <byte> versionBytes)
        {
            Span <byte> data = new byte[versionBytes.Length + hash.Bytes.Length];

            versionBytes.CopyTo(data);
            hash.Bytes.CopyTo(data.Slice(versionBytes.Length, hash.Bytes.Length));
            return(Base58CheckEncoding.Encode(data));
        }
Exemple #2
0
 /// <summary>
 /// Sets a hash from a hex hash in a string representation
 /// </summary>
 /// <param name="hash">input hash</param>
 /// <param name="hexHash">hash hex value as a string</param>
 /// <returns>the hash</returns>
 public static Hash160 Set(this Hash160 hash, string hexHash)
 {
     hash.Bytes = hexHash.HexToBytes();
     return(hash);
 }
Exemple #3
0
 public bool Equals(Hash160 other)
 {
     return(Equals(this, other));
 }
Exemple #4
0
 /// <summary>
 /// Converts a hash to a hex in a string representation
 /// </summary>
 /// <param name="hash">the hash to convert</param>
 /// <returns>the hash in hex</returns>
 public static string ToHexString(this Hash160 hash)
 {
     return(hash.Bytes.ToHexString());
 }
Exemple #5
0
 public static bool Equals(Hash160 left, Hash160 right)
 {
     return(left.Bytes.SequenceEqual(right.Bytes));
 }