Пример #1
0
        public static T ToNetwork <T>(this T base58, Network network) where T : Base58Data
        {
            if (network == null)
            {
                throw new ArgumentNullException("network");
            }
            if (base58.Network == network)
            {
                return(base58);
            }
            if (base58 == null)
            {
                throw new ArgumentNullException("base58");
            }
            var inner = base58.ToBytes();

            if (base58.Type != Base58Type.COLORED_ADDRESS)
            {
                byte[] version   = network.GetVersionBytes(base58.Type);
                var    newBase58 = Encoders.Base58Check.EncodeData(version.Concat(inner).ToArray());
                return(Network.CreateFromBase58Data <T>(newBase58, network));
            }
            else
            {
                var colored = BitcoinColoredAddress.GetWrappedBase58(base58.ToWif(), base58.Network);
                var address = Network.CreateFromBase58Data <BitcoinAddress>(colored).ToNetwork(network);
                return((T)(object)address.ToColoredAddress());
            }
        }
Пример #2
0
 /// <summary>
 /// Detect whether the input base58 is a pubkey hash or a script hash
 /// </summary>
 /// <param name="base58">The Base58 string to parse</param>
 /// <param name="expectedNetwork">The expected network to which it belongs</param>
 /// <returns>A BitcoinAddress or BitcoinScriptAddress</returns>
 /// <exception cref="System.FormatException">Invalid format</exception>
 public static BitcoinAddress Create(string base58, Network expectedNetwork = null)
 {
     if (base58 == null)
     {
         throw new ArgumentNullException("base58");
     }
     return(Network.CreateFromBase58Data <BitcoinAddress>(base58, expectedNetwork));
 }
Пример #3
0
 public static ExtPubKey Parse(string wif, Network expectedNetwork = null)
 {
     return(Network.CreateFromBase58Data <BitcoinExtPubKey>(wif, expectedNetwork).ExtPubKey);
 }
Пример #4
0
 public static Base58Data GetFromBase58Data(string base58, Network expectedNetwork = null)
 {
     return(Network.CreateFromBase58Data(base58, expectedNetwork));
 }
Пример #5
0
 public static BitcoinEncryptedSecret Create(string wif, Network expectedNetwork = null)
 {
     return(Network.CreateFromBase58Data <BitcoinEncryptedSecret>(wif, expectedNetwork));
 }
Пример #6
0
 public static Key Parse(string wif, string password, Network network = null)
 {
     return(Network.CreateFromBase58Data <BitcoinEncryptedSecretNoEC>(wif, network).GetKey(password));
 }
Пример #7
0
 public static Key Parse(string wif, Network network = null)
 {
     return(Network.CreateFromBase58Data <BitcoinSecret>(wif, network).Key);
 }
Пример #8
0
 public static BitcoinAddress Create(string base58, Network expectedNetwork = null)
 {
     return(Network.CreateFromBase58Data <BitcoinAddress>(base58, expectedNetwork));
 }
Пример #9
0
 public static Base58Data GetFromBase58Data(string base58)
 {
     return(Network.CreateFromBase58Data(base58));
 }