Пример #1
0
 def test_valid_testnet(self):
     self.assertFalse(
         bitcoinaddress.validate(
             'mpc1rKeaMSCuQnJevMViLuq8uWjHwgdjiV'))
     self.assertTrue(
         bitcoinaddress.validate(
             'mpc1rKeaMSCuQnJevMViLuq8uWjHwgdjiV', magicbyte=111))
Пример #2
0
    def test_valid_and_invalid_bech32(self):
        # Address, testnet
        VALID_ADDRESS = [
            ["BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4", 0],
            [
                "tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7",
                1
            ],
            [
                "bc1pw508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7k7grplx",
                0
            ],
            ["BC1SW50QA3JX3S", 0],
            [
                "tb1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesrxh6hy",
                1
            ],
        ]

        INVALID_ADDRESS = [
            ["tc1qw508d6qejxtdg4y5r3zarvary0c5xw7kg3g4ty", 1],
            ["bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t5", 0],
            ["BC13W508D6QEJXTDG4Y5R3ZARVARY0C5XW7KN40WF2", 0],
            ["bc1rw5uspcuh", 0],
            [
                "bc10w508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7kw5rljs90",
                0
            ],
            ["BC1QR508D6QEJXTDG4Y5R3ZARVARYV98GJ9P", 0],
            [
                "tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sL5k7",
                1
            ],
            ["bc1zw508d6qejxtdg4y5r3zarvaryvqyzf3du", 0],
            [
                "tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3pjxtptv",
                1
            ],
            ["bc1gmk9yu", 0],
        ]

        for add, testnet in VALID_ADDRESS:
            self.assertTrue(bitcoinaddress.validate(add, testnet))

        for add, testnet in INVALID_ADDRESS:
            self.assertFalse(bitcoinaddress.validate(add, testnet))
Пример #3
0
 def test_invalid(self):
     for bitcoin_address in self.addresses:
         self.assertFalse(bitcoinaddress.validate(bitcoin_address))
Пример #4
0
 def test_valid(self):
     for bitcoin_address in self.addresses:
         self.assertTrue(bitcoinaddress.validate(bitcoin_address))
Пример #5
0
 def test_valid_multiple_magicbytes(self):
     self.assertTrue(
         bitcoinaddress.validate('mpc1rKeaMSCuQnJevMViLuq8uWjHwgdjiV',
                                 magicbyte=(0, 111)))
Пример #6
0
 def test_valid_multisig(self):
     self.assertTrue(
         bitcoinaddress.validate('3QJmV3qfvL9SuYo34YihAf3sRCW3qSinyC',
                                 magicbyte=5))
Пример #7
0
 def test_valid_testnet(self):
     self.assertFalse(
         bitcoinaddress.validate('mpc1rKeaMSCuQnJevMViLuq8uWjHwgdjiV'))
     self.assertTrue(
         bitcoinaddress.validate('mpc1rKeaMSCuQnJevMViLuq8uWjHwgdjiV',
                                 magicbyte=111))
Пример #8
0
 def test_invalid(self):
     for bitcoin_address in self.addresses:
         self.assertFalse(bitcoinaddress.validate(bitcoin_address))
Пример #9
0
 def test_valid(self):
     for bitcoin_address in self.addresses:
         self.assertTrue(bitcoinaddress.validate(bitcoin_address))
Пример #10
0
 def test_valid_multiple_magicbytes(self):
     self.assertTrue(
         bitcoinaddress.validate(
             'mpc1rKeaMSCuQnJevMViLuq8uWjHwgdjiV', magicbyte=(0, 111)))
Пример #11
0
 def test_valid_multisig(self):
     self.assertTrue(
         bitcoinaddress.validate(
             '3QJmV3qfvL9SuYo34YihAf3sRCW3qSinyC', magicbyte=5))
Пример #12
0
 def test_valid_multisig(self):
     self.assertTrue(
         bitcoinaddress.validate('3QJmV3qfvL9SuYo34YihAf3sRCW3qSinyC',
                                 testnet=False))