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, language: str = 'english', passphrase: Optional[str] = None) swap.providers.bytom.wallet.Wallet

Initiate Bytom wallet from entropy.

Parameters
  • entropy (str) – Bytom entropy hex string.

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

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

Returns

Wallet – Bytom wallet instance.

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

Initialize Bytom wallet from mnemonic.

Parameters
  • mnemonic (str) – Bytom mnemonic words.

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

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

Returns

Wallet – Bytom wallet instance.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet: Wallet = Wallet(network="mainnet")
>>> wallet.from_mnemonic(mnemonic="unfair divorce remind addict add roof park clown build renew illness fault")
<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 Seed hex string.

Returns

Wallet – Bytom wallet instance.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet: Wallet = Wallet(network="mainnet")
>>> wallet.from_seed(seed="1cfd5df8a523d53a36cee369a93fac4e9efab5e4e138d479da2fb6df730697574409d572fe8325ec22e8ed25dea7495f498c3f5235fe6ae6d47b989267b6777c")
<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 XPrivate key.

Returns

Wallet – Bytom wallet instance.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet: Wallet = Wallet(network="mainnet")
>>> wallet.from_xprivate_key(xprivate_key="58775359b7b3588dcdc1bcf373489fa1272cacc03909f78469657b0208e66e46daedfdd0fd8f8df14e2084c7e8df4701db3062dded1c713e0aae734ac09c4afd")
<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 = Wallet(network="mainnet")
>>> wallet.from_private_key(private_key="b0f9552e4fedac7f2e750ae984e36a97cf2b24609f7ec43f35606ed65eec6e46db35f71c405fd5948ecffa2c512adafb35cc621f99a60ecb6ec8aef815a8c6e5")
<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 derivation path.

Returns

Wallet – Bytom wallet instance.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet: Wallet = Wallet(network="mainnet")
>>> wallet.from_entropy(entropy="ed0802d701a033776811601dd6c5c4a9")
>>> wallet.from_path(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 instance.

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

Drive Bytom wallet from index.

Parameters
  • index (int) – Bytom wallet index.

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

Returns

Wallet – Bytom wallet instance.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet: Wallet = Wallet(network="mainnet")
>>> wallet.from_entropy(entropy="ed0802d701a033776811601dd6c5c4a9")
>>> wallet.from_index(index=44)
>>> wallet.from_index(index=153)
>>> wallet.from_index(index=1)
>>> wallet.from_index(index=0)
>>> wallet.from_index(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 = Wallet(network="mainnet")
>>> wallet.from_entropy(entropy="ed0802d701a033776811601dd6c5c4a9")
>>> wallet.from_path(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
strength() Optional[int]

Get Bytom wallet strength.

Returns

int – Bytom wallet strength.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet: Wallet = Wallet(network="mainnet")
>>> wallet.from_entropy(entropy="ed0802d701a033776811601dd6c5c4a9")
>>> wallet.strength()
128
entropy() Optional[str]

Get Bytom wallet entropy.

Returns

str – Bytom wallet entropy.

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

Get Bytom wallet mnemonic.

Returns

str – Bytom wallet mnemonic.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet: Wallet = Wallet(network="mainnet")
>>> wallet.from_entropy(entropy="ed0802d701a033776811601dd6c5c4a9")
>>> wallet.mnemonic()
"unfair divorce remind addict add roof park clown build renew illness fault"
passphrase() Optional[str]

Get Bytom wallet passphrase.

Returns

str – Bytom wallet passphrase.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet: Wallet = Wallet(network="mainnet")
>>> wallet.from_entropy(entropy="ed0802d701a033776811601dd6c5c4a9", 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 = Wallet(network="mainnet")
>>> wallet.from_entropy(entropy="ed0802d701a033776811601dd6c5c4a9")
>>> wallet.language()
"english"
seed() Optional[str]

Get Bytom wallet seed.

Returns

str – Bytom wallet seed.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet: Wallet = Wallet(network="mainnet")
>>> wallet.from_entropy(entropy="ed0802d701a033776811601dd6c5c4a9")
>>> wallet.seed()
"1cfd5df8a523d53a36cee369a93fac4e9efab5e4e138d479da2fb6df730697574409d572fe8325ec22e8ed25dea7495f498c3f5235fe6ae6d47b989267b6777c"
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(entropy="ed0802d701a033776811601dd6c5c4a9")
>>> wallet.from_path(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 = Wallet(network="mainnet")
>>> wallet.from_entropy(entropy="ed0802d701a033776811601dd6c5c4a9")
>>> wallet.from_path(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 = Wallet(network="mainnet")
>>> wallet.from_entropy(entropy="ed0802d701a033776811601dd6c5c4a9")
>>> wallet.xprivate_key()
"58775359b7b3588dcdc1bcf373489fa1272cacc03909f78469657b0208e66e46daedfdd0fd8f8df14e2084c7e8df4701db3062dded1c713e0aae734ac09c4afd"
xpublic_key() Optional[str]

Get Bytom wallet xpublic key.

Returns

str – Bytom xpublic key.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet: Wallet = Wallet(network="mainnet")
>>> wallet.from_entropy(entropy="ed0802d701a033776811601dd6c5c4a9")
>>> wallet.xpublic_key()
"f80a401807fde1ee5727ae032ee144e4b757e69431e68e6cd732eda3c8cd3936daedfdd0fd8f8df14e2084c7e8df4701db3062dded1c713e0aae734ac09c4afd"
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 = Wallet(network="mainnet")
>>> wallet.from_entropy(entropy="ed0802d701a033776811601dd6c5c4a9")
>>> wallet.expand_xprivate_key()
"58775359b7b3588dcdc1bcf373489fa1272cacc03909f78469657b0208e66e465c68d75d8a29eb3ffd7e82138088eec937e0c3d753946d35ae2d40d84a03bcf9"
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 = Wallet(network="mainnet")
>>> wallet.from_entropy(entropy="ed0802d701a033776811601dd6c5c4a9")
>>> wallet.from_path(path="m/44/153/1/0/1")
>>> wallet.child_xprivate_key()
"b0f9552e4fedac7f2e750ae984e36a97cf2b24609f7ec43f35606ed65eec6e46db35f71c405fd5948ecffa2c512adafb35cc621f99a60ecb6ec8aef815a8c6e5"
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 = Wallet(network="mainnet")
>>> wallet.from_entropy(entropy="ed0802d701a033776811601dd6c5c4a9")
>>> wallet.from_path(path="m/44/153/1/0/1")
>>> wallet.child_xpublic_key()
"fe6b3fd4458291b19605d92837ae1060cc0237e68022b2eb9faf01a118226212db35f71c405fd5948ecffa2c512adafb35cc621f99a60ecb6ec8aef815a8c6e5"
guid() Optional[str]

Get Bytom wallet Blockcenter GUID.

Returns

str – Bytom Blockcenter GUID.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet: Wallet = Wallet(network="mainnet")
>>> wallet.from_entropy(entropy="ed0802d701a033776811601dd6c5c4a9")
>>> wallet.guid()
"9ed61a9b-e7b6-4cb7-94fb-932b738e4f66"
private_key() str

Get Bytom wallet private key.

Returns

str – Bytom private key.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet: Wallet = Wallet(network="mainnet")
>>> wallet.from_entropy(entropy="ed0802d701a033776811601dd6c5c4a9")
>>> wallet.from_path(path="m/44/153/1/0/1")
>>> wallet.private_key()
"b0f9552e4fedac7f2e750ae984e36a97cf2b24609f7ec43f35606ed65eec6e46db35f71c405fd5948ecffa2c512adafb35cc621f99a60ecb6ec8aef815a8c6e5"
public_key() str

Get Bytom wallet public key.

Returns

str – Bytom public key.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet: Wallet = Wallet(network="mainnet")
>>> wallet.from_entropy(entropy="ed0802d701a033776811601dd6c5c4a9")
>>> wallet.from_path(path="m/44/153/1/0/1")
>>> wallet.public_key()
"fe6b3fd4458291b19605d92837ae1060cc0237e68022b2eb9faf01a118226212"
program() str

Get Bytom wallet control program.

Returns

str – Bytom control program.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet: Wallet = Wallet(network="mainnet")
>>> wallet.from_entropy(entropy="ed0802d701a033776811601dd6c5c4a9")
>>> wallet.from_path(path="m/44/153/1/0/1")
>>> wallet.program()
"0014b1592acbb917f13937166c2a9b6ce973296ebb60"
address(network: Optional[str] = None) 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 = Wallet(network="mainnet")
>>> wallet.from_entropy(entropy="ed0802d701a033776811601dd6c5c4a9")
>>> wallet.from_indexes(indexes=["2c000000", "99000000", "01000000", "00000000", "01000000"])
>>> wallet.address(network="mainnet")
"bm1qk9vj4jaezlcnjdckds4fkm8fwv5kawmq9qrufx"
balance(asset: Union[str, swap.providers.bytom.assets.AssetNamespace] = 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', unit: str = 'NEU') Union[int, float]

Get Bytom wallet balance.

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

  • unit (str) – Bytom unit, default to NEU.

Returns

int, float – Bytom wallet balance.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet: Wallet = Wallet(network="mainnet")
>>> wallet.from_entropy(entropy="ed0802d701a033776811601dd6c5c4a9")
>>> wallet.from_path(path="m/44/153/1/0/1")
>>> wallet.balance(unit="BTM")
2.0
utxos(asset: Union[str, swap.providers.bytom.assets.AssetNamespace] = 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', limit: int = 15) list

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

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

  • limit (int) – Limit of UTXO’s, default is 15.

Returns

list – Bytom unspent transaction outputs.

>>> from swap.providers.bytom.wallet import Wallet
>>> wallet: Wallet = Wallet(network="mainnet")
>>> wallet.from_entropy(entropy="ed0802d701a033776811601dd6c5c4a9")
>>> wallet.from_path(path="m/44/153/1/0/1")
>>> wallet.utxos()
[{'hash': '9843c9b9130bd87a9683f2c4e66456326beeefb2522c3352326de870c5c1329e', 'asset': 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 'amount': 200000000}]