All Projects → sr-gi → Bitcoin_tools

sr-gi / Bitcoin_tools

Licence: bsd-3-clause
Python Bitcoin tools

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Bitcoin tools

Awesome Decentralized
🕶 Awesome list of distributed, decentralized, p2p apps and tools 👍
Stars: ✭ 358 (+104.57%)
Mutual labels:  bitcoin, tools
Recsech
Recsech is a tool for doing Footprinting and Reconnaissance on the target web. Recsech collects information such as DNS Information, Sub Domains, HoneySpot Detected, Subdomain takeovers, Reconnaissance On Github and much more you can see in Features in tools .
Stars: ✭ 173 (-1.14%)
Mutual labels:  tools
Awesome Vault Tools
Awesome tools around HashiCorp Vault
Stars: ✭ 167 (-4.57%)
Mutual labels:  tools
Devsecops
🔱 Collection and Roadmap for everyone who wants DevSecOps.
Stars: ✭ 171 (-2.29%)
Mutual labels:  tools
Unity resources
A list of resources and tutorials for those doing programming in Unity.
Stars: ✭ 170 (-2.86%)
Mutual labels:  tools
Cbpro Trader
Automated cryptocurrency trading on Coinbase Pro (formerly gdax-trader)
Stars: ✭ 171 (-2.29%)
Mutual labels:  bitcoin
Tools
Ancillary tools for the D programming language compiler
Stars: ✭ 166 (-5.14%)
Mutual labels:  tools
Xcodeplugintool
🎧a easy way use plugins after Xcode upgraded
Stars: ✭ 174 (-0.57%)
Mutual labels:  tools
J2team Community
Join our group to see more
Stars: ✭ 172 (-1.71%)
Mutual labels:  tools
Mobilehackersweapons
Mobile Hacker's Weapons / A collection of cool tools used by Mobile hackers. Happy hacking , Happy bug-hunting
Stars: ✭ 170 (-2.86%)
Mutual labels:  tools
My Wallet V3 Ios
Blockchain iOS Wallet
Stars: ✭ 170 (-2.86%)
Mutual labels:  bitcoin
Bitcoinecdsa.php
PHP library to generate BTC addresses and signatures from private keys.
Stars: ✭ 169 (-3.43%)
Mutual labels:  bitcoin
Coot
玩转 IFTTT 体验极客生活,互联网自动化神器【已经停止开发】
Stars: ✭ 172 (-1.71%)
Mutual labels:  tools
Bdk
A modern, lightweight, descriptor-based wallet library written in Rust!
Stars: ✭ 168 (-4%)
Mutual labels:  bitcoin
Bitcoin Etl
ETL scripts for Bitcoin, Litecoin, Dash, Zcash, Doge, Bitcoin Cash. Available in Google BigQuery https://goo.gl/oY5BCQ
Stars: ✭ 174 (-0.57%)
Mutual labels:  bitcoin
Unstoppable Wallet Android
A secure and decentralized Bitcoin and other cryptocurrency wallet for Android phones. Supports Bitcoin, Ethereum, EOS, Binance Chain, Bitcoin Cash, DASH, ...
Stars: ✭ 165 (-5.71%)
Mutual labels:  bitcoin
Exportsheetdata
Add-on for Google Sheets that allows sheets to be exported as JSON or XML.
Stars: ✭ 170 (-2.86%)
Mutual labels:  tools
Lite Server
Lightweight node server
Stars: ✭ 2,137 (+1121.14%)
Mutual labels:  tools
Zeus
A mobile Bitcoin/Lightning app for lnd, c-lightning, and Eclair node operators ⚡️
Stars: ✭ 175 (+0%)
Mutual labels:  bitcoin
Lopp.net
Personal web site of Jameson Lopp
Stars: ✭ 174 (-0.57%)
Mutual labels:  bitcoin

bitcoin_tools

Mentioned in Awesome tippin.me

bitcoin_tools is a Python library created for teaching and researching purposes. It's main objective is twofold. First it aims to ease the understanding of Bitcoin transaction creation, by using well-documented and easy to understand python code. Second, it aims to provide a tool able to create custom transactions / scripts. Either scriptSig and scriptPubKey can be built from human readable strings created using Script syntax. Finally, tools for accessing and analysing interesting data such as the utxo set are also provided, along with several examples.

bitcoin_tools allows you to:

  • Bitcoin keys creation and management.
  • Creation of Bitcoin transactions from scratch.
  • Customize any field of your transaction.
  • Transaction serialization / deserialization.
  • Creation of standard and custom scripts (scriptSig and scriptPubKey).
  • Transaction analysis from hex encoded transactions.

Additionally, bitcoin_tools contains STATUS an STatistical Analysis Tool for Utxo Set under analysis/status

Dependencies

Refer to DEPENCENCIES.md

Installation

Refer to INSTALL.md

Some trouble getting started with the repo?

Refer to FAQ.md

Still not working?

Feel free to open an issue.

Examples

Down below you can find some examples of how to use some of the library functions. More examples can be found in examples/

Key management and Bitcoin address generation

from bitcoin_tools.core.keys import generate_keys, store_keys
from bitcoin_tools.wallet import generate_wif, generate_btc_addr

# First of all the ECDSA keys are generated.
sk, pk = generate_keys()
# Then, the Bitcoin address is derived from the public key created above.
btc_addr = generate_btc_addr(pk)
# Both the public and private key are stored in disk in pem format. The Bitcoin address is used as an identifier in the
# name of the folder that contains both keys.
store_keys(sk.to_pem(), pk.to_pem(), btc_addr)
# Finally, the private key is encoded as WIF and also stored in disk, ready to be imported in a wallet.
generate_wif(btc_addr, sk)

Raw transaction building

from bitcoin_tools.core.keys import load_keys
from bitcoin_tools.core.transaction import TX

# Key loading
btc_addr = "miWdbNn9zDLnKpcNuCLdfRiJx59c93bT8t"
sk, pk = load_keys(btc_addr)

# Reference to the previous transaction output that will be used to redeem and spend the funds, consisting on an id and
# an output index.
prev_tx_id = "7767a9eb2c8adda3ffce86c06689007a903b6f7e78dbc049ef0dbaf9eeebe075"
prev_out_index = 0

# Amount to be spent, in Satoshis, and the fee to be deduced (should be calculated).
value = 6163910
fee = 230 * 240

# Destination Bitcoin address where the value in bitcoins will be sent and locked until the owner redeems it.
destination_btc_addr = "miWdbNn9zDLnKpcNuCLdfRiJx59c93bT8t"

# First, we  build our transaction from io (input/output) using the previous transaction references, the value, and the
# destination.
tx = TX.build_from_io(prev_tx_id, prev_out_index, value - fee, destination_btc_addr)
# Finally, the transaction is signed using the private key associated with the Bitcoin address from each input.
# Input 0 will be signed, since we have only created one.
tx.sign(sk, 0)

# Once created we can display the serialized transaction. Transaction is now ready to be broadcast.
print "hex: " + tx.serialize()

# Finally, we can analyze each field of the transaction.
tx.display()

Raw tx analysis

from bitcoin_tools.core.transaction import TX

# First a transaction object is created (through the deserialize constructor) by deserializing the hex transaction we
# have selected.
hex_tx = "01000000013ca58d2f6fac36602d831ee0cf2bc80031c7472e80a322b57f614c5ce9142b71000000006b483045022100f0331d85cb7f7ec1bedc41f50c695d654489458e88aec0076fbad5d8aeda1673022009e8ca2dda1d6a16bfd7133b0008720145dacccb35c0d5c9fc567e52f26ca5f7012103a164209a7c23227fcd6a71c51efc5b6eb25407f4faf06890f57908425255e42bffffffff0241a20000000000001976a914e44839239ab36f5bc67b2079de00ecf587233ebe88ac74630000000000001976a914dc7016484646168d99e49f907c86c271299441c088ac00000000"
tx = TX.deserialize(hex_tx)

# Then, the transaction can be displayed using the display method to analyze how it's been constructed.
tx.display()

Using STATUS to dump the UTXOs LevelDB

from bitcoin_tools.analysis.status.data_dump import utxo_dump
from bitcoin_tools.analysis.status.utils import parse_ldb

# Set the version of the Bitcoin Core you are using (which defines the chainstate format)
# and the IO files.

f_utxos = "decoded_utxos.txt"
f_parsed_utxos = "parsed_utxos.txt"

# Set the coin we're working with
coin = 'bitcoin'

# Parse all the data in the chainstate.
parse_ldb(f_utxos)
# Parses transactions and utxos from the dumped data.
utxo_dump(f_utxos, f_parsed_utxos, coin)

# Data is stored in f_utxos and f_parsed_utxos files respectively

Support

If you find this repository useful, show us some love, give us a star!

Small Bitcoin donations to the following address are also welcome:

1srgi8sqPkCKq7gsVfhUZB7dvoi72UsqP

Disclaimer

This library allow you to modify any transaction field as you pleased. However, some modifications can make your transactions non-standard, or even non-spendable. We totally discourage the use of the library outside the testnet if you are not sure about what you are doing, specially when dealing with non-standard scripts. A bad use of the library can lead you to lose some of your bitcoins.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].