def test_exponent_creation(self): p = PrivateKey(secret_exponent=1) self.assertEqual(p.to_bytes(), self.key_bytes) self.assertEqual(p.to_wif(compressed=False), self.key_wif) self.assertEqual(p.to_wif(), self.key_wifc)
help(PrivateKey) help(Script) # // LAB: Relative Timelock Example // # 0. What is the type of network you working on? (mainnet / testnet) # Always remember to setup the network before anything else. setup('testnet') # 1. Create a new private key # Use secret_exponent parameter to get a non random private key priv = PrivateKey(secret_exponent=1) priv.to_wif() priv.to_bytes() # 32 bytes = 32 * 8 bits = 256 bits # 2a. Get the corresponding public Key pub = priv.get_public_key() pub.to_hex() pub.to_hash160() pub.to_bytes() # 2b. Get the address that corresponds to that public key. # The string representation of this address starts with m on n, because it is a Bitcoin testnet address address = priv.get_public_key().get_address() address.to_string() address.to_hash160() address._is_address_valid(address.to_string()) # True address._is_address_valid(address.to_hash160()) # False
def test_wif_creation(self): p = PrivateKey(self.key_wifc) self.assertEqual(p.to_bytes(), self.key_bytes) self.assertEqual(p.to_wif(compressed=False), self.key_wif)