Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Simplexum/python-elementstx
Python3 library that implements support for Elements transactions. It builds on top, and is intended to be used along with python-bitcointx library.
https://github.com/Simplexum/python-elementstx
elements liquid
Last synced: 21 days ago
JSON representation
Python3 library that implements support for Elements transactions. It builds on top, and is intended to be used along with python-bitcointx library.
- Host: GitHub
- URL: https://github.com/Simplexum/python-elementstx
- Owner: Simplexum
- License: other
- Created: 2019-06-25T09:22:37.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-04-09T12:50:16.000Z (8 months ago)
- Last Synced: 2024-11-01T21:36:43.725Z (about 1 month ago)
- Topics: elements, liquid
- Language: Python
- Size: 555 KB
- Stars: 13
- Watchers: 3
- Forks: 8
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-liquid - python-elementstx - elementstx/tree/master/examples)) (Python)
README
This Python3 module implements support for Elements transactions.
It builds on top, and is intended to be used along with python-bitcointx library.
## Requirements
- [python-bitcointx](https://github.com/Simplexum/python-bitcointx) (version >= 1.0.0)
- [secp256k1-zkp](https://github.com/ElementsProject/secp256k1-zkp)Configure parameters for `secp256k1-zkp`:
```
./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:
```python
import os
import elementstx
from bitcointx import ChainParams, get_current_chain_params
from bitcointx.wallet import CCoinKey, CCoinExtKey, CCoinAddress, P2PKHCoinAddresswith 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:
```python
from elementstx import ElementsParams
from bitcointx import select_chain_paramsselect_chain_params('elements')
# or, using the chain params class directly
select_chain_params(ElementsParams)# To switch to Liquid Network parameters:
select_chain_params('elements/liquidv1')```
Without the switch of chain parameters:
```python
from elementstx.core import CElementsTransactiontransaction_data = read_tx_data()
tx = CElementsTransaction.deserialze(transaction_data)
print("Number of txout witnesses:", len(tx.wit.vtxoutwit))```
# Example Code
See `examples/` directory.