def wif_to_key(wif): private_key_bytes, compressed, version = wif_to_bytes(wif) if version == 'main': if compressed: return PrivateKey.from_bytes(private_key_bytes) else: return PrivateKey(wif) else: raise NotImplementedError('Testnet not implemented in this library')
def test_invalid_network(self): with pytest.raises(ValueError): wif_to_bytes(BITCOIN_ADDRESS)
def test_testnet(self): assert wif_to_bytes(WALLET_FORMAT_TEST) == (PRIVATE_KEY_BYTES, False, 'test')
def test_compressed(self): assert wif_to_bytes(WALLET_FORMAT_COMPRESSED_MAIN) == ( PRIVATE_KEY_BYTES, True, 'main')
def test_mainnet(self): assert wif_to_bytes(WALLET_FORMAT_MAIN) == (PRIVATE_KEY_BYTES, False, 'main')