Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Hot answers tagged

23

This is a fun little puzzle on the blockchain, basically. First, you need to know a little about pdf's and how they're structured, which you can find here. Second, you'll note from section 3.4.1 that all pdf's start with this string: %PDF- In hex, that is 255044462d. And indeed that is in the very first output in the very first bare multisig pubkey: <...


11

In case you have not seen it, there is a good (IMHO) article which describes how to generate a transaction "manually" using "raw" python (no bitcoin libs or RPC): "Bitcoins the hard way: Using the raw Bitcoin protocol"


9

You cannot determine (from only a base58check address) if the corresponding public key is compressed. A "normal" pay-to-public-key-hash (P2PKH) is a cryptographic hash of either a compressed or an uncompressed public key. Because hashes cannot be feasibly reversed, you cannot tell if the public key, before being hashed, was compressed or uncompressed. More ...


8

Vitalik Buterin has recently shared Pybitcointools, a nice and simple-to-use Python library for handcrafting Bitcoin transactions. The example shows the basic workflow, which is pretty much what you have described in your example (just broken down to few more steps). If you need more help, this nice article explains bitcoin transactions technically and ...


8

In comparison to languages like Java or C++, Python has several advantages for coding bitcoin projects: Simplified rules of coding allows beginners and experienced alike to code and get results without getting bogged down in formatting etc Shell allows on the fly calculations Python code is easily read and as such can be edited to suit Python can be ...


8

Yes, this is supported. As specified by JSON-RPC 2.0, you can send in an array of requests, and receive an array of solutions.


7

AFAIK, there is no fundamental issues with implementing a complete bitcoin node using python, there is even some cool projects of Bitcoin full node in Python https://github.com/samrushing/caesure https://bitcointalk.org/index.php?topic=94645.0


7

First, you need to understand what the two formats actually are. The first is the compressed SEC format and the second is the uncompressed SEC format. The difference between the two is that the compressed format only includes the X value and the parity of the Y value while the uncompressed format includes both the X and Y values. The 02 at the beginning of ...


6

There isn't yet a complete implementation AFAIK, but there are different libraries that implement bitcoin features (wallets, keys, utilities, Depends on whether you want an implementation of bitcoin network protocol or wallet or just an overlay on top of the JSON-RPC interface of bitcoind. Useful code on github: https://github.com/jgarzik/python-...


6

OK, I figured out how to sign the raw Tx using Python ecdsa. I'll step through it: Recall: createrawtransaction '[{"txid" : "72b764383b99fb3d112ac8b474a5d7c4242b75dbfee2d4e9cf9a6703d90f805a", "vout" : 1}]' '{"n2kx7k6JuA5Wy27fawaeiPX7dq8mbRDPAv" : 0.99}' = ...


6

(The language used in this post is Python) Breadwallet uses BIP39 to generate the 128-bit master seed from the 12-word mnemonic. The master seed is then used to generate a set of wallets/accounts containing chains of addresses, using BIP32. First off, import hashlib and binascii, we're going to need them later. import hashlib from binascii import hexlify, ...


5

In ECDSA s can be on either side of the curve and the signature will still be valid. The term "low s" is referring to the value literally being being below the curve order (0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0). The requirement of low-s is arbitrary (high s would have worked just fine as well), and is one of the new BIP62 ...


5

Just like in regular bitcoin addresses (or anything base 58 encoded), the version bytes don't get encoded by themselves. As described in the Serialization format section, there is 78 byte payload that gets versioned and checksumed before then being encoded into base 58: 4 byte: version bytes (mainnet: 0x0488B21E public, 0x0488ADE4 private; testnet: ...


5

That strongly depends on your definition of complete. There are a number of implementations that implement parts of the Bitcoin node functionality. For example cdecker/pycoin has a solid network implementation, but does not include wallet management code and validation logic. richardkiss/pycoin on the other hand has some of the wallet logic, but lacks ...


5

Check out my ccxt library on GitHub: https://github.com/kroitor/ccxt With it you can access market data and trade bitcoin, ether and altcoins with many crypto currency exchanges. It is used to connect and trade with crypto markets and payment processing services worldwide. It provides quick access to market data for storage, analysis, visualization, ...


5

There was a recent presentation by Portia Burton going over some of the basic steps in creating your own custom blockchain based on Ethereum, however it is in Node not Python as you are requesting. It's not incredibly detailed, but still it could be useful: https://youtu.be/QWHjp_nzxaY?t=14m11s There's also this guide on bitcointalk using C++ and the ...


5

in debian =) sudo apt-get install libssl-dev pip install python-bitcoinlib or pip3 install python-bitcoinlib


5

If you convert the difficulty bits to hex you will get: 0x1F00FFFF Coefficient = 0x00FFFF Exponent = 1F = 31 Target = Coefficient * 2**( 8 * ( exponent-3 ) ) Target = 0xFFFF with 31 - 3 = 28 trailing NULL (0x00) bytes Target: 0x0000FFFF00000000000000000000000000000000000000000000000000000000 Your Hash: ...


4

You might find it easier to just query an electrum server directly. Stratum is a nice protocol in that it's easy to use in an ad-hoc fashion. If you're using python3 this is almost certainly the easier solution, too. def get_from_electrum(method, params=[]): params = [params] if type(params) is not list else params s = socket.create_connection(('...


4

You probably make the right decision to not use one of the centralized API (blockchain.com, etc.). Run you own bitcoin-core fullnode(s) and connect to the RPC or REST interface. You could connect via python with things like http://laanwj.github.io/bitcoin-python/doc/examples.html or any other RPC client. If you need blocks / headers / chaininfos and ...


3

os.getpid() in Python is getting the current process id. The processor id is 'random-ish', in that running the entire test several times will result in a different pid, but within the same test the pid will remain constant. The % operator is the modulus operator, which is essentially chopping off all but the last 3 digits of the processor id. Together os....


3

In order to create a transaction, you need the blockchain, or at least the transactions in the blockchain that belong to a particular address (technical term would be unspent transaction outputs or UTXOs for a particular script). There are three ways this can happen: You have a local bitcoind or btcd installed which would let you query for transactions, at ...


3

How do I send a Bitcoin address from an iPhone to my server? Basic Python client socket example: Server side: import socket serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) serversocket.bind(('localhost', 8089)) serversocket.listen(5) # become a server socket, maximum 5 connections while True: connection, address = serversocket....


3

In addition to aantonop's links, there is also for python: PyCoin https://github.com/richardkiss/pycoin Utilities for transactions signing and verification, and creation of deterministic wallets according to the BIP0032 standard. PyWallet https://github.com/jackjack-jj/pywallet bitcoin wallet importer/exporter


3

You are submitting a float value. Float values are not totaly accurate: >>> 0.9 0.90000000000000002 Thats why the specification requires a Decimal datatype: >>> from decimal import Decimal >>> Decimal("0.001")


3

I'm using pycoin (https://github.com/richardkiss/pycoin) in a project right now actually, tring to verify the data that needs to be signed in a bitcoin transaction, so I think I can speak to this. Python is good because it's easy to get projects up and running quickly. There are libraries that take the work out of things like ECDSA. Python is a more ...


3

A closer look at their API page, you will find LakeBTC has provided a simple code for Python: https://github.com/LakeBTC/lakebtc_python And others Sample Code you can find here: https://www.lakebtc.com/s/api include PHP, Node.JS, Ruby and Python, maybe will more Code in the future :)


3

The code you linked works for me in Python 3.4, so I'll assume you're looking for something for Python 2.7. This code is straight from here on GitHub: import base64, hashlib, collections, struct def int_to_bytes(int_rep, min_length = 0): """convert an unsigned integer to a string of bytes (in big-endian order) :param int_rep: a non-negative ...


3

Background info: What is a compressed Bitcoin key? Given just the address itself, no, there is no way to tell if it was generated from a compressed or an uncompressed public key. This is calculated from the base58 encoding of the RIPEMD(SHA256(public_key_bytes)). Since the hash isn't reversible, without the public key already in hand, you won't be able to ...


3

Yes, Pybitcointools (or this fork which has BIP39, file embedding and mk_opreturn) can do this. Install either version of pybitcointools using setup.py install, as usual. Then, with a raw hex transaction, rawtx, simply use txo = deserialize(rawtx). rawtx can be either a signed or unsigned hex transaction. The returned txo is deserialized as a dict object. ...


Only top voted, non community-wiki answers of a minimum length are eligible