public void NetworksAreValid() { foreach (Network network in NetworksContainer.GetNetworks()) { Assert.NotNull(network); } }
//https://en.bitcoin.it/wiki/List_of_address_prefixes public void CanDetectBase58NetworkAndType() { var tests = new[] { new { Base58 = "bc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qccfmv3", ExpectedType = typeof(BitcoinWitScriptAddress), Network = Network.Main }, new { Base58 = "tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7", ExpectedType = typeof(BitcoinWitScriptAddress), Network = Network.TestNet }, new { Base58 = "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4", ExpectedType = typeof(BitcoinWitPubKeyAddress), Network = Network.Main }, new { Base58 = "tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx", ExpectedType = typeof(BitcoinWitPubKeyAddress), Network = Network.TestNet }, new { Base58 = "bWqaKUZETiECYgmJNbNZUoanBxnAzoVjCNx", ExpectedType = typeof(BitcoinColoredAddress), Network = Network.TestNet }, new { Base58 = "17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem", ExpectedType = typeof(BitcoinPubKeyAddress), Network = Network.Main }, new { Base58 = "17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem", ExpectedType = typeof(BitcoinPubKeyAddress), Network = Network.Main }, new { Base58 = "3EktnHQD7RiAE6uzMj2ZifT9YgRrkSgzQX", ExpectedType = typeof(BitcoinScriptAddress), Network = Network.Main }, new { Base58 = "mipcBbFg9gMiCh81Kj8tqqdgoZub1ZJRfn", ExpectedType = typeof(BitcoinPubKeyAddress), Network = Network.TestNet }, new { Base58 = "5Hwgr3u458GLafKBgxtssHSPqJnYoGrSzgQsPwLFhLNYskDPyyA", ExpectedType = typeof(BitcoinSecret), Network = Network.Main }, new { Base58 = "92Pg46rUhgTT7romnV7iGW6W1gbGdeezqdbJCzShkCsYNzyyNcc", ExpectedType = typeof(BitcoinSecret), Network = Network.TestNet }, new { Base58 = "3qdi7TXgRo1qR", ExpectedType = (Type)null, Network = (Network)null }, new { Base58 = "6PYLtMnXvfG3oJde97zRyLYFZCYizPU5T3LwgdYJz1fRhh16bU7u6PPmY7", ExpectedType = typeof(BitcoinEncryptedSecretNoEC), Network = (Network)null }, new { Base58 = "6PfQu77ygVyJLZjfvMLyhLMQbYnu5uguoJJ4kMCLqWwPEdfpwANVS76gTX", ExpectedType = typeof(BitcoinEncryptedSecretEC), Network = (Network)null }, new { Base58 = "passphrasepxFy57B9v8HtUsszJYKReoNDV6VHjUSGt8EVJmux9n1J3Ltf1gRxyDGXqnf9qm", ExpectedType = typeof(BitcoinPassphraseCode), Network = (Network)null }, new { Base58 = "cfrm38V8aXBn7JWA1ESmFMUn6erxeBGZGAxJPY4e36S9QWkzZKtaVqLNMgnifETYw7BPwWC9aPD", ExpectedType = typeof(BitcoinConfirmationCode), Network = (Network)null }, new { Base58 = "xprv9s21ZrQH143K3Gx1VAAD1ueDmwoPQUApekxWYSJ1f4W4m1nUPpRGdV5sTVhixZJT5cP2NqtEMZ2mrwHdW5RWpohCwspWidCpcLALvioXDyz", ExpectedType = typeof(BitcoinExtKey), Network = Network.Main }, new { Base58 = "xpub661MyMwAqRbcEhHavVcryjNF2uA5woK6JCNRNJB8Z3dxPU8VNBd9E8GP7fusw2bhgYe7BXt6izr5iUaYo483919jjdtfEpG8j97djnEgJqo", ExpectedType = typeof(BitcoinExtPubKey), Network = Network.Main }, new { Base58 = "akB4NBW9UuCmHuepksob6yfZs6naHtRCPNy", ExpectedType = typeof(BitcoinColoredAddress), Network = Network.Main } }; foreach (var test in tests) { if (test.ExpectedType == null) { Assert.Throws <FormatException>(() => Network.Parse(test.Base58, null)); } else { IBitcoinString result = Network.Parse(test.Base58, null); Assert.True(test.ExpectedType == result.GetType()); if (test.Network != null) { Assert.Equal(test.Network, result.Network); } Network.Parse(test.Base58, test.Network); if (test.Network != null) { foreach (Network network in NetworksContainer.GetNetworks()) { if (network == test.Network) { break; } Assert.Throws <FormatException>(() => Network.Parse(test.Base58, network)); } } } } }