Skip to main content

The Swiss Army Knife of the Litecoin protocol.

Project description

python-litecoinlib

This Python3 library provides an easy interface to the litecoin data structures and protocol. The approach is low-level and "ground up", with a focus on providing tools to manipulate the internals of how litecoin works.

Requirements

sudo apt-get install libssl-dev

The RPC interface, litecoin.rpc, is designed to work with Litecoin Core v0.18. Older versions may work but there do exist some incompatibilities.

Structure

Everything consensus critical is found in the modules under litecoin.core. This rule is followed pretty strictly, for instance chain parameters are split into consensus critical and non-consensus-critical.

litecoin.core            - Basic core definitions, datastructures, and
                          (context-independent) validation
litecoin.core.key        - ECC pubkeys
litecoin.core.script     - Scripts and opcodes
litecoin.core.scripteval - Script evaluation/verification
litecoin.core.serialize  - Serialization

In the future the litecoin.core may use the Satoshi sourcecode directly as a library. Non-consensus critical modules include the following:

litecoin          - Chain selection
litecoin.base58   - Base58 encoding
litecoin.bloom    - Bloom filters (incomplete)
litecoin.net      - Network communication (in flux)
litecoin.messages - Network messages (in flux)
litecoin.rpc      - Litecoin Core RPC interface support
litecoin.wallet   - Wallet-related code, currently Litecoin address and
                   private key support

Effort has been made to follow the Satoshi source relatively closely, for instance Python code and classes that duplicate the functionality of corresponding Satoshi C++ code uses the same naming conventions: CTransaction, CBlockHeader, nValue etc. Otherwise Python naming conventions are followed.

Mutable vs. Immutable objects

Like the Litecoin Core codebase CTransaction is immutable and CMutableTransaction is mutable; unlike the Litecoin Core codebase this distinction also applies to COutPoint, CTxIn, CTxOut, and CBlock.

Endianness Gotchas

Rather confusingly Litecoin Core shows transaction and block hashes as little-endian hex rather than the big-endian the rest of the world uses for SHA256. python-litecoinlib provides the convenience functions x() and lx() in litecoin.core to convert from big-endian and little-endian hex to raw bytes to accommodate this. In addition see b2x() and b2lx() for conversion from bytes to big/little-endian hex.

Module import style

While not always good style, it's often convenient for quick scripts if import * can be used. To support that all the modules have __all__ defined appropriately.

Selecting the chain to use

Do the following:

import litecoin
litecoin.SelectParams(NAME)

Where NAME is one of 'testnet', 'mainnet', 'signet', or 'regtest'. The chain currently selected is a global variable that changes behavior everywhere, just like in the Satoshi codebase.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python-litecoinlib-0.12.0.dev0.tar.gz (58.5 kB view details)

Uploaded Source

Built Distribution

python_litecoinlib-0.12.0.dev0-py3-none-any.whl (65.9 kB view details)

Uploaded Python 3

File details

Details for the file python-litecoinlib-0.12.0.dev0.tar.gz.

File metadata

File hashes

Hashes for python-litecoinlib-0.12.0.dev0.tar.gz
Algorithm Hash digest
SHA256 ec8644d064ad4cc1849647ce19709015ca5cd2cc76f003d926bd7058ca6d8331
MD5 b0b892bc720f145b6de9ef8064140f38
BLAKE2b-256 36dc3651d62558bb687a44ce33e66995f2cd8a4fe535cd6823289d36e65f8337

See more details on using hashes here.

File details

Details for the file python_litecoinlib-0.12.0.dev0-py3-none-any.whl.

File metadata

File hashes

Hashes for python_litecoinlib-0.12.0.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 a221c9997322fb0dcfbe80d9477fb9fa892f25d664adb0407957155af2035cf9
MD5 1057271798a1ae98635033f9f82abcb5
BLAKE2b-256 af5d0342e81121bc9e1c109beab1f4f282d2c0f7718eacdccddcac55b3f9c8d9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page