diff --git a/sphinx-generator-wallet/.gitignore b/sphinx-generator-wallet/.gitignore new file mode 100644 index 0000000000..d4022367b4 --- /dev/null +++ b/sphinx-generator-wallet/.gitignore @@ -0,0 +1,49 @@ +# Sphinx build outputs +build/ +_build/ + +# Python virtual environments +sphinx_venv/ +venv/ +env/ +ENV/ +.venv + +# Python cache files +__pycache__/ +*.py[cod] +*$py.class +*.so +.mypy_cache/ +.ruff_cache/ +.pytest_cache/ + +# Distribution / packaging +.Python +*.egg-info/ +dist/ +downloads/ +*.egg + +# IDE files +.vscode/ +.idea/ +*.swp +*.swo +*~ +.DS_Store + +# Sphinx doctrees (intermediate build files) +.doctrees/ + +# Environment variables +.env +.env.local + +# Log files +*.log + +# Temporary files +*.tmp +.cache/ + diff --git a/sphinx-generator-wallet/Makefile b/sphinx-generator-wallet/Makefile new file mode 100644 index 0000000000..d0c3cbf102 --- /dev/null +++ b/sphinx-generator-wallet/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = source +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/sphinx-generator-wallet/make.bat b/sphinx-generator-wallet/make.bat new file mode 100644 index 0000000000..747ffb7b30 --- /dev/null +++ b/sphinx-generator-wallet/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.https://www.sphinx-doc.org/ + exit /b 1 +) + +if "%1" == "" goto help + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/sphinx-generator-wallet/readme.md b/sphinx-generator-wallet/readme.md new file mode 100644 index 0000000000..9fe99fa7e9 --- /dev/null +++ b/sphinx-generator-wallet/readme.md @@ -0,0 +1,98 @@ +# Generating Bittensor Wallet Python SDK Documentation with Sphinx + +This folder contains the Sphinx configuration for generating documentation for the `bittensor_wallet` SDK. It imports the installed `bittensor_wallet` package (built via `pip install -e "$BTWALLET_ROOT"`) so docstrings coming from the Rust bindings can be rendered. The `BTWALLET_ROOT` environment variable must be configured to point to your local `btwallet` repository. + +## Prerequisites + +- Python 3.9+ +- Rust toolchain (needed when building the PyO3 extension during `pip install -e "$BTWALLET_ROOT"`) +- Access to the [`developer-docs`](https://github.com/opentensor/developer-docs) repo for publishing + +## Quick Start + +1. **Create/activate the virtualenv** + + ```bash + cd sphinx-generator-wallet + python3 -m venv sphinx_venv + source sphinx_venv/bin/activate + ``` + +2. **Install Sphinx dependencies** + + ```bash + pip install -r requirements.txt + ``` + +3. **Configure Paths** + + Set the `BTWALLET_ROOT` environment variable to point to your local `btwallet` repository: + + ```bash + export BTWALLET_ROOT=/path/to/btwallet + ``` + + **Important:** Replace `/path/to/btwallet` with the actual path to your `btwallet` repository on your system. + +4. **Install the wallet package into the env** + + Install the `bittensor_wallet` package from the configured path: + + ```bash + pip install -e "$BTWALLET_ROOT" + ``` + + This will build the PyO3 extension from the Rust sources and install it in editable mode. + +5. **Build docs** + + ```bash + make html + ``` + +6. **Open locally** + ```bash + open build/html/index.html + ``` + +## Publishing Workflow + +1. (Optional) remove previous build `rm -rf build/html/` + +2. Copy output into `developer-docs`. The generated docs must be copied to the `static/btwallet-api/html` folder within your `develoer docs` directory e.g. + + ```bash + rm -rf /path/to/developer-docs/static/btwallet-api/html + cp -r build/html /path/to/developer-docs/static/btwallet-api/html + ``` + +3. Commit/push from the developer-docs repo. + ```bash + git add static/wallet-api/html + git commit -m "Update Wallet SDK API docs" + git push + ``` + +Link to the published docs using `[Wallet SDK API Reference](pathname:///wallet-api/html/index.html)`. + +## Troubleshooting + +- **`ModuleNotFoundError: bittensor_wallet`** – ensure step 4 (package installation) succeeded and the venv is activated when running `make html`. Verify that `BTWALLET_ROOT` is set correctly. + +- **`BTWALLET_ROOT path does not exist`** – ensure the `BTWALLET_ROOT` environment variable points to a valid `btwallet` repository directory that contains `src/wallet.rs`. + +- **`pip install -e` fails with "pyproject.toml not found"** – verify that `BTWALLET_ROOT` is set to the root of the `btwallet` repository (where `pyproject.toml` is located), not a subdirectory. + +- **Rust build failures** – verify the Rust toolchain is installed and PyO3 prerequisites are met. You may need to install `maturin` first: `pip install maturin`. + +- **Missing docstrings** – confirm `pip install -e "$BTWALLET_ROOT"` ran after any Rust edits; the doc fallback only applies when the package is installed in the venv. Also verify `BTWALLET_ROOT` is set correctly. + +- **Start fresh** – `rm -rf build && make html`. + +- **Virtual environment symlink errors** – If you see "Unable to symlink" errors when creating the venv, this is often a Homebrew Python issue on macOS. Solutions: + - Use `python3 -m venv --copies sphinx_venv` to copy files instead of symlinking + - Ensure you have write permissions: `chmod -R u+w sphinx_venv` (if venv already exists) + - Try removing the existing venv and recreating: `rm -rf sphinx_venv && python3 -m venv --copies sphinx_venv` + - If using Homebrew Python, ensure it's properly linked: `brew link python@3.14` (or your Python version) + +For everything else, refer to the original `sphinx-generator/readme.md` guidance or contact the docs team. diff --git a/sphinx-generator-wallet/requirements.txt b/sphinx-generator-wallet/requirements.txt new file mode 100644 index 0000000000..ebe0321673 --- /dev/null +++ b/sphinx-generator-wallet/requirements.txt @@ -0,0 +1,9 @@ +# Main Sphinx documentation generator +sphinx>=7.1.0 + +# Theme that we use for Python reference +sphinx-book-theme>=1.0.1 + +# Required extensions +sphinx-autoapi>=3.0.0 # For autoapi.extension +myst-parser>=2.0.0 # For MyST Markdown support diff --git a/sphinx-generator-wallet/source/_static/bittensor-custom.css b/sphinx-generator-wallet/source/_static/bittensor-custom.css new file mode 100644 index 0000000000..71e3492e85 --- /dev/null +++ b/sphinx-generator-wallet/source/_static/bittensor-custom.css @@ -0,0 +1,157 @@ +/* CSS customized by Raj Karamchedu on 29 January 2024 */ + +@font-face { + font-family: "Haffer"; + src: url(./fonts/Haffer-Light.ttf); + font-weight: 200; + font-style: normal; +} + +@font-face { + font-family: "Haffer"; + src: url(./fonts/Haffer-Medium.ttf); + font-weight: 400; + font-style: normal; +} + +@font-face { + font-family: "Haffer"; + src: url(./fonts/Haffer-Regular.ttf); + font-weight: normal; + font-style: normal; +} + +@font-face { + font-family: "Haffer"; + src: url(./fonts/Haffer-SemiBold.ttf); + font-weight: bold; + font-style: normal; +} + +@font-face { + font-family: "HafferSQ"; + src: url(./fonts/HafferSQ-Light.ttf); + font-weight: 200; + font-style: normal; +} + +@font-face { + font-family: "HafferSQ"; + src: url(./fonts/HafferSQ-Medium.ttf); + font-weight: 400; + font-style: normal; +} + +@font-face { + font-family: "HafferSQ"; + src: url(./fonts/HafferSQ-Regular.ttf); + font-weight: normal; + font-style: normal; +} + +@font-face { + font-family: "HafferSQ"; + src: url(./fonts/HafferSQ-SemiBold.ttf); + font-weight: bold; + font-style: normal; +} + +@font-face { + font-family: "TTCommonsPro"; + src: url(./fonts/TTCommonsProMonoMedium.ttf); + font-weight: 200; + font-style: normal; +} + +@font-face { + font-family: "TTCommonsPro"; + src: url(./fonts/TTCommonsProMonoRegular.ttf); + font-weight: 100; + font-style: normal; +} + +@font-face { + font-family: "FiraCode"; + src: url(./fonts/FiraCode_VariableFont_wght.ttf); +} + + + +html { + --pst-font-family-base-system: 'Haffer', -apple-system, BlinkMacSystemFont, Segoe UI, "Helvetica Neue", Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol; + --pst-font-family-monospace-system: "TTCommonsPro", Menlo, Consolas, Monaco, + Liberation Mono, Lucida Console, monospace; + --pst-sidebar-font-size: 1.0rem; + --pst-font-family-base: var(--pst-font-family-base-system); + --pst-font-family-heading: var(--pst-font-family-base-system); + --pst-font-family-monospace: var(--pst-font-family-monospace-system); + --pst-color-inline-code-links: #0c0c0c; + +} + +html[data-theme=dark]{ + --pst-color-surface: none; + --pst-color-inline-code-links: #fff; + --pst-color-target: #545454; + --pst-color-inline-code: #1fd01f; + --pst-color-table-row-hover-bg: #003200; +} + + +html[data-theme=light]{ + --pst-color-surface: none; + --pst-color-inline-code-links: #000; + --pst-color-target: #eaebed; + --pst-color-inline-code: #0fa50f; + --pst-color-table-row-hover-bg: #ffffc0; +} + +html[data-theme=dark], html[data-theme=light] { + --pst-color-primary: #838793; +} + +p { + font-size: 16px !important; +} + +code.xref, a code { + font-weight: normal; +} + +code.literal { + background-color: none; + border: none; +} + +.dropdown, .dropdown-center, .dropend, .dropstart, .dropup, .dropup-center { + position: relative; + display: none; +} + +/* .search-button { + display: none; +} */ + +.btn-fullscreen-button { + display: none; +} + +.bd-sidebar-secondary .onthispage { + display: none; +} + +@media (min-width: 992px){ +.bd-sidebar-primary { + flex-basis: 25%; +} +} + +.bd-sidebar-secondary{ + max-height: calc(100vh - var(--pst-header-height)); +} + +@media (min-width: 960px){ +.bd-page-width { + max-width: 98rem; +} +} \ No newline at end of file diff --git a/sphinx-generator-wallet/source/_static/custom-css-for-sphinx-book-theme.css b/sphinx-generator-wallet/source/_static/custom-css-for-sphinx-book-theme.css new file mode 100644 index 0000000000..143a284db8 --- /dev/null +++ b/sphinx-generator-wallet/source/_static/custom-css-for-sphinx-book-theme.css @@ -0,0 +1,174 @@ +@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600;700&family=Poppins:wght@400;500;600&family=JetBrains+Mono&display=swap'); + +body { + color: #221f1f; + font-family: 'Open Sans', sans-serif; +} + +h1 { + font-size: 2.2em; +} + +h2 { + font-size: 1.5em; +} + +h3 { + font-size: 1.2em; +} + +h4 { + font-size: 1.0em; +} + +.nav { + font-family: 'Poppins', sans-serif; +} + +.header-style, h1, h2, h3, h4, h5, h6 { + font-family: 'Poppins', sans-serif; + font-weight: 500; +} + +.bd-toc .tocsection { + padding: 4.0rem 0 .5rem 1rem !important; /* Right-side bar top padding to align with the main content title. */ +} + + +#main-content { + margin-top: 1rem !important; /* Main content pushed down to align with the site title below logo on the left-side bar. If you change this you must change the .bd-toc .tocsection padding from 7.8rem. */ +} + + +.admonition.note .admonition-title { + background-color: #fff0ec; + letter-spacing: 0.045rem; +} + +.admonition .admonition-title { + font-family: 'Poppins', sans-serif; +} + + +nav.bd-links li.toctree-l1 { + line-height: 1.45; +} + +.card { + box-shadow: 0 .5rem 1rem rgba(0,0,0,.15)!important; + transition: all 0.3s ease-in-out!important; +} + +@media (min-width: 576px) { + .card-deck .card { + margin-bottom: 15px; + transition: all 0.3s ease-in-out!important; + } +} + +@media (min-width: 1200px) { + .container, .container-lg, .container-md, .container sm, .container-xl { + max-width: 1400px; + } +} + +nav.bd-links p.caption { + letter-spacing: 0.1em; + font-family: 'Poppins', sans-serif; +} + +.caption-text { + letter-spacing: 0.1em; + font-family: 'Poppins', sans-serif; + font-size: 0.9em; + text-transform: uppercase; + font-weight: bold; + position: relative; + margin-top: 1.25em; + margin-bottom: 0; +} + +toc-h1, .toc-h2, .toc-h3, .toc-h4 { + line-height: 1.45; + margin-bottom: 0.5em; +} + +@media only screen and (min-width: 768px) { + #navbar-toggler { + display: none; + } +} + +div.navbar_extra_footer { + display: none; +} + +div.dropdown-buttons-trigger { + display: none; +} + +a.full-screen-button { + display: none; +} + +pre { + line-height: 150%; + background-color: #f1f3f4; /* #ffc1070d; */ + padding: 22px; + color: #37474f; + font-size: 95%; + border: none; + box-shadow: none; + /* font-family: 'JetBrains Mono', sans-serif; Avoid this here or else glyphs in code snippets. */ +} + +.header-style, h1, h2, h3, h4, h5, h6 { + line-height: 1.35; +} + +nav.bd-links li.toctree-l1, nav.bd-links li.toctree-l2, nav.bd-links li.toctree-l3, nav.bd-links li.toctree-l4, nav.bd-links li.toctree-l5 { + margin-bottom: 0.35em; +} + +.bd-sidebar nav ul.nav a:hover, .bd-sidebar nav ul.nav li.active>a, .bd-sidebar nav ul.nav li.active>a:hover { + color: #221f1f; +} +.bd-sidebar-secondary .onthispage { + height: 3rem; + min-height: 3rem; + display: none; +} + +.prev-next-bottom { + height: 3em; + font-family: 'Poppins', sans-serif; + font-weight: 500; +} + +blockquote { + margin: 1rem 0 1rem; + border-left: 0px solid #ccc; + padding: .1em .1em; +} + +main.bd-content #main-content div.section ul p, main.bd-content #main-content div.section ol p { + margin-bottom: .5rem; +} + +table td, .table th { + padding: .75rem; + vertical-align: top; + border-top: 1px solid #dee2e6; + border-bottom: 1px solid #dee2e6; + border-right: 1px solid #dee2e6; + border-left: 1px solid #dee2e6; +} + +.footer { + font-size: .8em; +} + +.bd-header-article .article-header-buttons { + /* display: flex; */ + display: none; +} diff --git a/sphinx-generator-wallet/source/_static/fonts/FiraCode_VariableFont_wght.ttf b/sphinx-generator-wallet/source/_static/fonts/FiraCode_VariableFont_wght.ttf new file mode 100644 index 0000000000..0013e0ad05 Binary files /dev/null and b/sphinx-generator-wallet/source/_static/fonts/FiraCode_VariableFont_wght.ttf differ diff --git a/sphinx-generator-wallet/source/_static/fonts/Haffer-Light.ttf b/sphinx-generator-wallet/source/_static/fonts/Haffer-Light.ttf new file mode 100644 index 0000000000..4823831012 Binary files /dev/null and b/sphinx-generator-wallet/source/_static/fonts/Haffer-Light.ttf differ diff --git a/sphinx-generator-wallet/source/_static/fonts/Haffer-Medium.ttf b/sphinx-generator-wallet/source/_static/fonts/Haffer-Medium.ttf new file mode 100644 index 0000000000..1977e1df34 Binary files /dev/null and b/sphinx-generator-wallet/source/_static/fonts/Haffer-Medium.ttf differ diff --git a/sphinx-generator-wallet/source/_static/fonts/Haffer-Regular.ttf b/sphinx-generator-wallet/source/_static/fonts/Haffer-Regular.ttf new file mode 100644 index 0000000000..fb2b457ab1 Binary files /dev/null and b/sphinx-generator-wallet/source/_static/fonts/Haffer-Regular.ttf differ diff --git a/sphinx-generator-wallet/source/_static/fonts/Haffer-SemiBold.ttf b/sphinx-generator-wallet/source/_static/fonts/Haffer-SemiBold.ttf new file mode 100644 index 0000000000..ef01086009 Binary files /dev/null and b/sphinx-generator-wallet/source/_static/fonts/Haffer-SemiBold.ttf differ diff --git a/sphinx-generator-wallet/source/_static/fonts/HafferSQ-Light.ttf b/sphinx-generator-wallet/source/_static/fonts/HafferSQ-Light.ttf new file mode 100644 index 0000000000..1abd355828 Binary files /dev/null and b/sphinx-generator-wallet/source/_static/fonts/HafferSQ-Light.ttf differ diff --git a/sphinx-generator-wallet/source/_static/fonts/HafferSQ-Medium.ttf b/sphinx-generator-wallet/source/_static/fonts/HafferSQ-Medium.ttf new file mode 100644 index 0000000000..a27000db2c Binary files /dev/null and b/sphinx-generator-wallet/source/_static/fonts/HafferSQ-Medium.ttf differ diff --git a/sphinx-generator-wallet/source/_static/fonts/HafferSQ-Regular.ttf b/sphinx-generator-wallet/source/_static/fonts/HafferSQ-Regular.ttf new file mode 100644 index 0000000000..df3a2190d5 Binary files /dev/null and b/sphinx-generator-wallet/source/_static/fonts/HafferSQ-Regular.ttf differ diff --git a/sphinx-generator-wallet/source/_static/fonts/HafferSQ-SemiBold.ttf b/sphinx-generator-wallet/source/_static/fonts/HafferSQ-SemiBold.ttf new file mode 100644 index 0000000000..f2d0584595 Binary files /dev/null and b/sphinx-generator-wallet/source/_static/fonts/HafferSQ-SemiBold.ttf differ diff --git a/sphinx-generator-wallet/source/_static/fonts/TTCommonsProMonoMedium.ttf b/sphinx-generator-wallet/source/_static/fonts/TTCommonsProMonoMedium.ttf new file mode 100644 index 0000000000..987ee9fded Binary files /dev/null and b/sphinx-generator-wallet/source/_static/fonts/TTCommonsProMonoMedium.ttf differ diff --git a/sphinx-generator-wallet/source/_static/fonts/TTCommonsProMonoRegular.ttf b/sphinx-generator-wallet/source/_static/fonts/TTCommonsProMonoRegular.ttf new file mode 100644 index 0000000000..c2bf574c06 Binary files /dev/null and b/sphinx-generator-wallet/source/_static/fonts/TTCommonsProMonoRegular.ttf differ diff --git a/sphinx-generator-wallet/source/_static/logo-dark-mode.svg b/sphinx-generator-wallet/source/_static/logo-dark-mode.svg new file mode 100644 index 0000000000..a56a46c7c0 --- /dev/null +++ b/sphinx-generator-wallet/source/_static/logo-dark-mode.svg @@ -0,0 +1 @@ + diff --git a/sphinx-generator-wallet/source/_static/logo.svg b/sphinx-generator-wallet/source/_static/logo.svg new file mode 100644 index 0000000000..337ffe2d33 --- /dev/null +++ b/sphinx-generator-wallet/source/_static/logo.svg @@ -0,0 +1 @@ + diff --git a/sphinx-generator-wallet/source/autoapi/bittensor_wallet/config/index.rst b/sphinx-generator-wallet/source/autoapi/bittensor_wallet/config/index.rst new file mode 100644 index 0000000000..c4f794749a --- /dev/null +++ b/sphinx-generator-wallet/source/autoapi/bittensor_wallet/config/index.rst @@ -0,0 +1,19 @@ +bittensor\_wallet.config +======================== + +.. automodule:: bittensor_wallet.config + + + .. autosummary:: + + ~bittensor_wallet.config.Config + + Module Contents + --------------- + + .. rubric:: Classes Details + + .. autoclass:: bittensor_wallet.config.Config + :show-inheritance: + :special-members: __init__ + diff --git a/sphinx-generator-wallet/source/autoapi/bittensor_wallet/errors/index.rst b/sphinx-generator-wallet/source/autoapi/bittensor_wallet/errors/index.rst new file mode 100644 index 0000000000..32a91f1ca0 --- /dev/null +++ b/sphinx-generator-wallet/source/autoapi/bittensor_wallet/errors/index.rst @@ -0,0 +1,23 @@ +bittensor\_wallet.errors +======================== + +.. automodule:: bittensor_wallet.errors + + + .. autosummary:: + + ~bittensor_wallet.errors.ConfigurationError + ~bittensor_wallet.errors.KeyFileError + ~bittensor_wallet.errors.PasswordError + ~bittensor_wallet.errors.WalletError + + Module Contents + --------------- + + .. rubric:: Exceptions Details + + .. automodule:: bittensor_wallet.errors + :members: + :undoc-members: + :imported-members: + diff --git a/sphinx-generator-wallet/source/autoapi/bittensor_wallet/index.rst b/sphinx-generator-wallet/source/autoapi/bittensor_wallet/index.rst new file mode 100644 index 0000000000..2e3a02ab83 --- /dev/null +++ b/sphinx-generator-wallet/source/autoapi/bittensor_wallet/index.rst @@ -0,0 +1,18 @@ +bittensor\_wallet +================= + +.. automodule:: bittensor_wallet + +Submodules +---------- + +.. toctree:: + :maxdepth: 1 + + wallet/index + keyfile/index + keypair/index + config/index + errors/index + utils/index + diff --git a/sphinx-generator-wallet/source/autoapi/bittensor_wallet/keyfile/index.rst b/sphinx-generator-wallet/source/autoapi/bittensor_wallet/keyfile/index.rst new file mode 100644 index 0000000000..ce795113e6 --- /dev/null +++ b/sphinx-generator-wallet/source/autoapi/bittensor_wallet/keyfile/index.rst @@ -0,0 +1,58 @@ +bittensor\_wallet.keyfile +========================= + +.. automodule:: bittensor_wallet.keyfile + + + .. autosummary:: + + ~bittensor_wallet.keyfile.ask_password + ~bittensor_wallet.keyfile.decrypt_keyfile_data + ~bittensor_wallet.keyfile.deserialize_keypair_from_keyfile_data + ~bittensor_wallet.keyfile.encrypt_keyfile_data + ~bittensor_wallet.keyfile.get_coldkey_password_from_environment + ~bittensor_wallet.keyfile.get_password_from_environment + ~bittensor_wallet.keyfile.keyfile_data_encryption_method + ~bittensor_wallet.keyfile.keyfile_data_is_encrypted + ~bittensor_wallet.keyfile.keyfile_data_is_encrypted_ansible + ~bittensor_wallet.keyfile.keyfile_data_is_encrypted_legacy + ~bittensor_wallet.keyfile.keyfile_data_is_encrypted_nacl + ~bittensor_wallet.keyfile.legacy_encrypt_keyfile_data + ~bittensor_wallet.keyfile.serialized_keypair_to_keyfile_data + ~bittensor_wallet.keyfile.validate_password + ~bittensor_wallet.keyfile.Keyfile + + Module Contents + --------------- + + .. rubric:: Functions Details + + .. automodule:: bittensor_wallet.keyfile + :members: + :undoc-members: + :imported-members: + :exclude-members: ask_password_to_encrypt + :show-inheritance: + + .. rubric:: Classes Details + + .. autoclass:: bittensor_wallet.keyfile.Keyfile + :show-inheritance: + :special-members: __init__ + + .. automethod:: check_and_update_encryption + .. automethod:: decrypt + .. automethod:: encrypt + .. automethod:: env_var_name + .. automethod:: exists_on_device + .. automethod:: get_keypair + .. automethod:: is_encrypted + .. automethod:: is_readable + .. automethod:: is_writable + .. automethod:: make_dirs + .. automethod:: set_keypair + .. autoattribute:: data + .. autoattribute:: keyfile_data + .. autoattribute:: get_name + .. autoattribute:: get_path + diff --git a/sphinx-generator-wallet/source/autoapi/bittensor_wallet/keypair/index.rst b/sphinx-generator-wallet/source/autoapi/bittensor_wallet/keypair/index.rst new file mode 100644 index 0000000000..7d0c28bfa5 --- /dev/null +++ b/sphinx-generator-wallet/source/autoapi/bittensor_wallet/keypair/index.rst @@ -0,0 +1,21 @@ +bittensor\_wallet.keypair +========================= + +.. automodule:: bittensor_wallet.keypair + + + .. autosummary:: + + ~bittensor_wallet.keypair.Keypair + + Module Contents + --------------- + + .. rubric:: Classes Details + + .. autoclass:: bittensor_wallet.keypair.Keypair + :members: + :undoc-members: + :show-inheritance: + :special-members: __init__ + diff --git a/sphinx-generator-wallet/source/autoapi/bittensor_wallet/utils/index.rst b/sphinx-generator-wallet/source/autoapi/bittensor_wallet/utils/index.rst new file mode 100644 index 0000000000..5a16e57841 --- /dev/null +++ b/sphinx-generator-wallet/source/autoapi/bittensor_wallet/utils/index.rst @@ -0,0 +1,23 @@ +bittensor\_wallet.utils +======================= + +.. automodule:: bittensor_wallet.utils + + + .. autosummary:: + + ~bittensor_wallet.utils.get_ss58_format + ~bittensor_wallet.utils.is_valid_bittensor_address_or_public_key + ~bittensor_wallet.utils.is_valid_ed25519_pubkey + ~bittensor_wallet.utils.is_valid_ss58_address + + Module Contents + --------------- + + .. rubric:: Functions Details + + .. automodule:: bittensor_wallet.utils + :members: + :undoc-members: + :imported-members: + diff --git a/sphinx-generator-wallet/source/autoapi/bittensor_wallet/wallet/index.rst b/sphinx-generator-wallet/source/autoapi/bittensor_wallet/wallet/index.rst new file mode 100644 index 0000000000..d330cda5c9 --- /dev/null +++ b/sphinx-generator-wallet/source/autoapi/bittensor_wallet/wallet/index.rst @@ -0,0 +1,30 @@ +bittensor\_wallet.wallet +======================== + +.. automodule:: bittensor_wallet.wallet + + + .. autosummary:: + + ~bittensor_wallet.wallet.display_mnemonic_msg + ~bittensor_wallet.wallet.Wallet + + Module Contents + --------------- + + .. rubric:: Functions Details + + .. automodule:: bittensor_wallet.wallet + :members: + :undoc-members: + :imported-members: + :exclude-members: Wallet + + .. rubric:: Classes Details + + .. autoclass:: bittensor_wallet.wallet.Wallet + :members: + :undoc-members: + :show-inheritance: + :special-members: __init__ + diff --git a/sphinx-generator-wallet/source/conf.py b/sphinx-generator-wallet/source/conf.py new file mode 100644 index 0000000000..4d23a44fa2 --- /dev/null +++ b/sphinx-generator-wallet/source/conf.py @@ -0,0 +1,137 @@ +# Configuration file for the Sphinx documentation builder. +# +# For the full list of built-in configuration values, see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information + +# project = 'BTCLI Docs' +project = "Bittensor Wallet SDK Docs" +copyright = "2025, Opentensor Foundation" +author = "Opentensor Foundation" +# release = '1.0' + +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration + + +import os +import site +import sys + +# Add current directory and parent directories to path for local imports +sys.path.insert(0, os.path.abspath(".")) +sys.path.insert(0, os.path.abspath("..")) + +# Add site-packages to path (where bittensor_wallet will be installed) +for site_path in site.getsitepackages(): + if site_path not in sys.path: + sys.path.append(site_path) + +html_theme = "sphinx_book_theme" +html_theme_options = { + "show_navbar_depth": 4, + "logo": { + "image_light": "_static/logo.svg", + "image_dark": "_static/logo-dark-mode.svg", + }, + "repository_url": "https://github.com/opentensor/btwallet", + "use_source_button": True, + "use_repository_button": True, + "use_issues_button": True, +} +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.autosummary", + "sphinx.ext.napoleon", + "sphinx.ext.viewcode", + "myst_parser", + "sphinx.ext.intersphinx", +] + +myst_enable_extensions = ["dollarmath", "amsmath"] + +# Napoleon settings +napoleon_google_docstring = True +napoleon_numpy_docstring = False +napoleon_include_init_with_doc = True +napoleon_include_private_with_doc = True +napoleon_include_special_with_doc = True +napoleon_use_admonition_for_examples = True +napoleon_use_admonition_for_notes = True +napoleon_use_admonition_for_references = True +napoleon_use_ivar = True + +intersphinx_mapping = { + "python": ("https://docs.python.org/3", None), + "numpy": ("https://numpy.org/doc/stable/", None), + "torch": ("https://pytorch.org/docs/stable/", None), + "pydantic": ("https://docs.pydantic.dev/latest/", None), +} + +autosummary_generate = True +autosummary_imported_members = True # Include imported members to get class methods +autosummary_ignore_module_all = False +# Mock the mock module so autosummary can handle it without importing +autodoc_mock_imports = ["bittensor_wallet.mock", "Crypto"] +autodoc_typehints = "description" +autodoc_default_options = { + "members": True, + "undoc-members": True, + "show-inheritance": True, + "special-members": "__init__", + "no-index": True, +} +templates_path = [] +# Exclude mock module from being documented +exclude_patterns = ["generated/bittensor_wallet.mock.rst"] + +# Make Sphinx more tolerant of formatting issues +suppress_warnings = [ + "autosectionlabel.*", + "autosummary.*mock", # Suppress warnings about mock module (test-only, not needed for docs) + "autosummary:failed to import mock", # Suppress specific mock import warnings +] +nitpicky = False + +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output + +html_static_path = ["_static"] +html_css_files = ["bittensor-custom.css"] + +from docstring_utils import format_docstring, load_rust_docstrings, needs_reformatting + +DOC_OVERRIDES = load_rust_docstrings() + + +def _short_name(fullname: str) -> str: + return fullname.split(".")[-1] + + +def handle_autodoc(app, what, name, obj, options, lines): + existing = "\n".join(lines).strip() + source_text = existing + key = _short_name(name) + + # Try to get docstring from overrides if missing or needs reformatting + if not source_text: + source_text = DOC_OVERRIDES.get(key, "") + elif needs_reformatting(source_text): + # If existing docstring needs reformatting, use it + pass + else: + # If docstring exists and doesn't need reformatting, return early + return + + if not source_text: + return + + formatted = format_docstring(source_text) + if formatted: + lines[:] = formatted + + +def setup(app): + app.connect("autodoc-process-docstring", handle_autodoc) diff --git a/sphinx-generator-wallet/source/docstring_utils.py b/sphinx-generator-wallet/source/docstring_utils.py new file mode 100644 index 0000000000..03cde1ac47 --- /dev/null +++ b/sphinx-generator-wallet/source/docstring_utils.py @@ -0,0 +1,225 @@ +"""Docstring helpers for wallet SDK documentation.""" +from __future__ import annotations + +from pathlib import Path +import re +from typing import Dict, List + +# Get the btwallet repo root from environment variable or default to relative path +import os +_BTWALLET_ROOT = os.environ.get("BTWALLET_ROOT") +if _BTWALLET_ROOT: + _REPO_ROOT = Path(_BTWALLET_ROOT).resolve() + if not _REPO_ROOT.exists(): + raise RuntimeError(f"BTWALLET_ROOT path does not exist: {_BTWALLET_ROOT}") +else: + # Default: assume sphinx-generator-wallet-enhanced is inside btwallet repo + _REPO_ROOT = Path(__file__).resolve().parents[2] + +# Verify the repo root exists and has src/wallet.rs +_wallet_rs = _REPO_ROOT / "src" / "wallet.rs" +if not _wallet_rs.exists(): + raise RuntimeError( + f"Could not find btwallet repo root at {_REPO_ROOT}.\n" + f"Expected to find: {_wallet_rs}\n" + f"Set BTWALLET_ROOT environment variable to the path of the btwallet repo.\n" + f"Example: export BTWALLET_ROOT=/path/to/btwallet" + ) + +RUST_SOURCES = [ + _REPO_ROOT / "src" / "wallet.rs", + _REPO_ROOT / "src" / "keyfile.rs", + _REPO_ROOT / "src" / "keypair.rs", + _REPO_ROOT / "src" / "config.rs", + _REPO_ROOT / "src" / "utils.rs", +] + +DOCBLOCK_RE = re.compile( + r"(?P(?:^\s*///.*\n)+)(?:^\s*(?:#\[[^\n]+\]|//).*\n)*\s*pub\s+(?:fn|struct)\s+(?P[a-zA-Z0-9_]+)", + re.MULTILINE, +) + +PARAM_RE = re.compile( + r"^`?(?P[a-zA-Z0-9_\.]+)`?\s*(?:\((?P[^)]+)\))?\s*[:\-]\s*(?P.+)$" +) + +IGNORED_HEADERS = { + "arguments:", "args:", "# arguments", "# args", "# arguments:", "# args:", + "returns:", "# returns", "# returns:", "# returns", + "arguments", "args", "returns", + "raises:", "raised:", "# raises", "# raised", "# raises:", "# raised:", + "raises", "raised" +} + + +def load_rust_docstrings() -> Dict[str, str]: + docs: Dict[str, str] = {} + for path in RUST_SOURCES: + if not path.exists(): + continue + text = path.read_text() + for match in DOCBLOCK_RE.finditer(text): + raw_lines = match.group("block").splitlines() + cleaned = [] + for line in raw_lines: + if "///" in line: + cleaned.append(line.split("///", 1)[1].lstrip()) + doc = "\n".join(cleaned).strip() + if doc: + docs.setdefault(match.group("name"), doc) + return docs + + +def needs_reformatting(text: str) -> bool: + lowered = text.lower() + return any(header in lowered for header in IGNORED_HEADERS) + + +def _parse_param_line(line: str) -> List[str]: + stripped = line.strip().lstrip("*- ") + + # Handle markdown-style: `* `param_name` - description` + if stripped.startswith("`") and "`" in stripped[1:]: + # Format: `* `param_name` - description` + parts = stripped.split("`", 2) + if len(parts) >= 3: + name = parts[1].strip() + desc = parts[2].lstrip("- ").strip() + return [f":param {name}: {desc}"] + + # Handle format: `* keyfile_data (): The bytes to decrypt.` or `* param_name (type): description` + # Remove leading `*` and whitespace if present + if stripped.startswith("*"): + stripped = stripped[1:].strip() + + match = PARAM_RE.match(stripped) + if not match: + # If no match, try to extract name and description manually + # Handle cases like "keyfile_data (): The bytes to decrypt." + if "(" in stripped and ")" in stripped: + paren_match = re.match(r"^([a-zA-Z0-9_\.]+)\s*\([^)]*\)\s*[:\-]?\s*(.+)$", stripped) + if paren_match: + name = paren_match.group(1) + desc = paren_match.group(2).strip() + return [f":param {name}: {desc}"] + return [stripped] if stripped else [] + name = match.group("name") + desc = match.group("desc").strip() + type_hint = (match.group("type") or "").strip() + parts = [f":param {name}: {desc}"] + if type_hint: + parts.append(f":type {name}: {type_hint}") + return parts + + +def _parse_raises_line(line: str) -> List[str]: + """Parse a raises/exceptions line into Sphinx format.""" + stripped = line.strip().lstrip("*- ") + + # Handle markdown-style: `* `ExceptionName` - description` + if stripped.startswith("`") and "`" in stripped[1:]: + parts = stripped.split("`", 2) + if len(parts) >= 3: + exc_name = parts[1].strip() + desc = parts[2].lstrip("- ").strip() + return [f":raises {exc_name}: {desc}"] + + # Handle format: `* ExceptionName: description` or `ExceptionName - description` + if ":" in stripped or "-" in stripped: + # Split on first : or - + sep = ":" if ":" in stripped else "-" + parts = stripped.split(sep, 1) + if len(parts) == 2: + exc_name = parts[0].strip() + desc = parts[1].strip() + # Remove "Raised if" prefix from description if present + if desc.lower().startswith("raised if"): + desc = desc[9:].strip().capitalize() + return [f":raises {exc_name}: {desc}"] + + # Default: treat the whole line as a raises entry + return [f":raises: {stripped}"] if stripped else [] + + +def format_docstring(text: str) -> List[str]: + lines = text.strip().splitlines() + result: List[str] = [] + buffer: List[str] = [] + state: str | None = None + + def flush(): + nonlocal buffer, state + if not buffer: + return + if state == "params": + if result and result[-1] != "": + result.append("") + for entry in buffer: + result.extend(_parse_param_line(entry)) + elif state == "returns": + # Ensure there's a blank line before returns field + if result and result[-1] != "": + result.append("") + # Clean up returns content - remove markdown bullets and extract description + content_parts = [] + for entry in buffer: + cleaned = entry.strip().lstrip("*- ") + # If it's in format "decrypted_data (bytes): description", extract just description + if "(" in cleaned and ")" in cleaned and ":" in cleaned: + match = re.match(r"^[^:]*\([^)]*\)\s*:\s*(.+)$", cleaned) + if match: + content_parts.append(match.group(1).strip()) + else: + content_parts.append(cleaned) + else: + content_parts.append(cleaned) + content = " ".join(s for s in content_parts if s.strip()) + if content: + result.append(f":returns: {content}") + elif state == "raises": + # Ensure there's a blank line before raises field + if result and result[-1] != "": + result.append("") + # Parse raises entries similar to params + for entry in buffer: + result.extend(_parse_raises_line(entry)) + else: + result.extend(buffer) + buffer = [] + + for line in lines: + stripped = line.rstrip() + lower = stripped.strip().lower() + # Check if this line is a header (with or without # prefix, with or without colon) + header_match = False + for header in IGNORED_HEADERS: + header_clean = header.lstrip("#").strip().rstrip(":") + if (lower == header or + lower == header_clean or + lower == header_clean + ":" or + lower.endswith(":") and lower.rstrip(":").strip() == header_clean or + (lower.startswith("#") and header_clean in lower)): + flush() + if result and result[-1] != "": + result.append("") + # Determine state based on header type + if "arguments" in lower or "args" in lower: + state = "params" + elif "raises" in lower or "raised" in lower: + state = "raises" + else: + state = "returns" + header_match = True + break + if header_match: + continue + if not stripped.strip(): + flush() + if result and result[-1] != "": + result.append("") + state = None + continue + buffer.append(stripped.strip()) + + flush() + return result diff --git a/sphinx-generator-wallet/source/images/logo-dark-mode.svg b/sphinx-generator-wallet/source/images/logo-dark-mode.svg new file mode 100644 index 0000000000..a56a46c7c0 --- /dev/null +++ b/sphinx-generator-wallet/source/images/logo-dark-mode.svg @@ -0,0 +1 @@ + diff --git a/sphinx-generator-wallet/source/images/logo.svg b/sphinx-generator-wallet/source/images/logo.svg new file mode 100644 index 0000000000..337ffe2d33 --- /dev/null +++ b/sphinx-generator-wallet/source/images/logo.svg @@ -0,0 +1 @@ + diff --git a/sphinx-generator-wallet/source/index.rst b/sphinx-generator-wallet/source/index.rst new file mode 100644 index 0000000000..7fea67c643 --- /dev/null +++ b/sphinx-generator-wallet/source/index.rst @@ -0,0 +1,8 @@ +Bittensor Wallet SDK Documentation +================================== + +.. toctree:: + :maxdepth: 2 + :caption: API Reference + + modules \ No newline at end of file diff --git a/sphinx-generator-wallet/source/modules.rst b/sphinx-generator-wallet/source/modules.rst new file mode 100644 index 0000000000..1accd9d3d1 --- /dev/null +++ b/sphinx-generator-wallet/source/modules.rst @@ -0,0 +1,7 @@ +Bittensor Wallet Modules +======================== + +.. toctree:: + :maxdepth: 2 + + autoapi/bittensor_wallet/index diff --git a/sphinx-generator/.gitignore b/sphinx-generator/.gitignore new file mode 100644 index 0000000000..86822144b4 --- /dev/null +++ b/sphinx-generator/.gitignore @@ -0,0 +1,52 @@ +# Sphinx build outputs +build/ +_build/ + +# AutoAPI generated files +source/autoapi/ + +# Python virtual environments +sphinx_venv/ +venv/ +env/ +ENV/ +.venv + +# Python cache files +__pycache__/ +*.py[cod] +*$py.class +*.so +.mypy_cache/ +.ruff_cache/ +.pytest_cache/ + +# Distribution / packaging +.Python +*.egg-info/ +dist/ +downloads/ +*.egg + +# IDE files +.vscode/ +.idea/ +*.swp +*.swo +*~ +.DS_Store + +# Sphinx doctrees (intermediate build files) +.doctrees/ + +# Environment variables +.env +.env.local + +# Log files +*.log + +# Temporary files +*.tmp +.cache/ + diff --git a/sphinx-generator/Makefile b/sphinx-generator/Makefile new file mode 100644 index 0000000000..d0c3cbf102 --- /dev/null +++ b/sphinx-generator/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = source +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/sphinx-generator/make.bat b/sphinx-generator/make.bat new file mode 100644 index 0000000000..747ffb7b30 --- /dev/null +++ b/sphinx-generator/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.https://www.sphinx-doc.org/ + exit /b 1 +) + +if "%1" == "" goto help + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/sphinx-generator/readme.md b/sphinx-generator/readme.md new file mode 100644 index 0000000000..8b9a6fb61c --- /dev/null +++ b/sphinx-generator/readme.md @@ -0,0 +1,423 @@ +# Generating Bittensor Python SDK Documentation with Sphinx + +This guide explains how to build and publish the Bittensor Python API reference documentation using Sphinx and AutoAPI. + +## Prerequisites + +- Python 3.9 or higher +- Access to the Bittensor repository +- Write access to the [developer-docs repository](https://github.com/opentensor/developer-docs) (for publishing) + +## Quick Start + +### 1. Set Up Virtual Environment + +Run the following command from the root of the developer-docs directory: + +```bash +cd sphinx-generator +python3 -m venv sphinx_venv +source sphinx_venv/bin/activate +``` + +### 2. Install Dependencies + +The `sphinx-generator` directory contains a pre-configured setup. Install required packages: + +```bash +pip install -r requirements.txt +``` + +This installs: + +- Sphinx (documentation generator) +- sphinx-autoapi (automatic API documentation from docstrings) +- sphinx-book-theme (theme with custom CSS) +- myst-parser (Markdown support) + +### 3. Configure Paths + +Edit `source/conf.py` and update these paths: + +**Line 72** - Point to your Bittensor repository: + +```python +autoapi_dirs = ["/path/to/your/bittensor"] +``` + +**Line 28** - Point to your Python site-packages (if needed): + +```python +sys.path.append("/path/to/your/python/site-packages/") +``` + +### 4. Build Documentation + +```bash +make html +``` + +The generated HTML will be in `build/html/`. + +### 5. View Documentation Locally + +```bash +open build/html/index.html +``` + +## Configuration Details + +### Index Files + +The `source/` directory contains different index files for different documentation types: + +- `index.rst` - Main index (currently configured for Bittensor SDK) +- `index.rst.btsdk` - For Bittensor SDK documentation +- `index.rst.legacy` - For legacy documentation + +To switch documentation types, copy the appropriate index file: + +```bash +cp source/index.rst.btwallet source/index.rst +``` + +### AutoAPI Configuration + +Key settings in `source/conf.py`: + +```python +# Don't keep stale generated files +autoapi_keep_files = False + +# Ignore test files and internal modules +autoapi_ignore = [ + "*e2e*", + "*setup*", + "*test*", + "*mock*", + "*/site-packages/*", + "*post*", + "*cli*", + "chain_interactions", + "*/mock/*", + "*/tests/*", +] +``` + +### Custom Styling + +Custom CSS is located in `source/_static/bittensor-custom.css` and automatically applied via the Sphinx Book Theme. + +## Publishing Documentation + +### 1. Clean Build Directory + +Before publishing, remove the `_sources` directory (contains reStructuredText source files we don't want to version control): + +```bash +rm -r build/html/_sources +``` + +### 2. Push to Developer Docs Repository + +The documentation is published at `docs.bittensor.com` through the developer-docs repository: + +1. Clone/navigate to the developer-docs repo: + + ```bash + cd /path/to/developer-docs + ``` + +2. Replace the entire `static/python-api/html` directory: + + ```bash + rm -rf static/python-api/html + cp -r /path/to/sphinx-generator/build/html static/python-api/html + ``` + +3. Commit and push: + ```bash + git add static/python-api/html + git commit -m "Update Python API documentation" + git push + ``` + +### 3. Linking to Documentation + +In Markdown files within developer-docs, link to the Python reference docs using: + +```markdown +[API Reference](pathname:///python-api/html/index.html) +``` + +See the `docs/sdk/bt-api-ref.md` file for examples. + +## Troubleshooting + +### Common Build Errors + +#### 1. Unexpected Indentation Errors + +**Error:** + +``` +ERROR: Unexpected indentation. +WARNING: Block quote ends without a blank line; unexpected unindent. +``` + +**Cause:** Improper formatting in Google-style docstrings, typically: + +- Missing blank lines before `Note:`, `Example:`, or `Warning:` sections +- Inconsistent indentation in example code blocks +- Text continuing on the next line without proper indentation + +**Solution:** +Ensure proper formatting in docstrings: + +```python +def my_function(): + """Function description. + + Parameters: + param1: Description. + + Returns: + Return value description. + + Note: + Important note here with proper blank line above. + + Example: + # Example code here + result = my_function() + """ +``` + +For literal blocks (code examples), use `::` directive: + +```python + Example:: + { + "key": "value" + } +``` + +#### 2. KeyError for Missing Symbols + +**Error:** + +``` +KeyError: 'bittensor.core.extrinsics.asyncex.commit_reveal.commit_reveal_v3_extrinsic' +``` + +**Cause:** Stale AutoAPI files referencing functions that no longer exist or have been moved. + +**Solution:** +Clean the AutoAPI directory before rebuilding: + +```bash +rm -rf source/autoapi build +make html +``` + +Set `autoapi_keep_files = False` in `conf.py` to prevent this issue. + +#### 3. Definition List Formatting + +**Error:** + +``` +WARNING: Definition list ends without a blank line; unexpected unindent. +``` + +**Cause:** Missing blank line after parameter descriptions or before section headers. + +**Solution:** +Add blank lines between sections: + +```python + Parameters: + param1: Description. + param2: Description. + Returns: + Description of return value. +``` + +#### 4. Inline Literal Errors + +**Error:** + +``` +WARNING: Inline literal start-string without end-string. +``` + +**Cause:** Mismatched backticks in docstrings. + +**Solution:** +Check for: + +- Unclosed backticks: \`\`text vs \`\`text\`\` +- Proper escaping of special characters in code + +#### 5. Build Warnings About Unknown Types + +**Warning:** + +``` +WARNING: Unknown type: placeholder +``` + +**Cause:** Type hints that Sphinx cannot resolve. + +**Solution:** +This is usually harmless. To suppress, add to `conf.py`: + +```python +suppress_warnings = ["autoapi", "autosectionlabel.*"] +nitpicky = False +``` + +### Docstring Formatting Best Practices + +Follow Google-style docstrings with these requirements: + +1. **Always add blank lines before section headers:** + + ```python + """ + Description here. + + Parameters: + param1: Description. + + Returns: + Return description. + + Note: + Note content here. + """ + ``` + +2. **Use proper indentation for multi-line content:** + + ```python + Note: + First line of note. + Second line must be indented consistently. + ``` + +3. **For code blocks in examples, use proper formatting:** + + ```python + Example: + # Comment + code_here = True + more_code() + ``` + +4. **For literal blocks (JSON, dicts), use `::`:** + + ```python + Example:: + + { + "key": "value" + } + ``` + +5. **Avoid inline `Note:` - always make it a section:** + + ```python + # ❌ Bad + Note: This is important. + + # ✅ Good + Note: + This is important. + ``` + +### Rebuilding from Scratch + +If you encounter persistent issues: + +```bash +# Clean everything +rm -rf build source/autoapi + +# Rebuild +make html +``` + +### Python Environment Issues + +If imports fail during build: + +1. Ensure all Bittensor dependencies are installed in your virtual environment +2. Check that the `autoapi_dirs` path is correct +3. Verify Python can import bittensor: + ```bash + python -c "import bittensor; print(bittensor.__version__)" + ``` + +## Documentation Standards + +### Docstring Style Guide + +Follow the [Bittensor Writing Style Guide](https://github.com/opentensor/developer-docs/blob/main/WRITING-STYLE-GUIDE.md#python-docstrings). + +Key points: + +- Use Google-style docstrings +- Include type hints in function signatures when possible +- Provide examples for complex functions +- Document all parameters and return values +- Add notes for important behaviors or limitations + +### Testing Changes + +Before publishing: + +1. Build locally and check for warnings/errors +2. Verify all pages render correctly +3. Test navigation and links +4. Check code examples for accuracy +5. Review styling and formatting + +## Useful Resources + +- [Sphinx Documentation](https://www.sphinx-doc.org/en/master/index.html) +- [Sphinx AutoAPI](https://sphinx-autoapi.readthedocs.io/en/latest/reference/config.html) +- [Sphinx Book Theme](https://sphinx-book-theme.readthedocs.io/en/stable/tutorials/get-started.html) +- [Google Style Python Docstrings](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html) +- [Bittensor Writing Style Guide](https://github.com/opentensor/developer-docs/blob/main/WRITING-STYLE-GUIDE.md) + +## Quick Reference Commands + +```bash +# Activate virtual environment +source sphinx_venv/bin/activate + +# Clean build +rm -rf build && make html + +# Clean everything including generated API files +rm -rf build source/autoapi && make html + +# View docs +open build/html/index.html + +# Deactivate virtual environment +deactivate +``` + +## Getting Help + +If you encounter issues: + +1. Check build output for specific error messages +2. Review the troubleshooting section above +3. Ensure docstrings follow Google style conventions +4. Verify all paths in `conf.py` are correct +5. Try a clean rebuild: `rm -rf build source/autoapi && make html` + +For questions or issues, contact the Bittensor documentation team or open an issue in the developer-docs repository. diff --git a/sphinx-generator/requirements.txt b/sphinx-generator/requirements.txt new file mode 100644 index 0000000000..ebe0321673 --- /dev/null +++ b/sphinx-generator/requirements.txt @@ -0,0 +1,9 @@ +# Main Sphinx documentation generator +sphinx>=7.1.0 + +# Theme that we use for Python reference +sphinx-book-theme>=1.0.1 + +# Required extensions +sphinx-autoapi>=3.0.0 # For autoapi.extension +myst-parser>=2.0.0 # For MyST Markdown support diff --git a/sphinx-generator/source/_static/bittensor-custom.css b/sphinx-generator/source/_static/bittensor-custom.css new file mode 100644 index 0000000000..71e3492e85 --- /dev/null +++ b/sphinx-generator/source/_static/bittensor-custom.css @@ -0,0 +1,157 @@ +/* CSS customized by Raj Karamchedu on 29 January 2024 */ + +@font-face { + font-family: "Haffer"; + src: url(./fonts/Haffer-Light.ttf); + font-weight: 200; + font-style: normal; +} + +@font-face { + font-family: "Haffer"; + src: url(./fonts/Haffer-Medium.ttf); + font-weight: 400; + font-style: normal; +} + +@font-face { + font-family: "Haffer"; + src: url(./fonts/Haffer-Regular.ttf); + font-weight: normal; + font-style: normal; +} + +@font-face { + font-family: "Haffer"; + src: url(./fonts/Haffer-SemiBold.ttf); + font-weight: bold; + font-style: normal; +} + +@font-face { + font-family: "HafferSQ"; + src: url(./fonts/HafferSQ-Light.ttf); + font-weight: 200; + font-style: normal; +} + +@font-face { + font-family: "HafferSQ"; + src: url(./fonts/HafferSQ-Medium.ttf); + font-weight: 400; + font-style: normal; +} + +@font-face { + font-family: "HafferSQ"; + src: url(./fonts/HafferSQ-Regular.ttf); + font-weight: normal; + font-style: normal; +} + +@font-face { + font-family: "HafferSQ"; + src: url(./fonts/HafferSQ-SemiBold.ttf); + font-weight: bold; + font-style: normal; +} + +@font-face { + font-family: "TTCommonsPro"; + src: url(./fonts/TTCommonsProMonoMedium.ttf); + font-weight: 200; + font-style: normal; +} + +@font-face { + font-family: "TTCommonsPro"; + src: url(./fonts/TTCommonsProMonoRegular.ttf); + font-weight: 100; + font-style: normal; +} + +@font-face { + font-family: "FiraCode"; + src: url(./fonts/FiraCode_VariableFont_wght.ttf); +} + + + +html { + --pst-font-family-base-system: 'Haffer', -apple-system, BlinkMacSystemFont, Segoe UI, "Helvetica Neue", Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol; + --pst-font-family-monospace-system: "TTCommonsPro", Menlo, Consolas, Monaco, + Liberation Mono, Lucida Console, monospace; + --pst-sidebar-font-size: 1.0rem; + --pst-font-family-base: var(--pst-font-family-base-system); + --pst-font-family-heading: var(--pst-font-family-base-system); + --pst-font-family-monospace: var(--pst-font-family-monospace-system); + --pst-color-inline-code-links: #0c0c0c; + +} + +html[data-theme=dark]{ + --pst-color-surface: none; + --pst-color-inline-code-links: #fff; + --pst-color-target: #545454; + --pst-color-inline-code: #1fd01f; + --pst-color-table-row-hover-bg: #003200; +} + + +html[data-theme=light]{ + --pst-color-surface: none; + --pst-color-inline-code-links: #000; + --pst-color-target: #eaebed; + --pst-color-inline-code: #0fa50f; + --pst-color-table-row-hover-bg: #ffffc0; +} + +html[data-theme=dark], html[data-theme=light] { + --pst-color-primary: #838793; +} + +p { + font-size: 16px !important; +} + +code.xref, a code { + font-weight: normal; +} + +code.literal { + background-color: none; + border: none; +} + +.dropdown, .dropdown-center, .dropend, .dropstart, .dropup, .dropup-center { + position: relative; + display: none; +} + +/* .search-button { + display: none; +} */ + +.btn-fullscreen-button { + display: none; +} + +.bd-sidebar-secondary .onthispage { + display: none; +} + +@media (min-width: 992px){ +.bd-sidebar-primary { + flex-basis: 25%; +} +} + +.bd-sidebar-secondary{ + max-height: calc(100vh - var(--pst-header-height)); +} + +@media (min-width: 960px){ +.bd-page-width { + max-width: 98rem; +} +} \ No newline at end of file diff --git a/sphinx-generator/source/_static/custom-css-for-sphinx-book-theme.css b/sphinx-generator/source/_static/custom-css-for-sphinx-book-theme.css new file mode 100644 index 0000000000..143a284db8 --- /dev/null +++ b/sphinx-generator/source/_static/custom-css-for-sphinx-book-theme.css @@ -0,0 +1,174 @@ +@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600;700&family=Poppins:wght@400;500;600&family=JetBrains+Mono&display=swap'); + +body { + color: #221f1f; + font-family: 'Open Sans', sans-serif; +} + +h1 { + font-size: 2.2em; +} + +h2 { + font-size: 1.5em; +} + +h3 { + font-size: 1.2em; +} + +h4 { + font-size: 1.0em; +} + +.nav { + font-family: 'Poppins', sans-serif; +} + +.header-style, h1, h2, h3, h4, h5, h6 { + font-family: 'Poppins', sans-serif; + font-weight: 500; +} + +.bd-toc .tocsection { + padding: 4.0rem 0 .5rem 1rem !important; /* Right-side bar top padding to align with the main content title. */ +} + + +#main-content { + margin-top: 1rem !important; /* Main content pushed down to align with the site title below logo on the left-side bar. If you change this you must change the .bd-toc .tocsection padding from 7.8rem. */ +} + + +.admonition.note .admonition-title { + background-color: #fff0ec; + letter-spacing: 0.045rem; +} + +.admonition .admonition-title { + font-family: 'Poppins', sans-serif; +} + + +nav.bd-links li.toctree-l1 { + line-height: 1.45; +} + +.card { + box-shadow: 0 .5rem 1rem rgba(0,0,0,.15)!important; + transition: all 0.3s ease-in-out!important; +} + +@media (min-width: 576px) { + .card-deck .card { + margin-bottom: 15px; + transition: all 0.3s ease-in-out!important; + } +} + +@media (min-width: 1200px) { + .container, .container-lg, .container-md, .container sm, .container-xl { + max-width: 1400px; + } +} + +nav.bd-links p.caption { + letter-spacing: 0.1em; + font-family: 'Poppins', sans-serif; +} + +.caption-text { + letter-spacing: 0.1em; + font-family: 'Poppins', sans-serif; + font-size: 0.9em; + text-transform: uppercase; + font-weight: bold; + position: relative; + margin-top: 1.25em; + margin-bottom: 0; +} + +toc-h1, .toc-h2, .toc-h3, .toc-h4 { + line-height: 1.45; + margin-bottom: 0.5em; +} + +@media only screen and (min-width: 768px) { + #navbar-toggler { + display: none; + } +} + +div.navbar_extra_footer { + display: none; +} + +div.dropdown-buttons-trigger { + display: none; +} + +a.full-screen-button { + display: none; +} + +pre { + line-height: 150%; + background-color: #f1f3f4; /* #ffc1070d; */ + padding: 22px; + color: #37474f; + font-size: 95%; + border: none; + box-shadow: none; + /* font-family: 'JetBrains Mono', sans-serif; Avoid this here or else glyphs in code snippets. */ +} + +.header-style, h1, h2, h3, h4, h5, h6 { + line-height: 1.35; +} + +nav.bd-links li.toctree-l1, nav.bd-links li.toctree-l2, nav.bd-links li.toctree-l3, nav.bd-links li.toctree-l4, nav.bd-links li.toctree-l5 { + margin-bottom: 0.35em; +} + +.bd-sidebar nav ul.nav a:hover, .bd-sidebar nav ul.nav li.active>a, .bd-sidebar nav ul.nav li.active>a:hover { + color: #221f1f; +} +.bd-sidebar-secondary .onthispage { + height: 3rem; + min-height: 3rem; + display: none; +} + +.prev-next-bottom { + height: 3em; + font-family: 'Poppins', sans-serif; + font-weight: 500; +} + +blockquote { + margin: 1rem 0 1rem; + border-left: 0px solid #ccc; + padding: .1em .1em; +} + +main.bd-content #main-content div.section ul p, main.bd-content #main-content div.section ol p { + margin-bottom: .5rem; +} + +table td, .table th { + padding: .75rem; + vertical-align: top; + border-top: 1px solid #dee2e6; + border-bottom: 1px solid #dee2e6; + border-right: 1px solid #dee2e6; + border-left: 1px solid #dee2e6; +} + +.footer { + font-size: .8em; +} + +.bd-header-article .article-header-buttons { + /* display: flex; */ + display: none; +} diff --git a/sphinx-generator/source/_static/fonts/FiraCode_VariableFont_wght.ttf b/sphinx-generator/source/_static/fonts/FiraCode_VariableFont_wght.ttf new file mode 100644 index 0000000000..0013e0ad05 Binary files /dev/null and b/sphinx-generator/source/_static/fonts/FiraCode_VariableFont_wght.ttf differ diff --git a/sphinx-generator/source/_static/fonts/Haffer-Light.ttf b/sphinx-generator/source/_static/fonts/Haffer-Light.ttf new file mode 100644 index 0000000000..4823831012 Binary files /dev/null and b/sphinx-generator/source/_static/fonts/Haffer-Light.ttf differ diff --git a/sphinx-generator/source/_static/fonts/Haffer-Medium.ttf b/sphinx-generator/source/_static/fonts/Haffer-Medium.ttf new file mode 100644 index 0000000000..1977e1df34 Binary files /dev/null and b/sphinx-generator/source/_static/fonts/Haffer-Medium.ttf differ diff --git a/sphinx-generator/source/_static/fonts/Haffer-Regular.ttf b/sphinx-generator/source/_static/fonts/Haffer-Regular.ttf new file mode 100644 index 0000000000..fb2b457ab1 Binary files /dev/null and b/sphinx-generator/source/_static/fonts/Haffer-Regular.ttf differ diff --git a/sphinx-generator/source/_static/fonts/Haffer-SemiBold.ttf b/sphinx-generator/source/_static/fonts/Haffer-SemiBold.ttf new file mode 100644 index 0000000000..ef01086009 Binary files /dev/null and b/sphinx-generator/source/_static/fonts/Haffer-SemiBold.ttf differ diff --git a/sphinx-generator/source/_static/fonts/HafferSQ-Light.ttf b/sphinx-generator/source/_static/fonts/HafferSQ-Light.ttf new file mode 100644 index 0000000000..1abd355828 Binary files /dev/null and b/sphinx-generator/source/_static/fonts/HafferSQ-Light.ttf differ diff --git a/sphinx-generator/source/_static/fonts/HafferSQ-Medium.ttf b/sphinx-generator/source/_static/fonts/HafferSQ-Medium.ttf new file mode 100644 index 0000000000..a27000db2c Binary files /dev/null and b/sphinx-generator/source/_static/fonts/HafferSQ-Medium.ttf differ diff --git a/sphinx-generator/source/_static/fonts/HafferSQ-Regular.ttf b/sphinx-generator/source/_static/fonts/HafferSQ-Regular.ttf new file mode 100644 index 0000000000..df3a2190d5 Binary files /dev/null and b/sphinx-generator/source/_static/fonts/HafferSQ-Regular.ttf differ diff --git a/sphinx-generator/source/_static/fonts/HafferSQ-SemiBold.ttf b/sphinx-generator/source/_static/fonts/HafferSQ-SemiBold.ttf new file mode 100644 index 0000000000..f2d0584595 Binary files /dev/null and b/sphinx-generator/source/_static/fonts/HafferSQ-SemiBold.ttf differ diff --git a/sphinx-generator/source/_static/fonts/TTCommonsProMonoMedium.ttf b/sphinx-generator/source/_static/fonts/TTCommonsProMonoMedium.ttf new file mode 100644 index 0000000000..987ee9fded Binary files /dev/null and b/sphinx-generator/source/_static/fonts/TTCommonsProMonoMedium.ttf differ diff --git a/sphinx-generator/source/_static/fonts/TTCommonsProMonoRegular.ttf b/sphinx-generator/source/_static/fonts/TTCommonsProMonoRegular.ttf new file mode 100644 index 0000000000..c2bf574c06 Binary files /dev/null and b/sphinx-generator/source/_static/fonts/TTCommonsProMonoRegular.ttf differ diff --git a/sphinx-generator/source/_static/logo-dark-mode.svg b/sphinx-generator/source/_static/logo-dark-mode.svg new file mode 100644 index 0000000000..a56a46c7c0 --- /dev/null +++ b/sphinx-generator/source/_static/logo-dark-mode.svg @@ -0,0 +1 @@ + diff --git a/sphinx-generator/source/_static/logo.svg b/sphinx-generator/source/_static/logo.svg new file mode 100644 index 0000000000..337ffe2d33 --- /dev/null +++ b/sphinx-generator/source/_static/logo.svg @@ -0,0 +1 @@ + diff --git a/sphinx-generator/source/conf.py b/sphinx-generator/source/conf.py new file mode 100644 index 0000000000..d2daf5cecd --- /dev/null +++ b/sphinx-generator/source/conf.py @@ -0,0 +1,113 @@ +# Configuration file for the Sphinx documentation builder. +# +# For the full list of built-in configuration values, see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information + +# project = 'BTCLI Docs' +project = "Bittensor SDK Docs" +copyright = "2025, Opentensor Foundation" +author = "Opentensor Foundation" +# release = '1.0' + +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration + + +import os +import sys + +sys.path.insert(0, os.path.abspath("..")) +sys.path.insert(0, os.path.abspath("../..")) + +# This below path insert is needed for the source link to work for all +sys.path.insert(0, os.path.abspath("../bittensor")) +# sys.path.insert(0, os.path.abspath('../../btwallet')) +sys.path.append("/Users/michaeltrestman/Library/Python/3.9/lib/python/site-packages/") + +html_theme = "sphinx_book_theme" +html_theme_options = { + "show_navbar_depth": 4, + "logo": { + "image_light": "_static/logo.svg", + "image_dark": "_static/logo-dark-mode.svg", + }, + "repository_url": "https://github.com/opentensor/btcli", + "use_source_button": True, + "use_repository_button": True, + "use_issues_button": True, +} +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.napoleon", + "autoapi.extension", + "sphinx.ext.viewcode", + "myst_parser", + "sphinx.ext.intersphinx", +] + +myst_enable_extensions = ["dollarmath", "amsmath"] + +# Napoleon settings +napoleon_google_docstring = True +napoleon_numpy_docstring = False +napoleon_include_init_with_doc = True +napoleon_include_private_with_doc = True +napoleon_include_special_with_doc = True +napoleon_use_admonition_for_examples = True +napoleon_use_admonition_for_notes = True +napoleon_use_admonition_for_references = True +napoleon_use_ivar = True + +intersphinx_mapping = { + "python": ("https://docs.python.org/3", None), + "numpy": ("https://numpy.org/doc/stable/", None), + "torch": ("https://pytorch.org/docs/stable/", None), + "pydantic": ("https://docs.pydantic.dev/latest/", None), +} + +# Source directory and ignore patterns for Bittensor SDK +autoapi_dirs = ["/Users/michaeltrestman/bittensor_workspace/latents/bittensor"] +autoapi_ignore = [ + "*e2e*", + "*setup*", + "*test*", + "*mock*", + "*/site-packages/*", + "*post*", + "*cli*", + "chain_interactions", + "*/mock/*", + "*/tests/*", +] +autoapi_python_class_content = "both" +autodoc_typehints = "description" +autodoc_default_options = { + "special-members": "__init__", +} +autoapi_options = [ + "members", + "undoc-members", + "show-inheritance", + "show-module-summary", +] +autoapi_keep_files = False + +# Legacy stuff +# autoapi_ignore = ["*axon*", "*btlogging*", "*chain_data*", "*cli*", "*config*", "*dendrite*", "*errors*", "*keyfile*", "metagraph*", "*stream*", "*subtensor*", "*synapse*", "*tensor*", "*threadpool*", "*types*", "*wallet*", "*mock*", "*utils*", "*setup*"] + +autoapi_member_order = "alphabetical" +templates_path = ["_templates"] +exclude_patterns = [] + +# Make Sphinx more tolerant of formatting issues +suppress_warnings = ["autoapi", "autosectionlabel.*"] +nitpicky = False + +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output + +html_static_path = ["_static"] +html_css_files = ["bittensor-custom.css"] diff --git a/sphinx-generator/source/images/logo copy.svg b/sphinx-generator/source/images/logo copy.svg new file mode 100644 index 0000000000..337ffe2d33 --- /dev/null +++ b/sphinx-generator/source/images/logo copy.svg @@ -0,0 +1 @@ + diff --git a/sphinx-generator/source/images/logo-dark-mode.svg b/sphinx-generator/source/images/logo-dark-mode.svg new file mode 100644 index 0000000000..a56a46c7c0 --- /dev/null +++ b/sphinx-generator/source/images/logo-dark-mode.svg @@ -0,0 +1 @@ + diff --git a/sphinx-generator/source/images/logo.svg b/sphinx-generator/source/images/logo.svg new file mode 100644 index 0000000000..337ffe2d33 --- /dev/null +++ b/sphinx-generator/source/images/logo.svg @@ -0,0 +1 @@ + diff --git a/sphinx-generator/source/index.rst b/sphinx-generator/source/index.rst new file mode 100644 index 0000000000..b5a4198675 --- /dev/null +++ b/sphinx-generator/source/index.rst @@ -0,0 +1,9 @@ +Bittensor SDK Documentation +=========================== + +This is the developer documentation for the Bittensor SDK. + +.. toctree:: + :maxdepth: 2 + :caption: Table of Contents + diff --git a/sphinx-generator/source/index.rst.btsdk b/sphinx-generator/source/index.rst.btsdk new file mode 100644 index 0000000000..8ee6095760 --- /dev/null +++ b/sphinx-generator/source/index.rst.btsdk @@ -0,0 +1,8 @@ +Bittensor SDK Documentation +=========================== + +This is the developer documentation for the Bittensor SDK. + +.. toctree:: + :maxdepth: 2 + :caption: Table of Contents diff --git a/sphinx-generator/source/index.rst.btwallet b/sphinx-generator/source/index.rst.btwallet new file mode 100644 index 0000000000..cf7d62e51f --- /dev/null +++ b/sphinx-generator/source/index.rst.btwallet @@ -0,0 +1,8 @@ +Bittensor Wallet Python SDK Reference +===================================== + +Table of Contents +----------------- + +.. toctree:: + :maxdepth: 2 diff --git a/sphinx-generator/source/index.rst.legacy b/sphinx-generator/source/index.rst.legacy new file mode 100644 index 0000000000..c7919bf8dc --- /dev/null +++ b/sphinx-generator/source/index.rst.legacy @@ -0,0 +1,13 @@ +Legacy Bittensor 7.4.0 Documentation +==================================== + +Table of Contents +----------------- + +.. toctree:: + :maxdepth: 2 + + +.. admonition:: STOP, READ THIS FIRST + + This is the developer documentation for the legacy Bittensor 7.4.0. For the latest Bittensor SDK documentation, see `Bittensor SDK Docs `_. \ No newline at end of file diff --git a/static/btwallet-api/html/.buildinfo b/static/btwallet-api/html/.buildinfo index 51d0fb66a7..990e733377 100644 --- a/static/btwallet-api/html/.buildinfo +++ b/static/btwallet-api/html/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 -# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: 790454dd4a137ddea3d2d266795e841b +# This file records the configuration used when building these files. When it is not found, a full rebuild will be done. +config: d4739118bd871b707c971337125cb60f tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/static/btwallet-api/html/autoapi/index.html b/static/btwallet-api/html/_modules/index.html similarity index 58% rename from static/btwallet-api/html/autoapi/index.html rename to static/btwallet-api/html/_modules/index.html index f62d6c2881..505a6cc0fa 100644 --- a/static/btwallet-api/html/autoapi/index.html +++ b/static/btwallet-api/html/_modules/index.html @@ -6,9 +6,8 @@ - - - API Reference — BTCLI Docs 1.0 documentation + + Overview: module code — Bittensor Wallet SDK Docs documentation @@ -28,9 +27,8 @@ - - - + + @@ -38,15 +36,13 @@ - - + + - + - - @@ -109,6 +105,8 @@ + +
@@ -138,8 +136,8 @@ - BTCLI Docs 1.0 documentation - Home - + Bittensor Wallet SDK Docs  documentation - Home +
@@ -156,21 +154,16 @@ @@ -156,21 +155,16 @@ @@ -403,25 +393,51 @@

Contents

-
-

bittensor_wallet.errors#

-
-

Attributes#

-
+
+

bittensor_wallet.errors#

+
- + + + + + + + + + +

KeyFileError

ConfigurationError(msg)

KeyFileError(msg)

PasswordError(msg)

WalletError(msg)

-
-
-

Package Contents#

-
-
-bittensor_wallet.errors.KeyFileError#
-
+
+

Module Contents#

+

Exceptions Details

+
+
+exception bittensor_wallet.errors.ConfigurationError(msg)
+

Bases: Exception

+
+ +
+
+exception bittensor_wallet.errors.KeyFileError(msg)
+

Bases: Exception

+
+ +
+
+exception bittensor_wallet.errors.PasswordError(msg)
+

Bases: Exception

+
+ +
+
+exception bittensor_wallet.errors.WalletError(msg)
+

Bases: Exception

+
@@ -438,20 +454,20 @@

Package Contents

previous

-

bittensor_wallet

+

bittensor_wallet.config

next

-

bittensor_wallet.keyfile

+

bittensor_wallet.utils

@@ -471,11 +487,7 @@

Package Contents @@ -500,7 +512,7 @@

Package Contents - © Copyright 2024, Opentensor Foundation. + © Copyright 2025, Opentensor Foundation.

diff --git a/static/btwallet-api/html/autoapi/bittensor_wallet/index.html b/static/btwallet-api/html/autoapi/bittensor_wallet/index.html index a8c58774ed..08f3a2d376 100644 --- a/static/btwallet-api/html/autoapi/bittensor_wallet/index.html +++ b/static/btwallet-api/html/autoapi/bittensor_wallet/index.html @@ -8,7 +8,7 @@ - bittensor_wallet — BTCLI Docs 1.0 documentation + bittensor_wallet — Bittensor Wallet SDK Docs documentation @@ -28,9 +28,8 @@ - - - + + @@ -38,15 +37,15 @@ - - + + - - + + @@ -138,8 +137,8 @@ - BTCLI Docs 1.0 documentation - Home - + Bittensor Wallet SDK Docs  documentation - Home +
@@ -156,21 +155,16 @@

@@ -399,16 +393,18 @@

Contents

-
-

bittensor_wallet#

-
-

Subpackages#

+
+

bittensor_wallet#

+
+

Submodules#

@@ -426,20 +422,20 @@

Subpackages

previous

-

btwallet.wallet

+

Bittensor Wallet Modules

next

-

bittensor_wallet.errors

+

bittensor_wallet.wallet

@@ -459,7 +455,7 @@

Subpackages @@ -484,7 +480,7 @@

Subpackages - © Copyright 2024, Opentensor Foundation. + © Copyright 2025, Opentensor Foundation.

diff --git a/static/btwallet-api/html/autoapi/bittensor_wallet/keyfile/index.html b/static/btwallet-api/html/autoapi/bittensor_wallet/keyfile/index.html index 7f933c78bd..ccb8a0c5c2 100644 --- a/static/btwallet-api/html/autoapi/bittensor_wallet/keyfile/index.html +++ b/static/btwallet-api/html/autoapi/bittensor_wallet/keyfile/index.html @@ -8,7 +8,7 @@ - bittensor_wallet.keyfile — BTCLI Docs 1.0 documentation + bittensor_wallet.keyfile — Bittensor Wallet SDK Docs documentation @@ -28,9 +28,8 @@ - - - + + @@ -38,15 +37,15 @@ - - + + - - + + @@ -138,8 +137,8 @@ - BTCLI Docs 1.0 documentation - Home - + Bittensor Wallet SDK Docs  documentation - Home +
@@ -156,21 +155,16 @@

@@ -417,137 +393,721 @@

Contents

-
-

bittensor_wallet.keyfile#

-
-

Attributes#

-
+
+

bittensor_wallet.keyfile#

+
- - + + - - + + - - + + - - + + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - +

serialized_keypair_to_keyfile_data

ask_password(validation_required)

Prompts the user to enter a password for key encryption.

deserialize_keypair_from_keyfile_data

decrypt_keyfile_data(keyfile_data[, ...])

Decrypts the passed keyfile data using ansible vault.

validate_password

deserialize_keypair_from_keyfile_data(...)

Deserializes Keypair object from passed keyfile data.

ask_password

encrypt_keyfile_data(keyfile_data[, password])

Encrypts the passed keyfile data using ansible vault.

ask_password_to_encrypt

get_coldkey_password_from_environment(...)

keyfile_data_is_encrypted_nacl

get_password_from_environment(env_var_name)

Retrieves the cold key password from the environment variables.

keyfile_data_is_encrypted_ansible

keyfile_data_encryption_method(keyfile_data)

Returns type of encryption method as a string.

keyfile_data_is_encrypted_legacy

keyfile_data_is_encrypted(keyfile_data)

Returns true if the keyfile data is encrypted.

keyfile_data_is_encrypted

keyfile_data_is_encrypted_ansible(keyfile_data)

Returns true if the keyfile data is ansible encrypted.

keyfile_data_encryption_method

keyfile_data_is_encrypted_legacy(keyfile_data)

Returns true if the keyfile data is legacy encrypted.

legacy_encrypt_keyfile_data

keyfile_data_is_encrypted_nacl(keyfile_data)

Returns true if the keyfile data is NaCl encrypted.

get_coldkey_password_from_environment

legacy_encrypt_keyfile_data(keyfile_data[, ...])

legacy_encrypt_keyfile_data.

encrypt_keyfile_data

serialized_keypair_to_keyfile_data(keypair)

Serializes keypair object into keyfile data.

decrypt_keyfile_data

validate_password(password)

Validates the password against a password policy.

Keyfile

Keyfile([path, name, should_save_to_env])

-
-
-

Package Contents#

-
-
-bittensor_wallet.keyfile.serialized_keypair_to_keyfile_data#
-
- -
-
-bittensor_wallet.keyfile.deserialize_keypair_from_keyfile_data#
-
- -
-
-bittensor_wallet.keyfile.validate_password#
-
- -
-
-bittensor_wallet.keyfile.ask_password#
-
- -
-
-bittensor_wallet.keyfile.ask_password_to_encrypt#
-
- -
-
-bittensor_wallet.keyfile.keyfile_data_is_encrypted_nacl#
-
- -
-
-bittensor_wallet.keyfile.keyfile_data_is_encrypted_ansible#
-
- -
-
-bittensor_wallet.keyfile.keyfile_data_is_encrypted_legacy#
-
- -
-
-bittensor_wallet.keyfile.keyfile_data_is_encrypted#
-
- -
-
-bittensor_wallet.keyfile.keyfile_data_encryption_method#
-
- -
-
-bittensor_wallet.keyfile.legacy_encrypt_keyfile_data#
-
- -
-
-bittensor_wallet.keyfile.get_coldkey_password_from_environment#
-
- -
-
-bittensor_wallet.keyfile.encrypt_keyfile_data#
+
+

Module Contents#

+

Functions Details

+
+
+class bittensor_wallet.keyfile.Keyfile(path=None, name=None, should_save_to_env=False)
+

Bases: object

+
+
+check_and_update_encryption(print_result=True, no_prompt=False)
+

Check the version of keyfile and update if needed.

+
+
Parameters:
+
    +
  • print_result (bool) – If True, prints the result of the encryption check.

  • +
  • no_prompt (bool) – If True, skips user prompts during the update process.

  • +
+
+
Returns:
+

True if the keyfile was successfully updated to the latest encryption method.

+
+
+
+ +
+
+data
+

Returns the keyfile data under path.

+
+ +
+
+decrypt(password=None)
+

Decrypts the file under the path.

+
+
Parameters:
+

password (Option<String>) – The password used to decrypt the data. If None, asks for user input.

+
+
+
+ +
+
+encrypt(password=None)
+

Encrypts the file under the path.

+
+
Parameters:
+

password (Option<String>) – The password used to encrypt the data. If None, asks for user input.

+
+
+
+ +
+
+env_var_name()
+

Returns local environment variable key name based on Keyfile path.

+
+ +
+
+exists_on_device()
+

Returns True if the file exists on the device.

+
+
Returns:
+

True if the file is readable.

+
+
+
+ +
+
+get_keypair(password=None)
+

Returns the keypair from path, decrypts data if the file is encrypted.

+
+
Parameters:
+

password (Option<String>) – The password used to decrypt the data. If None, asks for user input.

+
+
Returns:
+

The Keypair loaded from the file.

+
+
+
+ +
+
+is_encrypted()
+

Returns True if the file under path is encrypted.

+
+
Returns:
+

True if the file is encrypted.

+
+
+
+ +
+
+is_readable()
+

Returns True if the file under path is readable.

+
+ +
+
+is_writable()
+

Returns True if the file under path is writable.

+
+
Returns:
+

True if the file is writable.

+
+
+
+ +
+
+keypair
+

Returns the keypair from path, decrypts data if the file is encrypted.

+
+ +
+
+make_dirs()
+

Creates directories for the path if they do not exist.

+
+ +
+
+path
+

Returns the wallet path.

+
+ +
+
+remove_password_from_env()
+

Removes the password associated with the Keyfile from the local environment.

+
+ +
+
+save_password_to_env(password=None)
+

Saves the key’s password to the associated local environment variable.

+
+
Parameters:
+

password (Option<String>) – The password to save. If None, asks for user input.

+
+
Returns:
+

The base64-encoded encrypted password.

+
+
+
+ +
+
+set_keypair(keypair, encrypt=True, overwrite=False, password=None)
+

Writes the keypair to the file and optionally encrypts data.

+
+
Parameters:
+
    +
  • keypair (Keypair) – The keypair object to be stored.

  • +
  • encrypt (bool) – If True, encrypts the keyfile data.

  • +
  • overwrite (bool) – If True, overwrites existing file without prompting.

  • +
  • password (Option<String>) – The password used to encrypt the data. If None, asks for user input.

  • +
+
+
+
+ +
+ +
+
+bittensor_wallet.keyfile.ask_password(validation_required)
+

Prompts the user to enter a password for key encryption.

+
+
Parameters:
+

validation_required (bool) – If True, validates the password against policy requirements.

+
+
Returns:
+

The valid password entered by the user.

+
+
+
+ +
+
+bittensor_wallet.keyfile.decrypt_keyfile_data(keyfile_data, password=None, password_env_var=None)
+

Decrypts the passed keyfile data using ansible vault.

+
+
Parameters:
+
    +
  • keyfile_data – The bytes to decrypt.

  • +
  • password (str) – The password used to decrypt the data. If None, asks for user input.

  • +
  • coldkey_name (str) – The name of the cold key. If provided, retrieves the password from environment variables.

  • +
+
+
Returns:
+

The decrypted data.

+
+
+
+ +
+
+bittensor_wallet.keyfile.deserialize_keypair_from_keyfile_data(keyfile_data)
+

Deserializes Keypair object from passed keyfile data.

+
+
Parameters:
+

keyfile_data (PyBytes) – The keyfile data to be loaded.

+
+
Returns:
+

The Keypair loaded from bytes.

+
+
Raises:
+

KeyFileError – The passed pybytes cannot construct a keypair object.

+
+
+
+ +
+
+bittensor_wallet.keyfile.encrypt_keyfile_data(keyfile_data, password=None)
+

Encrypts the passed keyfile data using ansible vault.

+
+
Parameters:
+
    +
  • keyfile_data (bytes) – The bytes to encrypt.

  • +
  • password (str) – The password used to encrypt the data. If None, asks for user input.

  • +
+
+
Returns:
+

The encrypted data.

+
+
+
+ +
+
+bittensor_wallet.keyfile.get_coldkey_password_from_environment(env_var_name)
-
-
-bittensor_wallet.keyfile.decrypt_keyfile_data#
-
+
+
+bittensor_wallet.keyfile.get_password_from_environment(env_var_name)
+

Retrieves the cold key password from the environment variables.

+
+
Parameters:
+

coldkey_name – The name of the cold key.

+
+
Returns:
+

Option<String> - The password retrieved from the environment variables, or None if not found.

+
+
+
+ +
+
+bittensor_wallet.keyfile.keyfile_data_encryption_method(keyfile_data)
+

Returns type of encryption method as a string.

+
+
Parameters:
+

keyfile_data (bytes) – Bytes to validate.

+
+
Returns:
+

A string representing the name of encryption method.

+
+
Return type:
+

(str)

+
+
+
+ +
+
+bittensor_wallet.keyfile.keyfile_data_is_encrypted(keyfile_data)
+

Returns true if the keyfile data is encrypted.

+
+
Parameters:
+

keyfile_data (bytes) – The bytes to validate.

+
+
Returns:
+

true if the data is encrypted.

+
+
Return type:
+

is_encrypted (bool)

+
+
+
+ +
+
+bittensor_wallet.keyfile.keyfile_data_is_encrypted_ansible(keyfile_data)
+

Returns true if the keyfile data is ansible encrypted.

+
+
Parameters:
+

validate. (keyfile_data - The bytes to)

+
+
Returns:
+

is_ansible - True if the data is ansible encrypted.

+
+
+
+ +
+
+bittensor_wallet.keyfile.keyfile_data_is_encrypted_legacy(keyfile_data)
+

Returns true if the keyfile data is legacy encrypted.

+
+
Parameters:
+

validate. (keyfile_data - The bytes to)

+
+
Returns:
+

is_legacy - true if the data is legacy encrypted.

+
+
+
+ +
+
+bittensor_wallet.keyfile.keyfile_data_is_encrypted_nacl(keyfile_data)
+

Returns true if the keyfile data is NaCl encrypted.

+
+
Parameters:
+

validate (keyfile_data - Bytes to)

+
+
Returns:
+

is_nacl - true if the data is ansible encrypted.

+
+
+
+ +
+
+bittensor_wallet.keyfile.legacy_encrypt_keyfile_data(keyfile_data, password=None)
+

legacy_encrypt_keyfile_data.

+
+
Parameters:
+
    +
  • keyfile_data (bytes) – Bytes of data from the keyfile.

  • +
  • password (str) – Optional string that represents the password.

  • +
+
+
Returns:
+

The encrypted keyfile data in bytes.

+
+
+
+ +
+
+bittensor_wallet.keyfile.serialized_keypair_to_keyfile_data(keypair)
+

Serializes keypair object into keyfile data.

+
+
Parameters:
+

keypair (Keypair) – The keypair object to be serialized.

+
+
Returns:
+

Serialized keypair data.

+
+
+
+ +
+
+bittensor_wallet.keyfile.validate_password(password)
+

Validates the password against a password policy.

+
+
Parameters:
+

password (str) – The password to verify.

+
+
Returns:
+

True if the password meets validity requirements.

+
+
+
+ +

Classes Details

+
+
+class bittensor_wallet.keyfile.Keyfile(path=None, name=None, should_save_to_env=False)
+

Bases: object

+
+
+check_and_update_encryption(print_result=True, no_prompt=False)
+

Check the version of keyfile and update if needed.

+
+
Parameters:
+
    +
  • print_result (bool) – If True, prints the result of the encryption check.

  • +
  • no_prompt (bool) – If True, skips user prompts during the update process.

  • +
+
+
Returns:
+

True if the keyfile was successfully updated to the latest encryption method.

+
+
+
+ +
+
+decrypt(password=None)
+

Decrypts the file under the path.

+
+
Parameters:
+

password (Option<String>) – The password used to decrypt the data. If None, asks for user input.

+
+
+
+ +
+
+encrypt(password=None)
+

Encrypts the file under the path.

+
+
Parameters:
+

password (Option<String>) – The password used to encrypt the data. If None, asks for user input.

+
+
+
+ +
+
+env_var_name()
+

Returns local environment variable key name based on Keyfile path.

+
+ +
+
+exists_on_device()
+

Returns True if the file exists on the device.

+
+
Returns:
+

True if the file is readable.

+
+
+
+ +
+
+get_keypair(password=None)
+

Returns the keypair from path, decrypts data if the file is encrypted.

+
+
Parameters:
+

password (Option<String>) – The password used to decrypt the data. If None, asks for user input.

+
+
Returns:
+

The Keypair loaded from the file.

+
+
+
+ +
+
+is_encrypted()
+

Returns True if the file under path is encrypted.

+
+
Returns:
+

True if the file is encrypted.

+
+
+
+ +
+
+is_readable()
+

Returns True if the file under path is readable.

+
+ +
+
+is_writable()
+

Returns True if the file under path is writable.

+
+
Returns:
+

True if the file is writable.

+
+
+
+ +
+
+make_dirs()
+

Creates directories for the path if they do not exist.

+
+ +
+
+set_keypair(keypair, encrypt=True, overwrite=False, password=None)
+

Writes the keypair to the file and optionally encrypts data.

+
+
Parameters:
+
    +
  • keypair (Keypair) – The keypair object to be stored.

  • +
  • encrypt (bool) – If True, encrypts the keyfile data.

  • +
  • overwrite (bool) – If True, overwrites existing file without prompting.

  • +
  • password (Option<String>) – The password used to encrypt the data. If None, asks for user input.

  • +
+
+
+
+ +
+
+data
+

Returns the keyfile data under path.

+
+ +
+
+check_and_update_encryption(print_result=True, no_prompt=False)
+

Check the version of keyfile and update if needed.

+
+
Parameters:
+
    +
  • print_result (bool) – If True, prints the result of the encryption check.

  • +
  • no_prompt (bool) – If True, skips user prompts during the update process.

  • +
+
+
Returns:
+

True if the keyfile was successfully updated to the latest encryption method.

+
+
+
+ +
+
+data
+

Returns the keyfile data under path.

+
+ +
+
+decrypt(password=None)
+

Decrypts the file under the path.

+
+
Parameters:
+

password (Option<String>) – The password used to decrypt the data. If None, asks for user input.

+
+
+
+ +
+
+encrypt(password=None)
+

Encrypts the file under the path.

+
+
Parameters:
+

password (Option<String>) – The password used to encrypt the data. If None, asks for user input.

+
+
+
+ +
+
+env_var_name()
+

Returns local environment variable key name based on Keyfile path.

+
+ +
+
+exists_on_device()
+

Returns True if the file exists on the device.

+
+
Returns:
+

True if the file is readable.

+
+
+
+ +
+
+get_keypair(password=None)
+

Returns the keypair from path, decrypts data if the file is encrypted.

+
+
Parameters:
+

password (Option<String>) – The password used to decrypt the data. If None, asks for user input.

+
+
Returns:
+

The Keypair loaded from the file.

+
+
+
+ +
+
+is_encrypted()
+

Returns True if the file under path is encrypted.

+
+
Returns:
+

True if the file is encrypted.

+
+
+
+ +
+
+is_readable()
+

Returns True if the file under path is readable.

+
+ +
+
+is_writable()
+

Returns True if the file under path is writable.

+
+
Returns:
+

True if the file is writable.

+
+
+
+ +
+
+keypair
+

Returns the keypair from path, decrypts data if the file is encrypted.

+
+ +
+
+make_dirs()
+

Creates directories for the path if they do not exist.

+
+ +
+
+path
+

Returns the wallet path.

+
+ +
+
+remove_password_from_env()
+

Removes the password associated with the Keyfile from the local environment.

+
+ +
+
+save_password_to_env(password=None)
+

Saves the key’s password to the associated local environment variable.

+
+
Parameters:
+

password (Option<String>) – The password to save. If None, asks for user input.

+
+
Returns:
+

The base64-encoded encrypted password.

+
+
+
+ +
+
+set_keypair(keypair, encrypt=True, overwrite=False, password=None)
+

Writes the keypair to the file and optionally encrypts data.

+
+
Parameters:
+
    +
  • keypair (Keypair) – The keypair object to be stored.

  • +
  • encrypt (bool) – If True, encrypts the keyfile data.

  • +
  • overwrite (bool) – If True, overwrites existing file without prompting.

  • +
  • password (Option<String>) – The password used to encrypt the data. If None, asks for user input.

  • +
+
+
+
-
-
-bittensor_wallet.keyfile.Keyfile#
-
+
@@ -564,20 +1124,20 @@

Package Contents

previous

-

bittensor_wallet.errors

+

bittensor_wallet.wallet

next

-

bittensor_wallet.utils

+

bittensor_wallet.keypair

@@ -597,25 +1157,7 @@

Package Contents @@ -640,7 +1182,7 @@

Package Contents - © Copyright 2024, Opentensor Foundation. + © Copyright 2025, Opentensor Foundation.

diff --git a/static/btwallet-api/html/autoapi/btwallet/utils/index.html b/static/btwallet-api/html/autoapi/bittensor_wallet/keypair/index.html similarity index 51% rename from static/btwallet-api/html/autoapi/btwallet/utils/index.html rename to static/btwallet-api/html/autoapi/bittensor_wallet/keypair/index.html index 186d010227..f0c3a2cc35 100644 --- a/static/btwallet-api/html/autoapi/btwallet/utils/index.html +++ b/static/btwallet-api/html/autoapi/bittensor_wallet/keypair/index.html @@ -8,7 +8,7 @@ - btwallet.utils — BTCLI Docs 1.0 documentation + bittensor_wallet.keypair — Bittensor Wallet SDK Docs documentation @@ -28,9 +28,8 @@ - - - + + @@ -38,15 +37,15 @@ - - + + - + - - + + @@ -138,8 +137,8 @@ - BTCLI Docs 1.0 documentation - Home - + Bittensor Wallet SDK Docs  documentation - Home +
@@ -156,21 +155,16 @@ @@ -595,7 +619,7 @@

Module Contents - © Copyright 2024, Opentensor Foundation. + © Copyright 2025, Opentensor Foundation.

diff --git a/static/btwallet-api/html/autoapi/bittensor_wallet/utils/index.html b/static/btwallet-api/html/autoapi/bittensor_wallet/utils/index.html index f31f13085a..5d34b2057e 100644 --- a/static/btwallet-api/html/autoapi/bittensor_wallet/utils/index.html +++ b/static/btwallet-api/html/autoapi/bittensor_wallet/utils/index.html @@ -8,7 +8,7 @@ - bittensor_wallet.utils — BTCLI Docs 1.0 documentation + bittensor_wallet.utils — Bittensor Wallet SDK Docs documentation @@ -28,9 +28,8 @@ - - - + + @@ -38,15 +37,14 @@ - - + + - - + @@ -138,8 +136,8 @@ - BTCLI Docs 1.0 documentation - Home - + Bittensor Wallet SDK Docs  documentation - Home +
@@ -156,21 +154,16 @@

@@ -407,57 +392,86 @@

Contents

-
-

bittensor_wallet.utils#

-
-

Attributes#

-
+
+

bittensor_wallet.utils#

+
- - + + - - + + - - + + - - - - - + +

get_ss58_format

get_ss58_format(ss58_address)

Returns the SS58 format of the given address string.

is_valid_ss58_address

is_valid_bittensor_address_or_public_key(address)

Checks if the given address is a valid destination address.

is_valid_ed25519_pubkey

is_valid_ed25519_pubkey(public_key)

Checks if the given public_key is a valid ed25519 key.

is_valid_bittensor_address_or_public_key

SS58_FORMAT

is_valid_ss58_address(address)

Checks if the given address is a valid ss58 address.

-
-
-

Package Contents#

-
-
-bittensor_wallet.utils.get_ss58_format#
-
- -
-
-bittensor_wallet.utils.is_valid_ss58_address#
-
- -
-
-bittensor_wallet.utils.is_valid_ed25519_pubkey#
-
- -
-
-bittensor_wallet.utils.is_valid_bittensor_address_or_public_key#
-
- -
-
-bittensor_wallet.utils.SS58_FORMAT#
-
+
+

Module Contents#

+

Functions Details

+
+
+bittensor_wallet.utils.get_ss58_format(ss58_address)
+

Returns the SS58 format of the given address string.

+
+
Parameters:
+

ss58_address (str) – The SS58 address to extract the format from.

+
+
Returns:
+

The SS58 format number.

+
+
+
+ +
+
+bittensor_wallet.utils.is_valid_bittensor_address_or_public_key(address)
+

Checks if the given address is a valid destination address.

+
+
Parameters:
+

address (str) – The address to check.

+
+
Returns:
+

True if the address is a valid destination address, False otherwise.

+
+
+
+ +
+
+bittensor_wallet.utils.is_valid_ed25519_pubkey(public_key)
+

Checks if the given public_key is a valid ed25519 key.

+
+
Parameters:
+

public_key (bytes) – The public_key to check as bytes.

+
+
Returns:
+

True if the public_key is a valid ed25519 key, False otherwise.

+
+
Return type:
+

valid (bool)

+
+
+
+ +
+
+bittensor_wallet.utils.is_valid_ss58_address(address)
+

Checks if the given address is a valid ss58 address.

+
+
Parameters:
+

address (str) – The address to check.

+
+
Returns:
+

True if the address is a valid ss58 address for Bittensor, False otherwise.

+
+
+
@@ -474,23 +488,14 @@

Package Contents

previous

-

bittensor_wallet.keyfile

+

bittensor_wallet.errors

- -
-

next

-

bittensor_wallet.wallet

-
- -
@@ -507,15 +512,7 @@

Package Contents @@ -540,7 +537,7 @@

Package Contents - © Copyright 2024, Opentensor Foundation. + © Copyright 2025, Opentensor Foundation.

diff --git a/static/btwallet-api/html/autoapi/bittensor_wallet/wallet/index.html b/static/btwallet-api/html/autoapi/bittensor_wallet/wallet/index.html index 91c22bc624..9c13d56e64 100644 --- a/static/btwallet-api/html/autoapi/bittensor_wallet/wallet/index.html +++ b/static/btwallet-api/html/autoapi/bittensor_wallet/wallet/index.html @@ -8,7 +8,7 @@ - bittensor_wallet.wallet — BTCLI Docs 1.0 documentation + bittensor_wallet.wallet — Bittensor Wallet SDK Docs documentation @@ -28,9 +28,8 @@ - - - + + @@ -38,14 +37,15 @@ - - + + - + + @@ -137,8 +137,8 @@ - BTCLI Docs 1.0 documentation - Home - + Bittensor Wallet SDK Docs  documentation - Home +
@@ -155,21 +155,16 @@

@@ -403,34 +393,540 @@

Contents

-
-

bittensor_wallet.wallet#

-
-

Attributes#

-
+
+

bittensor_wallet.wallet#

+
- - + + - +

display_mnemonic_msg

display_mnemonic_msg(mnemonic, key_type)

Display the mnemonic and a warning message to keep the mnemonic safe.

Wallet

Wallet([name, hotkey, path, config])

-
-
-

Package Contents#

-
-
-bittensor_wallet.wallet.display_mnemonic_msg#
+
+

Module Contents#

+

Functions Details

+
+
+bittensor_wallet.wallet.display_mnemonic_msg(mnemonic, key_type)
+

Display the mnemonic and a warning message to keep the mnemonic safe.

+
+
Parameters:
+
    +
  • mnemonic (str) – The mnemonic phrase to display.

  • +
  • key_type (str) – The type of key e.g. “coldkey” or “hotkey”.

  • +
+
+
+
+ +

Classes Details

+
+
+class bittensor_wallet.wallet.Wallet(name=None, hotkey=None, path=None, config=None)
+

Bases: object

+
+
+classmethod add_args(parser, prefix=None)
+

Accept specific arguments from parser.

+
+ +
+
+coldkey
+
+ +
+
+coldkey_file
+

Returns the coldkey file.

+
+ +
+
+coldkeypub
+
+ +
+
+coldkeypub_file
+

Returns the coldkeypub file.

+
+ +
+
+create(coldkey_use_password=True, hotkey_use_password=False, save_coldkey_to_env=False, save_hotkey_to_env=False, coldkey_password=None, hotkey_password=None, overwrite=False, suppress=False)
+

Checks for existing coldkeypub and hotkeys, and creates them if non-existent.

+
+
Parameters:
+
    +
  • coldkey_use_password (bool) – Whether to use a password for coldkey. Defaults to True.

  • +
  • hotkey_use_password (bool) – Whether to use a password for hotkey. Defaults to False.

  • +
  • save_coldkey_to_env (bool) – Whether to save a coldkey password to local env. Defaults to False.

  • +
  • save_hotkey_to_env (bool) – Whether to save a hotkey password to local env. Defaults to False.

  • +
  • coldkey_password (Optional[str]) – Coldkey password for encryption. Defaults to None. If coldkey_password is passed, then coldkey_use_password is automatically True.

  • +
  • hotkey_password (Optional[str]) – Hotkey password for encryption. Defaults to None. If hotkey_password is passed, then hotkey_use_password is automatically True.

  • +
  • overwrite (bool) – Whether to overwrite an existing keys. Defaults to False.

  • +
  • suppress (bool) – If True, suppresses the display of the keys mnemonic message. Defaults to False.

  • +
+
+
Returns:
+

Wallet instance with created keys.

+
+
Raises:
+

WalletError – If key generation or file operations fail.

+
+
+
+ +
+
+create_coldkey_from_uri(uri, use_password=False, overwrite=False, suppress=True, save_coldkey_to_env=False, coldkey_password=None)
+

Creates coldkey from uri string, optionally encrypts it with the user-provided password.

+
+
Parameters:
+
    +
  • uri (str) – The URI string to create the coldkey from.

  • +
  • use_password (bool) – Whether to use a password for coldkey. Defaults to False.

  • +
  • overwrite (bool) – Whether to overwrite existing keys. Defaults to False.

  • +
  • suppress (bool) – Whether to suppress mnemonic display. Defaults to True.

  • +
  • save_coldkey_to_env (bool) – Whether to save coldkey password to local env. Defaults to False.

  • +
  • coldkey_password (Optional[str]) – Coldkey password for encryption. Defaults to None.

  • +
+
+
Returns:
+

Wallet - The wallet instance with created coldkey.

+
+
Raises:
+

KeyFileError – If key creation or file operations fail.

+
+
+
+ +
+
+create_hotkey_from_uri(uri, use_password=False, overwrite=False, suppress=True, save_hotkey_to_env=False, hotkey_password=None)
+

Creates hotkey from uri string, optionally encrypts it with the user-provided password.

+
+
Parameters:
+
    +
  • uri (str) – The URI string to create the hotkey from.

  • +
  • use_password (bool) – Whether to use a password for hotkey. Defaults to False.

  • +
  • overwrite (bool) – Whether to overwrite existing keys. Defaults to False.

  • +
  • suppress (bool) – Whether to suppress mnemonic display. Defaults to True.

  • +
  • save_hotkey_to_env (bool) – Whether to save hotkey password to local env. Defaults to False.

  • +
  • hotkey_password (Optional[str]) – Hotkey password for encryption. Defaults to None.

  • +
+
+
Returns:
+

Wallet - The wallet instance with created hotkey.

+
+
Raises:
+

KeyFileError – If key creation or file operations fail.

+
+
+
+ +
+
+create_if_non_existent(coldkey_use_password=Ellipsis, hotkey_use_password=Ellipsis, save_coldkey_to_env=Ellipsis, save_hotkey_to_env=Ellipsis, coldkey_password=None, hotkey_password=None, overwrite=Ellipsis, suppress=Ellipsis)
+

Checks for existing coldkeypub, hotkeypub, hotkeys, and creates them if non-existent.

+
+
Parameters:
+
    +
  • coldkey_use_password (bool) – Whether to use a password for coldkey. Defaults to True.

  • +
  • hotkey_use_password (bool) – Whether to use a password for hotkey. Defaults to False.

  • +
  • save_coldkey_to_env (bool) – Whether to save a coldkey password to local env. Defaults to False.

  • +
  • save_hotkey_to_env (bool) – Whether to save a hotkey password to local env. Defaults to False.

  • +
  • coldkey_password (Optional[str]) – Coldkey password for encryption. Defaults to None. If coldkey_password is passed, then coldkey_use_password is automatically True.

  • +
  • hotkey_password (Optional[str]) – Hotkey password for encryption. Defaults to None. If hotkey_password is passed, then hotkey_use_password is automatically True.

  • +
  • overwrite (bool) – Whether to overwrite an existing keys. Defaults to False.

  • +
  • suppress (bool) – If True, suppresses the display of the keys mnemonic message. Defaults to False.

  • +
+
+
Returns:
+

Wallet - The wallet instance with created keys.

+
+
Raises:
+

WalletError – If key generation or file operations fail.

+
+
+
+ +
+
+create_new_coldkey(n_words=Ellipsis, use_password=None, overwrite=None, suppress=None, save_coldkey_to_env=None, coldkey_password=None)
+
+ +
+
+create_new_hotkey(n_words=Ellipsis, use_password=None, overwrite=None, suppress=None, save_hotkey_to_env=None, hotkey_password=None)
+

Creates a new hotkey, optionally encrypts it with the user-provided password and saves to disk.

+
+
Parameters:
+
    +
  • n_words (int) – The number of words in the mnemonic. Defaults to 12.

  • +
  • use_password (bool) – Whether to use a password for hotkey. Defaults to False.

  • +
  • overwrite (bool) – Whether to overwrite existing keys. Defaults to False.

  • +
  • suppress (bool) – Whether to suppress mnemonic display. Defaults to False.

  • +
  • save_hotkey_to_env (bool) – Whether to save hotkey password to local env. Defaults to False.

  • +
  • hotkey_password (Optional[str]) – Hotkey password for encryption. Defaults to None. If hotkey_password is passed, then use_password is automatically True.

  • +
+
+
Returns:
+

Wallet - The wallet instance with created hotkey.

+
+
Raises:
+

WalletError – If key generation or file operations fail.

+
+
+
+ +
+
+debug_string()
-
-
-bittensor_wallet.wallet.Wallet#
+
+
+get_coldkey(password=None)
+

Gets the coldkey from the wallet.

+
+
Parameters:
+

password (Optional[str]) – Password for decryption. Defaults to None. If not provided, asks for user input.

+
+
Returns:
+

Keypair - The coldkey keypair.

+
+
Raises:
+

KeyFileError – If the coldkey file doesn’t exist or decryption fails.

+
+
+
+ +
+
+get_coldkeypub(password=None)
+

Gets the coldkeypub from the wallet.

+
+
Parameters:
+

password (Optional[str]) – Password for decryption. Defaults to None. If not provided, asks for user input.

+
+
Returns:
+

Keypair - The coldkeypub keypair.

+
+
Raises:
+

KeyFileError – If the coldkeypub file doesn’t exist or decryption fails.

+
+
+
+ +
+
+get_hotkey(password=None)
+

Gets the hotkey from the wallet.

+
+
Parameters:
+

password (Optional[str]) – Password for decryption. Defaults to None. If not provided, asks for user input.

+
+
Returns:
+

Keypair - The hotkey keypair.

+
+
Raises:
+

KeyFileError – If the hotkey file doesn’t exist or decryption fails.

+
+
+
+ +
+
+get_hotkeypub(password=None)
+

Gets the hotkeypub from the wallet.

+
+
Parameters:
+

password (Optional[str]) – Password for decryption. Defaults to None. If not provided, asks for user input.

+
+
Returns:
+

Keypair - The hotkeypub keypair.

+
+
Raises:
+

KeyFileError – If the hotkeypub file doesn’t exist or decryption fails.

+
+
+
+ +
+
+hotkey
+

Returns the hotkey name.

+
+ +
+
+hotkey_file
+

Returns the hotkey file.

+
+ +
+
+hotkey_str
+
+
+hotkeypub
+
+ +
+
+hotkeypub_file
+

Returns the hotkeypub file.

+
+ +
+
+name
+

Returns the wallet name.

+
+ +
+
+path
+

Returns the wallet path.

+
+ +
+
+recreate(coldkey_use_password=Ellipsis, hotkey_use_password=Ellipsis, save_coldkey_to_env=Ellipsis, save_hotkey_to_env=Ellipsis, coldkey_password=None, hotkey_password=None, overwrite=Ellipsis, suppress=Ellipsis)
+

Checks for existing coldkeypub and hotkeys, and recreates them if non-existent.

+
+
Parameters:
+
    +
  • coldkey_use_password (bool) – Whether to use a password for coldkey. Defaults to True.

  • +
  • hotkey_use_password (bool) – Whether to use a password for hotkey. Defaults to False.

  • +
  • save_coldkey_to_env (bool) – Whether to save a coldkey password to local env. Defaults to False.

  • +
  • save_hotkey_to_env (bool) – Whether to save a hotkey password to local env. Defaults to False.

  • +
  • coldkey_password (Optional[str]) – Coldkey password for encryption. Defaults to None. If coldkey_password is passed, then coldkey_use_password is automatically True.

  • +
  • hotkey_password (Optional[str]) – Hotkey password for encryption. Defaults to None. If hotkey_password is passed, then hotkey_use_password is automatically True.

  • +
  • overwrite (bool) – Whether to overwrite an existing keys. Defaults to False.

  • +
  • suppress (bool) – If True, suppresses the display of the keys mnemonic message. Defaults to False.

  • +
+
+
Returns:
+

Wallet instance with created keys.

+
+
Raises:
+

WalletError – If key generation or file operations fail.

+
+
+
+ +
+
+regenerate_coldkey(mnemonic=None, seed=None, json=None, use_password=True, overwrite=False, suppress=False, save_coldkey_to_env=False, coldkey_password=None)
+

Regenerates the coldkey from the passed mnemonic or seed, or JSON encrypts it with the user’s password and saves the file.

+
+
Parameters:
+
    +
  • mnemonic (Optional[str]) – Mnemonic phrase to regenerate the coldkey from. Defaults to None.

  • +
  • seed (Optional[str]) – Seed hex to regenerate the coldkey from. Defaults to None.

  • +
  • json (Optional[tuple]) – Tuple of (JSON data, passphrase) to regenerate the coldkey from. Defaults to None.

  • +
  • use_password (bool) – Whether to use a password for coldkey. Defaults to True.

  • +
  • overwrite (bool) – Whether to overwrite existing keys. Defaults to False.

  • +
  • suppress (bool) – Whether to suppress mnemonic display. Defaults to False.

  • +
  • save_coldkey_to_env (bool) – Whether to save coldkey password to local env. Defaults to False.

  • +
  • coldkey_password (Optional[str]) – Coldkey password for encryption. Defaults to None.

  • +
+
+
Returns:
+

Wallet - The wallet instance with regenerated coldkey.

+
+
Raises:
+

WalletError – If key generation or file operations fail.

+
+
+
+ +
+
+regenerate_coldkeypub(ss58_address=None, public_key=None, overwrite=None)
+

Regenerates the coldkeypub from the passed ss58_address or public_key and saves the file. +Requires either ss58_address or public_key to be passed.

+
+
Parameters:
+
    +
  • ss58_address (Optional[str]) – SS58 address to regenerate the coldkeypub from. Defaults to None.

  • +
  • public_key (Optional[str]) – Public key hex to regenerate the coldkeypub from. Defaults to None.

  • +
  • overwrite (bool) – Whether to overwrite existing keys. Defaults to False.

  • +
+
+
Returns:
+

Wallet - The wallet instance with regenerated coldkeypub.

+
+
Raises:
+

WalletError – If key generation or file operations fail.

+
+
+
+ +
+
+regenerate_hotkey(mnemonic=None, seed=None, json=None, use_password=False, overwrite=False, suppress=False, save_hotkey_to_env=False, hotkey_password=None)
+

Regenerates the hotkey from passed mnemonic or seed, encrypts it with the user’s password and saves the file.

+
+
Parameters:
+
    +
  • mnemonic (Optional[str]) – Mnemonic phrase to regenerate the hotkey from. Defaults to None.

  • +
  • seed (Optional[str]) – Seed hex to regenerate the hotkey from. Defaults to None.

  • +
  • json (Optional[tuple]) – Tuple of (JSON data, passphrase) to regenerate the hotkey from. Defaults to None.

  • +
  • use_password (bool) – Whether to use a password for hotkey. Defaults to False.

  • +
  • overwrite (bool) – Whether to overwrite existing keys. Defaults to False.

  • +
  • suppress (bool) – Whether to suppress mnemonic display. Defaults to False.

  • +
  • save_hotkey_to_env (bool) – Whether to save hotkey password to local env. Defaults to False.

  • +
  • hotkey_password (Optional[str]) – Hotkey password for encryption. Defaults to None.

  • +
+
+
Returns:
+

Wallet - The wallet instance with regenerated hotkey.

+
+
Raises:
+

KeyFileError – If key generation or file operations fail.

+
+
+
+ +
+
+regenerate_hotkeypub(ss58_address=None, public_key=None, overwrite=None)
+

Regenerates the hotkeypub from the passed ss58_address or public_key and saves the file. +Requires either ss58_address or public_key to be passed.

+
+
Parameters:
+
    +
  • ss58_address (Optional[str]) – SS58 address to regenerate the hotkeypub from. Defaults to None.

  • +
  • public_key (Optional[str]) – Public key hex to regenerate the hotkeypub from. Defaults to None.

  • +
  • overwrite (bool) – Whether to overwrite existing keys. Defaults to False.

  • +
+
+
Returns:
+

Wallet - The wallet instance with regenerated hotkeypub.

+
+
Raises:
+

WalletError – If key generation or file operations fail.

+
+
+
+ +
+
+set_coldkey(keypair, encrypt=True, overwrite=False, save_coldkey_to_env=False, coldkey_password=None)
+

Sets the coldkey for the wallet.

+
+
Parameters:
+
    +
  • keypair (Keypair) – The keypair to set as coldkey.

  • +
  • encrypt (bool) – Whether to encrypt the key. Defaults to True.

  • +
  • overwrite (bool) – Whether to overwrite if key exists. Defaults to False.

  • +
  • save_coldkey_to_env (bool) – Whether to save coldkey password to local env. Defaults to False.

  • +
  • coldkey_password (Optional[str]) – Coldkey password for encryption. Defaults to None.

  • +
+
+
Raises:
+

KeyFileError – If file operations fail.

+
+
+
+ +
+
+set_coldkeypub(keypair, encrypt=False, overwrite=False)
+

Sets the coldkeypub for the wallet.

+
+
Parameters:
+
    +
  • keypair (Keypair) – The keypair to set as coldkeypub.

  • +
  • encrypt (bool) – Whether to encrypt the key. Defaults to False.

  • +
  • overwrite (bool) – Whether to overwrite if key exists. Defaults to False.

  • +
+
+
Raises:
+

KeyFileError – If file operations fail.

+
+
+
+ +
+
+set_hotkey(keypair, encrypt=False, overwrite=False, save_hotkey_to_env=False, hotkey_password=None)
+

Sets the hotkey for the wallet.

+
+
Parameters:
+
    +
  • keypair (Keypair) – The keypair to set as hotkey.

  • +
  • encrypt (bool) – Whether to encrypt the key. Defaults to False.

  • +
  • overwrite (bool) – Whether to overwrite if key exists. Defaults to False.

  • +
  • save_hotkey_to_env (bool) – Whether to save hotkey password to local env. Defaults to False.

  • +
  • hotkey_password (Optional[str]) – Hotkey password for encryption. Defaults to None.

  • +
+
+
Raises:
+

KeyFileError – If file operations fail.

+
+
+
+ +
+
+set_hotkeypub(keypair, encrypt=False, overwrite=False)
+

Sets the hotkeypub for the wallet.

+
+
Parameters:
+
    +
  • keypair (Keypair) – The keypair to set as hotkeypub.

  • +
  • encrypt (bool) – Whether to encrypt the key. Defaults to False.

  • +
  • overwrite (bool) – Whether to overwrite if key exists. Defaults to False.

  • +
+
+
Raises:
+

KeyFileError – If file operations fail.

+
+
+
+ +
+
+to_string()
+
+ +
+
+unlock_coldkey()
+

Unlocks the coldkey.

+
+ +
+
+unlock_coldkeypub()
+

Unlocks the coldkeypub.

+
+ +
+
+unlock_hotkey()
+

Unlocks the hotkey.

+
+ +
+
+unlock_hotkeypub()
+

Unlocks the hotkeypub.

+
+ +
+
@@ -446,14 +942,23 @@

Package Contents

previous

-

bittensor_wallet.utils

+

bittensor_wallet

+ +
+

next

+

bittensor_wallet.keyfile

+
+ +
@@ -470,12 +975,7 @@

Package Contents @@ -500,7 +1000,7 @@

Package Contents - © Copyright 2024, Opentensor Foundation. + © Copyright 2025, Opentensor Foundation.

diff --git a/static/btwallet-api/html/autoapi/btwallet/config/index.html b/static/btwallet-api/html/autoapi/btwallet/config/index.html deleted file mode 100644 index 5bd9e91713..0000000000 --- a/static/btwallet-api/html/autoapi/btwallet/config/index.html +++ /dev/null @@ -1,965 +0,0 @@ - - - - - - - - - - - btwallet.config — BTCLI Docs 1.0 documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - -
-
-
-
-
- -
- -
- - - - - -
-
- - - -
- - - - - - - - - - - - - -
- -
- - - -
- -
-
- -
-
- -
- -
- -
- - -
- -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- -
-
- - - - - - - - -
- -
-

btwallet.config#

-

Implementation of the config class, which manages the configuration of different Bittensor modules.

-
-

Attributes#

-
- - - - - -

T

-
-
-
-

Exceptions#

-
- - - - - -

InvalidConfigFile

In place of YAMLError

-
-
-
-

Classes#

-
- - - - - - - - -

Config

Implementation of the config class, which manages the configuration of different Bittensor modules.

DefaultConfig

A Config with a set of default values.

-
-
-
-

Module Contents#

-
-
-exception btwallet.config.InvalidConfigFile#
-

Bases: Exception

-

In place of YAMLError

-

Initialize self. See help(type(self)) for accurate signature.

-
- -
-
-class btwallet.config.Config(parser=None, args=None, strict=False, default=None)#
-

Bases: munch.DefaultMunch

-

Implementation of the config class, which manages the configuration of different Bittensor modules.

-

Construct a new DefaultMunch. Like collections.defaultdict, the -first argument is the default value; subsequent arguments are the -same as those for dict.

-
-
Parameters:
-
-
-
-
-
-__is_set: Dict[str, bool]#
-

Translates the passed parser into a nested Bittensor config.

-
-
Parameters:
-
    -
  • parser (argparse.ArgumentParser) – Command line parser object.

  • -
  • strict (bool) – If true, the command line arguments are strictly parsed.

  • -
  • args (list of str) – Command line arguments.

  • -
  • default (Optional[Any]) – Default value for the Config. Defaults to None. -This default will be returned for attributes that are undefined.

  • -
-
-
Returns:
-

Nested config object created from parser arguments.

-
-
Return type:
-

config (Config)

-
-
-
- -
-
-missing_required_args#
-
- -
-
-config_params#
-
- -
-
-strict#
-
- -
-
-params#
-
- -
-
-_config#
-
- -
-
-parser_no_defaults#
-
- -
-
-default_param_args#
-
- -
-
-default_params#
-
- -
-
-all_default_args#
-
- -
-
-defaults_as_suppress#
-
- -
-
-params_no_defaults#
-
- -
-
-static __split_params__(params, _config)#
-
-
Parameters:
-
-
-
-
- -
-
-static __parse_args__(args, parser=None, strict=False)#
-

Parses the passed args use the passed parser.

-
-
Parameters:
-
    -
  • args (List[str]) – List of arguments to parse.

  • -
  • parser (argparse.ArgumentParser) – Command line parser object.

  • -
  • strict (bool) – If true, the command line arguments are strictly parsed.

  • -
-
-
Returns:
-

Namespace object created from parser arguments.

-
-
Return type:
-

Namespace

-
-
-
- -
-
-__deepcopy__(memo)#
-
-
Return type:
-

Config

-
-
-
- -
-
-__repr__()#
-

Invertible* string-form of a Munch.

-
>>> b = Munch(foo=Munch(lol=True), hello=42, ponies='are pretty!')
->>> print (repr(b))
-Munch({'ponies': 'are pretty!', 'foo': Munch({'lol': True}), 'hello': 42})
->>> eval(repr(b))
-Munch({'ponies': 'are pretty!', 'foo': Munch({'lol': True}), 'hello': 42})
-
-
-
>>> with_spaces = Munch({1: 2, 'a b': 9, 'c': Munch({'simple': 5})})
->>> print (repr(with_spaces))
-Munch({'a b': 9, 1: 2, 'c': Munch({'simple': 5})})
->>> eval(repr(with_spaces))
-Munch({'a b': 9, 1: 2, 'c': Munch({'simple': 5})})
-
-
-

(*) Invertible so long as collection contents are each repr-invertible.

-
-
Return type:
-

str

-
-
-
- -
-
-static _remove_private_keys(d)#
-
- -
-
-__str__()#
-

Return str(self).

-
-
Return type:
-

str

-
-
-
- -
-
-copy()#
-

D.copy() -> a shallow copy of D

-
-
Return type:
-

Config

-
-
-
- -
-
-to_string(items)#
-

Get string from items

-
-
Return type:
-

str

-
-
-
- -
-
-update_with_kwargs(kwargs)#
-

Add config to self

-
- -
-
-classmethod _merge(a, b)#
-

Merge two configurations recursively. -If there is a conflict, the value from the second configuration will take precedence.

-
- -
-
-merge(b)#
-

Merges the current config with another config.

-
-
Parameters:
-

b – Another config to merge.

-
-
-
- -
-
-classmethod merge_all(configs)#
-

Merge all configs in the list into one config. -If there is a conflict, the value from the last configuration in the list will take precedence.

-
-
Parameters:
-

configs (list of config) – List of configs to be merged.

-
-
Returns:
-

Merged config object.

-
-
Return type:
-

config

-
-
-
- -
-
-is_set(param_name)#
-

Returns a boolean indicating whether the parameter has been set or is still the default.

-
-
Parameters:
-

param_name (str)

-
-
Return type:
-

bool

-
-
-
- -
-
-__check_for_missing_required_args(parser, args)#
-
-
Parameters:
-
-
-
Return type:
-

List[str]

-
-
-
- -
-
-static __get_required_args_from_parser(parser)#
-
-
Parameters:
-

parser (argparse.ArgumentParser)

-
-
Return type:
-

List[str]

-
-
-
- -
- -
-
-btwallet.config.T#
-
- -
-
-class btwallet.config.DefaultConfig(parser=None, args=None, strict=False, default=None)#
-

Bases: Config

-

A Config with a set of default values.

-

Construct a new DefaultMunch. Like collections.defaultdict, the -first argument is the default value; subsequent arguments are the -same as those for dict.

-
-
Parameters:
-
-
-
-
-
-classmethod default()#
-
-
Abstractmethod:
-

-
Return type:
-

T

-
-
-

Get default config.

-
- -
- -
-
- - -
- - - - - - - - -
- - - - - - -
-
- - -
- - -
-
-
- - - - - -
-
- - \ No newline at end of file diff --git a/static/btwallet-api/html/autoapi/btwallet/index.html b/static/btwallet-api/html/autoapi/btwallet/index.html deleted file mode 100644 index f5284253e2..0000000000 --- a/static/btwallet-api/html/autoapi/btwallet/index.html +++ /dev/null @@ -1,547 +0,0 @@ - - - - - - - - - - - btwallet — BTCLI Docs 1.0 documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - -
-
-
-
-
- -
- -
- - - - - -
-
- - - -
- - - - - - - - - - - - - -
- -
- - - -
- -
-
- -
-
- -
- -
- -
- - -
- -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- -
-
- - - -
-

btwallet

- -
-
- -
-

Contents

-
- -
-
-
- - - - - - - - - - - - - -
- - - -
- - -
-
- - -
- - -
-
-
- - - - - -
-
- - \ No newline at end of file diff --git a/static/btwallet-api/html/autoapi/btwallet/keyfile/index.html b/static/btwallet-api/html/autoapi/btwallet/keyfile/index.html deleted file mode 100644 index 6fc32099a8..0000000000 --- a/static/btwallet-api/html/autoapi/btwallet/keyfile/index.html +++ /dev/null @@ -1,1201 +0,0 @@ - - - - - - - - - - - btwallet.keyfile — BTCLI Docs 1.0 documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - -
-
-
-
-
- -
- -
- - - - - -
-
- - - -
- - - - - - - - - - - - - -
- -
- - - -
- -
-
- -
-
- -
- -
- -
- - -
- -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- -
-
- - - - - - - - -
- -
-

btwallet.keyfile#

-
-

Attributes#

-
- - - - - - - - -

NACL_SALT

console

-
-
-
-

Classes#

-
- - - - - -

Keyfile

Defines an interface for a substrate interface keypair stored on device.

-
-
-
-

Functions#

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

serialized_keypair_to_keyfile_data(keypair)

Serializes keypair object into keyfile data.

deserialize_keypair_from_keyfile_data(keyfile_data)

Deserializes Keypair object from passed keyfile data.

validate_password(password)

Validates the password against a password policy.

ask_password_to_encrypt()

Prompts the user to enter a password for key encryption.

keyfile_data_is_encrypted_nacl(keyfile_data)

Returns true if the keyfile data is NaCl encrypted.

keyfile_data_is_encrypted_ansible(keyfile_data)

Returns true if the keyfile data is ansible encrypted.

keyfile_data_is_encrypted_legacy(keyfile_data)

Returns true if the keyfile data is legacy encrypted.

keyfile_data_is_encrypted(keyfile_data)

Returns true if the keyfile data is encrypted.

keyfile_data_encryption_method(keyfile_data)

Returns type of encryption method as a string.

legacy_encrypt_keyfile_data(keyfile_data[, password])

encrypt_keyfile_data(keyfile_data[, password])

Encrypts the passed keyfile data using ansible vault.

get_coldkey_password_from_environment(coldkey_name)

Retrieves the cold key password from the environment variables.

decrypt_keyfile_data(keyfile_data[, password, ...])

Decrypts the passed keyfile data using ansible vault.

-
-
-
-

Module Contents#

-
-
-btwallet.keyfile.NACL_SALT = b'\x13q\x83\xdf\xf1Z\t\xbc\x9c\x90\xb5Q\x879\xe9\xb1'#
-
- -
-
-btwallet.keyfile.console#
-
- -
-
-btwallet.keyfile.serialized_keypair_to_keyfile_data(keypair)#
-

Serializes keypair object into keyfile data.

-
-
Parameters:
-

keypair (Keypair) – The keypair object to be serialized.

-
-
Returns:
-

Serialized keypair data.

-
-
Return type:
-

data (bytes)

-
-
-
- -
-
-btwallet.keyfile.deserialize_keypair_from_keyfile_data(keyfile_data)#
-

Deserializes Keypair object from passed keyfile data.

-
-
Parameters:
-

keyfile_data (bytes) – The keyfile data as bytes to be loaded.

-
-
Returns:
-

The Keypair loaded from bytes.

-
-
Return type:
-

keypair (Keypair)

-
-
Raises:
-

KeyFileError – Raised if the passed bytes cannot construct a keypair object.

-
-
-
- -
-
-btwallet.keyfile.validate_password(password)#
-

Validates the password against a password policy.

-
-
Parameters:
-

password (str) – The password to verify.

-
-
Returns:
-

True if the password meets validity requirements.

-
-
Return type:
-

valid (bool)

-
-
-
- -
-
-btwallet.keyfile.ask_password_to_encrypt()#
-

Prompts the user to enter a password for key encryption.

-
-
Returns:
-

The valid password entered by the user.

-
-
Return type:
-

password (str)

-
-
-
- -
-
-btwallet.keyfile.keyfile_data_is_encrypted_nacl(keyfile_data)#
-

Returns true if the keyfile data is NaCl encrypted.

-
-
Parameters:
-

keyfile_data (bytes, required) – Bytes to validate.

-
-
Returns:
-

True if data is ansible encrypted.

-
-
Return type:
-

is_nacl (bool)

-
-
-
- -
-
-btwallet.keyfile.keyfile_data_is_encrypted_ansible(keyfile_data)#
-

Returns true if the keyfile data is ansible encrypted.

-
-
Parameters:
-

keyfile_data (bytes) – The bytes to validate.

-
-
Returns:
-

True if the data is ansible encrypted.

-
-
Return type:
-

is_ansible (bool)

-
-
-
- -
-
-btwallet.keyfile.keyfile_data_is_encrypted_legacy(keyfile_data)#
-

Returns true if the keyfile data is legacy encrypted. -:param keyfile_data: The bytes to validate. -:type keyfile_data: bytes

-
-
Returns:
-

True if the data is legacy encrypted.

-
-
Return type:
-

is_legacy (bool)

-
-
Parameters:
-

keyfile_data (bytes)

-
-
-
- -
-
-btwallet.keyfile.keyfile_data_is_encrypted(keyfile_data)#
-

Returns true if the keyfile data is encrypted.

-
-
Parameters:
-

keyfile_data (bytes) – The bytes to validate.

-
-
Returns:
-

True if the data is encrypted.

-
-
Return type:
-

is_encrypted (bool)

-
-
-
- -
-
-btwallet.keyfile.keyfile_data_encryption_method(keyfile_data)#
-

Returns type of encryption method as a string.

-
-
Parameters:
-

keyfile_data (bytes, required) – Bytes to validate

-
-
Returns:
-

returns the name of encryption method.

-
-
Return type:
-

encryption_method (str)

-
-
-
- -
-
-btwallet.keyfile.legacy_encrypt_keyfile_data(keyfile_data, password=None)#
-
-
Parameters:
-
    -
  • keyfile_data (bytes)

  • -
  • password (Optional[str])

  • -
-
-
Return type:
-

bytes

-
-
-
- -
-
-btwallet.keyfile.encrypt_keyfile_data(keyfile_data, password=None)#
-

Encrypts the passed keyfile data using ansible vault.

-
-
Parameters:
-
    -
  • keyfile_data (bytes) – The bytes to encrypt.

  • -
  • password (str, optional) – The password used to encrypt the data. If None, asks for user input.

  • -
-
-
Returns:
-

The encrypted data.

-
-
Return type:
-

encrypted_data (bytes)

-
-
-
- -
-
-btwallet.keyfile.get_coldkey_password_from_environment(coldkey_name)#
-

Retrieves the cold key password from the environment variables.

-
-
Parameters:
-

coldkey_name (str) – The name of the cold key.

-
-
Returns:
-

The password retrieved from the environment variables, or None if not found.

-
-
Return type:
-

password (str)

-
-
-
- -
-
-btwallet.keyfile.decrypt_keyfile_data(keyfile_data, password=None, coldkey_name=None)#
-

Decrypts the passed keyfile data using ansible vault.

-
-
Parameters:
-
    -
  • keyfile_data (bytes) – The bytes to decrypt.

  • -
  • password (str, optional) – The password used to decrypt the data. If None, asks for user input.

  • -
  • coldkey_name (str, optional) – The name of the cold key. If provided, retrieves the password from environment variables.

  • -
-
-
Returns:
-

The decrypted data.

-
-
Return type:
-

decrypted_data (bytes)

-
-
Raises:
-

KeyFileError – Raised if the file is corrupted or if the password is incorrect.

-
-
-
- -
-
-class btwallet.keyfile.Keyfile(path, name)#
-

Defines an interface for a substrate interface keypair stored on device.

-
-
Parameters:
-
-
-
-
-
-path#
-
- -
-
-name#
-
- -
-
-_name#
-
- -
-
-__str__()#
-
- -
-
-__repr__()#
-
- -
-
-property keypair: substrateinterface.Keypair#
-

Returns the keypair from path, decrypts data if the file is encrypted.

-
-
Returns:
-

The keypair stored under the path.

-
-
Return type:
-

keypair (Keypair)

-
-
Raises:
-

KeyFileError – Raised if the file does not exist, is not readable, writable, corrupted, or if the password is incorrect.

-
-
-
- -
-
-property data: bytes#
-

Returns the keyfile data under path.

-
-
Returns:
-

The keyfile data stored under the path.

-
-
Return type:
-

keyfile_data (bytes)

-
-
Raises:
-

KeyFileError – Raised if the file does not exist, is not readable, or writable.

-
-
-
- -
-
-property keyfile_data: bytes#
-

Returns the keyfile data under path.

-
-
Returns:
-

The keyfile data stored under the path.

-
-
Return type:
-

keyfile_data (bytes)

-
-
Raises:
-

KeyFileError – Raised if the file does not exist, is not readable, or writable.

-
-
-
- -
-
-set_keypair(keypair, encrypt=True, overwrite=False, password=None)#
-

Writes the keypair to the file and optionally encrypts data.

-
-
Parameters:
-
    -
  • keypair (Keypair) – The keypair to store under the path.

  • -
  • encrypt (bool, optional) – If True, encrypts the file under the path. Default is True.

  • -
  • overwrite (bool, optional) – If True, forces overwrite of the current file. Default is False.

  • -
  • password (str, optional) – The password used to encrypt the file. If None, asks for user input.

  • -
-
-
Raises:
-

KeyFileError – Raised if the file does not exist, is not readable, writable, or if the password is incorrect.

-
-
-
- -
-
-get_keypair(password=None)#
-

Returns the keypair from the path, decrypts data if the file is encrypted.

-
-
Parameters:
-

password (str, optional) – The password used to decrypt the file. If None, asks for user input.

-
-
Returns:
-

The keypair stored under the path.

-
-
Return type:
-

keypair (Keypair)

-
-
Raises:
-

KeyFileError – Raised if the file does not exist, is not readable, writable, corrupted, or if the password is incorrect.

-
-
-
- -
-
-make_dirs()#
-

Creates directories for the path if they do not exist.

-
- -
-
-exists_on_device()#
-

Returns True if the file exists on the device.

-
-
Returns:
-

True if the file is on the device.

-
-
Return type:
-

on_device (bool)

-
-
-
- -
-
-is_readable()#
-

Returns True if the file under path is readable.

-
-
Returns:
-

True if the file is readable.

-
-
Return type:
-

readable (bool)

-
-
-
- -
-
-is_writable()#
-

Returns True if the file under path is writable.

-
-
Returns:
-

True if the file is writable.

-
-
Return type:
-

writable (bool)

-
-
-
- -
-
-is_encrypted()#
-

Returns True if the file under path is encrypted.

-
-
Returns:
-

True if the file is encrypted.

-
-
Return type:
-

encrypted (bool)

-
-
-
- -
-
-_may_overwrite()#
-

Asks the user if it is okay to overwrite the file.

-
-
Returns:
-

True if the user allows overwriting the file.

-
-
Return type:
-

may_overwrite (bool)

-
-
-
- -
-
-check_and_update_encryption(print_result=True, no_prompt=False)#
-

Check the version of keyfile and update if needed.

-
-
Parameters:
-
    -
  • print_result (bool) – Print the checking result or not.

  • -
  • no_prompt (bool) – Skip if no prompt.

  • -
-
-
Raises:
-

KeyFileError – Raised if the file does not exist, is not readable, writable.

-
-
Returns:
-

Return True if the keyfile is the most updated with nacl, else False.

-
-
Return type:
-

result (bool)

-
-
-
- -
-
-encrypt(password=None)#
-

Encrypts the file under the path.

-
-
Parameters:
-

password (str, optional) – The password for encryption. If None, asks for user input.

-
-
Raises:
-

KeyFileError – Raised if the file does not exist, is not readable, or writable.

-
-
-
- -
-
-decrypt(password=None)#
-

Decrypts the file under the path.

-
-
Parameters:
-

password (str, optional) – The password for decryption. If None, asks for user input.

-
-
Raises:
-

KeyFileError – Raised if the file does not exist, is not readable, writable, corrupted, or if the password is incorrect.

-
-
-
- -
-
-_read_keyfile_data_from_file()#
-

Reads the keyfile data from the file.

-
-
Returns:
-

The keyfile data stored under the path.

-
-
Return type:
-

keyfile_data (bytes)

-
-
Raises:
-

KeyFileError – Raised if the file does not exist or is not readable.

-
-
-
- -
-
-_write_keyfile_data_to_file(keyfile_data, overwrite=False)#
-

Writes the keyfile data to the file.

-
-
Parameters:
-
    -
  • keyfile_data (bytes) – The byte data to store under the path.

  • -
  • overwrite (bool, optional) – If True, overwrites the data without asking for permission from the user. Default is False.

  • -
-
-
Raises:
-

KeyFileError – Raised if the file is not writable or the user responds No to the overwrite prompt.

-
-
-
- -
- -
-
- - -
- - - - - - - - -
- - - - - - -
-
- - -
- - -
-
-
- - - - - -
-
- - \ No newline at end of file diff --git a/static/btwallet-api/html/autoapi/btwallet/wallet/index.html b/static/btwallet-api/html/autoapi/btwallet/wallet/index.html deleted file mode 100644 index e1f44e5464..0000000000 --- a/static/btwallet-api/html/autoapi/btwallet/wallet/index.html +++ /dev/null @@ -1,1372 +0,0 @@ - - - - - - - - - - - btwallet.wallet — BTCLI Docs 1.0 documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - -
-
-
-
-
- -
- -
- - - - - -
-
- - - -
- - - - - - - - - - - - - -
- -
- - - -
- -
-
- -
-
- -
- -
- -
- - -
- -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- -
-
- - - - - - - - -
- -
-

btwallet.wallet#

-

Implementation of the wallet class, which manages balances with staking and transfer. Also manages hotkey and coldkey.

-
-

Attributes#

-
- - - - - - - - -

BT_WALLET_NAME

BT_WALLET_PATH

-
-
-
-

Classes#

-
- - - - - -

Wallet

The wallet class in the Bittensor framework handles wallet functionality, crucial for participating in the Bittensor network.

-
-
-
-

Functions#

-
- - - - - -

display_mnemonic_msg(keypair, key_type)

Display the mnemonic and a warning message to keep the mnemonic safe.

-
-
-
-

Module Contents#

-
-
-btwallet.wallet.BT_WALLET_NAME = 'default'#
-
- -
-
-btwallet.wallet.BT_WALLET_PATH = '~/.bittensor/wallets/'#
-
- -
-
-btwallet.wallet.display_mnemonic_msg(keypair, key_type)#
-

Display the mnemonic and a warning message to keep the mnemonic safe.

-
-
Parameters:
-
    -
  • keypair (Keypair) – Keypair object.

  • -
  • key_type (str) – Type of the key (coldkey or hotkey).

  • -
-
-
-
- -
-
-class btwallet.wallet.Wallet(name=None, hotkey=None, path=None, config=None)#
-

The wallet class in the Bittensor framework handles wallet functionality, crucial for participating in the Bittensor network.

-

It manages two types of keys: coldkey and hotkey, each serving different purposes in network operations. Each wallet contains a coldkey and a hotkey.

-

The coldkey is the user’s primary key for holding stake in their wallet and is the only way that users -can access Tao. Coldkeys can hold tokens and should be encrypted on your device.

-

The coldkey is the primary key used for securing the wallet’s stake in the Bittensor network (Tao) and -is critical for financial transactions like staking and unstaking tokens. It’s recommended to keep the -coldkey encrypted and secure, as it holds the actual tokens.

-

The hotkey, in contrast, is used for operational tasks like subscribing to and setting weights in the -network. It’s linked to the coldkey through the metagraph and does not directly hold tokens, thereby -offering a safer way to interact with the network during regular operations.

-
-
Parameters:
-
    -
  • name (str) – The name of the wallet, used to identify it among possibly multiple wallets.

  • -
  • hotkey (str) – String identifier for the hotkey.

  • -
  • path (str) – File system path where wallet keys are stored.

  • -
  • config (Config) – Bittensor configuration object.

  • -
  • _hotkey (Keypair) – Internal representations of the hotkey and coldkey.

  • -
  • _coldkey (Keypair) – Internal representations of the hotkey and coldkey.

  • -
  • _coldkeypub (Keypair) – Internal representations of the hotkey and coldkey.

  • -
-
-
-
-
-create_if_non_existent, create, recreate
-

Methods to handle the creation of wallet keys.

-
- -
-
-get_coldkey, get_hotkey, get_coldkeypub
-

Methods to retrieve specific keys.

-
- -
-
-set_coldkey, set_hotkey, set_coldkeypub
-

Methods to set or update keys.

-
- -
-
-hotkey_file, coldkey_file, coldkeypub_file
-

Properties that return respective key file objects.

-
- -
-
-regenerate_coldkey, regenerate_hotkey, regenerate_coldkeypub
-

Methods to regenerate keys from different sources.

-
- -
-
-Config, help, add_args
-

Utility methods for configuration and assistance.

-
- -

The wallet class is a fundamental component for users to interact securely with the Bittensor network, facilitating both operational tasks and transactions involving value transfer across the network.

-

Example Usage:

-
# Create a new wallet with default coldkey and hotkey names
-my_wallet = wallet()
-
-# Access hotkey and coldkey
-hotkey = my_wallet.get_hotkey()
-coldkey = my_wallet.get_coldkey()
-
-# Set a new coldkey
-my_wallet.new_coldkey(n_words=24) # number of seed words to use
-
-# Update wallet hotkey
-my_wallet.set_hotkey(new_hotkey)
-
-# Print wallet details
-print(my_wallet)
-
-# Access coldkey property, must use password to unlock
-my_wallet.coldkey
-
-
-

Initialize the bittensor wallet object containing a hot and coldkey.

-
-
Parameters:
-
    -
  • name (str, optional) – The name of the wallet to unlock for running bittensor. Defaults to default.

  • -
  • hotkey (str, optional) – The name of hotkey used to running the miner. Defaults to default.

  • -
  • path (str, optional) – The path to your bittensor wallets. Defaults to ~/.bittensor/wallets/.

  • -
  • config (Config, optional) – config.Config(). Defaults to None.

  • -
-
-
-
-
-config#
-
- -
-
-name#
-
- -
-
-property hotkey: substrateinterface.Keypair#
-

Loads the hotkey from wallet.path/wallet.name/hotkeys/wallet.hotkey or raises an error.

-
-
Returns:
-

hotkey loaded from Config arguments.

-
-
Return type:
-

hotkey (Keypair)

-
-
Raises:
-
    -
  • KeyFileError – Raised if the file is corrupt of non-existent.

  • -
  • CryptoKeyError – Raised if the user enters an incorrect password for an encrypted keyfile.

  • -
-
-
-
- -
-
-path#
-
- -
-
-hotkey_str#
-
- -
-
-_hotkey = None#
-
- -
-
-_coldkey = None#
-
- -
-
-_coldkeypub = None#
-
- -
-
-__str__()#
-

Returns a human-readable string representation of the wallet object.

-
-
Returns:
-

The string representation.

-
-
Return type:
-

str

-
-
-
- -
-
-__repr__()#
-

Returns the string representation of the wallet object.

-
-
Returns:
-

The string representation.

-
-
Return type:
-

str

-
-
-
- -
-
-classmethod help()#
-

Print help to stdout.

-
- -
-
-classmethod add_args(parser, prefix=None)#
-

Accept specific arguments from parser.

-
-
Parameters:
-
-
-
-
- -
-
-create_if_non_existent(coldkey_use_password=True, hotkey_use_password=False)#
-

Checks for existing coldkeypub and hotkeys, and creates them if non-existent.

-
-
Parameters:
-
    -
  • coldkey_use_password (bool, optional) – Whether to use a password for coldkey. Defaults to True.

  • -
  • hotkey_use_password (bool, optional) – Whether to use a password for hotkey. Defaults to False.

  • -
-
-
Returns:
-

The wallet object.

-
-
Return type:
-

wallet

-
-
-
- -
-
-create(coldkey_use_password=True, hotkey_use_password=False)#
-

Checks for existing coldkeypub and hotkeys, and creates them if non-existent.

-
-
Parameters:
-
    -
  • coldkey_use_password (bool, optional) – Whether to use a password for coldkey. Defaults to True.

  • -
  • hotkey_use_password (bool, optional) – Whether to use a password for hotkey. Defaults to False.

  • -
-
-
Returns:
-

The wallet object.

-
-
Return type:
-

wallet

-
-
-
- -
-
-recreate(coldkey_use_password=True, hotkey_use_password=False)#
-

Checks for existing coldkeypub and hotkeys and creates them if non-existent.

-
-
Parameters:
-
    -
  • coldkey_use_password (bool, optional) – Whether to use a password for coldkey. Defaults to True.

  • -
  • hotkey_use_password (bool, optional) – Whether to use a password for hotkey. Defaults to False.

  • -
-
-
Returns:
-

The wallet object.

-
-
Return type:
-

wallet

-
-
-
- -
-
-property hotkey_file: btwallet.keyfile.Keyfile#
-

Property that returns the hotkey file.

-
-
Returns:
-

The hotkey file.

-
-
Return type:
-

Keyfile

-
-
-
- -
-
-property coldkey_file: btwallet.keyfile.Keyfile#
-

Property that returns the coldkey file.

-
-
Returns:
-

The coldkey file.

-
-
Return type:
-

Keyfile

-
-
-
- -
-
-property coldkeypub_file: btwallet.keyfile.Keyfile#
-

Property that returns the coldkeypub file.

-
-
Returns:
-

The coldkeypub file.

-
-
Return type:
-

Keyfile

-
-
-
- -
-
-set_hotkey(keypair, encrypt=False, overwrite=False)#
-

Sets the hotkey for the wallet.

-
-
Parameters:
-
    -
  • keypair (Keypair) – The hotkey keypair.

  • -
  • encrypt (bool, optional) – Whether to encrypt the hotkey. Defaults to False.

  • -
  • overwrite (bool, optional) – Whether to overwrite an existing hotkey. Defaults to False.

  • -
-
-
-
- -
-
-set_coldkeypub(keypair, encrypt=False, overwrite=False)#
-

Sets the coldkeypub for the wallet.

-
-
Parameters:
-
    -
  • keypair (Keypair) – The coldkeypub keypair.

  • -
  • encrypt (bool, optional) – Whether to encrypt the coldkeypub. Defaults to False.

  • -
  • overwrite (bool, optional) – Whether to overwrite an existing coldkeypub. Defaults to False.

  • -
-
-
Returns:
-

The coldkeypub file.

-
-
Return type:
-

Keyfile

-
-
-
- -
-
-set_coldkey(keypair, encrypt=True, overwrite=False)#
-

Sets the coldkey for the wallet.

-
-
Parameters:
-
    -
  • keypair (Keypair) – The coldkey keypair.

  • -
  • encrypt (bool, optional) – Whether to encrypt the coldkey. Defaults to True.

  • -
  • overwrite (bool, optional) – Whether to overwrite an existing coldkey. Defaults to False.

  • -
  • Returns

  • -
-
-
Return type:
-

btwallet.keyfile.Keyfile

-
-
-

Keyfile: The coldkey file.

-
- -
-
-get_coldkey(password=None)#
-

Gets the coldkey from the wallet.

-
-
Parameters:
-

password (str, optional) – The password to decrypt the coldkey. Defaults to None.

-
-
Returns:
-

The coldkey keypair.

-
-
Return type:
-

Keypair

-
-
-
- -
-
-get_hotkey(password=None)#
-

Gets the hotkey from the wallet.

-
-
Parameters:
-

password (str, optional) – The password to decrypt the hotkey. Defaults to None.

-
-
Returns:
-

The hotkey keypair.

-
-
Return type:
-

Keypair

-
-
-
- -
-
-get_coldkeypub(password=None)#
-

Gets the coldkeypub from the wallet.

-
-
Parameters:
-

password (str, optional) – The password to decrypt the coldkeypub. Defaults to None.

-
-
Returns:
-

The coldkeypub keypair.

-
-
Return type:
-

Keypair

-
-
-
- -
-
-property coldkey: substrateinterface.Keypair#
-

Loads the coldkey from wallet.path/wallet.name/coldkey or raises an error.

-
-
Returns:
-

coldkey loaded from Config arguments.

-
-
Return type:
-

coldkey (Keypair)

-
-
Raises:
-
    -
  • KeyFileError – Raised if the file is corrupt of non-existent.

  • -
  • CryptoKeyError – Raised if the user enters an incorrect password for an encrypted keyfile.

  • -
-
-
-
- -
-
-property coldkeypub: substrateinterface.Keypair#
-

Loads the coldkeypub from wallet.path/wallet.name/coldkeypub.txt or raises an error.

-
-
Returns:
-

coldkeypub loaded from Config arguments.

-
-
Return type:
-

coldkeypub (Keypair)

-
-
Raises:
-
    -
  • KeyFileError – Raised if the file is corrupt of non-existent.

  • -
  • CryptoKeyError – Raised if the user enters an incorrect password for an encrypted keyfile.

  • -
-
-
-
- -
-
-create_coldkey_from_uri(uri, use_password=True, overwrite=False, suppress=False)#
-

Creates coldkey from uri string, optionally encrypts it with the user-provided password.

-
-
Parameters:
-
    -
  • uri (str) – (str, required): URI string to use i.e., /Alice or /Bob.

  • -
  • use_password (bool, optional) – Is the created key password protected.

  • -
  • overwrite (bool, optional) – Determines if this operation overwrites the coldkey under the same path <wallet path>/<wallet name>/coldkey.

  • -
  • suppress (bool, optional) – If True, suppresses the display of the mnemonic message. Defaults to False.

  • -
-
-
Returns:
-

This object with newly created coldkey.

-
-
Return type:
-

wallet (Wallet)

-
-
-
- -
-
-create_hotkey_from_uri(uri, use_password=False, overwrite=False, suppress=False)#
-

Creates hotkey from uri string, optionally encrypts it with the user-provided password.

-
-
Parameters:
-
    -
  • uri (str) – (str, required): URI string to use i.e., /Alice or /Bob

  • -
  • use_password (bool, optional) – Is the created key password protected.

  • -
  • overwrite (bool, optional) – Determines if this operation overwrites the hotkey under the same path <wallet path>/<wallet name>/hotkeys/<hotkey>.

  • -
  • suppress (bool, optional) – If True, suppresses the display of the mnemonic message. Defaults to False.

  • -
-
-
Returns:
-

This object with newly created hotkey.

-
-
Return type:
-

wallet (Wallet)

-
-
-
- -
-
-unlock_coldkey()#
-

Unlocks the coldkey (prompts password if locked)

-
-
Returns:
-

the unlocked coldkey Keypair.

-
-
Return type:
-

coldkey (Keypair)

-
-
-
- -
-
-unlock_coldkeypub()#
-

Unlocks the coldkeypub.

-
-
Returns:
-

the unlocked coldkeypub Keypair.

-
-
Return type:
-

coldkeypub (Keypair)

-
-
-
- -
-
-unlock_hotkey()#
-

Unlocks the hotkey.

-
-
Returns:
-

the unlocked hotkey Keypair.

-
-
Return type:
-

hotkey (Keypair)

-
-
-
- -
-
-new_coldkey(n_words=12, use_password=True, overwrite=False, suppress=False)#
-

Creates a new coldkey, optionally encrypts it with the user-provided password and saves to disk.

-
-
Parameters:
-
    -
  • n_words (int) – (int, optional): Number of mnemonic words to use.

  • -
  • use_password (bool, optional) – Is the created key password protected.

  • -
  • overwrite (bool, optional) – Determines if this operation overwrites the coldkey under the same path <wallet path>/<wallet name>/coldkey.

  • -
  • suppress (bool, optional) – If True, suppresses the display of the mnemonic message. Defaults to False.

  • -
-
-
Returns:
-

This object with newly created coldkey.

-
-
Return type:
-

wallet (Wallet)

-
-
-
- -
-
-create_new_coldkey(n_words=12, use_password=True, overwrite=False, suppress=False)#
-

Creates a new coldkey, optionally encrypts it with the user-provided password and saves to disk.

-
-
Parameters:
-
    -
  • n_words (int) – (int, optional): Number of mnemonic words to use.

  • -
  • use_password (bool, optional) – Is the created key password protected.

  • -
  • overwrite (bool, optional) – Determines if this operation overwrites the coldkey under the same path <wallet path>/<wallet name>/coldkey.

  • -
  • suppress (bool, optional) – If True, suppresses the display of the mnemonic message. Defaults to False.

  • -
-
-
Returns:
-

This object with newly created coldkey.

-
-
Return type:
-

wallet (Wallet)

-
-
-
- -
-
-new_hotkey(n_words=12, use_password=False, overwrite=False, suppress=False)#
-

Creates a new hotkey, optionally encrypts it with the user-provided password and saves to disk.

-
-
Parameters:
-
    -
  • n_words (int) – (int, optional): Number of mnemonic words to use.

  • -
  • use_password (bool, optional) – Is the created key password protected.

  • -
  • overwrite (bool, optional) – Determines if this operation overwrites the hotkey under the same path <wallet path>/<wallet name>/hotkeys/<hotkey>.

  • -
  • suppress (bool, optional) – If True, suppresses the display of the mnemonic message. Defaults to False.

  • -
-
-
Returns:
-

This object with newly created hotkey.

-
-
Return type:
-

wallet (Wallet)

-
-
-
- -
-
-create_new_hotkey(n_words=12, use_password=False, overwrite=False, suppress=False)#
-

Creates a new hotkey, optionally encrypts it with the user-provided password and saves to disk.

-
-
Parameters:
-
    -
  • n_words (int) – (int, optional): Number of mnemonic words to use.

  • -
  • use_password (bool, optional) – Is the created key password protected.

  • -
  • overwrite (bool, optional) – Will this operation overwrite the hotkey under the same path <wallet path>/<wallet name>/hotkeys/<hotkey>

  • -
  • suppress (bool, optional) – If True, suppresses the display of the mnemonic message. Defaults to False.

  • -
-
-
Returns:
-

This object with newly created hotkey.

-
-
Return type:
-

wallet (Wallet)

-
-
-
- -
-
-regenerate_coldkeypub(ss58_address=None, public_key=None, overwrite=False)#
-

Regenerates the coldkeypub from the passed ss58_address or public_key and saves the file. Requires either ss58_address or public_key to be passed.

-
-
Parameters:
-
    -
  • ss58_address (Optional[str]) – (str, optional): Address as ss58 string.

  • -
  • public_key (Optional[Union[str, bytes]]) – (str | bytes, optional): Public key as hex string or bytes.

  • -
  • overwrite (bool, optional) – False): Determines if this operation overwrites the coldkeypub (if exists) under the same path <wallet path>/<wallet name>/coldkeypub.

  • -
-
-
Returns:
-

Newly re-generated wallet with coldkeypub.

-
-
Return type:
-

wallet (Wallet)

-
-
-
- -
-
-regenerate_coldkey(mnemonic: list | str | None = None, use_password: bool = True, overwrite: bool = False, suppress: bool = False) Wallet#
-
-regenerate_coldkey(seed: str | None = None, use_password: bool = True, overwrite: bool = False, suppress: bool = False) Wallet
-
-regenerate_coldkey(json: Tuple[str | Dict, str] | None = None, use_password: bool = True, overwrite: bool = False, suppress: bool = False) Wallet
-

Regenerates the coldkey from the passed mnemonic or seed, or JSON encrypts it with the user’s password and saves the file.

-
-
Parameters:
-
    -
  • use_password (bool, optional) – Is the created key password protected.

  • -
  • overwrite (bool, optional) – Determines if this operation overwrites the coldkey under the same path <wallet path>/<wallet name>/coldkey.

  • -
  • suppress (bool, optional) – If True, suppresses the display of the mnemonic message. Defaults to False.

  • -
  • kwargs["mnemonic"] – (Union[list, str], optional item of kwargs): Key mnemonic as list of words or string space separated words.

  • -
  • kwargs["seed"] – (str, optional item of kwargs): Seed as hex string.

  • -
  • kwargs["json"] – (Tuple[Union[str, Dict], str], optional item of kwargs): Restore from encrypted JSON backup as (json_data: Union[str, Dict], passphrase: str)

  • -
-
-
Returns:
-

This object with newly created coldkey.

-
-
Return type:
-

wallet (Wallet)

-
-
-
-

Note

-

Uses priority order: mnemonic > seed > json.

-
-
- -
-
-regenerate_hotkey(*, mnemonic: list | str | None = None, use_password: bool = True, overwrite: bool = False, suppress: bool = False) Wallet#
-
-regenerate_hotkey(*, seed: str | None = None, use_password: bool = True, overwrite: bool = False, suppress: bool = False) Wallet
-
-regenerate_hotkey(*, json: Tuple[str | Dict, str] | None = None, use_password: bool = True, overwrite: bool = False, suppress: bool = False) Wallet
-

Regenerates the hotkey from passed mnemonic or seed, encrypts it with the user’s password and saves the file.

-
-
Parameters:
-
    -
  • mnemonic (Union[list, str], optional) – Key mnemonic as list of words or string space separated words.

  • -
  • seed (str, optional) – Seed as hex string.

  • -
  • json (Tuple[Union[str, Dict], str], optional) – Restore from encrypted JSON backup as (json_data: Union[str, Dict], passphrase: str).

  • -
  • use_password (bool, optional) – Is the created key password protected.

  • -
  • overwrite (bool, optional) – Determines if this operation overwrites the hotkey under the same path <wallet path>/<wallet name>/hotkeys/<hotkey>.

  • -
  • suppress (bool, optional) – If True, suppresses the display of the mnemonic message. Defaults to False.

  • -
-
-
Returns:
-

This object with newly created hotkey.

-
-
Return type:
-

wallet (Wallet)

-
-
-
- -
- -
-
- - -
- - - - - - - - -
- - - - - - -
-
- - -
- - -
-
-
- - - - - -
-
- - \ No newline at end of file diff --git a/static/btwallet-api/html/genindex.html b/static/btwallet-api/html/genindex.html index 183222410c..e3a9de7261 100644 --- a/static/btwallet-api/html/genindex.html +++ b/static/btwallet-api/html/genindex.html @@ -7,7 +7,7 @@ - Index — BTCLI Docs 1.0 documentation + Index — Bittensor Wallet SDK Docs documentation @@ -27,9 +27,8 @@ - - - + + @@ -37,8 +36,8 @@ - - + + @@ -137,8 +136,8 @@ - BTCLI Docs 1.0 documentation - Home - + Bittensor Wallet SDK Docs  documentation - Home + @@ -155,21 +154,16 @@

Index

- _ - | A - | B - | C - | D - | E - | G - | H - | I - | K - | L - | M - | N - | P - | R - | S - | T - | U - | V - | W
-

_

- - - -
- -

A

- - - -
- -

B

- - - -
    -
  • - btwallet - -
  • -
  • - btwallet.config - -
  • -
  • - btwallet.errors - -
  • -
  • - btwallet.keyfile - -
  • -
  • - btwallet.utils - -
  • -
  • - btwallet.wallet - -
  • -
- -

C

- - - -
- -

D

- - - -
- -

E

- - - -
- -

G

- - - -
- -

H

- - - -
- -

I

- - - -
- -

K

- - - -
- -

L

- - - -
- -

M

- - -
- -

N

- - - -
- -

P

- - - -
- -

R

- - - -
- -

S

- - - -
- -

T

- - - -
- -

U

- - - -
- -

V

- - - -
- -

W

- - -
-
@@ -945,7 +361,7 @@

W

diff --git a/static/btwallet-api/html/index.html b/static/btwallet-api/html/index.html index 4bda65b236..d8a76e224e 100644 --- a/static/btwallet-api/html/index.html +++ b/static/btwallet-api/html/index.html @@ -8,7 +8,7 @@ - Bittensor Wallet Python SDK Reference — BTCLI Docs 1.0 documentation + Bittensor Wallet SDK Documentation — Bittensor Wallet SDK Docs documentation @@ -28,9 +28,8 @@ - - - + + @@ -38,14 +37,14 @@ - - + + - + @@ -139,8 +138,8 @@ - BTCLI Docs 1.0 documentation - Home - + Bittensor Wallet SDK Docs  documentation - Home + @@ -157,21 +156,16 @@ @@ -378,19 +370,11 @@ @@ -400,20 +384,17 @@

Contents

-
-

Bittensor Wallet Python SDK Reference#

-
-

Table of Contents#

+
+

Bittensor Wallet SDK Documentation#

-
@@ -428,11 +409,11 @@

Table of Contents

next

-

API Reference

+

Bittensor Wallet Modules

@@ -443,21 +424,6 @@

Table of Contents -