Wallet¶
The implementation of Hierarchical Deterministic (HD) wallets generator for Bitcoin blockchain.
-
class
shuttle.providers.bitcoin.wallet.
Wallet
(network='testnet')¶ Bitcoin Wallet class.
- Parameters
network (str) – Bitcoin network, defaults to testnet.
- Returns
Wallet – Bitcoin wallet instance.
Note
Bitcoin has only two networks,
mainnet
andtestnet
.-
from_private_key
(private_key, compressed=True)¶ Initiate Bitcoin wallet from private key.
- Parameters
private_key (str.) – Bitcoin wallet private key.
compressed (bool) – Bitcoin public key compressed, default is True.
- Returns
Wallet – Bitcoin wallet instance.
>>> from shuttle.providers.bitcoin.wallet import Wallet >>> wallet = Wallet(network="mainnet") >>> wallet.from_private_key("92cbbc5990cb5090326a76feeb321cad01048635afe5756523bbf9f7a75bf38b") <shuttle.providers.bitcoin.wallet.Wallet object at 0x040DA268>
-
from_passphrase
(passphrase, compressed=True)¶ Initiate Bitcoin wallet from passphrase.
- Parameters
passphrase (str.) – Bitcoin wallet passphrase.
compressed (bool) – Bitcoin public key compressed, default is True.
- Returns
Wallet – Bitcoin wallet instance.
>>> from shuttle.providers.bitcoin.wallet import Wallet >>> wallet = Wallet(network="mainnet") >>> wallet.from_passphrase("meherett")
-
from_address
(address)¶ Initiate Bitcoin wallet from address.
- Parameters
address (str.) – Bitcoin wallet private key.
- Returns
Wallet – Bitcoin wallet instance.
>>> from shuttle.providers.bitcoin.wallet import Wallet >>> wallet = Wallet(network="testnet") >>> wallet.from_address("mqLyrNDjpENRMZAoDpspH7kR9RtgvhWzYE") <shuttle.providers.bitcoin.wallet.Wallet object at 0x040DA268>
-
private_key
()¶ Get Bitcoin wallet private key.
- Returns
str – Bitcoin private key.
>>> from shuttle.providers.bitcoin.wallet import Wallet >>> wallet = Wallet(network="testnet") >>> wallet.from_passphrase("meherett") >>> wallet.private_key() "d4f5c55a45c004660b95ec833bb24569eba1559f214e90efa6e8d0b3afa14394"
-
public_key
(private_key=None, compressed=True)¶ Get Bitcoin wallet public key.
- Parameters
private_key (str) – Bitcoin private key, default is None.
compressed (bool) – Bitcoin public key compressed, default is True.
- Returns
str – Bitcoin public key.
>>> from shuttle.providers.bitcoin.wallet import Wallet >>> wallet = Wallet(network="testnet") >>> wallet.from_passphrase("meherett", compressed=False) >>> wallet.public_key() "04afa8301b068c2c184e0a3e77183dc95ec1130371c02ed172bec8f3bfbad6b17334244f64fe877d5e4839690c62b9d1f4095608f2ac29235e4b0299b6b96f6f35"
-
compressed
(public_key=None)¶ Get Bitcoin wallet compressed public key.
- Parameters
public_key (str) – Bitcoin public key, default is None.
- Returns
str – Bitcoin compressed public key.
>>> from shuttle.providers.bitcoin.wallet import Wallet >>> wallet = Wallet(network="testnet") >>> wallet.from_passphrase("meherett") >>> wallet.compressed() "03afa8301b068c2c184e0a3e77183dc95ec1130371c02ed172bec8f3bfbad6b173"
-
uncompressed
(public_key=None)¶ Get Bitcoin wallet uncompressed public key.
- Parameters
public_key (str) – Bitcoin public key, default is None.
- Returns
str – Bitcoin uncompressed public key.
>>> from shuttle.providers.bitcoin.wallet import Wallet >>> wallet = Wallet(network="testnet") >>> wallet.from_passphrase("meherett") >>> wallet.uncompressed() "04afa8301b068c2c184e0a3e77183dc95ec1130371c02ed172bec8f3bfbad6b17334244f64fe877d5e4839690c62b9d1f4095608f2ac29235e4b0299b6b96f6f35"
-
address
(public_key=None)¶ Get Bitcoin wallet address.
- Parameters
public_key (str) – Bitcoin address, default is None.
- Returns
str – Bitcoin address.
>>> from shuttle.providers.bitcoin.wallet import Wallet >>> wallet = Wallet(network="testnet") >>> wallet.from_passphrase("meherett") >>> wallet.address() "mm357rHaKqVmhEhFFwUhz6mRVAHkJaDTKt"
-
hash
(public_key=None)¶ Get Bitcoin wallet hash.
- Parameters
public_key (str) – Bitcoin hash, default is None.
- Returns
str – Bitcoin hash.
>>> from shuttle.providers.bitcoin.wallet import Wallet >>> wallet = Wallet(network="testnet") >>> wallet.from_passphrase("meherett") >>> wallet.hash() "3c8acde1c7cf370d970725f13eff03bf74b3fc61"
-
p2pkh
(address=None)¶ Get Bitcoin wallet p2pkh.
- Parameters
address (str) – Bitcoin p2pkh, default is None.
- Returns
str – Bitcoin p2pkh.
>>> from shuttle.providers.bitcoin.wallet import Wallet >>> wallet = Wallet(network="testnet") >>> wallet.from_passphrase("meherett") >>> wallet.p2pkh() "76a9143c8acde1c7cf370d970725f13eff03bf74b3fc6188ac"
-
p2sh
(address=None)¶ Get Bitcoin wallet p2sh.
- Parameters
address (str) – Bitcoin p2sh, default is None.
- Returns
str – Bitcoin p2sh.
>>> from shuttle.providers.bitcoin.wallet import Wallet >>> wallet = Wallet(network="testnet") >>> wallet.from_passphrase("meherett") >>> wallet.p2sh() "a914a3c4995d9cd0303e5f89ee1433212c797d04ee5d87"
-
balance
(address=None, network='testnet')¶ Get Bitcoin wallet balance.
- Parameters
address (str) – Bitcoin balance, default is None.
network (str) – Bitcoin balance, default is testnet.
- Returns
int – Bitcoin balance.
>>> from shuttle.providers.bitcoin.wallet import Wallet >>> wallet = Wallet(network="testnet") >>> wallet.from_passphrase("meherett") >>> wallet.balance() 1000000
-
unspent
(address=None, network='testnet', limit=15)¶ Get Bitcoin wallet unspent transaction output.
- Parameters
address (str) – Bitcoin balance, default is None.
network (str) – Bitcoin balance, default is testnet.
limit (int) – Bitcoin balance, default is 15.
- Returns
list – Bitcoin unspent transaction outputs.
>>> from shuttle.providers.bitcoin.wallet import Wallet >>> wallet = Wallet(network="testnet") >>> wallet.from_passphrase("meherett") >>> wallet.unspent() [{'index': 0, 'hash': 'be346626628199608926792d775381e54d8632c14b3ce702f90639481722392c', 'output_index': 1, 'amount': 12340, 'script': '76a9146bce65e58a50b97989930e9a4ff1ac1a77515ef188ac'}]