Answer the question
In order to leave comments, you need to log in
Library/framework for working with Bitcoin transactions in Python?
Good day, I'm looking for a library for Python 3.x, with which I could create and sign BTC transactions.
You need a library that supports SegWit addresses in Bech32 encoding.
Namely, to support three Bitcoin address formats: P2PKH, P2SH, P2WPKH (Bech32).
Sample code I need:
import some_libary
inputs = {
# btc_addr: private_key
'bc1qayxpas47nrljgkkcuvx0kfyjpj9edh0ch6k3j2': 'L2aiRXYVbn95jFdjsMzcHvD4JG9Edf1Z1v9gvQEip4fN4i2yWwcc'
}
outputs = {
# btc_addr: value (satoshi)
'3JXRVxhrk2o9f4w3cQchBLwUeegJBj6BEp': 1000000,
'bc1qayxpas47nrljgkkcuvx0kfyjpj9edh0ch6k3j2': 21000000 # Сдача
}
tx = some_libary.mktx(ins=list(inputs.keys()), outs=outputs)
signed_tx = some_libary.signtx(tx, priv_keys=list(inputs.values()))
tx_hash = some_libary.pushtx(signed_tx)
print('TX ID:', tx_hash)
Answer the question
In order to leave comments, you need to log in
One of the best options is python-bitcoin-utils .
I also recommend cryptos for analyzing Bitcoin transactions and other useful features.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question