Beispiel #1
0
    def test_errors(self):
        # This tries to access some attribute of the string, expecting an
        # address object.
        with self.assertRaises(AttributeError):
            transaction.Transaction.pay_script('')

        with self.assertRaises(BaseException):
            xpubkey_to_address('')
Beispiel #2
0
 def test_parse_xpub(self):
     res = xpubkey_to_address(
         'fe4e13b0f311a55b8a5db9a32e959da9f011b131019d4cebe6141b9e2c93edcbfc0954c358b062a9f94111548e50bde5847a3096b8b7872dcffadb0e9579b9017b01000200'
     )
     self.assertEqual(res, (
         '04ee98d63800824486a1cf5b4376f2f574d86e0a3009a6448105703453f3368e8e1d8d090aaecdd626a45cc49876709a3bbb6dc96a4311b3cac03e225df5f63dfc',
         Address.from_string('19h943e4diLc68GXW7G75QNe2KWuMu7BaJ')))
Beispiel #3
0
def test_xpubkey_to_address():
    privkey = PrivateKey.from_random()
    public_key = privkey.public_key
    x_pubkey = 'fd' + public_key.P2PKH_script().to_hex()
    assert xpubkey_to_address(x_pubkey) == (
        x_pubkey, Address.from_string(public_key.to_address().to_string()))