Hot answers tagged

9 votes

Convert WIF to private key

converts WIF private key back to basic private key format import hashlib import base58 import binascii private_key_WIF = input("WIF: ") first_encode = base58.b58decode(private_key_WIF) ...
george7n's user avatar
8 votes

How do I convert Public Key x value to y in Python and verify?

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 ...
Jimmy Song's user avatar
  • 7,759
8 votes

How is the whitepaper decoded from the blockchain (Tx with ~1000x m of n multisig outputs)

This is a bash command that can also give you the file: bitcoin-cli getrawtransaction 54e48e5f5c656b26c3bca14a8c95aa583d07ebe84dde3b7dd4a78f4e4186e713 0 ...
Steven Roose's user avatar
  • 11.8k
8 votes
Accepted

How does bitcoin functional test framework work?

The functional tests test the RPCs. The unit tests test the C++ code directly by calling the functions. The functional test frameworks uses a version of python-bitcoinrpc which can be found here. ...
Ava Chow's user avatar
  • 69.9k
8 votes
Accepted

Why is the Bitcoin Core HWI written in Python? If it was rewritten in Rust should the Python HWI still be maintained?

Why is/was the Bitcoin Core HWI written in Python? The biggest factor was that, at the time, every the major hardware wallet vendor provided a Python library to interact with them. Over time, this ...
Ava Chow's user avatar
  • 69.9k
7 votes
Accepted

bitcoin.rpc python library problem

in debian =) sudo apt-get install libssl-dev pip install python-bitcoinlib or pip3 install python-bitcoinlib
Guillermo Graña's user avatar
7 votes
Accepted

Why bitcoin's generator point does not satisfy Elliptic Curve Cryptography equation?

The secp256k1 arithmetic is defined over the finite field of integers modulo 2256 - 232 - 977. The following code works: M = 2**256 - 2**32 - 977 Acurve = 0 Bcurve = 7 Gx = ...
Pieter Wuille's user avatar
6 votes

Recovering a HD wallet from a partial seed phrase

(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 ...
LivingInformation's user avatar
6 votes
Accepted

python-bitcoinlib | Create Private Keys, Public Keys and Addresses - How to Do It?

Sorry I am not familiar with python-bitcoinlib but if your goal is to just create keys/addresses you can use this library (disclosure: I wrote it) the following way: Generating a private key ...
Mike D's user avatar
  • 3,569
6 votes

How to generate public and private key pairs from the 12 seed words in python

Please try the following demo, and the result is same with https://iancoleman.io/bip39/. $ python3.6 test.py {'addr': '1A9vZ4oPLb29szfRWVFe1VoEe7a2qEMjvJ', 'coin': 'BTC', 'mnemonic_words': 'aware ...
debug's user avatar
  • 161
5 votes

Algorithmic trading python library?

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 ...
Igor Kroitor's user avatar
5 votes
Accepted

Mining Block header bit reversing

Let's take a look at this block, because it only has one transaction (the coinbase): 000000000000000000eb2d0ed97a7b2cff7f1408417dca83908004beb6fd9b95 Let's grab the raw hex data: ...
meshcollider's user avatar
  • 11.8k
5 votes

Python: How generate bitcoin addresses using electrum library

The derivation path you used is incorrect. Electrum does not use bip44. Anyway here's one way to do this for p2pkh addresses: from electrum import bitcoin from electrum import keystore seed = "<...
Abdussamad's user avatar
  • 2,689
5 votes
Accepted

Why is Target < Blockhash?

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 ...
James C.'s user avatar
  • 2,511
5 votes
Accepted

How to use python reference for encoding a bech32 address?

The reference implementation provides a handy all-in-one encode function. To encode the scriptPubKey 0014751e76e8199196d454941c45d1b3a323f1433bd6 as a mainnet bech32 address, you would do: import ...
Ava Chow's user avatar
  • 69.9k
5 votes

How can I access remote lightningd with pyln-client

c-lightning by itself does not expose it's RPC over the network. This is to avoid having to dictate what kind of authorization and authentication to use in order to provide access control. There are ...
cdecker's user avatar
  • 9,418
5 votes
Accepted

Optimising blockchain parsing with rpc + python

You're going to see much better performance by doing the parsing of block data yourself directly off disk, though that involves a decent amount of complexity. If you want to stick with bitcoind RPC ...
Pieter Wuille's user avatar
4 votes

Where can I learn how to build a blockchain from scratch?

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. ...
m1xolyd1an's user avatar
  • 5,626
4 votes
Accepted

How can I sign transaction hex with Python library

There is pybitcointools, which allows you to do just that using the sign(tx, index, priv) function. There are others but I at least found this one the easiest to work with. EDIT: You have many ...
hartmut's user avatar
  • 681
4 votes
Accepted

How to convert a WIF private key to a BIP32 extended private key

You can't. The BIP 32 extended private key format contains information which is not present in the WIF private key. The extended private key format contains the chaincode of the private key, the index,...
Ava Chow's user avatar
  • 69.9k
4 votes
Accepted

Convert WIF to private key

Don't do this: binascii.hexlify(private_key_WIF). That's not how you use binascii.hexlify. There is no hex here, and the string is not a bytes-like object. private_key_WIF is just a string. You want ...
Ava Chow's user avatar
  • 69.9k
4 votes

How to produce a Hash160 bitcoin address?

The address is already a hash, together with a 4-byte checksum and a version byte. To get from an address to a hash160, you don't have to compute sha256 or ripemd160 of anything. You just have to ...
Nate Eldredge's user avatar
4 votes
Accepted

How to fetch the latest unspent transaction by an address using bitcoind?

Bitcoind does not index transactions for non-wallet addresses. If you wish to build this yourself, you will need to: Enable txindex=1 in your bitcoin.conf Rescan the chain Set up blocknotify and then ...
Raghav Sood's user avatar
4 votes
Accepted

Why future Bitcoin Core release shouldn't be in python?

Apart, from having to tear down the entire code, and re-write it in python and check for vulnerabilities, This is what is known as a self-answering question. The obstacles you list are not trivial. ...
RedGrittyBrick's user avatar
4 votes
Accepted

Checking external bitcoin address balances via JSON-RPC API

Bitcoin Core does not track each individual address, only the addresses associated with your wallet. There are other clients, such as bitcore-insight and btcd, which maintain a separate address index....
Raghav Sood's user avatar
4 votes

convert private key to bitcoin address using python or php

I think this video will explain it in details (python): https://youtu.be/tX-XokHf_nI Using the code from video, pip packages ecdsa , hashlib and base58: import ecdsa import hashlib import base58 # ...
Tony Sanak's user avatar
  • 1,689
4 votes

Download blocks in blk00000.dat format from a specific period

Bitcoin Core is the only software that saves the blocks in the blk*.dat format. This format is not standardized and internal (i.e. not exposed to users). The contents of, for example, blk2342.dat can ...
0xb10c's user avatar
  • 1,400
4 votes
Accepted

how to convert WIF key return to HEX format

Using this python library (I am the author) >>> from cryptotools import PrivateKey >>> prv = PrivateKey.from_wif('5KUkQNKHA9cVmhSyKuNmop7r83DN2fMhPtNUW843Q6JxqRddEVz') >>> ...
Mike D's user avatar
  • 3,569
4 votes
Accepted

What is the probability of an ECDSA signature being less than 71 bytes

The following Python program computes all the possible total lengths as accurately as computationally feasible: from fractions import Fraction P = 2**256 - 2**32 - 977 N = ...
Pieter Wuille's user avatar

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