Example #1
0
 private static IEnumerable <IBase58Data> GetCandidates(IEnumerable <Network> networks, string base58)
 {
     if (base58 == null)
     {
         throw new ArgumentNullException("base58");
     }
     foreach (Network network in networks)
     {
         Base58Type?type = network.GetBase58Type(base58);
         if (type.HasValue)
         {
             IBase58Data data = null;
             try
             {
                 data = network.CreateBase58Data(type.Value, base58);
             }
             catch (FormatException)
             {
             }
             if (data != null)
             {
                 yield return(data);
             }
         }
     }
 }
Example #2
0
        static IEnumerable <IBase58Data> GetCandidates(IEnumerable <Network> networks, string base58)
        {
            if (base58 == null)
            {
                throw new ArgumentNullException("base58");
            }
            foreach (var network in networks)
            {
                var type = network.GetBase58Type(base58);
                if (type.HasValue)
                {
                    if (type.Value == Base58Type.COLORED_ADDRESS)
                    {
                        var wrapped     = BitcoinColoredAddress.GetWrappedBase58(base58, network);
                        var wrappedType = network.GetBase58Type(wrapped);
                        if (wrappedType == null)
                        {
                            continue;
                        }
                        try
                        {
                            var inner = network.CreateBase58Data(wrappedType.Value, wrapped);
                            if (inner.Network != network)
                            {
                                continue;
                            }
                        }
                        catch (FormatException)
                        {
                        }
                    }

                    IBase58Data data = null;
                    try
                    {
                        data = network.CreateBase58Data(type.Value, base58);
                    }
                    catch (FormatException)
                    {
                    }

                    if (data != null)
                    {
                        yield return(data);
                    }
                }
            }
        }