Questions tagged [python]

Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability.

Filter by
Sorted by
Tagged with
2
votes
1answer
592 views

help me to understand this mining code

Help me to understand this code, spend all day to understand this code, and learned python from scratch, now I understand what operators do, but still some parts are complex to me. import hashlib, ...
2
votes
2answers
675 views

getting bitcoin address of blk*.dat files

I know that getting the address from the blk*.dat files is discussed a lot of times. But I don't get it why? When I have the raw scriptSig I can encode it and get the bitcoin address or not? E.g. the ...
2
votes
2answers
1k views

OP_RETURN using python

I'm trying to make a simple program that can reliably upload an OP_RETURN transaction. I have found some examples online, but so far they don't work consistently. The ones that go through seem to be ...
2
votes
2answers
651 views

“value” field in raw transaction: Rounded Bitcoins (float) or Satoshis?

I am getting confused about the Bitcoin amount presentation in a raw transaction's "value" field. If i want to spend 0.05 BTC, for instance, which of these is the correct value? "value" : 0.05 "...
2
votes
2answers
2k views

How can I create a list of X richest bitcoin addresses?

I have looked around, but I can't find the code related directly to my question. I want to create a list in any format that contains the all accounts with balance over 0 for example. Thanks ahead for ...
2
votes
1answer
52 views

How do I sign a transaction in Python?

How do I sign a P2SH transaction in Python? I am using the Python API that ships with the bitcoin source code, in directory bitcoin/test/functional. I'm using regtest. Here is a fragment of my unit ...
2
votes
1answer
310 views

Python: How generate bitcoin addresses using electrum library

What am I doing wrong here? I'm trying to generate bitcoin addresses from the seed but they do not match with ones from electrum application. Did I miss something? And I also have trouble with ...
2
votes
1answer
244 views

Cannot make valid Bitcoin Cash transaction

I've been way in over my head hacking around in various Python Bitcoin libraries. From what I understand, input public keys have to be compressed to be accepted. Is that correct? I have an ...
2
votes
1answer
254 views

Python testnet raw transaction creation error

Based on the script from github. I tried to construct a valid testnet transaction. I had to do some modifications to the script so here is the current code. import struct import base58 import hashlib ...
2
votes
1answer
433 views

from b58check to hex and back

I am manipulating (with pybitcointools) some regular addresses as well as some P2SH and stumbled upon the following: Case 1: >>> b58check_to_hex('17rq8m5SW8XoZ9dHEkQyBfc5w2XQnQvznz') '...
2
votes
1answer
435 views

Duplicate r value for an address: only an issue for a multi-input Tx?

I've modified the r-scan Python code to look beyond the 50 Txs the Blockchain.info API usually returns. My modifications take all the r values for my address and look for duplicates, but a commented ...
2
votes
1answer
292 views

Pushing a large signed transaction (testnet) using Python

I have been trying to send a signed transaction using pybitcointools (Python) using the blockr_pushtx function, however it consistently returns Exception: {"status":"fail","data":"Could not push your ...
2
votes
2answers
2k views

Bitcoin RPC works in bitcoin-cli but not in python-bitcoinrpc: No JSON object

I'm running a testnet node. I can use bitcoin-cli just fine: >bitcoin-cli.exe getinfo { "version" : 100000, "protocolversion" : 70002, "walletversion" : 60000, [... snipped] But when ...
2
votes
1answer
28 views

How to parse values in block index leveldb?

So I'm trying to read the block files with Python. From this link, What are the keys used in the blockchain levelDB (ie what are the key:value pairs)?, it tells you how to access the files with ...
2
votes
1answer
2k views

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

I'm trying to use the python-bitcoinlib library but its docs aren't entirely clear to me. I'm a programmer but quite new to Python, and not very versed in the Bitcoin protocol. What's the process, ...
2
votes
0answers
778 views

I can't connect to RPC from python. JSONRPCException: -342

Tryed to run this code : from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException import logging import json logging.basicConfig() logging.getLogger("BitcoinRPC").setLevel(logging.DEBUG) ...
2
votes
1answer
320 views

Python code to vb.net (2012) - help me to eliminate the errors

I wanted to convert the following bitcoin mining python code to VB.net (2012) and I tried to convert it's functionality, but it throws some errors and I'm stuck as I even can't get the resulting value ...
2
votes
0answers
444 views

How to add blockchain.info API key to pibitcointools

I have a query-intensive app I'm building that keeps timing out with the message: Traceback (most recent call last): File "test.py", line 72, in <module> array = bitcoin.multiaccess (...
2
votes
1answer
488 views

What is the required input for python-bitcoinlib getrawtransaction command?

I am running a bitcoin node on my machine, fully synced with RPC commands enabled, rpc server live and txindex=1. In the command-line I can run the following RPC call and obtain the information ...
1
vote
1answer
59 views

Why is Target < Blockhash?

I am currently trying to validate a blocks hash against its target in python3: This is a block in the Blockcypher testnet, and I am using this formula from the Bitcoin Wiki. block_hash = '...
1
vote
2answers
840 views

API Authentication via Python

I'm having trouble following LakeBTC's API instructions for connecting to their API via Python. API Documentation: https://www.lakebtc.com/s/api I have my key (email address) and secret. I'm using ...
1
vote
3answers
2k views

Bitcoin library in python

I need a good library for bitcoin and other BTC-like cryptocurrencies in python. I'm looking for something similar to bitcoinjs but in python. Minimal requirements: generate an EC keypair and get ...
1
vote
1answer
1k views

getrawtransaction seems to only work for certain transactions

I am working through mastering bitcoin. I am confused by getrawtransaction. I would like to look at the first transaction in block 277316. from bitcoinrpc.authproxy import AuthServiceProxy, ...
1
vote
3answers
1k views

Library for generating HD keys/addresses (ideally for python)

I require a library that I can create (and later import) a HD master key, which I will use to generate hundreds of addresses for both testnet and mainnet! Ideally, I need a python library (but had ...
1
vote
2answers
879 views

Help me use python-bitcoinrpc

I have got the api working and i can run commands like access = AuthServiceProxy("http://root:123@127.0.0.1:8332") access.getinfo() However not sure how to use more complicated commands such as: ...
1
vote
1answer
210 views

os.getpid() in Bitcoin's python test scripts - What does it actually do?

I was looking at ../qa/rpc-tests/util.py in order to figure out how arbitrary ports are assigned to each created node. In the first lines of the code it says: ...def p2p_port(n):return 11000 + n + ...
1
vote
1answer
2k views

API Bitfinex question: “key amount should be a decimal string”?

I started writing code for the Bitfinex api yesterday and I've been struggling quite a lot with this. I am using jndok's python implementation. I added my pyblic and secret keys and wrote this line ...
1
vote
1answer
48 views

In Python RPC Calls, How is vout Address Derived for P2PK transaction?

How is the vout address derived for a P2PK transaction? I am using the Python API that ships with the bitcoin source code, in directory bitcoin/test/functional. I'm using regtest. I have written a ...
1
vote
2answers
60 views

Why are my Signature Scripts Different from my professors?

bob_addr = "1NWzVg38ggPoVGAG2VWt6ktdWMaV6S1pJk"#"1FMb8Jnn1jSh7yjDFfonC8xCCH3ittoEzB" bob_hashed_pubkey = base58check.b58decode(bob_addr)[1:] bob2_hashed_pubkey = b'\xec\x06\xb2\xbf\x18\xc8\x97\x06\...
1
vote
1answer
3k views

ecdsa - Create Private key and Bitcoin Address

I have the following code: import binascii import hashlib from fastecdsa import keys, curve # generate a private key for curve P256 priv_key = keys.gen_private_key(curve.secp256k1) print (priv_key) ...
1
vote
1answer
370 views

When I call the blockchain.info API, I an error. What can i do to solve this problem?

A script that calls the blockchain.info API to find the UTXO related to an address # get unspent outputs from blockchain API import json import requests # example address address = '...
1
vote
1answer
445 views

ScriptSig field during P2PKH transaction signature

In P2PKH transactions, the content after signing the transaction contains: <signature(with hash_flag)><public_key>. However, since the signature can't sign itself, during the signature ...
1
vote
1answer
262 views

python-bitcoinrpc: only DEBUG available?

I'm starting with python-bitcoinrpc from J.Garzik. I'm using to try it the code provided by James D'Angelo (from Bitcoin 101 on youtube): Apparently, there were some major changes with python-...
1
vote
1answer
266 views

Regular Expressions for DER signature hex (also req, address, TxIDs)?

I'm using Python (2.7) and its re module for recognition of various Bitcoin data, namely: addresses, DER sigs, OP Return hexdata, TxIDs I've been using re.compile: for example, for a valid Tx ...
1
vote
2answers
9k views

Solving PyCrypto 2.6.1 errors for Python 3.4 (Windows7 x64)?

Whilst there's less of an issue with Python 2.7, Python 3.4 relies on the pycrypto library for numerous wrappers/APIs/tools such as BlockTrail, pycoin, pybitcointools, etc etc. The error I'm getting:...
1
vote
1answer
38 views

How to Pay to Multisig Wallet Using python-bitcoinrpc?

How do I pay to a multisig wallet? I am using the Python API (based on python-bitcoinrpc) that ships with the bitcoin source code, in directory bitcoin/test/functional. I'm using regtest. I call ...
1
vote
2answers
36 views

Why getinfo() and listchannels() inactive channel count differs?

I have strange results comparing node information outputs between getinfo() and listchannels() calls. Maybe someone has thoughts what is wrong (with my trivial code or with c-lightning itself): chans ...
1
vote
1answer
44 views

Create a transaction spendable in a specific block height

I am new in Bitcoin and I try to create an address in Bitcoind and send a transaction that the amount will be spendable in a specific height of the blockchain. Here is what I have done: privateKey = ...
1
vote
1answer
60 views

Mutlisig tansactions with trezor with multiple inputs and outputs not able to broadcast

I am trying to do a multisig here is my final hex ...
1
vote
3answers
2k views

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

I basically followed the instructions here How to generate mycelium addresses from the 12 words in python So my code is similar: from bip32utils import BIP32Key from bip32utils import BIP32_HARDEN ...
1
vote
1answer
329 views

Altcoin - genesis block - TypeError: __init__() takes exactly 2 arguments (3 given)

I'm trying to use the genesis script from innova to generate a genesis block of Xevan_hash https://github.com/innovacoin/GenesisH0/blob/master/genesis.py I'm using these parameters: python genesis....
1
vote
1answer
205 views

bitcoin chainstate database parsing in python giving wrong value

I am trying to decode chainstate db for a specific out index for a transaction in python just for learning. Transaction ID: 4d4a4c6ca4f3c91e69563199943336d3279fad71c9e8d9c1708ef9dc6ac16000 out index = ...
1
vote
1answer
162 views

Project on modelling Bitcoin blockchain data

I am doing a thesis project on modelling Bitcoin blockchain data, but atm I am having trouble getting data from the Bitcoin blockchain into a format that is easy to deal with in e.g. Python. I have ...
1
vote
1answer
480 views

Can I connect to Litecoin, Dash, BitcoinCash, Doge, etc. RPC with Bitcoin RPC client?

I want to set up a few nodes for different Bitcoin-derived cryptocurrencies and regularly query them for data via the JSON-RPC API. The thing is: I can't find much information on any other RPC API ...
1
vote
1answer
396 views

Is it possible to spend bitcoins from private key 0?

In [1]: from bitcoin import * In [2]: privtoaddr(0) Out[2]: '16QaFeudRUt8NYy2yzjm3BMvG4xBbAsBFM' On blockchain.info, there is 0.01 BTC unspent in this address. Is it possible to spend the bitcoins? ...
1
vote
1answer
2k views

How to start working with blk*.dat data?

I have the complete bitcoins block data (blk00000.dat, blk00001.dat.....). I want to convert it into some readable format like csv or json. Can it be done using python or any other software ?
1
vote
1answer
814 views

Stratum Server Exception “[coin] is not connected”

When i running 'twistd -ny launcher.tac' i getting the following Exception. The connection okay. Please help me to fix this issue. 2017-01-30 19:33:43,094 INFO bitcoin_rpc # Checking for submitblock ...
1
vote
1answer
799 views

Sending transaction with Python + raw protocol

Two days ago I've found a few articles, about using raw bitcoin protocol, and now I'm still trying to send a transaction. My code is based on this class, and if I understand all of this bitcoin magic ...
1
vote
1answer
342 views

anyone attempted a multiple p2sh(multisig) send (ideally using python)?

I attempted to use pycoin to do a "create_signed_tx" in python, but had no joy: Do you think it might be technically possible to use spendables(UTXOs) from multiple source P2SH wallets in a single ...
1
vote
1answer
125 views

micropayment channels, n-m addresses, interoperability

I just read bitcoinJ's working with contracts tutorial and I am puzzled as: it seems to me that n-m addresses are implemented in Bitcoinj using plain multisig (as defined in this bit of the developer'...