IdentityForPubkeyHashPrefix() публичный статический Метод

public static IdentityForPubkeyHashPrefix ( AddressPrefix prefix, BlockChainIdentity &identity ) : bool
prefix AddressPrefix
identity BlockChainIdentity
Результат bool
Пример #1
0
        public static bool TryDecode(string encodedAddress, out Address address)
        {
            byte[] base58DecodedAddress;
            if (!Base58.TryDecode(encodedAddress, out base58DecodedAddress))
            {
                address = null;
                return(false);
            }

            if (base58DecodedAddress.Length != 1 + Ripemd160Hash.Length + Checksum.SumLength)
            {
                address = null;
                return(false);
            }

            if (!Checksum.Verify(base58DecodedAddress))
            {
                address = null;
                return(false);
            }

            var addressID = base58DecodedAddress[0];
            BlockChainIdentity intendedBlockChain;

            if (AddressPrefix.IdentityForPubkeyHashPrefix(addressID, out intendedBlockChain))
            {
                var pubKeyHash = new byte[Ripemd160Hash.Length];
                Array.Copy(base58DecodedAddress, 1, pubKeyHash, 0, Ripemd160Hash.Length);
                address = new PayToPubKeyHash(intendedBlockChain, pubKeyHash);
                return(true);
            }
            else if (AddressPrefix.IdentityForScriptHashPrefix(addressID, out intendedBlockChain))
            {
                var scriptHash = new byte[Ripemd160Hash.Length];
                Array.Copy(base58DecodedAddress, 1, scriptHash, 0, Ripemd160Hash.Length);
                address = new PayToScriptHash(intendedBlockChain, scriptHash);
                return(true);
            }
            else
            {
                address = null;
                return(false);
            }
        }