Skip to main content
Share Your Experience: Take the 2024 Developer Survey
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
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
3 votes

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

Some usage examples are now available in the repository. This example demonstrates how to generate a key pair, and create a transaction paying to the public key hash (P2WPKH). There is also the ...
Antoine Poinsot's user avatar
3 votes
Accepted

Should an offline address generated from private key send funds to wallet?

From what I understand, that address is created from my private key, so shouldn't the funds I send to it go straight back to my wallet? Unless you told your wallet to expect transactions sent to that ...
Pieter Wuille's user avatar
2 votes
Accepted

Keep getting wrong bitcoin addresses

Some key points here: The private key cannot reach 2**256 because you must respect the order of the curve, which is n = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141. Set the ...
phantom's user avatar
  • 121
2 votes

Why do I have a socket.timeout with python-bitcoinlib?

Change the timeout inside the file bitcoin.conf or when you start the bitcoind, This is an example ## ## bitcoin.conf configuration file. Lines beginning with # are comments. ## # On client-side, ...
vincenzopalazzo's user avatar
2 votes
Accepted

How to get scriptPubKey from public key hash

Clarification on what is the difference between these things: public key hash, scriptPubKey, addresses. Public key hash represents, as it name says, the hash of the public key. So you take the public ...
LeaBit's user avatar
  • 950
1 vote

How does bitcoin core API work locally (network) - bitcoinlib in python using too many web sockets

This seems to be an issue with how Windows deals with ports. According to https://help.socketlabs.com/docs/how-to-fix-error-only-one-usage-of-each-socket-address-protocolnetwork-addressport-is-...
Ava Chow's user avatar
  • 70.8k
1 vote

Unable to get Taproot address using bitcoinlib

python-bitcoinlib doesn't have Taproot support at all (including bech32m, key tweaking, Taproot trees of scripts) at the time of writing (January 2024). There is an open issue here. Taproot tweaks an ...
Michael Folkson's user avatar
1 vote

I am trying to convert the 12 words into BTC addresses, but they do not match

For P2PKH, you've hashed the private key rather than the public key. For P2SH, you've hashed the public key and used the P2SH version number, however that is not what a P2SH address should be. Rather ...
Ava Chow's user avatar
  • 70.8k
1 vote

Recreate Java code in python

I have a java code that I need to pass to python Unless the same library has been ported to both languages, there will probably be no direct equivalent. Instead it will probably be best to describe ...
RedGrittyBrick's user avatar
1 vote
Accepted

Invalid transaction. Error: TX decode failed. Make sure the tx has at least one input

I figured it out, I simply was missing a step. I wasn't signing my transaction before sending. >>> t.sign('my_private_key') >>> res = srv.sendrawtransaction(t.raw_hex()) >>> ...
Sonny Parlin's user avatar
1 vote
Accepted

Does python-bitcoinlib and the Bitcoin Core functional test framework share code? Were changes ever pushed down/upstream?

script.py of the Bitcoin Core functional test framework contains a comment that it was initially modified from python-bitcoinlib. There doesn't appear to have been any code sharing beyond that and ...
Michael Folkson's user avatar
1 vote

What is the Best Way to Learn python-bitcoinlib?

Official documentations provides several examples. https://github.com/petertodd/python-bitcoinlib/tree/master/examples project1 of Stanford cs251 guide you through P2PKH, atomic swap, etc. https://...
Paul Yu's user avatar
  • 35

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