Tool-API.md
The tool API provides a convenient interface to selected methods in the mmgen.tool module. Type pydoc3 mmgen.tool.api
for available methods and call signatures.
Examples
Initialize:
from mmgen.tool.api import tool_api
tool = tool_api()
Key/address generation:
# List available coins:
print(' '.join(tool.coins))
# Initialize a coin/network pair:
proto = tool.init_coin('btc','mainnet')
# Print the available address types for current coin/network, along with a
# description. If tool.addrtype is unset, the first-listed will be used:
tool.print_addrtypes()
# Set the address type to P2PKH with compressed public key:
tool.addrtype = 'compressed'
# Skip user entropy gathering (not recommended)
tool.usr_randchars = 0
# Generate a random hex secret:
hexsec = tool.randhex()
# Generate the key and address:
wif = tool.hex2wif(hexsec)
addr = tool.wif2addr(wif)
# Generate an LTC regtest Segwit key and address:
proto = tool.init_coin('ltc','regtest')
tool.addrtype = 'segwit'
wif = tool.hex2wif(hexsec)
addr = tool.wif2addr(wif)
# Generate a random LTC regtest Bech32 key/address pair:
tool.addrtype = 'bech32'
wif,addr = tool.randpair()
Mnemonic seed phrase generation:
# Generate an MMGen native mnemonic seed phrase:
mmgen_seed = tool.hex2mn(hexsec)
# Generate a BIP39 mnemonic seed phrase:
bip39_seed = tool.hex2mn(hexsec,fmt='bip39')
Utility methods:
# Reverse the hex string:
hexsec_rev = tool.hexreverse(hexsec)
# Get the HASH160 of the value:
sec_hash160 = tool.hash160(hexsec)
# Convert the value to base58 format:
sec_b58 = tool.hextob58(hexsec)
# Convert the value to base58 check format:
sec_b58chk = tool.hextob58chk(hexsec)
# Convert the byte specification '4G' to an integer:
four_g = tool.bytespec('4G')
# Convert the byte specification '4GB' to an integer:
four_gb = tool.bytespec('4GB')
- Страницы
- A-word-on-text-editors
- Altcoin-and-Forkcoin-Support
- Editing-the-user-path-in-Windows
- Getting-Started-with-MMGen-Wallet
- Home
- Install-Bitcoind-from-Source-on-Linux
- Install-Bitcoind
- Install-MMGen-Wallet-on-Linux-or-macOS
- Install-MMGen-Wallet-on-Microsoft-Windows
- Install-the-Offline-Bitcoind
- Key-address-files
- MMGen-Signing-Keys
- MMGen-Wallet-Quick-Start-with-Regtest-Mode
- MMGen-command-help
- Recovering-Your-Keys-Without-the-MMGen-Wallet-Software
- Subwallets
- Test-Suite
- Tool-API
- Tracking-and-spending-ordinary-Bitcoin-addresses
- Unix-commands-and-environment
- XOR-Seed-Splitting:-Theory-and-Practice
- command-help-addrgen
- command-help-addrimport
- command-help-autosign
- command-help-keygen
- command-help-msg
- command-help-passchg
- command-help-passgen
- command-help-regtest
- command-help-seedjoin
- command-help-seedsplit
- command-help-subwalletgen
- command-help-tool(detail)
- command-help-tool(usage)
- command-help-tool
- command-help-txbump
- command-help-txcreate
- command-help-txdo
- command-help-txsend
- command-help-txsign
- command-help-walletchk
- command-help-walletconv
- command-help-walletgen
- command-help-xmrwallet
- A-word-on-text-editors
- Altcoin-and-Forkcoin-Support
- Editing-the-user-path-in-Windows
- Getting-Started-with-MMGen-Wallet
- Home
- Install-Bitcoind-from-Source-on-Linux
- Install-Bitcoind
- Install-MMGen-Wallet-on-Linux-or-macOS
- Install-MMGen-Wallet-on-Microsoft-Windows
- Install-the-Offline-Bitcoind
- Key-address-files
- MMGen-Signing-Keys
- MMGen-Wallet-Quick-Start-with-Regtest-Mode
- MMGen-command-help
- Recovering-Your-Keys-Without-the-MMGen-Wallet-Software
- Subwallets
- Test-Suite
- Tool-API
- Tracking-and-spending-ordinary-Bitcoin-addresses
- Unix-commands-and-environment
- XOR-Seed-Splitting:-Theory-and-Practice
- command-help-addrgen
- command-help-addrimport
- command-help-autosign
- command-help-keygen
- command-help-msg
- command-help-passchg
- command-help-passgen
- command-help-regtest
- command-help-seedjoin
- command-help-seedsplit
- command-help-subwalletgen
- command-help-tool(detail)
- command-help-tool(usage)
- command-help-tool
- command-help-txbump
- command-help-txcreate
- command-help-txdo
- command-help-txsend
- command-help-txsign
- command-help-walletchk
- command-help-walletconv
- command-help-walletgen
- command-help-xmrwallet