zpywallet package
Subpackages
- zpywallet.address package
- Submodules
- zpywallet.address.blockcypher module
- zpywallet.address.blockstream module
- zpywallet.address.cache module
DatabaseConnectionDatabaseErrorMySQLConnectionPostgreSQLConnectionSQLTransactionStorageSQLTransactionStorage.clear_transactions()SQLTransactionStorage.commit()SQLTransactionStorage.connect()SQLTransactionStorage.create_metadata_table()SQLTransactionStorage.create_transactions_table()SQLTransactionStorage.create_txos_table()SQLTransactionStorage.delete_dropped_txids()SQLTransactionStorage.delete_transaction()SQLTransactionStorage.disconnect()SQLTransactionStorage.get_block_height()SQLTransactionStorage.get_transaction_by_txid()SQLTransactionStorage.get_transactions_by_address()SQLTransactionStorage.have_transaction()SQLTransactionStorage.reconnect()SQLTransactionStorage.rollback()SQLTransactionStorage.set_block_height()SQLTransactionStorage.store_transaction()
SQLiteConnection
- zpywallet.address.esplora module
- zpywallet.address.fullnode module
- zpywallet.address.loadbalancer module
- zpywallet.address.mempoolspace module
- zpywallet.address.provider module
- zpywallet.address.web3node module
- Module contents
- zpywallet.broadcast package
- Subpackages
- zpywallet.broadcast.bcy package
- zpywallet.broadcast.btc package
- Submodules
- zpywallet.broadcast.btc.all module
- zpywallet.broadcast.btc.bitaps module
- zpywallet.broadcast.btc.blockchain_info module
- zpywallet.broadcast.btc.blockchair module
- zpywallet.broadcast.btc.blockcypher module
- zpywallet.broadcast.btc.blockstream module
- zpywallet.broadcast.btc.esplora module
- zpywallet.broadcast.btc.fullnode module
- zpywallet.broadcast.btc.mempool_space module
- zpywallet.broadcast.btc.smartbit module
- zpywallet.broadcast.btc.viabtc module
- Module contents
- zpywallet.broadcast.btctest package
- Submodules
- zpywallet.broadcast.btctest.all module
- zpywallet.broadcast.btctest.bitaps module
- zpywallet.broadcast.btctest.blockchair module
- zpywallet.broadcast.btctest.blockcypher module
- zpywallet.broadcast.btctest.blockstream module
- zpywallet.broadcast.btctest.esplora module
- zpywallet.broadcast.btctest.fullnode module
- zpywallet.broadcast.btctest.mempool_space module
- Module contents
- zpywallet.broadcast.dash package
- zpywallet.broadcast.dashtest package
- zpywallet.broadcast.doge package
- zpywallet.broadcast.dogetest package
- zpywallet.broadcast.eth package
- zpywallet.broadcast.ltc package
- zpywallet.broadcast.ltctest package
- Submodules
- zpywallet.broadcast.broadcast module
- Module contents
- Subpackages
- zpywallet.fees package
- zpywallet.generated package
- zpywallet.mnemonic package
- zpywallet.nodes package
- zpywallet.transactions package
- Submodules
- zpywallet.transactions.decode module
- zpywallet.transactions.encode module
- zpywallet.transactions.script module
ScriptScript.scriptScript.copy()Script.from_raw()Script.get_script()Script.is_p2pkh()Script.is_p2sh()Script.is_p2tr()Script.is_p2wpkh()Script.is_p2wsh()Script.to_bytes()Script.to_hex()Script.to_p2pkh()Script.to_p2sh()Script.to_p2sh_script_pub_key()Script.to_p2tr()Script.to_p2wpkh()Script.to_p2wsh()Script.to_p2wsh_script_pub_key()
hash160()p2sh_address()parse_varint()to_bytes()
- Module contents
- zpywallet.utils package
- Submodules
- zpywallet.utils.aes module
- zpywallet.utils.base58 module
- zpywallet.utils.bech32 module
- zpywallet.utils.bip32 module
HDWalletHDWallet.__init__()HDWallet.address()HDWallet.bitcoin_seedHDWallet.crack_private_key()HDWallet.create_new_address_for_user()HDWallet.dump_str_xkey()HDWallet.dump_xkey()HDWallet.fingerprintHDWallet.from_brainwallet()HDWallet.from_master_seed()HDWallet.from_mnemonic()HDWallet.from_random()HDWallet.get_child()HDWallet.get_child_for_path()HDWallet.get_private_key_hex()HDWallet.get_public_key_hex()HDWallet.identifierHDWallet.legacy_child()HDWallet.load_str_xkey()HDWallet.load_xkey()HDWallet.mnemonic_phraseHDWallet.new_random_wallet()HDWallet.public_copy()HDWallet.segwit_child()
bytes_int()hex_check_length()hex_int()is_hex_string()long_to_hex()
- zpywallet.utils.descriptors module
- zpywallet.utils.keccak module
- zpywallet.utils.keys module
PointPrivateKeyPrivateKey.base64_sign()PrivateKey.der_sign()PrivateKey.from_brainwallet()PrivateKey.from_bytes()PrivateKey.from_hex()PrivateKey.from_int()PrivateKey.from_random()PrivateKey.from_wif()PrivateKey.get_extended_key()PrivateKey.networkPrivateKey.public_keyPrivateKey.rfc2440_sign()PrivateKey.rsz_sign()PrivateKey.to_hex()PrivateKey.to_wif()
PublicKeyPublicKey.address()PublicKey.address_script()PublicKey.base58_address()PublicKey.base64_verify()PublicKey.bech32_address()PublicKey.der_verify()PublicKey.from_address()PublicKey.from_bytes()PublicKey.from_hex()PublicKey.from_point()PublicKey.hash160()PublicKey.hex_address()PublicKey.keccak256()PublicKey.networkPublicKey.p2pk_script()PublicKey.p2pkh_script()PublicKey.p2sh_script()PublicKey.p2wpkh_script()PublicKey.p2wsh_script()PublicKey.rfc2440_verify()PublicKey.rsz_verify()PublicKey.script()PublicKey.to_bytes()PublicKey.to_hex()PublicKey.to_point()
decode_der_signature()encode_der_signature()secp256k1
- zpywallet.utils.ripemd160 module
- Module contents
Submodules
zpywallet.bip38 module
- class Bip38PrivateKey(privkey: PrivateKey, passphrase, compressed=True, segwit=False, witness_version=0)[source]
Bases:
objectRepresents a BIP38 encrypted private key for Bitcoin.
- BLOCK_SIZE = 16
- IV_LEN = 16
- KEY_LEN = 32
- __init__(privkey: PrivateKey, passphrase, compressed=True, segwit=False, witness_version=0)[source]
Creates a BIP0038 private key with non-ec-multiply encryption.
- Parameters:
privkey (PrivateKey) – The private key.
passphrase (_type_) – The encryption passphrase
compressed (bool, optional) – Whether to use compressed public keys. Defaults to True.
segwit (bool, optional) – Whether to use segwit address. Defaults to False.
witness_version (int, optional) – The witness version for generating the segwit address. Defaults to 0.
- Raises:
ValueError – If the private key object does not support Base58 or Bech32.
- property base58
Returns the Base58 representation of the encrypted private key.
- private_key(passphrase, compressed=True, segwit=False, witness_version=0)[source]
Decrypts the encrypted private key using the given passphrase and returns the corresponding WIF private key.
- Parameters:
passphrase (_type_) – The passphrase to decrypt the key.
compressed (bool, optional) – Whether to use compressed public keys. Defaults to True.
segwit (bool, optional) – Whether to use segwit address. Defaults to False.
witness_version (int, optional) – The witness version for generating the segwit address. Defaults to 0.
- Raises:
ValueError – If the wrong decryption passphrase was supplied.
- Returns:
a Bitcoin private key.
- Return type:
- decrypt(enc, passphrase)[source]
Decrypts encrypted data with a passphrase.
This method should only be used for calculating BIP38 data. It uses AES settings that are not ideal for general-purpose use.
- Parameters:
enc (bytes) – The encrypted text to decrypt.
passphrase (str) – The passphrase used for decryption.
- Returns:
The decrypted text.
- Return type:
bytes
- encrypt(raw, passphrase)[source]
Encrypts data with a passphrase.
This method should only be used for calculating BIP38 data. It uses AES settings that are not ideal for general-purpose use.
- Parameters:
raw (str) – The text to encrypt.
passphrase (str) – The passphrase used for encryption.
- Returns:
The encrypted text.
- Return type:
bytes
zpywallet.destination module
- class Destination(address, amount, network, fee_policy=FeePolicy.NONE, in_standard_units=True)[source]
Bases:
objectRepresents a destination address and amount to send.
- __init__(address, amount, network, fee_policy=FeePolicy.NONE, in_standard_units=True)[source]
Initializes a Destination object.
- Parameters:
address (str) – The destination address.
amount (int) – The amount of the destination.
network – The network associated with the destination.
fee_policy (FeePolicy, optional) – The fee policy associated with the destination. Defaults to FeePolicy.NONE.
in_standard_units (bool, optional) – If True, amount is in BTC/ETH-style standard units. If False, amount is already in sats/wei.
- class FeePolicy(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
EnumEnumeration representing fee policies.
FeePolicy.NONE: Indicates no fee policy. FeePolicy.PROPORTIONAL: Indicates a proportional fee policy.
- NONE = 0
- PROPORTIONAL = 1
zpywallet.errors module
- exception ChecksumException[source]
Bases:
ExceptionRaised when the generated checksum of an address or public key does not match the expected checksum.
- exception IncompatibleNetworkException[source]
Bases:
ExceptionRaised when importing a piece of network data into the wrong network.
- exception InvalidChildException[source]
Bases:
ExceptionRaised when an invalid child key is passed.
- exception InvalidPathError[source]
Bases:
ExceptionRaised when the provided derivation path is invalid.
- exception PublicKeyHashException[source]
Bases:
ExceptionRaised when attempting a public key operation with a public key hash.
- exception SegwitError[source]
Bases:
ExceptionRaised when a network does not support Segwit (P2WPKH).
- exception WatchOnlyWalletError[source]
Bases:
ExceptionRaised when a wallet does not contain a private key when performing an operation that requires a public key.
zpywallet.network module
This file contains parameters and constants for all supported networks.
- class BitcoinCashMainNet[source]
Bases:
CryptoNetworkBitcoin Cash MainNet version bytes.
- ADDRESS_MODE = ['BASE58']
- BECH32_PREFIX = None
- BIP32_PATH = "m/44'/145'/0'"
- BIP32_SEGWIT_PATH = None
- CHAIN_ID = None
- COIN = 'BCH'
- EXT_PUBLIC_KEY = 76067358
- EXT_SECRET_KEY = 76066276
- EXT_SEGWIT_PUBLIC_KEY = None
- EXT_SEGWIT_SECRET_KEY = None
- INTERNAL_NAME = 19
- NAME = 'Bitcoin Cash'
- PUBKEY_ADDRESS = 28
- SCRIPT_ADDRESS = 40
- SECRET_KEY = 128
- SUPPORTS_EVM = False
- SUPPORTS_SEGWIT = False
- TESTNET = False
- class BitcoinMainNet[source]
Bases:
CryptoNetworkBitcoin MainNet version bytes defaulting to legacy addresses. From https://github.com/bitcoin/bitcoin/blob/v0.9.0rc1/src/chainparams.cpp
- ADDRESS_MODE = ['BASE58']
- BECH32_PREFIX = None
- BIP32_PATH = "m/44'/0'/0'"
- BIP32_SEGWIT_PATH = None
- CHAIN_ID = None
- COIN = 'BTC'
- EXT_PUBLIC_KEY = 76067358
- EXT_SECRET_KEY = 76066276
- EXT_SEGWIT_PUBLIC_KEY = None
- EXT_SEGWIT_SECRET_KEY = None
- INTERNAL_NAME = 1
- NAME = 'Bitcoin'
- PUBKEY_ADDRESS = 0
- SCRIPT_ADDRESS = 5
- SECRET_KEY = 128
- SUPPORTS_EVM = False
- SUPPORTS_SEGWIT = False
- TESTNET = False
- class BitcoinP2PKMainNet[source]
Bases:
BitcoinMainNetBitcoin MainNet version bytes, with no address support - P2PK only.
- ADDRESS_MODE = []
- INTERNAL_NAME = 21
- PUBKEY_ADDRESS = None
- SCRIPT_ADDRESS = None
- class BitcoinP2PKTestNet[source]
Bases:
BitcoinTestNetBitcoin TestNet version bytes, with no address support - P2PK only.
- ADDRESS_MODE = []
- INTERNAL_NAME = 22
- PUBKEY_ADDRESS = None
- SCRIPT_ADDRESS = None
- class BitcoinSegwitMainNet[source]
Bases:
BitcoinMainNetBitcoin MainNet version bytes, defaulting to segwit addresses.
- ADDRESS_MODE = ['BECH32', 'BASE58']
- BECH32_PREFIX = 'bc'
- BIP32_SEGWIT_PATH = "m/84'/0'/0'"
- EXT_SEGWIT_PUBLIC_KEY = 78792518
- EXT_SEGWIT_SECRET_KEY = 78791436
- INTERNAL_NAME = 0
- SUPPORTS_SEGWIT = True
- class BitcoinSegwitTestNet[source]
Bases:
BitcoinTestNetBitcoin TestNet version bytes, defaulting to segwit addresses.
- ADDRESS_MODE = ['BECH32', 'BASE58']
- BECH32_PREFIX = 'tb'
- BIP32_SEGWIT_PATH = "m/84'/1'/0'"
- EXT_SEGWIT_PUBLIC_KEY = 73342198
- EXT_SEGWIT_SECRET_KEY = 73341116
- INTERNAL_NAME = 2
- SUPPORTS_SEGWIT = True
- class BitcoinTestNet[source]
Bases:
CryptoNetworkBitcoin TestNet version bytes, defaulting to legacy addresses. From https://github.com/bitcoin/bitcoin/blob/v0.9.0rc1/src/chainparams.cpp
- ADDRESS_MODE = ['BASE58']
- BECH32_PREFIX = None
- BIP32_PATH = "m/44'/1'/0'"
- BIP32_SEGWIT_PATH = None
- CHAIN_ID = None
- COIN = 'BTC'
- EXT_PUBLIC_KEY = 70617039
- EXT_SECRET_KEY = 70615956
- EXT_SEGWIT_PUBLIC_KEY = None
- EXT_SEGWIT_SECRET_KEY = None
- INTERNAL_NAME = 3
- NAME = 'Bitcoin'
- PUBKEY_ADDRESS = 111
- SCRIPT_ADDRESS = 196
- SECRET_KEY = 239
- SUPPORTS_EVM = False
- SUPPORTS_SEGWIT = False
- TESTNET = True
- class BlockcypherTestNet[source]
Bases:
CryptoNetworkBlockcypher TestNet version bytes. From http://dev.blockcypher.com/#testing
- ADDRESS_MODE = ['BASE58']
- BECH32_PREFIX = None
- BIP32_PATH = "m/44'/1'/0'"
- BIP32_SEGWIT_PATH = None
- CHAIN_ID = None
- COIN = 'BCY'
- EXT_PUBLIC_KEY = 47453183
- EXT_SECRET_KEY = 47452099
- EXT_SEGWIT_PUBLIC_KEY = None
- EXT_SEGWIT_SECRET_KEY = None
- INTERNAL_NAME = 20
- NAME = 'BlockCypher'
- PUBKEY_ADDRESS = 27
- SCRIPT_ADDRESS = 31
- SECRET_KEY = 73
- SUPPORTS_EVM = False
- SUPPORTS_SEGWIT = False
- class CryptoNetwork[source]
Bases:
objectRepresents a cryptocurrency blockchain.
Don’t use this class - use one of the subclasses instead.
- P2PKH_TESTNET_PATH = "m/44'/1'/0'"
- class DashBTCMainNet[source]
Bases:
CryptoNetworkDash MainNet version bytes.
Extended version bytes are the same as for Bitcoin, i.e. xpub/xprv, for maximum wallet compatibility.
- ADDRESS_MODE = ['BASE58']
- BECH32_PREFIX = None
- BIP32_PATH = "m/44'/5'/0'"
- BIP32_SEGWIT_PATH = None
- CHAIN_ID = None
- COIN = 'DASH'
- EXT_PUBLIC_KEY = 76067358
- EXT_SECRET_KEY = 76066276
- EXT_SEGWIT_PUBLIC_KEY = None
- EXT_SEGWIT_SECRET_KEY = None
- INTERNAL_NAME = 16
- NAME = 'Dash'
- PUBKEY_ADDRESS = 76
- SCRIPT_ADDRESS = 16
- SECRET_KEY = 204
- SUPPORTS_EVM = False
- SUPPORTS_SEGWIT = False
- TESTNET = False
- class DashInvertedMainNet[source]
Bases:
DashMainNetDash MainNet version bytes.
This is the version that uses drkv/drkp as the public/private extended version bytes respectively. It intentionally has the same name and coin as the other Dash mainnets.
- EXT_PUBLIC_KEY = 50221816
- EXT_SECRET_KEY = 50221772
- INTERNAL_NAME = 15
- class DashInvertedTestNet[source]
Bases:
DashTestNetDash TestNet version bytes with inverted extended version bytes.
- EXT_PUBLIC_KEY = 981492128
- EXT_SECRET_KEY = 981489719
- INTERNAL_NAME = 18
- class DashMainNet[source]
Bases:
CryptoNetworkDash MainNet version bytes.
Dash’s xpub/xprv were originally drkp/drkv. But somehow, they were swapped when inserted into the refernece client. So there are actually two possible combinations of addresses in Dash (3, if you also count Bitcoin’s xpub/xprv)
For more information, see the following link: https://www.dash.org/forum/index.php?threads/dash-bip32-serialization-values-dev-discussion-wont-apply-to-most.8092/
- ADDRESS_MODE = ['BASE58']
- BECH32_PREFIX = None
- BIP32_PATH = "m/44'/5'/0'"
- BIP32_SEGWIT_PATH = None
- CHAIN_ID = None
- COIN = 'DASH'
- EXT_PUBLIC_KEY = 50221772
- EXT_SECRET_KEY = 50221816
- EXT_SEGWIT_PUBLIC_KEY = None
- EXT_SEGWIT_SECRET_KEY = None
- INTERNAL_NAME = 14
- NAME = 'Dash'
- PUBKEY_ADDRESS = 76
- SCRIPT_ADDRESS = 16
- SECRET_KEY = 204
- SUPPORTS_EVM = False
- SUPPORTS_SEGWIT = False
- TESTNET = False
- class DashTestNet[source]
Bases:
CryptoNetworkDash TestNet version bytes.
- ADDRESS_MODE = ['BASE58']
- BECH32_PREFIX = None
- BIP32_PATH = "m/44'/1'/0'"
- BIP32_SEGWIT_PATH = None
- CHAIN_ID = None
- COIN = 'DASH'
- EXT_PUBLIC_KEY = 981489719
- EXT_SECRET_KEY = 981492128
- EXT_SEGWIT_PUBLIC_KEY = None
- EXT_SEGWIT_SECRET_KEY = None
- INTERNAL_NAME = 17
- NAME = 'Dash'
- PUBKEY_ADDRESS = 140
- SCRIPT_ADDRESS = 19
- SECRET_KEY = 239
- SUPPORTS_EVM = False
- SUPPORTS_SEGWIT = False
- TESTNET = True
- class DogecoinBTCMainNet[source]
Bases:
CryptoNetworkDogecoin MainNet version bytes
Primary version bytes from: https://github.com/dogecoin/dogecoin/blob/1.5.2/src/base58.h
Extended version bytes are the same as for Bitocin mainnet, i.e. xpub/xprv, for wallet compatibility.
- ADDRESS_MODE = ['BASE58']
- BECH32_PREFIX = None
- BIP32_PATH = "m/44'/3'/0'"
- BIP32_SEGWIT_PATH = None
- CHAIN_ID = None
- COIN = 'DOGE'
- EXT_PUBLIC_KEY = 49990397
- EXT_SECRET_KEY = 49988504
- EXT_SEGWIT_PUBLIC_KEY = None
- EXT_SEGWIT_SECRET_KEY = None
- INTERNAL_NAME = 12
- NAME = 'Dogecoin'
- PUBKEY_ADDRESS = 30
- SCRIPT_ADDRESS = 22
- SECRET_KEY = 158
- SUPPORTS_EVM = False
- SUPPORTS_SEGWIT = False
- TESTNET = False
- class DogecoinMainNet[source]
Bases:
CryptoNetworkDogecoin MainNet version bytes
Primary version bytes from: https://github.com/dogecoin/dogecoin/blob/1.5.2/src/base58.h
Unofficial extended version bytes from https://bitcointalk.org/index.php?topic=409731
- ADDRESS_MODE = ['BASE58']
- BECH32_PREFIX = None
- BIP32_PATH = "m/44'/3'/0'"
- BIP32_SEGWIT_PATH = None
- CHAIN_ID = None
- COIN = 'DOGE'
- EXT_PUBLIC_KEY = 49990397
- EXT_SECRET_KEY = 49988504
- EXT_SEGWIT_PUBLIC_KEY = None
- EXT_SEGWIT_SECRET_KEY = None
- INTERNAL_NAME = 11
- NAME = 'Dogecoin'
- PUBKEY_ADDRESS = 30
- SCRIPT_ADDRESS = 22
- SECRET_KEY = 158
- SUPPORTS_EVM = False
- SUPPORTS_SEGWIT = False
- TESTNET = False
- class DogecoinTestNet[source]
Bases:
CryptoNetworkDogecoin TestNet version bytes
Primary version bytes from: https://github.com/dogecoin/dogecoin/blob/1.5.2/src/base58.h
Unofficial extended version bytes from https://bitcointalk.org/index.php?topic=409731
- ADDRESS_MODE = ['BASE58']
- BECH32_PREFIX = None
- BIP32_PATH = "m/44'/1'/0'"
- BIP32_SEGWIT_PATH = None
- CHAIN_ID = None
- COIN = 'DOGE'
- EXT_PUBLIC_KEY = 70429096
- EXT_SECRET_KEY = 70427203
- EXT_SEGWIT_PUBLIC_KEY = None
- EXT_SEGWIT_SECRET_KEY = None
- INTERNAL_NAME = 13
- NAME = 'Dogecoin'
- PUBKEY_ADDRESS = 113
- SCRIPT_ADDRESS = 196
- SECRET_KEY = 241
- SUPPORTS_EVM = False
- SUPPORTS_SEGWIT = False
- TESTNET = True
- class EthereumMainNet[source]
Bases:
CryptoNetworkEthereum MainNet version bytes.
- ADDRESS_MODE = ['HEX']
- BECH32_PREFIX = None
- BIP32_PATH = "m/44'/60'/0'"
- BIP32_SEGWIT_PATH = None
- CHAIN = 'main'
- CHAIN_ID = 1
- COIN = 'ETH'
- EXT_PUBLIC_KEY = 76067358
- EXT_SECRET_KEY = 76066276
- EXT_SEGWIT_PUBLIC_KEY = None
- EXT_SEGWIT_SECRET_KEY = None
- INTERNAL_NAME = 10
- NAME = 'Ethereum'
- PUBKEY_ADDRESS = None
- SCRIPT_ADDRESS = None
- SECRET_KEY = None
- SUPPORTS_EVM = True
- SUPPORTS_SEGWIT = False
- TESTNET = False
- class EthereumSepoliaTestNet[source]
Bases:
EthereumMainNetEthereum Sepolia TestNet version bytes.
- CHAIN = 'sepolia'
- CHAIN_ID = 11155111
- INTERNAL_NAME = 23
- NAME = 'Ethereum Sepolia'
- TESTNET = True
- class LitecoinBTCMainNet[source]
Bases:
CryptoNetworkLitecoin MainNet version bytes
Primary version bytes from: https://github.com/litecoin-project/litecoin/blob/master-0.8/src/base58.h
Extended version bytes same as bitcoin’s
- ADDRESS_MODE = ['BASE58']
- BECH32_PREFIX = None
- BIP32_PATH = "m/44'/2'/0'"
- BIP32_SEGWIT_PATH = None
- CHAIN_ID = None
- COIN = 'LTC'
- EXT_PUBLIC_KEY = 76067358
- EXT_SECRET_KEY = 76066276
- EXT_SEGWIT_PUBLIC_KEY = None
- EXT_SEGWIT_SECRET_KEY = None
- INTERNAL_NAME = 7
- NAME = 'Litecoin'
- PUBKEY_ADDRESS = 48
- SCRIPT_ADDRESS = 5
- SECRET_KEY = 176
- SUPPORTS_EVM = False
- SUPPORTS_SEGWIT = False
- TESTNET = False
- class LitecoinBTCSegwitMainNet[source]
Bases:
LitecoinBTCMainNetLitecoin MainNet version bytes, defaulting to segwit addresses.
- ADDRESS_MODE = ['BECH32', 'BASE58']
- BECH32_PREFIX = 'ltc'
- BIP32_SEGWIT_PATH = "m/84'/2'/0'"
- EXT_SEGWIT_PUBLIC_KEY = 78792518
- EXT_SEGWIT_SECRET_KEY = 78791436
- INTERNAL_NAME = 6
- SUPPORTS_SEGWIT = True
- class LitecoinMainNet[source]
Bases:
CryptoNetworkLitecoin MainNet version bytes
Primary version bytes from: https://github.com/litecoin-project/litecoin/blob/master-0.8/src/base58.h
Extemded version bytes from https://bitcointalk.org/index.php?topic=453395.0
- ADDRESS_MODE = ['BASE58']
- BECH32_PREFIX = None
- BIP32_PATH = "m/44'/2'/0'"
- BIP32_SEGWIT_PATH = None
- CHAIN_ID = None
- COIN = 'LTC'
- EXT_PUBLIC_KEY = 27108450
- EXT_SECRET_KEY = 27106558
- EXT_SEGWIT_PUBLIC_KEY = None
- EXT_SEGWIT_SECRET_KEY = None
- INTERNAL_NAME = 5
- NAME = 'Litecoin'
- PUBKEY_ADDRESS = 48
- SCRIPT_ADDRESS = 5
- SECRET_KEY = 176
- SUPPORTS_EVM = False
- SUPPORTS_SEGWIT = False
- TESTNET = False
- class LitecoinSegwitMainNet[source]
Bases:
LitecoinMainNetLitecoin MainNet version bytes, defaulting to segwit addresses.
- ADDRESS_MODE = ['BECH32', 'BASE58']
- BECH32_PREFIX = 'ltc'
- BIP32_SEGWIT_PATH = "m/84'/2'/0'"
- EXT_SEGWIT_PUBLIC_KEY = 78792518
- EXT_SEGWIT_SECRET_KEY = 78791436
- INTERNAL_NAME = 4
- SUPPORTS_SEGWIT = True
- class LitecoinSegwitTestNet[source]
Bases:
LitecoinTestNetLitecoin TestNet version bytes, defaulting to segwit addresses.
- ADDRESS_MODE = ['BECH32', 'BASE58']
- BECH32_PREFIX = 'tltc'
- BIP32_SEGWIT_PATH = "m/84'/1'/0'"
- EXT_SEGWIT_PUBLIC_KEY = 73342198
- EXT_SEGWIT_SECRET_KEY = 73341116
- INTERNAL_NAME = 5
- SUPPORTS_SEGWIT = True
- class LitecoinTestNet[source]
Bases:
CryptoNetworkLitecoin TestNet version bytes
Primary version bytes from: https://github.com/litecoin-project/litecoin/blob/master-0.8/src/base58.h
Litecoin testnet extended version bytes for legacy are the same as for Bitcoin testnet so we will just reuse the segwit for Bitcoin testnet as well. There is no official document I could find that supports this though.
- ADDRESS_MODE = ['BASE58']
- BECH32_PREFIX = None
- BIP32_PATH = "m/44'/1'/0'"
- BIP32_SEGWIT_PATH = None
- CHAIN_ID = None
- COIN = 'LTC'
- EXT_PUBLIC_KEY = 70711009
- EXT_SECRET_KEY = 70709117
- EXT_SEGWIT_PUBLIC_KEY = None
- EXT_SEGWIT_SECRET_KEY = None
- INTERNAL_NAME = 5
- NAME = 'Litecoin'
- PUBKEY_ADDRESS = 111
- SCRIPT_ADDRESS = 196
- SECRET_KEY = 239
- SUPPORTS_EVM = False
- SUPPORTS_SEGWIT = False
- TESTNET = True
zpywallet.transaction module
- class Transaction(transaction: Transaction, network)[source]
Bases:
objectRepresents a transaction with associated metadata.
- __init__(transaction: Transaction, network)[source]
Initializes a Transaction object.
- Parameters:
transaction (wallet_pb2.Transaction) – The transaction protobuf message.
network – The network associated with the transaction.
- evm_amount(in_standard_units=True)[source]
Returns the amount transferred in the transaction (EVM).
- Parameters:
in_standard_units (bool, optional) – If True, returns the amount in standard units. If False, returns the amount in the lowest denomination. Defaults to True.
- sat_inputs(include_witness=False)[source]
Returns the inputs of the transaction (Bitcoin-like).
- Parameters:
include_witness (bool, optional) – If True, includes witness data. Defaults to False.
- sat_outputs(only_unspent=False)[source]
Returns the outputs of the transaction (Bitcoin-like).
- Parameters:
only_unspent (bool, optional) – If True, returns only unspent outputs. Defaults to False.
zpywallet.utxo module
- class UTXO(transaction: Transaction, index: int, other_transactions=None, addresses=None, only_mine=False, only_unspent=True, _internal_param_do_not_use=None, _network=None)[source]
Bases:
objectRepresents an Unspent Transaction Output (UTXO) associated with a transaction.
NOTE: Currently, UTXO can only detect compressed/uncompressed P2PKH (legacy “1”) and compressed P2WPKH (bech32 “bc1q”) addresses.
- __init__(transaction: Transaction, index: int, other_transactions=None, addresses=None, only_mine=False, only_unspent=True, _internal_param_do_not_use=None, _network=None)[source]
Initializes a UTXO object.
- Parameters:
transaction (Transaction) – The transaction associated with the UTXO.
index (int) – The index of the UTXO in the transaction outputs.
other_transactions (list, optional) – Other transactions related to the UTXO. Defaults to None.
addresses (list, optional) – Addresses associated with the UTXO. Defaults to None.
only_mine (bool, optional) – If True, only includes UTXOs belonging to the specified addresses. Defaults to False.
zpywallet.wallet module
This module contains the methods for creating a crypto wallet.
- class Wallet(network, seed_phrase, password, receive_gap_limit=1000, change_gap_limit=None, derivation_path=None, _with_wallet=True, max_cycles=100, **kwargs)[source]
Bases:
objectData class representing a cryptocurrency wallet.
- __init__(network, seed_phrase, password, receive_gap_limit=1000, change_gap_limit=None, derivation_path=None, _with_wallet=True, max_cycles=100, **kwargs)[source]
Initializes a Wallet object.
- Parameters:
network – The network associated with the wallet.
seed_phrase – The seed phrase for the wallet.
password – The password to encrypt the wallet.
receive_gap_limit (int, optional) – The maximum gap limit for receive addresses. Defaults to 1000.
change_gap_limit (int, optional) – The maximum gap limit for change addresses. Defaults to the receive gap limit.
derivation_path (str, optional) – The derivation path for the wallet. Defaults to None.
max_cycles (int, optional) – The maximum number of cycles. Defaults to 100.
fullnode_endpoints (list, optional) – List of full node endpoints. Defaults to None.
esplora_endpoints (list, optional) – List of Esplora endpoints. Defaults to None.
blockcypher_tokens (list, optional) – List of Blockcypher tokens. Defaults to None.
- Raises:
ValueError – If an unknown network is provided or if the derivation path is invalid.
- addresses()[source]
Get the addresses associated with the wallet.
- Returns:
The list of addresses associated with the wallet.
- Return type:
List[str]
- broadcast_transaction(transaction)[source]
Broadcast a transaction to the network.
- Parameters:
transaction – The transaction to broadcast.
- create_transaction(password: bytes, destinations: List[Destination], fee_rate=None, spend_unconfirmed_inputs=False, **kwargs)[source]
Create a transaction.
- Parameters:
password (bytes) – The password used to encrypt the wallet.
destinations (List[Destination]) – The list of destinations for the transaction.
fee_rate – The fee rate for the transaction.
spend_unconfirmed_inputs (bool, optional) – If True, spend unconfirmed inputs. Defaults to False.
- Returns:
The created transaction.
- Return type:
- classmethod deserialize(data: bytes, password, max_cycles=100, **kwargs)[source]
Deserialize a Wallet object from its byte representation.
- Parameters:
cls – The class object.
data (bytes) – The byte representation of the Wallet object.
password – The password used to encrypt the wallet.
max_cycles (int, optional) – The maximum number of cycles. Defaults to 100.
- Returns:
The deserialized Wallet object.
- Return type:
- Raises:
ValueError – If an unknown network is encountered during deserialization.
- get_balance(in_standard_units=True)[source]
Get the balance of the wallet.
- Parameters:
in_standard_units (bool, optional) – If True, balance is returned in standard units (e.g., BTC, ETH). If False, balance is returned in raw units (e.g., satoshi, wei). Defaults to True.
- Returns:
The total balance and confirmed balance of the wallet.
- Return type:
Tuple[float, float]
- get_transaction_history()[source]
Get the transaction history associated with the wallet.
- Returns:
The list of transactions in the wallet’s history.
- Return type:
List[Transaction]
- get_utxos(only_unspent=False)[source]
Get the unspent transaction outputs (UTXOs) associated with the wallet.
- Parameters:
only_unspent (bool, optional) – If True, only unspent UTXOs are retrieved. Defaults to False.
- Returns:
The list of unspent transaction outputs.
- Return type:
List[UTXO]
- network()[source]
Get the network associated with the wallet.
- Returns:
The network associated with the wallet.
- Return type:
- private_keys(password)[source]
Get the private keys associated with the wallet.
- Parameters:
password – The password used to encrypt the wallet.
- Returns:
The list of private keys associated with the wallet.
- Return type:
List[str]
- create_keypair(network=<class 'zpywallet.network.BitcoinSegwitMainNet'>)[source]
Generates a random private/public keypair.
Args: :param network: The network to create this wallet for
- Returns:
a tuple of a private key and public key.
- Return type:
- Usage:
w = create_wallet(network=’BTC’, children=10)
- create_wallet(mnemonic=None, network=<class 'zpywallet.network.BitcoinSegwitMainNet'>, strength=128) HDWallet[source]
Deprecated: This function will be removed in v1.0
Generate a new wallet class from a mnemonic phrase, optionally randomly generated
Args:
- Parameters:
mnemonic – The key to use to generate this wallet. It may be a long string. Do not use a phrase from a book or song, as that will be guessed and is not secure. My advice is to not supply this argument and let me generate a new random key for you.
network – The network to create this wallet for
children – Create this many child addresses for this wallet. Default is 10, You should not use the master private key itself for sending or receiving funds, as a best practice.
- Returns:
a wallet class
- Return type:
- Usage:
w = create_wallet(network=’BTC’, children=10)