Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Elements module for python-bitcointx

Project description

This Python3 module implements support for Elements transactions.

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

Requirements

    ./configure --enable-experimental \
                --enable-module-generator \
                --enable-module-rangeproof \
                --enable-module-surjectionproof \
                --enable-module-ecdh \
                --enable-module-recovery

Usage:

With contextual switch to Elements parameters:

import os
import elementstx
from bitcointx import ChainParams, get_current_chain_params
from bitcointx.wallet import CCoinKey, CCoinExtKey, CCoinAddress, P2PKHCoinAddress

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

With global switch to Elements parameters:

from elementstx import ElementsParams
from bitcointx import select_chain_params

select_chain_params('elements')
# or, using the chain params class directly
select_chain_params(ElementsParams)

Without the switch of chain parameters:

from elementstx.core import ElementsTransaction

transaction_data = read_tx_data()
tx = CElementsTransaction.deserialze(transaction_data)
print("Number of txout witnesses:", len(tx.wit.vtxoutwit))

Example Code

See examples/ directory.

Project details


Release history Release notifications

Download files

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

Files for python-elementstx, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size python-elementstx-0.1.1.tar.gz (390.8 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page