Questions tagged [python]
Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability.
345
questions
0
votes
1
answer
46
views
How to convert the results of point doubling (Rx1 and Ry1) to point addition (Rx2 and Ry2) without knowledge of (Qx, Qy) in secp256k1 elliptic curve
I'm working with the secp256k1 elliptic curve and have point doubling and point addition formulas for this curve. Given the following formulas:
Point Addition Formula in Python3:
s = (Qy - Gy) * pow(...
0
votes
1
answer
55
views
Order 12 phrase for trust wallet
I have 12 phrases for trust wallet but he is not arranged in the right way.
What is the solution? Code python with bip39!! How !?
1
vote
0
answers
23
views
OP_CHECKLOCKTIMEVERIFY Using Python on Bitcoin Mainnet
I am trying to create a raw bitcoin transaction in hexadecimal form using python and I'm having trouble successfully broadcasting a transaction that uses OP_CHECKLOCKTIMEVERIFY (that is, fund-freezing ...
0
votes
1
answer
51
views
Converting compressed WIF to uncompressed WIF so it works with bitcoinaddress Python library
I'm trying to convert a compressed WIF generated by bitcoinaddress python Library but I couldn't find a function to do the task so I collected one. I would like someone to review my code and maybe ...
1
vote
1
answer
140
views
Native P2WSH over P2SH | P2SH-P2WSH
I'm in the process of attempting to generate a transaction using the Python Bitcoin Utils library. that involves P2WSH-over-P2SH (P2SH-P2WSH). My activity is on the regtest network. Below is the code ...
1
vote
0
answers
42
views
Error when trying to broadcast multi input tx (Programming Bitcoin by Jimmy Song)
I am reading Programming Bitcoin (chapter 7 exercise 5) and I have created a 2 inputs 1 output transaction on testnet which I have signed and it now verifies as true. When I go broadcast the ...
0
votes
0
answers
69
views
faster way to get bip44 address from mnemonic?
Long story short my 12 word seed phrase has a passphrase and I forgot the order.
So I did all the permutations of the 12 words to find the valid ones (29939407). So the script below is my way of ...
0
votes
0
answers
24
views
How to calculate the pool difficulty based on mining.set_difficulty method from Stratum protocol?
I am trying to build a simple python cpu miner and I have referenced a few other github repos (for learning purposes not for money purposes). I've noticed that many of them simply ignore the mining....
0
votes
2
answers
79
views
How to get UTXOs Data from the network Using python?
I want to have the Bitcoin Network UTXOs only for a data analysis project and the purpose is visualization of the time series of 1>BTC wallets . how can I do it using python ? ( or is there any ...
0
votes
1
answer
161
views
How to differentiate between BTC transactions and BRC20 transactions on a blockchain?
How to differentiate between BTC transactions and BRC20 transactions on a blockchain using the RCP interface?
This is a transaction record that contains BRC20 tokens which I found on a blockchain ...
0
votes
0
answers
39
views
Master Node(BIP32 Root Key) to xpriv and xpub
I struggle to make a python script that can make xpriv and xpub (extended public and private key) from the Master Node (BIP32 Root Key). I've derived the Master Node from the BIP39 seed with ...
1
vote
0
answers
64
views
How to set change address with python bitcoinlib
I am using python's bitcoinlib to try and set up payments where a client sends funds to a server and then sends requests signed with their key as proof that the request came from them. The server ...
1
vote
0
answers
85
views
How to get transaction size as byte before send with Python's bit library?
I am using bit library to make a Bitcoin transaction.
I can use methods like this:
key.create_transaction([('1Archive1n2C579dMsAu3iC6tWzuQJz8dN', 190, 'jpy')])
or
key.send([('...
1
vote
0
answers
95
views
Bitcoin Transaction Builder in Python
is there a python code that helps build raw bitcoin transactions (Legacy and Segwit)?
I have seen javascript but not in python.
1
vote
1
answer
48
views
How to build a raw signed transaction with a FIXED fee? [duplicate]
I was wondering how can we build a transaction with a fixed amount of fees already FIXED.
Let's have this configuration
2 Inputs (X:0 = 520 BTC, X:1 = 102 BTC) => 1 RECEIVER (+510 BTC)
Fees are: 0....
2
votes
1
answer
69
views
Failing to construct transaction that unlocks P2WSH
I am trying to unlock the P2WSH output of the following transaction:
https://blockstream.info/testnet/tx/b435b180c936564cc902ce3d7011643836a74d671159d494f59536e70d977cd2
The script that I'm paying to ...
2
votes
2
answers
78
views
Bitcoind python connection
I'm trying to connect to bitcoind with python3. I'm currently following the instructions of Antonopolous book.
This is my code on an IDE:
from bitcoin.rpc import RawProxy
p = RawProxy()
info = p....
1
vote
0
answers
73
views
I get a not a P2TR scriptPubKey error when trying to generate a bech32m taproot compliant P2TR address with python
I have the following script that is supposed to derive a taproot P2TR address:
from bitcointx import set_custom_secp256k1_path
set_custom_secp256k1_path('./bitcointx_secp256k1_here/libsecp256k1.2....
2
votes
2
answers
283
views
How do I generate a testnet segwit v1 taproot compliant bitcoin address?
I have a script that generates a segwit v1 taproot compliant address and private key. The script currently generates a regtest address but with minor tweaks it spits out a mainnet address. I think the ...
0
votes
0
answers
57
views
How to get unspents using the private key of the bip84 wallet
Maybe my question is stupid, but I really can't figure
out why when I use the bip44 private key, it works, but if it's bip84, it doesn't
from bit import PrivateKey, Key
import bitcoinlib
my_key = ...
3
votes
1
answer
269
views
How to get the derivation path of a multi-wallet seed phrase?
I only have the seed phrase. When I enter the seed phrase into, for example, Exodus or Trust Wallet, I can fully recover my Bitcoin in seconds. But how to do this using Python or Node.js?
2
votes
1
answer
64
views
How can I store a file hash in a Schnorr signature? Or something other than an OP_RETURN?
I have this python script that puts file hashes on the bitcoin blockchain:
from bitcoinutils.utils import to_satoshis
from bitcoinutils.setup import setup
from bitcoinutils.transactions import ...
1
vote
1
answer
72
views
How do I use python-bitcoin-utils to add an OP_RETURN message into a bitcoin transaction?
I have the following code that successfully created a bitcoin transaction with python-bitcoin-utils:
from bitcoinutils.utils import to_satoshis
from bitcoinutils.setup import setup
from bitcoinutils....
1
vote
1
answer
748
views
python-bitcoin-utils - sendrawtransaction RPC error: {"code":-25,"message":"bad-txns-inputs-missingorspent"} when trying to broadcast my tx?
I am trying to create a bitcoin transaction to send all of the funds from tb1qj6zz96g8xgrwpgmdlvmkrjlwzz54sf47086yc9 to tb1qxgm8j0cq7tnftef3t563psl56gtmzxanm5c9uy. ...
1
vote
1
answer
70
views
I am trying to convert the 12 words into BTC addresses, but they do not match
I am trying to convert the 12 words into BTC addresses, but they do not match the ones shown to me by Safepal, Coinomi, and Trust Wallet. I have tried using several libraries and doing it manually.
I ...
0
votes
1
answer
42
views
Recreate Java code in python
I have a java code that I need to pass to python but I don't know which libraries to use and how to start and if you can help me I would really appreciate it
MNEMONIC = "twenty four mnemonic ...
1
vote
0
answers
37
views
Pass Java code to Python [closed]
I have a Java code that I need to pass to python but I don't know which libraries to use and how to start and if you can help me it is very grateful
MNEMONIC = "twenty four word mnemonic here&...
2
votes
1
answer
48
views
python bitcoin_explorer can't read block 761249
I installed bitcoin node, synced up to date.
I am using python bitcoin_explorer to read the block data.
I can read all blocks, however, I can't read block 761249
I am not sure it's my syncing problem, ...
0
votes
0
answers
110
views
Interpreting descriptors from bitcoinrpc for python
I've been running through the Bitcoin blockchain like this and comparing the descriptors to https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md...
rpc_connection = AuthServiceProxy("...
1
vote
1
answer
49
views
Reading blk.dat files using pybtc does not yield transactions
I am trying to parse the blk.dat files using pybtc but I can't seem to get this right.
f = open(block_filename, "rb")
lines = f.readlines()
for block in tqdm(lines):
...
5
votes
1
answer
268
views
How do you construct witness stack and controlblock in P2TR Script Path outputs?
I have been documenting how to create different types of Tx outputs here, leveraging the Bitcoin Core Test Framework. Particularly for Taproot, I'm working on a scenario of a P2TR Script Path with a ...
0
votes
1
answer
238
views
How to create SegWit address from mnemonic in Python 3.8.10
I am having trouble creating SegWit address from mnemonic. I can't find any useful code to do that. I tried using BitcoinLib but I don't know how to disable saving wallets to disk.
EDIT:
I found ...
3
votes
1
answer
186
views
Optimising blockchain parsing with rpc + python
I have a python app to track and store utxo in a simple/flat structure that looks like this...
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
# track the utxo
trackUtxoList = []
...
0
votes
0
answers
68
views
Bitcoin RPC BrokenPipeError on specific block/transaction
I have a simple python app running through the blockchain as follows...
rpc_connection = AuthServiceProxy("http://%s:%[email protected]:8332"%(rpc_user, rpc_password))
for b in range(blockStart, ...
0
votes
1
answer
124
views
Retrieving bitcoin address of the receiver of a transaction with bitcoinrpc
I'm trying to write a simple python implementation using bitcoinrpc to extract the address receiving a transaction but...
I'm not sure why certain fields are only accessible inconsistently. E.g. tx['...
3
votes
1
answer
938
views
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?
What have the challenges been of having the HWI written in Python?
There seems to be interest and rationale(s) to write another HWI in Rust. Would ...
2
votes
1
answer
146
views
Error validating transaction: unexpected witness payload for non-witness script in a P2TR using script path
I am trying to create a raw transaction P2TR, spending a Taproot UTXO using the script path.
I did the following:
Create a random private key d and corresponding pubkey P (the internal pubkey)
...
4
votes
1
answer
479
views
non-mandatory-script-verify-flag (Invalid Schnorr signature) when I try to send a P2TR tx on testnet
I'm learning to create tx from scratch in order to understand better how bitcoin tx works and how they are structured. I learnt to create tx with legacy address, segwit v0 and I am now learning ...
2
votes
1
answer
192
views
Having issues properly generating a p2pkh address in Rust code. (for research purposes not for real use)
I have followed the steps to generate a p2pkh compressed base58 address and am consistently checking it to find that I get an invalid checksum.
I am using this python code to check the address:
(...
1
vote
0
answers
77
views
Cannot import python-bitcoinlib into a simple script
Im writing a simple python script to connect to a local bitcoin node and list transactions.
I created a virtual environment with:
virtualenv bitcoinenv
And then activated:
source bitcoinenv/bin/...
0
votes
1
answer
64
views
What is the correct way of formatting pubkey_script in coinbase generation transaction?
This may be a simple question for others but I'm struggling trying to understand pubkey_script in the generation transaction.
In this Python code I'm trying to create a pubkey_script:
from base58 ...
0
votes
0
answers
44
views
NameError at /register name 'privtopub' is not defined
from django.shortcuts import render, redirect
from django.contrib.auth.models import User, auth
from django.contrib import messages
from .models import Details
from bitcoin import *
import random
...
3
votes
1
answer
108
views
Is it possible to retrieve input addresses and input values of bitcoin transactions from raw blk.dat files?
I'm developing a script that processes blk.dat files from bitcoin core. So far, I am able to retrieve the following attributes for transaction inputs:
"vin",
"index",
"...
0
votes
0
answers
37
views
how does n work in Type 1 Deterministic Wallet?
According to Bitcoin wiki:
A type 1 deterministic wallet is a simple method of generating addresses from a known starting string. [...] To generate a private key take SHA256(string + n), where n is ...
1
vote
2
answers
216
views
Analyse huge amount of blockchain data
I am trying to go over all transactions data from every block on the bitcoin blockchain from the previous 4 years. With almost 2k transaction per block, it will take a lot of queries per block. I have ...
0
votes
2
answers
116
views
What is the python equivalent of this php code $values = unpack("C*", pack("H*", $scriptpubkey));
I'm trying to convert this php code:
$scriptpubkey = '4104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac'
$values = ...
-2
votes
1
answer
40
views
I have upgraded libsecp256k1 to latest master but I'm having issues to link it properly now. How can I resolve this?
I have upgraded libsecp256k1 to the latest master but I'm having issues to link it properly now. What is the problem and how might I resolve it?
The error message is:
collect2: error: ld returned 1 ...
0
votes
1
answer
160
views
How to get information from electrum wallet?
I have my wallet file and it is encrypted with a password.
How to decrypt wallet file using code?
Encryption seems similar to Fernet.
1
vote
1
answer
118
views
How can I tweak a private key in bitcoin core
I'm wondering what the workflow is for building tapscripts.
I can generate a new address, but how do I tweak it with the tap script?
I've done the bitcoin taproot workshop a couple times now and ...
1
vote
1
answer
123
views
How to add multihreading to a continuous SECP256K1 Python function?
I have an infinite loop Python function for measuring how fast are SECP256K1 public Keys are generated.
The script:
from time import time
a = 0
b = 7
n = ...