Skip to content
Meheret Tesfaye edited this page Apr 30, 2020 · 16 revisions

Wallet

Bytom wallet class.

Parameter

network (str) - Bytom network, [defaults to solonet].

Return

wallet (Wallet) - Bytom wallet class instance.

Note: Bytom has only three networks, ``mainnet``, ``solonet`` and ``testnet``.

from_entropy

Get bytom wallet from entropy.

Parameter

entropy (str) - Entropy hex string, [required].
passphrase (str) - Secret password/passphrase, [defaults to None].
language (str) - Mnemonic language, [defaults to english].

Return

wallet (Wallet) - Bytom wallet class instance.

>>> from pybytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_entropy(entropy="8d7454bb99e8e68de6adfc5519cbee64")
<pybytom.wallet.Wallet object at 0x040DA268>

from_mnemonic

Get bytom wallet from mnemonic.

Parameter

mnemonic (str) - 12 words mnemonic, [required].
passphrase (str) - Secret password/passphrase, [defaults to None].
language (str) - Mnemonic language, [defaults to None].

Return

wallet (Wallet) - Bytom wallet class instance.

>>> from pybytom.wallet import Wallet
>>> wallet = Wallet(network="testnet")
>>> wallet.from_mnemonic(mnemonic="舒 使 系 款 株 擾 麼 鄉 狗 振 誤 謀")
<pybytom.wallet.Wallet object at 0x040DA268>

from_seed

Get bytom wallet from seed.

Parameter

seed (str) - Mnemonic seed hex string, [required].

Return

wallet (Wallet) - Bytom wallet class instance.

>>> from pybytom.wallet import Wallet
>>> wallet = Wallet(network="solonet")
>>> wallet.from_seed(seed="baff3e1fe60e1f2a2d840d304acc98d1818140c79354a353b400fb019bfb256bc392d7aa9047adff1f14bce0342e14605c6743a6c08e02150588375eb2eb7d49")
<pybytom.wallet.Wallet object at 0x040DA268>

from_xprivate_key

Get bytom wallet from xprivate key.

Parameter

xprivate_key (str) - Bytom xprivate key, [required].

Return

wallet (Wallet) - Bytom wallet class instance.

>>> from pybytom.wallet import Wallet
>>> wallet = Wallet()
>>> wallet.from_xprivate_key(xprivate_key="205b15f70e253399da90b127b074ea02904594be9d54678207872ec1ba31ee51ef4490504bd2b6f997113671892458830de09518e6bd5958d5d5dd97624cfa4b")
<pybytom.wallet.Wallet object at 0x040DA268>

from_indexes

Drive bytom wallet from indexes.

Parameter

indexes (list) - Bytom derivation indexes, [required].

Return

wallet (Wallet) - Bytom wallet class instance.

>>> from pybytom.wallet import Wallet
>>> wallet = Wallet()
>>> wallet.from_xprivate_key(xprivate_key="205b15f70e253399da90b127b074ea02904594be9d54678207872ec1ba31ee51ef4490504bd2b6f997113671892458830de09518e6bd5958d5d5dd97624cfa4b")
>>> wallet.from_indexes(["2c000000", "99000000", "01000000", "00000000", "01000000"])
<pybytom.wallet.Wallet object at 0x040DA268>

from_index

Drive bytom wallet from index.

Parameter

index (int) - Bytom derivation index, [required].
harden (bool) - BIP 32 key harden, [default to False].

Return

wallet (Wallet) - Bytom wallet class instance.

>>> from pybytom.wallet import Wallet
>>> wallet = Wallet()
>>> wallet.from_entropy(entropy="8d7454bb99e8e68de6adfc5519cbee64", language="japaneses")
>>> wallet.from_index(44)
>>> wallet.from_index(153)
>>> wallet.from_index(1)  # Account
>>> wallet.from_index(0)  # Change False(0)/True(1)
>>> wallet.from_index(1)  # Address
<pybytom.wallet.Wallet object at 0x040DA268>

from_path

Drive bytom wallet from path.

Parameter

path (str) - Bytom derivation path, [required].

Return

wallet (Wallet) - Bytom wallet class instance.

>>> from pybytom.wallet import Wallet
>>> wallet = Wallet()
>>> wallet.from_mnemonic(mnemonic="舒 使 系 款 株 擾 麼 鄉 狗 振 誤 謀", passphrase="Hello Meheret!")
>>> wallet.from_path("m/44/153/1/0/1")
<pybytom.wallet.Wallet object at 0x040DA268>

entropy

Get wallet entropy.

Return

entropy (str) - Entropy hex string.

>>> from pybytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_entropy(entropy="8d7454bb99e8e68de6adfc5519cbee64", language="korean")
>>> wallet.entropy()
"8d7454bb99e8e68de6adfc5519cbee64"

mnemonic

Get wallet mnemonic.

Return

mnemonic (str) - 12 word mnemonic.

>>> from pybytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_entropy(entropy="8d7454bb99e8e68de6adfc5519cbee64", language="italian")
>>> wallet.mnemonic()
"occasione pizzico coltivato cremoso odorare epilogo patacca salone fonia sfuso vispo selettivo"

passphrase

Get wallet secret password/passphrase.

Return

passphrase (str) - Secret password/passphrase.

>>> from pybytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_entropy(entropy="8d7454bb99e8e68de6adfc5519cbee64", passphrase="Hello Meheret!", language="italian")
>>> wallet.passphrase()
"Hello Meheret!"

language

Get wallet mnemonic language.

Return

language (str) - Mnemonic language.

>>> from pybytom.wallet import Wallet
>>> wallet = Wallet(network="solonet")
>>> wallet.from_entropy(entropy="8d7454bb99e8e68de6adfc5519cbee64", passphrase="Hello Meheret!", language="italian")
>>> wallet.language()
"italian"

seed

Get wallet mnemonic seed.

Return

seed (str) - Mnemonic seed hex string.

>>> from pybytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_mnemonic("indicate warm sock mistake code spot acid ribbon sing over taxi toast")
>>> wallet.seed()
"baff3e1fe60e1f2a2d840d304acc98d1818140c79354a353b400fb019bfb256bc392d7aa9047adff1f14bce0342e14605c6743a6c08e02150588375eb2eb7d49"

xprivate_key

Get bytom wallet xprivate key.

Return

xprivate_key (str) - Bytom wallet xprivate key.

>>> from pybytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_mnemonic("indicate warm sock mistake code spot acid ribbon sing over taxi toast")
>>> wallet.xprivate_key()
"205b15f70e253399da90b127b074ea02904594be9d54678207872ec1ba31ee51ef4490504bd2b6f997113671892458830de09518e6bd5958d5d5dd97624cfa4b"

xpublic_key

Get bytom wallet xpublic key.

Return

xpublic_key (str) - Bytom wallet xpublic key.

>>> from pybytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_mnemonic("indicate warm sock mistake code spot acid ribbon sing over taxi toast")
>>> wallet.xpublic_key()
"16476b7fd68ca2acd92cfc38fa353e75d6103f828276f44d587e660a6bd7a5c5ef4490504bd2b6f997113671892458830de09518e6bd5958d5d5dd97624cfa4b"

expand_xprivate_key

Get bytom wallet expand xprivate key.

Return

expand_xprivate_key (str) - Bytom wallet expand xprivate key.

>>> from pybytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_mnemonic("indicate warm sock mistake code spot acid ribbon sing over taxi toast")
>>> wallet.expand_xprivate_key()
"205b15f70e253399da90b127b074ea02904594be9d54678207872ec1ba31ee5102416c643cfb46ab1ae5a524c8b4aaa002eb771d0d9cfc7490c0c3a8177e053e"

child_xprivate_key

Get bytom wallet child xprivate key.

Return

child_xprivate_key (str) - Bytom wallet child xprivate key.

>>> from pybytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_mnemonic("indicate warm sock mistake code spot acid ribbon sing over taxi toast")
>>> wallet.from_path("m/44/153/1/0/1")
>>> wallet.child_xprivate_key()
"e07af52746e7cccd0a7d1fba6651a6f474bada481f34b1c5bab5e2d71e36ee515803ee0a6682fb19e279d8f4f7acebee8abd0fc74771c71565f9a9643fd77141"

child_xpublic_key

Get bytom wallet child xpublic key.

Return

child_xpublic_key (str) - Bytom wallet child xpublic key.

>>> from pybytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_mnemonic("indicate warm sock mistake code spot acid ribbon sing over taxi toast")
>>> wallet.from_path("m/44/153/1/0/1")
>>> wallet.child_xpublic_key()
"91ff7f525ff40874c4f47f0cab42e46e3bf53adad59adef9558ad1b6448f22e25803ee0a6682fb19e279d8f4f7acebee8abd0fc74771c71565f9a9643fd77141"

private_key

Get bytom wallet private key.

Return

private_key (str) - Bytom wallet private key.

>>> from pybytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_mnemonic("indicate warm sock mistake code spot acid ribbon sing over taxi toast")
>>> wallet.from_path("m/44/153/1/0/1")
>>> wallet.private_key()
"e07af52746e7cccd0a7d1fba6651a6f474bada481f34b1c5bab5e2d71e36ee515803ee0a6682fb19e279d8f4f7acebee8abd0fc74771c71565f9a9643fd77141"

public_key

Get bytom wallet public key.

Return

public_key (str) - Bytom wallet public key.

>>> from pybytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_mnemonic("indicate warm sock mistake code spot acid ribbon sing over taxi toast")
>>> wallet.from_path("m/44/153/1/0/1")
>>> wallet.public_key()
"91ff7f525ff40874c4f47f0cab42e46e3bf53adad59adef9558ad1b6448f22e2"

indexes

Get bytom wallet derivation indexes.

Return

indexes (list) - Bytom derivation indexes.

>>> from pybytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_mnemonic("indicate warm sock mistake code spot acid ribbon sing over taxi toast")
>>> wallet.from_path("m/44/153/1/0/1")
>>> wallet.indexes()
["2c000000", "99000000", "01000000", "00000000", "01000000"]

path

Get bytom wallet derivation path.

Return

path (str) - Bytom derivation path.

>>> from pybytom.wallet import Wallet
>>> wallet = Wallet(network="solonet")
>>> wallet.from_mnemonic("indicate warm sock mistake code spot acid ribbon sing over taxi toast")
>>> wallet.from_indexes(["2c000000", "99000000", "01000000", "00000000", "01000000"])
>>> wallet.path()
"m/44/153/1/0/1"

program

Get bytom wallet control program.

Return

program (str) - Bytom wallet control program.

>>> from pybytom.wallet import Wallet
>>> wallet = Wallet(network="solonet")
>>> wallet.from_mnemonic("indicate warm sock mistake code spot acid ribbon sing over taxi toast")
>>> wallet.from_indexes(["2c000000", "99000000", "01000000", "00000000", "01000000"])
>>> wallet.program()
"00142cda4f99ea8112e6fa61cdd26157ed6dc408332a"

address

Get bytom wallet address.

Parameter

network (str) - Bytom network, [defaults to solonet].

Return

address (str) - Bytom wallet address.

>>> from pybytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_mnemonic("indicate warm sock mistake code spot acid ribbon sing over taxi toast")
>>> wallet.from_indexes(["2c000000", "99000000", "01000000", "00000000", "01000000"])
>>> wallet.address()
"bm1q9ndylx02syfwd7npehfxz4lddhzqsve2fu6vc7"

sign

Sign message data by private key.

Parameter

message (str) - Message data hex string, [required].

Return

signature (dict) - Signed message data (signature).

>>> from pybytom.wallet import Wallet
>>> message = "1246b84985e1ab5f83f4ec2bdf271114666fd3d9e24d12981a3c861b9ed523c6"
>>> wallet = Wallet(network="testnet")
>>> wallet.from_mnemonic("indicate warm sock mistake code spot acid ribbon sing over taxi toast")
>>> wallet.from_indexes(["2c000000", "99000000", "01000000", "00000000", "01000000"])
>>> wallet.sign(message=message)
"f6624fea84fadccbc1bc72dc384f662468e271c4e32d846bc0a1524470549992c8ffcc3ca43891a30de4235392b0868c506ed254f0f77cc1f2b9c1a2385ddb05"

verify

Verify signature by public key.

Parameter

message (str) - Message data hex string, [required]. signature (str) - Signed message data, [required].

Return

signature (bool) - Verified signature (True/False).

>>> from pybytom.wallet import Wallet
>>> message = "1246b84985e1ab5f83f4ec2bdf271114666fd3d9e24d12981a3c861b9ed523c6"
>>> signature = "f6624fea84fadccbc1bc72dc384f662468e271c4e32d846bc0a1524470549992c8ffcc3ca43891a30de4235392b0868c506ed254f0f77cc1f2b9c1a2385ddb05"
>>> wallet = Wallet(network="testnet")
>>> wallet.from_mnemonic("indicate warm sock mistake code spot acid ribbon sing over taxi toast")
>>> wallet.from_indexes(["2c000000", "99000000", "01000000", "00000000", "01000000"])
>>> wallet.verify(message=message, signature=signature)
True

dumps

Get bytom all wallet information's.

Return

dumps (dict) - Bytom all wallet information's.

>>> from pybytom.wallet import Wallet
>>> wallet = Wallet()
>>> wallet.from_mnemonic("indicate warm sock mistake code spot acid ribbon sing over taxi toast")
>>> wallet.from_indexes(["2c000000", "99000000", "01000000", "00000000", "01000000"])
>>> wallet.dumps()
{'entropy': None, 'mnemonic': 'indicate warm sock mistake code spot acid ribbon sing over taxi toast', 'language': 'english', 'passphrase': None, 'seed': 'baff3e1fe60e1f2a2d840d304acc98d1818140c79354a353b400fb019bfb256bc392d7aa9047adff1f14bce0342e14605c6743a6c08e02150588375eb2eb7d49', 'xprivate_key': '205b15f70e253399da90b127b074ea02904594be9d54678207872ec1ba31ee51ef4490504bd2b6f997113671892458830de09518e6bd5958d5d5dd97624cfa4b', 'xpublic_key': '16476b7fd68ca2acd92cfc38fa353e75d6103f828276f44d587e660a6bd7a5c5ef4490504bd2b6f997113671892458830de09518e6bd5958d5d5dd97624cfa4b', 'expand_xprivate_key': '205b15f70e253399da90b127b074ea02904594be9d54678207872ec1ba31ee5102416c643cfb46ab1ae5a524c8b4aaa002eb771d0d9cfc7490c0c3a8177e053e', 'indexes': ['2c000000', '99000000', '01000000', '00000000', '01000000'], 'path': 'm/44/153/1/0/1', 'child_xprivate_key': 'e07af52746e7cccd0a7d1fba6651a6f474bada481f34b1c5bab5e2d71e36ee515803ee0a6682fb19e279d8f4f7acebee8abd0fc74771c71565f9a9643fd77141', 'child_xpublic_key': '91ff7f525ff40874c4f47f0cab42e46e3bf53adad59adef9558ad1b6448f22e25803ee0a6682fb19e279d8f4f7acebee8abd0fc74771c71565f9a9643fd77141', 'private_key': 'e07af52746e7cccd0a7d1fba6651a6f474bada481f34b1c5bab5e2d71e36ee515803ee0a6682fb19e279d8f4f7acebee8abd0fc74771c71565f9a9643fd77141', 'public_key': '91ff7f525ff40874c4f47f0cab42e46e3bf53adad59adef9558ad1b6448f22e2', 'program': '00142cda4f99ea8112e6fa61cdd26157ed6dc408332a', 'address': {'mainnet': 'bm1q9ndylx02syfwd7npehfxz4lddhzqsve2fu6vc7', 'solonet': 'sm1q9ndylx02syfwd7npehfxz4lddhzqsve2gdsdcs', 'testnet': 'tm1q9ndylx02syfwd7npehfxz4lddhzqsve2d2mgc0'}}