Python implementation of BIP32 path template parser finite state machine
(compatible with micropython)
This repository contains an implementation of specification of the parser for BIP32 path templates described in bip-path-templates.mediawiki and specified by TLA+ specification at https://github.com/dgpv/bip32_template_parse_tplaplus_spec
The implementation is in bip32template/__init__.py
The tests is in tests/
To run tests on micropython, use micropython_unittest.py (you will need micropython-os.path module to run the tests)
to run static type checking, use run_mypy.sh
Example usage:
>>> from bip32template import BIP32Template
>>> tpl=BIP32Template.parse('m/0h/[1-9,23]/*')
>>> tpl
BIP32Template([[(2147483648, 2147483648)], [(1, 9), (23, 23)], [(0, 2147483647)]], is_partial=False, hardened_marker="h")
>>> tpl.sections
[[(2147483648, 2147483648)], [(1, 9), (23, 23)], [(0, 2147483647)]]
>>> str(tpl)
'm/0h/[1-9,23]/*'
>>> str(BIP32Template(tpl.sections, hardened_marker="'", is_partial=True))
"0'/[1-9,23]/*"
>>> tpl.to_path() is None
True
>>> tpl.match([0x80000000, 3, 33])
True
>>> tpl.match([0x80000000, 99, 33])
False
>>> BIP32Template.parse('m/0/1/[2-3]', is_format_onlypath=True)
...
bip32template.BIP32TemplateExceptionUnexpectedCharacter: unexpected character at position 7
>>> ptpl = BIP32Template.parse('m/0h/1/2', is_format_onlypath=True)
>>> ptpl
BIP32Template([[(2147483648, 2147483648)], [(1, 1)], [(2, 2)]], is_partial=False, hardened_marker="h")
>>> ptpl.to_path()
[2147483648, 1, 2]
>>> tpl.match(ptpl.to_path())
True
>>> str(BIP32Template.from_path(ptpl.to_path(), is_partial=True))
"0'/1/2"
>>> str(BIP32Template.from_path(ptpl.to_path(), is_partial=False, hardened_marker="h"))
'm/0h/1/2'
Authors and contributors
This implementation was created by Dmitry Petukhov (https://github.com/dgpv/)
License
Released under MIT license.
Metadata
Release files for bip32template 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bip32template-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for bip32template-0.0.4-py3-none-any.whl |
Release files / bip32template-0.0.4-py3-none-any.whl
| Download URL | bip32template-0.0.4-py3-none-any.whl |
|---|---|
| Size | 12.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d24eb2bdae90052333be7770438e55086bc1d55285816f5a34db0941de9e29ba
|
|
BLAKE2b-256 checksum How to use checksums |
d406d41632ff20cea41a918db5fdd000da9d2ad201eb4f5e820ab2f294f3a2ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.7.9
|
Security for bip32template 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.