Skip to content

Conversation

MBaum21
Copy link
Contributor

@MBaum21 MBaum21 commented Nov 4, 2023

easy changes:
INT64_MAX is 9223372036854775807 (2**63-1)
INT64_MIN is -9223372036854775808 (-2**63)

other changes:
For whatever reason, post # 1 in bitcointalk topic 822 contains a different output amount than post # 3
post #1: 92233720368.54277039 (0x7ffffffffff863af)
post #3: 92233720368.54275808 (0x7ffffffffff85ee0)
I'm assuming post # 3 ist right, because it's 2**63-500000, and the sum of outputs is a round number: -0.01 BTC (minus 1 million sats). (calculation: 9223372036854275808*2 - 2**64 = -1000000)

easy changes:
INT64_MAX is 9223372036854775807 (2**63-1)
INT64_MIN is -9223372036854775808 (-2**63)

for whatever reason, post bitcoinops#1 in bitcointalk topic 822
( https://bitcointalk.org/index.php?topic=822.0 )
contains a different output amount than post bitcoinops#3
post bitcoinops#1: 92233720368.54277039 (0x7ffffffffff863af)
post bitcoinops#3: 92233720368.54275808 (0x7ffffffffff85ee0)
I'm assuming post bitcoinops#3 ist right, because it's 2**63-500000,
and the sum of outputs is minus 1 million sats (-0.01 BTC).
(9223372036854275808*2 - 2**64 = -1000000)
@murchandamus
Copy link
Collaborator

murchandamus commented Apr 16, 2024

I spent some time looking into this. I found the raw transaction from the value overflow incident:

0100000001395d705a36b122c01c9be97f8c69994c03bb8a0531990411ce7ac78f34e87f23000000008b483045022100db8ccad098467a80bdb9ae16fc a82aa4214a66c1ee24b62b696073e7e4f6879302205ad02d53231be18c5d6a77ffdb39476a5b5da4be70f0acc6794b181f4e38027ca841046b5d97aeed 2979207f4ca7d9e75cdebf9ebb2a47d0b715370645f6845edfa7adfb0627ad7bda601ad2d129ebf037c5750841e9ba64ab199c4cb8280a95335d96ffff ffff02af63f8ffffffff7f1976a91490e8d5ba1c2a301824b18d383dead728b13ea7b788acaf63f8ffffffff7f1976a9142c72c4b5e0cbf9b6435f2cec 9df8668c5075121588ac00000000

The two output amounts were 0x7ffffffffff863af which corresponds to 9,223,372,036,854,277,039 sats and are in the range of int64.


Edit:

I notice that a second raw transaction is posted later in the thread which does appear to have the value of 9,223,372,036,854,275,808:

0100000001395d705a36b122c01c9be97f8c69994c03bb8a0531990411ce7ac78f34e87f23000000008b483045022100db8ccad098467a80bdb9ae16fca82aa4214a66c1ee24b62b696073e7e4f6879302205ad02d53231be18c5d6a77ffdb39476a5b5da4be70f0acc6794b181f4e38027ca841046b5d97aeed2979207f4ca7d9e75cdebf9ebb2a47d0b715370645f6845edfa7adfb0627ad7bda601ad2d129ebf037c5750841e9ba64ab199c4cb8280a95335d96ffffffff02e05ef8ffffffff7f1976a91490e8d5ba1c2a301824b18d383dead728b13ea7b788ace05ef8ffffffff7f1976a9142c72c4b5e0cbf9b6435f2cec9df8668c5075121588ac00000000

I’ll have to look further into this.

@murchandamus
Copy link
Collaborator

murchandamus commented Apr 16, 2024

Okay, yeah, you are right. The two outputs sum to –0.01 ₿ which then explains why the coinbase collects 50 ₿ new coins and 0.5 ₿ –(–0.01 ₿) = 50.51 ₿ from the transaction.

I will look over the text, I think we might need to amend the text a little further.

Comment on lines 498 to 499
starting with -9,223,372,036,854,775,808 sats. This meant it looked like the
transaction spent a total of -0.01 BTC (negative 0.01 BTC). This
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
starting with -9,223,372,036,854,775,808 sats. This meant it looked like the
transaction spent a total of -0.01 BTC (negative 0.01 BTC). This
starting with -9,223,372,036,854,775,808 sats. This meant it looked like the
transaction outputs summed to a total of -0.01 BTC (negative 0.01 BTC). This

@murchandamus
Copy link
Collaborator

Oh, I just realized that thread is from last month. Is that you digging up the actual raw transaction? :)

@MBaum21
Copy link
Contributor Author

MBaum21 commented Apr 25, 2024

Thanks for your response @murchandamus :)

Nice investigation by ercewubam in that thread from march. No, that's not me.
Good to have the amount confirmed, i.e. 92233720368.54275808 ₿.

I will look over the text, I think we might need to amend the text a little further.

Is there still something to amend? :)


Edit:

we could change the commit message to this:

easy changes:
INT64_MAX is 9223372036854775807 (2**63-1)
INT64_MIN is -9223372036854775808 (-2**63)

post # 1 in bitcointalk topic 822 ( https://bitcointalk.org/index.php?topic=822.0 )
contains a different output amount than post # 3
post # 1: 92233720368.54277039 (0x7ffffffffff863af)
post # 3: 92233720368.54275808 (0x7ffffffffff85ee0)
Turns out post # 3 ist right, see this thread:
https://bitcointalk.org/index.php?topic=5488487.msg63795653#msg63795653
That also makes sense, because the amount in post # 3 is 2**63-500000,
and the sum of outputs is minus 1 million sats (-0.01 BTC).
(9223372036854275808*2 - 2**64 = -1000000)

@jonatack jonatack force-pushed the master branch 3 times, most recently from 38028a8 to 9db038c Compare August 26, 2024 20:43
Copy link
Collaborator

@murchandamus murchandamus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I have rediscovered the minutiae of this situation.

• There were two 92 billion BTC outputs, each individually 500,000 sats below INT64_MAX
• In sum, these two outputs add up to -1,000,000 sats or -0.01 BTC due to an integer overflow when they were summed up
• This resulted in a transaction fee of 0.51 BTC, from the input with 0.5 BTC minus the -0.01 BTC (i.e., -(-0.01) = + 0.01) from the summed outputs

I’ve added half a sentence that would have helped me catch on faster, and otherwise concur with the proposed changes by @MBaum21.

Copy link
Contributor

@bitschmidty bitschmidty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK, thank you @MBaum21 and @murchandamus

@bitschmidty bitschmidty merged commit f5581dc into bitcoinops:master Jan 17, 2025
2 checks passed
@MBaum21 MBaum21 deleted the patch-1 branch January 21, 2025 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants