Wallet

The implementation of Hierarchical Deterministic (HD) wallets generator for Bytom blockchain.

class swap.providers.bytom.wallet.Wallet(network: str = 'mainnet')

Bytom Wallet class.

Parameters

network (str) – Bytom network, defaults to mainnet.

Returns

Wallet – Bytom wallet instance.

Note

Bytom has only two networks, mainnet, solonet and testnet.

from_entropy(entropy: str, passphrase: Optional[str] = None, language: str = 'english')swap.providers.bytom.wallet.Wallet

Initiate Bytom wallet from entropy.

Parameters
  • entropy (str) – Bytom wallet entropy.

  • passphrase (str) – Bytom wallet passphrase, default to None.

  • language (str) – Bytom wallet language, default to english.

Returns

Wallet – Bytom wallet instance.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_entropy("50f002376c81c96e430b48f1fe71df57")
<swap.providers.bytom.wallet.Wallet object at 0x040DA268>
from_mnemonic(mnemonic: str, passphrase: Optional[str] = None, language: Optional[str] = None)swap.providers.bytom.wallet.Wallet

Initialize Bytom wallet from mnemonic.

Parameters
  • mnemonic (str) – Bytom wallet mnemonic.

  • passphrase (str) – Bytom wallet passphrase, default to None.

  • language (str) – Bytom wallet language, default to english.

Returns

Wallet – Bytom wallet class instance.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_mnemonic("extend length miss suit broken rescue around harbor vehicle vicious jelly quality")
<swap.providers.bytom.wallet.Wallet object at 0x040DA268>
from_seed(seed: str)swap.providers.bytom.wallet.Wallet

Initialize Bytom wallet from seed.

Parameters

seed (str) – Bytom wallet seed.

Returns

Wallet – Bytom wallet class instance.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_seed("51a0f6fb9abd5e5aa27f42dd375d8e4fc6944c704c859454e557fc419d3979e5a50273743c93e5035244adb09e9a37914abc583fdfae0da1ae2bedaa373f050e")
<swap.providers.bytom.wallet.Wallet object at 0x040DA268>
from_xprivate_key(xprivate_key: str)swap.providers.bytom.wallet.Wallet

Initiate Bytom wallet from xprivate key.

Parameters

xprivate_key (str.) – Bytom wallet xprivate key.

Returns

Wallet – Bytom wallet instance.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_xprivate_key("d0d4862706cfe7d2ffdf53d00fba1d524587972e2eb0226ce9fff3ca58e5a14f031f74b091a04f3ff6b1722540eefcd4e2bcdcba0944a2df781cfdccf2f47e59")
<swap.providers.bytom.wallet.Wallet object at 0x040DA268>
from_private_key(private_key: str)swap.providers.bytom.wallet.Wallet

Initialize Bytom wallet from private key.

Parameters

private_key (str.) – Bytom private key.

Returns

Wallet – Bytom wallet instance.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_private_key("40d171e524c5d366c87f789e293e9e8d63ab95be796b3c04b63db29321eaa14f92de5a98859ca593b63f9e421958d8ded8e171aaad775d85f7a78515a1992f6c")
<swap.providers.bytom.wallet.Wallet object at 0x040DA268>
from_path(path: str)swap.providers.bytom.wallet.Wallet

Drive Bytom wallet from path.

Parameters

path (str) – Bytom wallet path.

Returns

Wallet – Bytom wallet instance.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_entropy("50f002376c81c96e430b48f1fe71df57")
>>> wallet.from_path("m/44/153/1/0/1")
<swap.providers.bytom.wallet.Wallet object at 0x040DA268>
from_indexes(indexes: List[str])swap.providers.bytom.wallet.Wallet

Drive Bytom wallet from indexes.

Parameters

indexes (list.) – Bytom derivation indexes.

Returns

Wallet – Bytom wallet class instance.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_xprivate_key("205b15f70e253399da90b127b074ea02904594be9d54678207872ec1ba31ee51ef4490504bd2b6f997113671892458830de09518e6bd5958d5d5dd97624cfa4b")
>>> wallet.from_indexes(["2c000000", "99000000", "01000000", "00000000", "01000000"])
<swap.providers.bytom.wallet.Wallet object at 0x040DA268>
from_index(index: int, harden: bool = False)swap.providers.bytom.wallet.Wallet

Drive Bytom wallet from index.

Parameters
  • index (int) – Bytom wallet index.

  • harden (bool) – Use harden, default to False.

Returns

Wallet – Bytom wallet instance.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_entropy("50f002376c81c96e430b48f1fe71df57")
>>> wallet.from_index(44)
>>> wallet.from_index(153)
>>> wallet.from_index(1)
>>> wallet.from_index(0)
>>> wallet.from_index(1)
<swap.providers.bytom.wallet.Wallet object at 0x040DA268>
clean_derivation()swap.providers.bytom.wallet.Wallet

Clean derivation Bytom wallet.

Returns

Wallet – Bytom wallet instance.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_entropy("50f002376c81c96e430b48f1fe71df57")
>>> wallet.from_path("m/44/153/1/0/1")
>>> wallet.indexes()
["2c000000", "99000000", "01000000", "00000000", "01000000"]
>>> wallet.path()
"m/44/153/1/0/1"
>>> wallet.clean_derivation()
>>> wallet.indexes()
[]
>>> wallet.path()
None
entropy() → Optional[str]

Get Bytom wallet entropy.

Returns

str – Bytom wallet entropy.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_entropy("50f002376c81c96e430b48f1fe71df57")
>>> wallet.entropy()
"50f002376c81c96e430b48f1fe71df57"
mnemonic() → Optional[str]

Get Bytom wallet mnemonic.

Returns

str – Bytom wallet mnemonic.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_entropy("50f002376c81c96e430b48f1fe71df57")
>>> wallet.mnemonic()
"extend length miss suit broken rescue around harbor vehicle vicious jelly quality"
passphrase() → Optional[str]

Get Bytom wallet passphrase.

Returns

str – Bytom wallet passphrase.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_entropy("50f002376c81c96e430b48f1fe71df57", passphrase="meherett")
>>> wallet.passphrase()
"meherett"
language() → Optional[str]

Get Bytom wallet language.

Returns

str – Bytom wallet language.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_entropy("50f002376c81c96e430b48f1fe71df57")
>>> wallet.language()
"english"
seed() → Optional[str]

Get Bytom wallet seed.

Returns

str – Bytom wallet seed.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_entropy("50f002376c81c96e430b48f1fe71df57")
>>> wallet.seed()
"51a0f6fb9abd5e5aa27f42dd375d8e4fc6944c704c859454e557fc419d3979e5a50273743c93e5035244adb09e9a37914abc583fdfae0da1ae2bedaa373f050e"
path() → Optional[str]

Get Bytom wallet derivation path.

Returns

str – Bytom derivation path.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet", change=True, address=3)
>>> wallet.from_entropy("50f002376c81c96e430b48f1fe71df57")
>>> wallet.from_path("m/44/153/1/0/1")
>>> wallet.path()
"m/44/153/1/0/1"
indexes() → list

Get Bytom wallet derivation indexes.

Returns

list – Bytom derivation indexes.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_entropy("50f002376c81c96e430b48f1fe71df57")
>>> wallet.from_path("m/44/153/1/0/1")
>>> wallet.indexes()
['2c000000', '99000000', '01000000', '00000000', '01000000']
xprivate_key() → Optional[str]

Get Bytom wallet xprivate key.

Returns

str – Bytom xprivate key.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_entropy("50f002376c81c96e430b48f1fe71df57")
>>> wallet.xprivate_key()
"d0d4862706cfe7d2ffdf53d00fba1d524587972e2eb0226ce9fff3ca58e5a14f031f74b091a04f3ff6b1722540eefcd4e2bcdcba0944a2df781cfdccf2f47e59"
xpublic_key() → Optional[str]

Get Bytom wallet xpublic key.

Returns

str – Bytom xpublic key.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_entropy("50f002376c81c96e430b48f1fe71df57")
>>> wallet.xpublic_key()
"5086c8522be8c3b8674d72a6b9aa19eef43ef1992a482e71f389d99159accc39031f74b091a04f3ff6b1722540eefcd4e2bcdcba0944a2df781cfdccf2f47e59"
expand_xprivate_key() → Optional[str]

Get Bytom wallet expand xprivate key.

Returns

str – Bytom expand xprivate key.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_entropy("50f002376c81c96e430b48f1fe71df57")
>>> wallet.expand_xprivate_key()
"d0d4862706cfe7d2ffdf53d00fba1d524587972e2eb0226ce9fff3ca58e5a14f7c15b70c1b0fc7a393fdb443c54b55e187635bf3dec62af44741085b7f12015a"
child_xprivate_key() → Optional[str]

Get Bytom child wallet xprivate key.

Returns

str – Bytom child xprivate key.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_entropy("50f002376c81c96e430b48f1fe71df57")
>>> wallet.child_xprivate_key()
"40d171e524c5d366c87f789e293e9e8d63ab95be796b3c04b63db29321eaa14f92de5a98859ca593b63f9e421958d8ded8e171aaad775d85f7a78515a1992f6c"
child_xpublic_key() → Optional[str]

Get Bytom child wallet xpublic key.

Returns

str – Bytom child xpublic key.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_entropy("50f002376c81c96e430b48f1fe71df57")
>>> wallet.child_xpublic_key()
"ffbbd79031060ef98fee4deda59818732e7665de15df34dff209d1f6f9a1443992de5a98859ca593b63f9e421958d8ded8e171aaad775d85f7a78515a1992f6c"
guid() → Optional[str]

Get Bytom wallet Blockcenter GUID.

Returns

str – Bytom Blockcenter GUID.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_entropy("50f002376c81c96e430b48f1fe71df57")
>>> wallet.guid()
"e34d612c-f1f9-42c6-8b14-3d93c5b21715"
private_key() → str

Get Bytom wallet private key.

Returns

str – Bytom private key.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_entropy("50f002376c81c96e430b48f1fe71df57")
>>> wallet.from_path("m/44/153/1/0/1")
>>> wallet.private_key()
"40d171e524c5d366c87f789e293e9e8d63ab95be796b3c04b63db29321eaa14f92de5a98859ca593b63f9e421958d8ded8e171aaad775d85f7a78515a1992f6c"
public_key() → str

Get Bytom wallet public key.

Returns

str – Bytom public key.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_entropy("50f002376c81c96e430b48f1fe71df57")
>>> wallet.from_path("m/44/153/1/0/1")
>>> wallet.public_key()
"ffbbd79031060ef98fee4deda59818732e7665de15df34dff209d1f6f9a14439"
program()

Get Bytom wallet control program.

Returns

str – Bytom control program.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_entropy("50f002376c81c96e430b48f1fe71df57")
>>> wallet.from_path("m/44/153/1/0/1")
>>> wallet.program()
"00144eaaa3205545eac08fb3a2d1b1570b67c3b46016"
address(network: Optional[str] = 'mainnet') → str

Get Bytom wallet address.

Parameters

network (str) – Bytom network, defaults to mainnet.

Returns

str – Bytom wallet address.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_entropy("50f002376c81c96e430b48f1fe71df57")
>>> wallet.from_indexes(["2c000000", "99000000", "01000000", "00000000", "01000000"])
>>> wallet.address(network="mainnet")
"bm1qf642xgz4gh4vpran5tgmz4ctvlpmgcqkmhn2le"
balance(asset: str = 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff') → int

Get Bytom wallet balance.

Parameters

asset (str) – Bytom asset id, defaults to BTM asset.

Returns

int – Bytom wallet balance.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_entropy("50f002376c81c96e430b48f1fe71df57")
>>> wallet.from_path("m/44/153/1/0/1")
>>> wallet.balance()
2450000000
utxos(asset: str = 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', limit: int = 15) → list

Get Bytom wallet unspent transaction output (UTXO’s).

Parameters
  • asset (str) – Bytom asset id, defaults to BTM asset.

  • limit (int) – Bytom balance, default is 15.

Returns

list – Bytom unspent transaction outputs.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet = Wallet(network="mainnet")
>>> wallet.from_entropy("50f002376c81c96e430b48f1fe71df57")
>>> wallet.from_path("m/44/153/1/0/1")
>>> wallet.utxos()
[{'hash': 'e152f88d33c6659ad823d15c5c65b2ed946d207c42430022cba9bb9b9d70a7a4', 'asset': 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 'amount': 587639800}, {'hash': '88289fa4c7633574931be7ce4102aeb24def0de20e38e7d69a5ddd6efc116b95', 'asset': 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 'amount': 8160000}, {'hash': 'f71c68f921b434cc2bcd469d26e7927aa6db7500e4cdeef814884f11c10f5de2', 'asset': 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 'amount': 10000}, {'hash': 'e46cfecc1f1a26413172ce81c78affb19408e613915642fa5fb04d3b0a4ffa65', 'asset': 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 'amount': 100}]