Skip to main content

Litecoin module for use with python-bitcointx

Project description

This Python3 library implements support for Litecoin transactions.

It builds on top, and is intended to be used along with python-bitcointx library.

Requirements

Usage:

With contextual switch to Litecoin parameters:

import os
import litecointx
from bitcointx import ChainParams, get_current_chain_params
from bitcointx.wallet import (
    CCoinKey, CCoinExtKey, P2WPKHCoinAddress, CCoinAddress
)

with ChainParams('litecoin'):
    k = CCoinExtKey.from_seed(os.urandom(32))
    a = P2WPKHCoinAddress.from_pubkey(k.derive_path("m/0h/0h/1").pub)
    print('example {} address: {}'.format(get_current_chain_params().NAME, a))
    assert CCoinAddress(str(a)) == a

With global switch to Litecoin parameters:

from litecointx import LitecoinMainnetParams
from bitcointx import select_chain_params

select_chain_params('litecoin')
# or, using the chain params class directly
select_chain_params(LitecoinMainnetParams)

Without the switch of chain parameters:

from litecointx.wallet import P2SHLitecoinLegacyAddress, P2SHLitecoinAddress

legacy_adr = P2SHLitecoinLegacyAddress('3F1c6UWAs9RLN2Mbt5bAJue12VhVCorXzs')
canonical_adr = P2SHLitecoinAddress.from_scriptPubKey(legacy_adr.to_scriptPubKey())
assert str(canonical_adr) == 'MMDkQMv8pGGmAXdVyxaW8YtQMCHw7eouma'

With special parameter that makes CCoinAddress to decode legacy p2sh addresses:

from bitcointx import select_chain_params
from bitcointx.wallet import CCoinAddress
from litecointx.wallet import P2SHLitecoinLegacyAddress

select_chain_params('litecoin', allow_legacy_p2sh=True)
legacy_adr = CCoinAddress('3F1c6UWAs9RLN2Mbt5bAJue12VhVCorXzs')
assert isinstance(legacy_adr, P2SHLitecoinLegacyAddress)

this also works with ChainParams context manager.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

python_litecointx-0.1.2-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file python_litecointx-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: python_litecointx-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.6.9

File hashes

Hashes for python_litecointx-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ea2d77ba5d84adc585fbdeb8bea09dc70728bccf7a0db8e45d78a18e36cd5ed3
MD5 3d017c0674c07d329128d1a35e81946d
BLAKE2b-256 26c4340fae3c2a3e29c5ab7a9c82c33a1702231b087e6ee30b2688087347e056

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