Skip to main content

Litecoin utility functions

Project description

This is a litecoin library that provides tools/utilities to interact with the Litecoin network and it is based on python-bitcoin-utils library. One of the primary goals of the library is to explain the low-level details of Litecoin. The code is easy to read and properly documented explaining in detail all the thorny aspects of the implementation. It is a low-level library which assumes some high-level understanding of how Litecoin works. In the future this might change.

This is an early version of the library (v0.5.4) and currently, it supports private/public keys, all type of addresses and creation of any transaction (incl. segwit) with all SIGHASH types. All script op codes are included. Timelock and non-standanrd transactions are supported. It does not currently support the new M and Q addresses. Currently, a simple node proxy exists to enable easy calls to a Litecoin core node. Extra functionality will be added continuously and the documentation will be improved as the work progresses.

The API documentation can be build with Sphinx but is also available as a PDF for convenience. One can currently use the library for experimenting and learning the inner workings of Litecoin. It is not meant for production yet and parts of the API might be updated with new versions.

Installation

Python version 3 is required. Then just install with:

$ pip install litecoin-utils

Examples

Keys and Addresses

https://github.com/karask/python-litecoin-utils/blob/master/examples/keys_addresses.py - creates a private key which we use to derive a public key and in turn an address. We also use the private key to sign a message and then verify it using the public key.

Segwit Addresses

https://github.com/karask/python-litecoin-utils/blob/master/examples/keys_segwit_addresses.py - creates P2WPKH, P2SH-P2WPKH, P2WSH and P2SH-P2WSH addresses.

Transaction with P2PKH input and outputs

https://github.com/karask/python-litecoin-utils/blob/master/examples/p2pkh_transaction.py - creates a simple transaction with one input and two outputs.

Create a P2PKH Transaction with different SIGHASHes

https://github.com/karask/python-litecoin-utils/blob/master/examples/multi_input_sighash_transaction.py - creates a 2-input 2-output transaction with different signature types.

Create a P2SH Address

https://github.com/karask/python-litecoin-utils/blob/master/examples/send_to_p2sh_transaction.py - creates a P2SH address that corresponds to a P2PK redeem script and sends some funds to it.

Create (spent) a P2SH Transaction

https://github.com/karask/python-litecoin-utils/blob/master/examples/spend_p2sh_transaction.py - creates a transaction that spends a P2SH output.

Create a non-standard tx

https://github.com/karask/python-litecoin-utils/blob/master/examples/create_non_std_tx.py - sends funds to an address with a non-standard tx (script: OP_ADD OP_5 OP_EQUAL)

Spend a non-standard tx

https://github.com/karask/python-litecoin-utils/blob/master/examples/spend_non_std_tx.py - spends funds from script OP_ADD OP_5 OP_EQUAL

Transaction to pay to a P2WPKH

http://github.com/karask/python-litecoin-utils/blob/master/examples/send_to_p2wpkh_transaction.py - send coins from two P2PKH UTXOs to a native segwit address (P2WPKH)

Spend from a P2SH(P2WPKH) nested segwit address

http://github.com/karask/python-litecoin-utils/blob/master/examples/spend_p2sh_p2wpkh_address.py - spend a P2WPKH that is nested into a P2SH for old client compatibility

Create a P2SH address with a relative timelock

https://github.com/karask/python-litecoin-utils/blob/master/examples/create_p2sh_csv_p2pkh_address.py - creates a P2SH address that locks funds (sent to it) with a private key (P2PKH) and a relative locktime of 200 blocks in the future.

Spend from a timelocked address

https://github.com/karask/python-litecoin-utils/blob/master/examples/spend_p2sh_csv_p2pkh.py - spends from a P2SH(CSV+P2PKH) address as created from above.

Use NodeProxy to make calls to a Litecoin node

https://github.com/karask/python-litecoin-utils/blob/master/examples/node_proxy.py - make Litecoin command-line interface calls programmatically (NodeProxy wraps jsonrpc-requests library)

Please explore the codebase or the API documentation (LitecoinUtilities.pdf) for supported functionality and other options.

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

litecoin-utils-0.5.4.tar.gz (26.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

litecoin_utils-0.5.4-py3-none-any.whl (29.3 kB view details)

Uploaded Python 3

File details

Details for the file litecoin-utils-0.5.4.tar.gz.

File metadata

  • Download URL: litecoin-utils-0.5.4.tar.gz
  • Upload date:
  • Size: 26.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.6.9

File hashes

Hashes for litecoin-utils-0.5.4.tar.gz
Algorithm Hash digest
SHA256 853171a033fd0904136f4c8f88087a2ab9ecd8a5fc387027284a80c6dc786f84
MD5 7a96a5e6cda1198da2e1e092f069a7f1
BLAKE2b-256 93050668d8c4588e38d6f56622e2c98afe61beb2469ed6924d234389dc233eca

See more details on using hashes here.

File details

Details for the file litecoin_utils-0.5.4-py3-none-any.whl.

File metadata

  • Download URL: litecoin_utils-0.5.4-py3-none-any.whl
  • Upload date:
  • Size: 29.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.6.9

File hashes

Hashes for litecoin_utils-0.5.4-py3-none-any.whl
Algorithm Hash digest
SHA256 99e8554b86d79ec5cfb9429e66fd9b6655385b4fb91fbf8713dc1d704b3dfd8e
MD5 63ea844e0f2759693bb60c61e36f1b8a
BLAKE2b-256 98bffe335a78a0a797280c3efe02bca751ca14ef9aaab645a3d18217094a4222

See more details on using hashes here.

Supported by

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