• Home
  • About Us
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Terms & Conditions
Friday, March 24, 2023
No Result
View All Result
AltCoin 247
  • Home
  • Cryptocurrency
  • Bitcoin
  • DEFI
  • Regulation
  • Litecoin
  • Dogecoin
  • Altcoin
  • Home
  • Cryptocurrency
  • Bitcoin
  • DEFI
  • Regulation
  • Litecoin
  • Dogecoin
  • Altcoin
No Result
View All Result
AltCoin 247
No Result
View All Result
Home Bitcoin

In what format does a block store the transaction data?

by altcoin247
May 7, 2022
in Bitcoin
0
currencies – How are crypto prices calculated by an exchange? Example game in a spreadsheet to illustrate


Bitcoin core stores the data in the network format for blocks and for the transactions in those blocks.


Here’s an example

Block 170 contains the first transaction other than coinbase transactions. In it Satoshi Nakamoto paid Hal Finney 10 BTC. This was the first time one person paid another person in Bitcoin.

Since the data is in binary, we must use a printable representation of it to make it viewable in this web-page. I choose hexadecimal:

0100000001c997a5e56e104102fa209c6a852dd90660a20b2d9c352423edce25
857fcd3704000000004847304402204e45e16932b8af514961a1d3a1a25fdf3f
4f7732e9d624c6c61548ab5fb8cd410220181522ec8eca07de4860a4acdd1290
9d831cc56cbbac4622082221a8768d1d0901ffffffff0200ca9a3b0000000043
4104ae1a62fe09c5f51b13905f07f06b99a2f7159b2225f374cd378d71302fa2
8414e7aab37397f554a7df5f142c21c1b7303b8a0626f1baded5c72a704f7e6c
d84cac00286bee0000000043410411db93e1dcdb8a016b49840f8c53bc1eb68a
382e97b1482ecad7b148a6909a5cb2e0eaddfb84ccf9744464f82e160bfa9b8b
64f9d4c03f999b8643f656b412a3ac00000000

Some weeks ago I thought it would be neat to work out by hand what that meant. here’s how far I got before losing interest:

Hex Data Meaning
01000000 Version 1 (little endian uint32)
01 Number of transaction inputs (compact-int)
First input
c997a5e56e104102 fa209c6a852dd906 60a20b2d9c352423 edce25857fcd3704 Hash of referenced transaction (32 octets)
00000000 index of output in referenced transaction (uint32)
48 length of unlocking script (compact-int). 48 hex is 72 decimal.
47304402204e45e1 6932b8af514961a1 d3a1a25fdf3f4f77 32e9d624c6c61548 ab5fb8cd41022018 1522ec8eca07de48 60a4acdd12909d83 1cc56cbbac462208 2221a8768d1d0901 unlocking script (72 octets)
ffffffff sequence
02 Number of outputs
First output
00ca9a3b00000000 amount 1000000000 satoshi i.e. 10 BTC (int64)
43 length of locking script
4104ae1a62fe09c5 f51b13905f07f06b 99a2f7159b2225f3 74cd378d71302fa2 8414e7aab37397f5 54a7df5f142c21c1 b7303b8a0626f1ba ded5c72a704f7e6c d84cac locking script
Second output
00286bee00000000 amount 40 BTC. This is change.
43 length of locking script
410411db93e1dcdb 8a016b49840f8c53 bc1eb68a382e97b1 482ecad7b148a690 9a5cb2e0eaddfb84 ccf9744464f82e16 0bfa9b8b64f9d4c0 3f999b8643f656b4 12a3ac locking script
00000000 lock time = unlocked (4 octets)

I should probably decode the locking scripts on the outputs. 41 is OP_PUSHDATA for 4116 bytes. Then we have the 4116 bytes of data to be pushed onto the stack and finally ac is OP_CHECKSIG which expects a signature and public key on the stack which it takes off the stack and checks. This script only really gets executed when the money is spent.

For historical reasons locking-scripts were called pubkey scripts, unlocking scripts were called signature scripts. But those older names are misleading for newer transaction types.

The compact form of integers used by Bitcoin is sometimes called varint (variable-length integer) but this is a potential source of confusion as there are other things named varint IIRC.

You can check the little endian numbers by reversing them byte-wise (two hex digits at a time) into a big endian representation and feeding that into Windows Calculator in programmer mode – here’s that second output amount (00286bee00000000LE -> 00000000ee6b2800BE):

That’s how we know 00286bee00000000 means 40000000000 Satoshi. Which is 40 BTC.

This early transaction is an early type known as Pay to Public Key (P2PK). It is the simplest type. Popular types used nowadays are more complicated.

You can, of course, rather easily get a JSON representation of this transaction using most blockchain explorers. I find that a bit unsatisfactory as they often introduce some artificial elements (e.g. both ‘hex’ and ‘asm’ representations of the script) so you’re never certain how exactly the JSON items correspond to parts of the underlying data. Hence the above decoding attempt.


Related questions



Source_link

altcoin247

altcoin247

Next Post
currencies – How are crypto prices calculated by an exchange? Example game in a spreadsheet to illustrate

armory - Does someone know how to recovery a private key

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recommended

Bitcoin and Ethereum Prices Soar 20%

Bitcoin and Ethereum Prices Soar 20%

2 months ago
Litecoin Could Have Limited Upside Without DeFi Apps and Uses

Litecoin Could Have Limited Upside Without DeFi Apps and Uses

1 year ago

Popular News

  • As Pound Crumbles, a Third of UK Citizens Now Own Cryptocurrency

    As Pound Crumbles, a Third of UK Citizens Now Own Cryptocurrency

    0 shares
    Share 0 Tweet 0
  • How Crypto Exchange Can Revolutionize Businesses

    0 shares
    Share 0 Tweet 0
  • Das Blockmagazin ist da! – Der Altcoinspekulant

    0 shares
    Share 0 Tweet 0
  • Dogecoin (DOGE) Price Prediction 2025-2030: What does 2023 have in store for DOGE traders?

    0 shares
    Share 0 Tweet 0
  • How Does Uniglo (GLO) Manage To Have A 35% Price Spike Unlike Fantom (FTM) And Dogecoin (DOGE)?

    0 shares
    Share 0 Tweet 0
AltCoin 247

Welcome to Altcoin247 The goal of Altcoin247 is to give you the absolute best news sources for any topic! Our topics are carefully curated and constantly updated as we know the web moves fast so we try to as well.

Category

  • Altcoin
  • Bitcoin
  • Cryptocurrency
  • DEFI
  • Dogecoin
  • Litecoin
  • Regulation

Site Links

  • Home
  • About Us
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Terms & Conditions

Recent Posts

  • Here’s When XRP Could Reach $0.50
  • The Three Cryptocurrencies To Keep An Eye On In April 2023: Orbeon Protocol (ORBN), ImmutableX (IMX), And Aptos (APT)

Copyright © 2022 Altcoin247.net | All Rights Reserved.

No Result
View All Result
  • Home
  • Cryptocurrency
  • Bitcoin
  • DEFI
  • Regulation
  • Litecoin
  • Dogecoin
  • Altcoin

Copyright © 2022 Altcoin247.net | All Rights Reserved.

What Are Cookies
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT