コード例 #1
0
        public void InvalidHexadecimalKeyLengthTest()
        {
            string privateKeyHex = "118e14a7b6a307f426a94f8114701e7c8e774e7f9a47e2c2035db29a206321725";

            (BitcoinAddress address, String result) = BitcoinAddress.CreateAddressFromPrivateKeyHex(privateKeyHex, NetworkType.Main);
            Assert.IsNull(address);
            Assert.AreEqual(result, $"Private key hex string has invalid length of {privateKeyHex.Length}, expected length of 64.");
        }
コード例 #2
0
 public void GenerateAddressFromKnownGoodPrivateKeyHex()
 {
     (BitcoinAddress address, String result) = BitcoinAddress.CreateAddressFromPrivateKeyHex("18e14a7b6a307f426a94f8114701e7c8e774e7f9a47e2c2035db29a206321725", NetworkType.Main);
     Assert.IsNotNull(address);
     Assert.AreEqual(address.PrivateKeyWIF, "Kx45GeUBSMPReYQwgXiKhG9FzNXrnCeutJp4yjTd5kKxCitadm3C");
     Assert.AreEqual(address.P2PKHAddress, "1PMycacnJaSqwwJqjawXBErnLsZ7RkXUAs");
     Assert.AreEqual(address.P2SHAddress, "3BxwGNjvG4CP14tAZodgYyZ7UTjruYDyAM");
 }
コード例 #3
0
 public void InvalidHexadecimalCharacterTest()
 {
     (BitcoinAddress address, String result) = BitcoinAddress.CreateAddressFromPrivateKeyHex("Z8e14a7b6a307f426a94f8114701e7c8e774e7f9a47e2c2035db29a206321725", NetworkType.Main);
     Assert.IsNull(address);
     Assert.AreEqual(result, "Private key is not in hexadecimal format. Unexpected character in string.");
 }