Bitcoin Forum
May 05, 2024, 01:11:24 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: If you have read "Mastering Bitcoin", can you please answer this question?  (Read 1912 times)
pf (OP)
Full Member
***
Offline Offline

Activity: 176
Merit: 105


View Profile
July 03, 2015, 06:47:36 AM
 #1

Will this book provide me with enough knowledge so that I can, with only Bitcoin Core and nothing else, create a bitcoin transaction that puts my own SHA-512 hash of a text onto the blockchain? (I want to prove 10 years from now that I wrote this text 10 years ago and I want to do this myself with only Bitcoin Core.)

I skimmed through the book and it seems very focused on the Blockchain.info API. Am I right about this? I'm not really interested in the Blockchain.info API. I wanna do things myself using the core software.
1714914684
Hero Member
*
Offline Offline

Posts: 1714914684

View Profile Personal Message (Offline)

Ignore
1714914684
Reply with quote  #2

1714914684
Report to moderator
1714914684
Hero Member
*
Offline Offline

Posts: 1714914684

View Profile Personal Message (Offline)

Ignore
1714914684
Reply with quote  #2

1714914684
Report to moderator
1714914684
Hero Member
*
Offline Offline

Posts: 1714914684

View Profile Personal Message (Offline)

Ignore
1714914684
Reply with quote  #2

1714914684
Report to moderator
You get merit points when someone likes your post enough to give you some. And for every 2 merit points you receive, you can send 1 merit point to someone else!
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714914684
Hero Member
*
Offline Offline

Posts: 1714914684

View Profile Personal Message (Offline)

Ignore
1714914684
Reply with quote  #2

1714914684
Report to moderator
1714914684
Hero Member
*
Offline Offline

Posts: 1714914684

View Profile Personal Message (Offline)

Ignore
1714914684
Reply with quote  #2

1714914684
Report to moderator
1714914684
Hero Member
*
Offline Offline

Posts: 1714914684

View Profile Personal Message (Offline)

Ignore
1714914684
Reply with quote  #2

1714914684
Report to moderator
TotalPanda
Legendary
*
Offline Offline

Activity: 1946
Merit: 1012

vertex output parameter not completely initialized


View Profile
July 03, 2015, 07:00:47 AM
 #2

I want to prove 10 years from now that I wrote this text 10 years ago
ConfessionCoin
https://bitcointalk.org/index.php?topic=606996
domob
Legendary
*
Offline Offline

Activity: 1135
Merit: 1161


View Profile WWW
July 03, 2015, 07:38:51 AM
 #3

If you do not insist on Bitcoin, you can use Namecoin - it is trivial there.  Just register any name, and set the value of that name to your desired hex string.  Due to merge-mining of Namecoin with Bitcoin, this will actually even produce a link of your hash to the Bitcoin blockchain.  See http://www.domob.eu/blog/2015/0225-NameStamp.php.

Use your Namecoin identity as OpenID: https://nameid.org/
Donations: 1domobKsPZ5cWk2kXssD8p8ES1qffGUCm | NMC: NCdomobcmcmVdxC5yxMitojQ4tvAtv99pY
BM-GtQnWM3vcdorfqpKXsmfHQ4rVYPG5pKS | GPG 0xA7330737
DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4616



View Profile
July 03, 2015, 02:00:14 PM
 #4

- snip -
with only Bitcoin Core and nothing else, create a bitcoin transaction that puts my own SHA-512 hash of a text onto the blockchain?
- snip -

I may be mistaken, but I thought I read somewhere that the developers of Bitcoin Core want to discourage people from storing non-currency data in the blockchain, and have therefore not implemented tools in Bitcoin Core for creating OP_RETURN transactions.  If that's true, then you will need to use some other tool to build the transaction.  Once the transaction is built, I think you'll be able to use Bitcoin Core to sign and broadcast it.

I haven't read the book, so I don't know if it explains how to create a bitcoin transaction with byte codes (essentially building the transaction with pen and paper unless you're really good at keeping all the information straight in your head) .  If it does, then you could just type the necessary bytes as input into the signrawtransaction API call.

Also, I don't know of any way to get Bitcoin Core to calculate a SHA-512 hash for you.  Are you planning on doing that with pen and paper (or in your head)?  Or are you willing to use some other (non Bitcoin  Core) tool for calculating that hash?
DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4616



View Profile
July 03, 2015, 05:56:41 PM
Last edit: July 04, 2015, 12:15:10 PM by DannyHamilton
 #5

In case you want to try creating the transaction without reading the book, follow these steps.

Create a new address in your Bitcoin Core wallet

Send a 0.0001 BTC transaction to your new address.

Wait for the transaction to confirm.

In the Console, enter "listunspent"

Find the output associated with the address you just created.  You will be using this output to pay the transaction fee for the transaction you are creating.  The "txid" is the SHA256 hash of the transaction that you used to send the 0.0001 BTC to the address.  The "vout" is the index of the 0.0001 BTC output in that transaction.

In the Console, use createrawtransaction to create a template for your final transaction.  In the following example replace YOURINPUTTXID with the txid of the 0.0001 BTC output which you found with the listunspent command.  In the following example replace YOURVOUT with the vout value of the 0.0001 BTC output which you found with the listunspent command. In the following example replace ANYVALIDADDRESS with any valid bitcoin address, it doesn't matter which address since this portion of the transaction will be eventually replaced with the SHA512 hash instead.

Code:
createrawtransaction [{\"txid\":\"YOURINPUTTXID\",\"vout\":YOURVOUT}] {\"ANYVALIDADDRESS\":0.00010000}

You will receive a string of approximately 170 hexadecimal charcters (about 85 bytes).  This is an unsigned raw transaction. Do not sign and send this transaction yet. If you do, you'll simply be sending 0.0001 BTC to the address you used for ANYVALIDADDRESS without a transaction fee.

We will not be changing the first 47 bytes (94 characters) at all.

The first 46 bytes (92 characters) define the input that is being used to fund the transaction.  You should find the following:
The first 4 bytes (8 characters) of the raw transaction are the transaction version number.  The value of these 4 bytes should be 01000000. If it isn't then you've done something wrong.
The next 1 byte (2 characters) is the number of inputs in the transaction.  Since we created the transaction with only one 0.00001 BTC input, the value of this byte should be 01.  If it isn't then you've done something wrong.
The next 32 bytes (64 characters) will be YOURINPUTTXID with the bytes in reversed order.
The next 4 bytes (8 characters) are the YOURVOUT value with the bytes in reversed order.
The next byte (2 characters) will be the length of the signature. Since this transaction is not yet signed, the current signature length is 00
The next 4 bytes (8 characters) are the sequence number.  The value of these 4 bytes should be ffffffff. If it isn't then you've done something wrong.

The next byte (2 characters) immediately following the ffffffff is the number of outputs.  Since we created the template transaction with only one output, the value of this byte should be 01.  If it isn't then you've done something wrong.

The next 8 bytes (16 characters) is the value in satoshis being sent to ANYVALIDADDRESS with the bytes in reverse order.  Since we created the template sending 0.0001 BTC to the address, the value of these 8 bytes (16 characters) should be 1027000000000000.  If it isn't then you've done something wrong.  Change the value of these 8 bytes to 0000000000000000.  If you don't do this step you'll still have a transaction that you can broadcast, but it won't be paying any transaction fee (so it may take a VERY long time to confirm, and it will permanently lock away 0.0001 BTC in an output that will never be spendable.

Skipping ahead for a moment, the last 4 bytes (8 characters) are the locktime on the transaction.  This should be all zeros.  If it isn't then you've done something wrong. We won't be changing these 4 bytes (8 characters) either.  We'll just leave them as zeros.

Everything between the value being sent and the locktime  is the list of outputs of the transaction.  In this case we created only one output.

You will be replacing this output with a script that stores your SHA512 hash.

Remove the output list from this template raw transaction (including the 7689 that it will start with and the 88ac that it will end with).  Note that if the output list that you are removing does not start with 7689 and end with 88ac, then you've done something wrong.

In place of the bytes that you've just removed, you'll first place 3 bytes (6 characters) with the value of 426a40
That first byte (42) is the hexadecimal representation of the length of the script that you are adding.
That next byte (6a) is the OP_RETURN byte code. It indicates to the bitcoin network that this output is data and that it is not spendable.
That third byte (40)  is the hexadecimal representation of the length of the data that you are storing in the transaction (40 is the hexadecimal representation of the decimal number 64 and there are 64 bytes in a SHA512 value).

Following that you'll put the 64 bytes (128 characters) of your SHA512 hash.

The locktime (00000000) should be following your SHA512 hash

Once you've built this transaction, you can post it here (or send it to me in a PM) and others (or myself if you send it via PM) can verify for you that you haven't made any mistakes.

If everything is correct, then you'll be able to use signrawtransaction to sign the transaction and sendrawtransaction to broadcast it to the network.
pf (OP)
Full Member
***
Offline Offline

Activity: 176
Merit: 105


View Profile
July 04, 2015, 07:32:03 AM
 #6

In case you want to try creating the transaction without reading the book, follow these steps.

Create a new address in your Bitcoin Core wallet

Send a 0.0001 BTC transaction to your new address.

Wait for the transaction to confirm.

In the Console, enter "listunspent"

Find the output associated with the address you just created.  You will be using this output to pay the transaction fee for the transaction you are creating.  The "txid" is the SHA256 hash of the transaction that you used to send the 0.0001 BTC to the address.  The "vout" is the index of the 0.0001 BTC output in that transaction.

In the Console, use createrawtransaction to create a template for your final transaction.  In the following example replace YOURINPUTTXID with the txid of the 0.0001 BTC output which you found with the listunspent command.  In the following example replace YOURVOUT with the vout value of the 0.0001 BTC output which you found with the listunspent command. In the following example replace ANYVALIDADDRESS with any valid bitcoin address, it doesn't matter which address since this portion of the transaction will be eventually replaced with the SHA512 hash instead.

Code:
createrawtransaction [{\"txid\":\"YOURINPUTTXID\",\"vout\":YOURVOUT}] {\"ANYVALIDADDRESS\":0.00010000}

You will receive a string of approximately 170 hexadecimal charcters (about 85 bytes).  This is an unsigned raw transaction. Do not sign and send this transaction yet. If you do, you'll simply be sending 0.0001 BTC to the address you used for ANYVALIDADDRESS without a transaction fee.

We will not be changing the first 47 bytes (94 characters) at all.

The first 46 bytes (92 characters) define the input that is being used to fund the transaction.  You should find the following:
The first 4 bytes (8 characters) of the raw transaction are the transaction version number.  The value of these 4 bytes should be 01000000. If it isn't then you've done something wrong.
The next 1 byte (2 characters) is the number of inputs in the transaction.  Since we created the transaction with only one 0.00001 BTC input, the value of this byte should be 01.  If it isn't then you've done something wrong.
The next 32 bytes (64 characters) will be YOURINPUTTXID with the bytes in reversed order.
The next 4 bytes (8 characters) are the YOURVOUT value with the bytes in reversed order.
The next byte (2 characters) will be the length of the signature. Since this transaction is not yet signed, the current signature length is 00
The next 4 bytes (8 characters) are the sequence number.  The value of these 4 bytes should be ffffffff. If it isn't then you've done something wrong.

The next byte (2 characters) immediately following the ffffffff is the number of outputs.  Since we created the template transaction with only one output, the value of this byte should be 01.  If it isn't then you've done something wrong.

The next 8 bytes (16 characters) is the value in satoshis being sent to ANYVALIDADDRESS with the bytes in reverse order.  Since we created the template sending 0.0001 BTC to the address, the value of these 8 bytes (16 characters) should be 1027000000000000.  If it isn't then you've done something wrong.  Change the value of these 8 bytes to 0000000000000000.  If you don't do this step you'll still have a transaction that you can broadcast, but it own't be paying any transaction fee (so it may take a VERY long time to confirm, and it will permanently lock away 0.0001 BTC in an output that will never be spendable.

Skipping ahead for a moment, the last 4 bytes (8 characters) are the locktime on the transaction.  This should be all zeros.  If it isn't then you've done something wrong. We won't be changing these 4 bytes (8 characters) either.  We'll just leave them as zeros.

Everything between the value being sent and the locktime  is the list of outputs of the transaction.  In this case we created only one output.

You will be replacing this output with a script that stores your SHA512 hash.

Remove the output list from this template raw transaction (including the 7689 that it will start with and the 88ac that it will end with).  Note that if the output list that you are removing does not start with 7689 and end with 88ac, then you've done something wrong.

In place of the bytes that you've just removed, you'll first place 3 bytes (6 characters) with the value of 426a40
That first byte (42) is the hexadecimal representation of the length of the script that you are adding.
That next byte (6a) is the OP_RETURN byte code. It indicates to the bitcoin network that this output is not data and that it is not spendable.
That third byte (40)  is the hexadecimal representation of the length of the data that you are storing in the transaction (40 is the hexadecimal representation of the decimal number 64 and there are 64 bytes in a SHA512 value).

Following that you'll put the 64 bytes (128 characters) of your SHA512 hash.

The locktime (00000000) should be following your SHA512 hash

Once you've built this transaction, you can post it here (or send it to me in a PM) and others (or myself if you send it via PM) can verify for you that you haven't made any mistakes.

If everything is correct, then you'll be able to use signrawtransaction to sign the transaction and sendrawtransaction to broadcast it to the network.

I'll be damned. You see, this is the kind of knowledge I want in my brain and I was just wondering if Antonopoulos's book will provide it. Of course, feel free to recommend other material too! Thanks.
DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4616



View Profile
July 04, 2015, 12:09:36 PM
 #7

Thanks.

You're welcome.

I'll be damned. You see, this is the kind of knowledge I want in my brain . . . Of course, feel free to recommend other material too!

If you haven't done so already, start by reading the original whitepaper released by Satoshi Nakamoto.

After that, feel free to ask any questions here at bitcointalk.  There are some very knowledgeable people here, and they are very willing to share their knowledge and help others learn.

and I was just wondering if Antonopoulos's book will provide it.

I really don't know much about the book.  I'm not sure what sort of technical details, if any, it has.
pf (OP)
Full Member
***
Offline Offline

Activity: 176
Merit: 105


View Profile
July 04, 2015, 01:23:18 PM
 #8

Thanks.

You're welcome.

I'll be damned. You see, this is the kind of knowledge I want in my brain . . . Of course, feel free to recommend other material too!

If you haven't done so already, start by reading the original whitepaper released by Satoshi Nakamoto.

After that, feel free to ask any questions here at bitcointalk.  There are some very knowledgeable people here, and they are very willing to share their knowledge and help others learn.

and I was just wondering if Antonopoulos's book will provide it.

I really don't know much about the book.  I'm not sure what sort of technical details, if any, it has.

Thanks, but one question, is everything in Nakamoto's paper still valid or has some of it been rendered out of date due to later developments? A lot has changed since then, I imagine - including maybe how the transactions look etc.?
DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4616



View Profile
July 04, 2015, 01:55:58 PM
 #9

Thanks, but one question, is everything in Nakamoto's paper still valid or has some of it been rendered out of date due to later developments? A lot has changed since then, I imagine - including maybe how the transactions look etc.?

The paper is really a high level view of how the overall concepts work.

There are a few implementation details that have changed, but the basic concepts are the core of how bitcoin works.

Probably the most significant detail that is not technically correct is in section 4. (Proof-of-work)

In that section, the paper describes "scanning for a value that when hashed, such as with SHA-256, the hash begins with a number of zero bits".  In reality, bitcoin uses a target value than can be adjusted with much more precision than simply increasing or decreasing the number of leading zeros.

Additionally, the paper assumes CPU mining and makes statements such as "Proof-of-work is essentially one-CPU-one-vote"  Mining has moved on to ASIC technologies and as such it would be more accurate to replace any reference to "CPU" in the paper with "hash".  As such, the statement would be more accurately understood as "Proof-of-work is essentially one-hash-one-vote".

The paper really doesn't go into details on the specific implementation of most of the concepts.  Once you have a good understanding of the basic concepts, I find that the bitcoin wiki is a great source of technical details.

For example, here are a few pages that I use frequently:

altcoinex
Sr. Member
****
Offline Offline

Activity: 293
Merit: 250


Director - www.cubeform.io


View Profile WWW
July 05, 2015, 08:08:25 PM
 #10

Although you seem to be an advanced enough user to go about this in a self tailored ideal way, I just wanted to present for reference: http://www.proofofexistence.com/


                                     ╓╢╬╣╣╖
                                   ┌║██████║∩
                                   ]█████████
                                    ╜██████╝`
                                      ╙╜╜╜`
                                   ╓╥@@@@@@╥╓
         ╓╖@@╖,                 ,@║██████████╢@,                 ,╓@@╖╓
       ╓╢██████╢.              ╓╢███████████████╖               ║╢█████║╓
       ║█████████    ,,╓╓,,   ┌║█████████████████┐   ,,╓╓,,    ]█████████
       └╢██████║` ╓╢║██████╢║∩``╙╙╙╙╙╙╙╙╙╙╙╙╙╙╙╙╙`»╢╢██████╢║╖  ║███████╜
         "╜╜╜╜` ╖╢█████████╣╜                      └╢██████████@ `╜╜╜╜╜
               ║██████████╜                          ╙╢██████████
              ┌█████████╜                              ╙╢█████████
              └███████╨`                                 ╜████████
               ║████╨╜                                    `╢█████
                ╙╢╣╜                                        └╢█╜
                ,,                                            ,,
             ╓@║██┐                                          ┌██║@╓
            ╢██████                                          ]█████H
           ╢███████∩                                        ┌████████
  ╓@@@@╓   █████████                                        ║████████`  ╓@@@@╖
╓╢██████║. █████████∩                                      ┌█████████ ,║███████╖
██████████ └█████████                                      ██████████ ]█████████
`║██████╜`  └╢████████                                    ┌███████╣╜   ╙██████╨`
  `╙╜╜╙`      `╙╨╢████                                    █████╝╜`       `╙╜╜`
                      ]@╓                              ╓╖H
                      ███╢║@╓,                    ,╓@╢╢███`
                      ████████╢@╖╓.           ╓╖@║████████`
                      ]███████████╢║@╓,  ,╓@╢╢████████████
                       ╙╢█████████████╨` ╜██████████████╜
                         ╙╝╢███████║╜`    `╜║████████╝╜`
                     ,╓@@@╓  `²╙``             `╙²`  ╓@@@╖,
                    ║╢█████╢H                      ╓╢██████H
                    █████████                      █████████`
                    ╙╢██████╜                      ╙╢██████╜
                      └╨╩╝┘                          └╨╩╝╜
WINFLOW.
██
██
██
██
██
██
██
██
██
██
██
██
██
..
██
██
██
██
██
██
██
██
██
██
██
██
██
.
HeadsOrTails
Full Member
***
Offline Offline

Activity: 233
Merit: 100



View Profile
July 07, 2015, 05:44:12 AM
 #11

Quote
Thanks, but one question, is everything in Nakamoto's paper still valid or has some of it been rendered out of date due to later developments? A lot has changed since then, I imagine - including maybe how the transactions look etc.?

It's almost clichéd how often you'll hear read the whitepaper. OP provided a fantastic answer to your question and is obviously very knowledgable, even still, whenever I hear someone give the generic read the whitepaper response, I kind of cringe. The whitepaper absolutely won't have any answers to this particular question if you've already read a bit about Bitcoin. It's a high level conceptual description which is either covering familiar ground in terse language, or confusing a newb with the same terse language, ie the whitepaper is certainly not more readable than the Andreas book

All of this IMO obviously
virtualx
Hero Member
*****
Offline Offline

Activity: 672
Merit: 507


LOTEO


View Profile
July 07, 2015, 08:50:18 AM
 #12

Will this book provide me with enough knowledge so that I can, with only Bitcoin Core and nothing else, create a bitcoin transaction that puts my own SHA-512 hash of a text onto the blockchain? (I want to prove 10 years from now that I wrote this text 10 years ago and I want to do this myself with only Bitcoin Core.)

I skimmed through the book and it seems very focused on the Blockchain.info API. Am I right about this? I'm not really interested in the Blockchain.info API. I wanna do things myself using the core software.

To put your SHA-512 hash on the blockchain you do not need to read a book. All you need is a script to create the transaction, have a look on github. Take one of the bitcoin libraries https://github.com/search?utf8=%E2%9C%93&q=bitcoin+library&type=Repositories&ref=searchresults and create the transaction.  

How to put your own message in the blockchain:
It's pretty easy to put your own 20-character message into the blockchain. The following steps explain how.

1. Take your 20-character string and convert it to hex. E.g. in Python: 'http://righto.com/bc'.encode('hex')
2.Convert the resulting hex string to an address. An easy way is online: https://blockchain.info/q/hashtoaddress/your hex value yields 1AXJnNiDijKUnY9UJZkV5Ggdgh36aWDBYj.
3. Send bitcoins to that address and your message will show up in the blockchain when your transaction gets mined. Important: those bitcoins will be lost forever, so send a very small amount, like 10 cents.



...loteo...
DIGITAL ERA LOTTERY


r

▄▄███████████▄▄
▄███████████████████▄
▄███████████████████████▄
▄██████████████████████████▄
▄██  ███████▌ ▐██████████████▄
▐██▌ ▐█▀  ▀█    ▐█▀   ▀██▀  ▀██▌
▐██  █▌ █▌ ██  ██▌ ██▌ █▌ █▌ ██▌
▐█▌ ▐█ ▐█ ▐█▌ ▐██  ▄▄▄██ ▐█ ▐██▌
▐█  ██▄  ▄██    █▄    ██▄  ▄███▌
▀████████████████████████████▀
▀██████████████████████████▀
▀███████████████████████▀
▀███████████████████▀
▀▀███████████▀▀
r

RPLAY NOWR
BE A MOON VISITOR!
[/center]
Mikestang
Legendary
*
Offline Offline

Activity: 1274
Merit: 1000



View Profile
July 10, 2015, 11:03:45 PM
 #13


I really don't know much about the book.  I'm not sure what sort of technical details, if any, it has.

It has many, many technical details and lots of code.  I don't know anything about code but read the book for the rest of the info, I probably missed out on ~50% of what was presented therein.

But yes, it does go over how to code your own tx and much, much more.  Worth the purchase and read for sure (I've read mine twice already).
arnuschky
Hero Member
*****
Offline Offline

Activity: 517
Merit: 501


View Profile
July 12, 2015, 09:42:48 PM
 #14


I really don't know much about the book.  I'm not sure what sort of technical details, if any, it has.

It has many, many technical details and lots of code.  I don't know anything about code but read the book for the rest of the info, I probably missed out on ~50% of what was presented therein.

But yes, it does go over how to code your own tx and much, much more.  Worth the purchase and read for sure (I've read mine twice already).

You can browse "Mastering Bitcoin" (or read it all) here.  Not in a nice published format, but most of the final content is there.  

If you end up reading it all - consider buying the "real" book to support the author.

It's a good book and worth the money. It explains all the underlying concepts very well, and it a more detailed and practical manner than most sources do. AFAIK he doesn't saw anything about blockchain.info's API (apart that it exists)
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!