Bitcoin Forum
October 01, 2025, 04:21:17 PM *
News: Latest Bitcoin Core release: 29.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Bitcoin / Development & Technical Discussion / Re: Hashing coinbase transaction to get txid on: September 23, 2017, 06:25:16 AM
Ok, this is great info. But why is the segwit data only attached to coinbase transactions? Of the the random picks of transactions I've checked, this is true.
Edit: Sorry, read the above post again and got it this time. Thanks for your answers.
2  Bitcoin / Development & Technical Discussion / Re: Hashing coinbase transaction to get txid on: September 22, 2017, 05:43:54 PM
Ok, great. But my regtest setup (version 14.1) gives me a similar raw coinbase transaction:
Code:
020000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff050282060101ffffffff020e642500000000002321031a70a95a57f63b7d63e46803d385fd483b77f7a71a7a753ffcf7aafb67ec3edcac0000000000000000266a24aa21a9edad9d9c439414e2d257fda34cdc00667c0ecd7d78256721a4178046b49ee7382f0120000000000000000000000000000000000000000000000000000000000000000000000000
Is the implementation error in the node? Maybe working in 15.0?
3  Bitcoin / Development & Technical Discussion / Re: Hashing coinbase transaction to get txid on: September 22, 2017, 04:47:53 PM
My node is a couple of days of synching behind, so I can't get the transaction from it yet. But I tried getting the raw transaction from electrum wallet and chainquery.com, and they all have the long tail starting with 12... Where did you get your raw transaction?
4  Bitcoin / Development & Technical Discussion / Re: Hashing coinbase transaction to get txid on: September 22, 2017, 05:15:47 AM
Thanks. That's really strange. I'm getting the raw transaction from https://blockchain.info/tx/d0783f480343fb37b009b5e3db90ccad85e2c8314639de98b3bb66c396dd7915?format=hex , I haven't tried getting the data from my node, since I'm currently running tests in regtest mode. By the way, I'm having this problem in regtest aswell. I'll look more into this when I get home from work.
5  Bitcoin / Development & Technical Discussion / Hashing coinbase transaction to get txid on: September 21, 2017, 07:57:40 AM
I'm not able to get a txid from coinbase transactions, by hashing. I can get it from any other transaction by doing the double hash. Here's what I'm trying:
Code:
import hashlib

txid = 'd3104f6e12f47b9fef672820ed8721670b087aaa801591b43fa2210bf3887649'
txRaw = "0100000001c4efdc5025c9816bd6cc098b205ec7a5e5d91b398969e5350d4ce528310ea7a4000000006b483045022100a33944bd7354dd464b605d30f7f94f728f41c3dc58d434d918b4685e645b183e02200d37ec139c4d0de363ddd66bdb29ff19aac538644440dee950d03b935f1d3900012103eb38b8ea461b42ec464f738e890ab0c9ca909ef2e7df9599e5d939cb441e5390feffffff02b0ac1600000000001976a91492b00d72d4ef77d5710e71c415be831900e8739488acd0480a00000000001976a9149cadc280f1873709b80d005764e7a8741ee8d94788ac796b0700"
print('**')
print('Raw transaction:')
print(txRaw)
print('**')
data=txRaw.decode("hex")
hash = hashlib.sha256(hashlib.sha256(data).digest()).digest()
print('txid:')
print(txid)
print "Hashed Raw tx:\n", hash[::-1].encode('hex_codec')

Output when using a normal transaction:
Code:
**
Raw transaction:
0100000001c4efdc5025c9816bd6cc098b205ec7a5e5d91b398969e5350d4ce528310ea7a4000000006b483045022100a33944bd7354dd464b605d30f7f94f728f41c3dc58d434d918b4685e645b183e02200d37ec139c4d0de363ddd66bdb29ff19aac538644440dee950d03b935f1d3900012103eb38b8ea461b42ec464f738e890ab0c9ca909ef2e7df9599e5d939cb441e5390feffffff02b0ac1600000000001976a91492b00d72d4ef77d5710e71c415be831900e8739488acd0480a00000000001976a9149cadc280f1873709b80d005764e7a8741ee8d94788ac796b0700
**
txid:
d3104f6e12f47b9fef672820ed8721670b087aaa801591b43fa2210bf3887649
Hashed Raw tx:
d3104f6e12f47b9fef672820ed8721670b087aaa801591b43fa2210bf3887649

Output when using a coinbase transaction:
Code:
**
Raw transaction:
010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff3103816b07244d696e656420627920416e74506f6f6c6b2f4542312f4144362f4e59412f332059c36d7be1550000df320000ffffffff0238252e4d000000001976a914660371326d3a2e064c278b20107a65dad847e8a988ac0000000000000000266a24aa21a9edc11e8cdbd8d442b27bf8f273395baa83b5da4c9c3d87fbc539dad742480437100120000000000000000000000000000000000000000000000000000000000000000000000000
**
txid:
d0783f480343fb37b009b5e3db90ccad85e2c8314639de98b3bb66c396dd7915
Hashed Raw tx:
4495cc1d511e61de206cd5b18998eeab11932d42c6b1d264c400a20eefc97e99

I haven't been able to find any documentation about this. Does anybody know why this is?
6  Bitcoin / Development & Technical Discussion / Re: python-bitcoinlib, creating CBlock with getblocktemplate data on: July 13, 2017, 07:09:09 PM
Well, there is some documentation, but it doesn't answer my question.. https://media.readthedocs.org/pdf/python-bitcoinlib/latest/python-bitcoinlib.pdf . I was rather hoping that one of the developers would read this forum. Im reading the source code, but its kind of difficult to follow with the high level of abstraction (at least with my experiencie in mostly simple python code).
7  Bitcoin / Development & Technical Discussion / Re: python-bitcoinlib, creating CBlock with getblocktemplate data on: July 07, 2017, 07:56:21 AM
BTW is this the correct subforum for this post? I can't really find one that seems to fit the question, but i read that this subforum is not for support inquiries.
8  Bitcoin / Development & Technical Discussion / python-bitcoinlib, creating CBlock with getblocktemplate data on: July 06, 2017, 08:56:59 PM
I'm trying to learn about bitcoin by writing a python bitcoin miner using python-bitcoinlib (https://github.com/petertodd/python-bitcoinlib).
I'm having problems creating a complete CBlock with data from a getblocktemplate request. I get all parameters right except from the transactions, the vtx() in the function argument. CBlock() accepts an array of CTransaction()-objects. Is this the correct parameter? If so, how do I populate add data to the CTransaction()-objects from the getblocktemplate data? I've tried using the template transaction-data, but I only get errors of the type:  AttributeError: 'unicode' object has no attribute 'read'. I tried formatting the data as string or int aswell. What kind of object should be passed to CTransaction()? I'm reading the source code, but I can't figure it out.

No error:
Code:
foo = [bitcoin.core.CTransaction() for i in range(5)]
mineBlock = bitcoin.core.CBlock(2, bitcoin.core.x(block['previousblockhash']),bitcoin.core.x(mHash),block['curtime'],int(block['bits'],16),0x00,foo)

Error:
Code:
foo[0].stream_deserialize(block['transactions'][0]['data'])
gives
Code:
Traceback (most recent call last):

  File "mining.py", line 165, in <module>
    foo[0].stream_deserialize(block['transactions'][0]['data'])
  File "/home/hadoque/.local/lib/python2.7/site-packages/bitcoin/core/__init__.py", line 328, in stream_deserialize
    nVersion = struct.unpack(b"<i", ser_read(f,4))[0]
  File "/home/hadoque/.local/lib/python2.7/site-packages/bitcoin/core/serialize.py", line 79, in ser_read
    r = f.read(n)
AttributeError: 'unicode' object has no attribute 'read'


So, am I submitting the right data but in wrong format (how do I make data a serializable object?) or is the data wrong all together?

Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!