Bitcoin Forum
November 20, 2017, 04:27:20 PM *
News: Latest stable version of Bitcoin Core: 0.15.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: bitcoin maximum fraction unit? there are something less than satoshi unit?  (Read 2160 times)
uray
Hero Member
*****
Offline Offline

Activity: 588


Any store can buy, sell, and accept Crypto


View Profile
March 27, 2014, 05:18:31 PM
 #1

based on transaction structure https://en.bitcoin.it/wiki/Protocol_specification

The TxOut structure consists of the following fields:
Code:
Field Size Description Data type Comments
8         value            int64_t Transaction Value
1+         pk_script length var_int Length of the pk_script
 ?         pk_script        uchar[] Usually contains the public key as a Bitcoin script setting up conditions to claim this output

so maximum transaction value is signed? 64-bit integer ?
why we use signed int? can transaction value be negative?

then

if its uin64_t so then max value would be
2^64-1 = 18,446,744,073,709,551,615

there are max 21 million cap of bitcoin so
Code:
184467440.73709551615
 21000000.00000000xxx
so we can add 3 more digits after satoshi unit?

if its int64_t then max value would be
2^63-1 = 9,223,372,036,854,775,807
Code:
92233720.36854775807
21000000.00000000xxx

still more 3 digits after satoshi unit?

███████████████████████████████████████████████████████████████████▀███▀████
████████████████████████████████████████████████████████████████████▄▀▄█████
███████████████████████████████████████████████████████████████████▀▄█▄▀████

███▀▀▀▀▀▀▀▀██████▀▀▀████████▀▀▀██▀▀▀███████████▀▀▀██▀▀▀▀▀▀▀▀████████▀▀▀█████
███          ▀███   ████████   ██    ▀█████████   ██           ▀████   █████
███   █████▄   ██   ████████   ██      ▀███████   ██   ██████▄   ███   █████
███   ██████   ██   ████████   ██   █▄   ▀█████   ██   ████████   ██   █████
███   █████▀   ██   ████████   ██   ███▄   ▀███   ██   ████████   ██   █████
███          ▄███   ▀██████▀   ██   █████▄   ▀█   ██   ███████▀   ██   █████
███   ▄▄▄▄▄███████   ▀▀▀▀▀▀   ███   ███████▄      ██   ▀▀▀▀▀▀   ▄███   █████
███   █████████████▄        ▄████   █████████▄    ██        ▄▄▄█████   █████
████████████████████████████████████████████████████████████████████████████
████████████████████████████████████████████████████████████████████████████
██
██
██
██
██
██
██
██
██
██
██
██
██
.Any Store Can Buy, Sell and Accept Cryptocurrency.██
██
██
██
██
██
██
██
██
██
██
██
██
[[[ Whitepaper    Twitter     Facebook]]]
[[[  Telegram      Medium     Youtube ]]]
Join ICO Now A blockchain platform for effective freelancing
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1511195240
Hero Member
*
Offline Offline

Posts: 1511195240

View Profile Personal Message (Offline)

Ignore
1511195240
Reply with quote  #2

1511195240
Report to moderator
1511195240
Hero Member
*
Offline Offline

Posts: 1511195240

View Profile Personal Message (Offline)

Ignore
1511195240
Reply with quote  #2

1511195240
Report to moderator
kjj
Legendary
*
Offline Offline

Activity: 1302



View Profile
March 27, 2014, 06:47:43 PM
 #2

You've got the xxx on the wrong end.  What we have is headroom.

p2pcoin: a USB/CD/PXE p2pool miner - 1N8ZXx2cuMzqBYSK72X4DAy1UdDbZQNPLf - todo
I routinely ignore posters with paid advertising in their sigs.  You should too.
Cryddit
Legendary
*
Offline Offline

Activity: 840


View Profile
March 27, 2014, 06:55:05 PM
 #3

So, yes, a uint64_t is capable of recording up to 18446744073709551615 Satoshi.  And the entire money supply of bitcoin only amounts to 2100000000000000 Satoshi, so there were a bit more than 3 orders of magnitude to play with.  

While the amount in a txin or txout can't be negative, you don't want to use an unsigned int for it, because internally you often compute differences, and those can be negative.  Remember, 'if (A - B < 0)' is *always* false with unsigned quantities.  So if you weren't super-careful you could get it wrong doing things like checking to see if the total outputs of a transaction are smaller than the total inputs.  

If you wanted to subdivide into smaller fractions, you could do that, up to 3 orders of magnitude.  All that would be required is raising the COIN constant, fiddling with the 'units.h' file, and a few other minor adjustments.  Of course, then you'd have to stick in code that interprets amounts written in the blockchain before the switchover differently.  

Conversely if you wanted to have a bigger money supply, which many altcoins do, you could do that too, by pretty much the same procedure plus modifying a few things like MAX_MONEY and the payout schedule, etc.

Or you could use something bigger than 64 bits, I guess.  But you don't need to.

olalonde
Newbie
*
Offline Offline

Activity: 25


View Profile
March 27, 2014, 09:57:07 PM
 #4

Is there any check in the transaction verification code that this value must be >= COIN ?
kjj
Legendary
*
Offline Offline

Activity: 1302



View Profile
March 27, 2014, 10:52:15 PM
 #5

Is there any check in the transaction verification code that this value must be >= COIN ?

util.cpp, line 386.  (0.9.0)

p2pcoin: a USB/CD/PXE p2pool miner - 1N8ZXx2cuMzqBYSK72X4DAy1UdDbZQNPLf - todo
I routinely ignore posters with paid advertising in their sigs.  You should too.
Cryddit
Legendary
*
Offline Offline

Activity: 840


View Profile
March 31, 2014, 10:36:56 PM
 #6

Actually I found something today that affects the discussion.

The RPC calls to bitcoind transmit amounts using a 'double' quantity which has only 53 bits of significand precision. 

So an RPC call which represents anything up to the number of bitcoins that actually exist will suffer no rounding error.  With about twice the number of bitcoins that actually exist, small rounding errors would become inevitable.

This is something that can be fixed (you can encode the RPC as a string for example), but given the 21-million coin limit there is no need to fix it in Bitcoin. 

Alts with lots more coins though will have accounting bugs in any financial application using RPC calls to their coins unless they fix it.

Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!