Beispiel #1
0
 public static BchAddrData Create(CashFormat format, CashNetwork network, CashType type, byte[] hash)
 {
     return(new BchAddrData
     {
         Format = format,
         Network = network,
         Type = type,
         Hash = hash,
     });
 }
Beispiel #2
0
        /// <summary>
        /// returns the Version byte for base58 formats
        /// </summary>
        /// <param name="format"></param>
        /// <param name="network"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        private static byte GetVersionByte(CashFormat format, CashNetwork network, CashType type)
        {
            switch (format)
            {
            case CashFormat.Legacy:
                if (network == CashNetwork.Mainnet && type == CashType.P2PKH)
                {
                    return(0);
                }
                else if (network == CashNetwork.Mainnet && type == CashType.P2SH)
                {
                    return(5);
                }
                break;

            case CashFormat.Bitpay:
                if (network == CashNetwork.Mainnet && type == CashType.P2PKH)
                {
                    return(28);
                }
                else if (network == CashNetwork.Mainnet && type == CashType.P2SH)
                {
                    return(40);
                }
                break;
            }
            if (network == CashNetwork.Testnet && type == CashType.P2PKH)
            {
                return(111);
            }
            else if (network == CashNetwork.Testnet && type == CashType.P2SH)
            {
                return(196);
            }
            else if (network == CashNetwork.RegTest && type == CashType.P2PKH)
            {
                return(111);
            }
            else if (network == CashNetwork.RegTest && type == CashType.P2SH)
            {
                return(196);
            }
            throw new Validation.ValidationError("Invalid parameters");
        }