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)
...
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 ...
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 ...
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. ...
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 ...
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
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 = ...
6
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:
...
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
...
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 ...
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 ...
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 = "<...
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 ...
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 ...
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 ...
5
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 = ...
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 ...
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 ...
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.
...
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,...
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 ...
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 ...
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 ...
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.
...
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....
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
# ...
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 ...
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')
>>> ...
4
votes
How does the BIP340 lift_x algorithm work?
def lift_x(x: int) -> Optional[Point]:
This is a function that given an X coordinate, computes one of the two corresponding Y coordinates on the curve; specifically, the even one.
Every possible ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
python × 372bitcoin-core × 53
blockchain × 30
transactions × 29
bitcoind × 29
json-rpc × 29
bip32-hd-wallets × 24
python-bitcoinlib × 23
private-key × 21
api × 19
signature × 19
mnemonic-seed × 19
script × 18
address × 16
segregated-witness × 16
public-key × 16
electrum × 15
ecdsa × 15
wallet × 14
block × 12
raw-transaction × 12
secp256k1 × 12
bitcoin-core-development × 11
development × 11
address-generation × 11