This Python3 module implements support for Elements transactions.
It builds on top, and is intended to be used along with python-bitcointx library.
python-bitcointx (version >= 1.0.0)
Configure parameters for
secp256k1-zkp:
./configure --enable-experimental \
--enable-module-generator \
--enable-module-rangeproof \
--enable-module-surjectionproof \
--enable-module-ecdh \
--enable-module-recovery
With contextual switch to Elements parameters:
importosimportelementstxfrombitcointximportChainParams, get_current_chain_paramsfrombitcointx.walletimportCCoinKey, CCoinExtKey, CCoinAddress, P2PKHCoinAddresswithChainParams('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))
assertCCoinAddress(str(a)) ==aWith global switch to Elements parameters:
fromelementstximportElementsParamsfrombitcointximportselect_chain_paramsselect_chain_params('elements')
# or, using the chain params class directlyselect_chain_params(ElementsParams)
# To switch to Liquid Network parameters:select_chain_params('elements/liquidv1')Without the switch of chain parameters:
fromelementstx.coreimportCElementsTransactiontransaction_data=read_tx_data()
tx=CElementsTransaction.deserialze(transaction_data)
print("Number of txout witnesses:", len(tx.wit.vtxoutwit))See examples/ directory.