Bitcoin Forum
December 11, 2017, 09:45:59 PM *
News: Latest stable version of Bitcoin Core: 0.15.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: sending combined inputs exceeding MAX_MONEY in PPC breaks wallet  (Read 663 times)
bumbacoin
Legendary
*
Offline Offline

Activity: 1190



View Profile
February 15, 2017, 02:03:03 AM
 #1

edited.

I've become aware of a bug which breaks the wallet.dat on PPC (and clones).
It's more likely to effect clones as it involves having a balance exceeding MAX_MONEY.

Basically sending any transaction with combined inputs exceeding MAX_MONEY results in failing various error checks.
and client will refuse to load the wallet.dat

brief list of experiments so far with MAX_MONEY=1000
- sending 10000 breaks wallet
- Setting the txfee to 100, then sending 9900, breaks wallet.
- setting up two inputs of 5001, then sending 5002, breaks wallet.

https://github.com/Peerunity/Peerunity/issues/199


notes: to be an issue
- it must be possible for one wallet to hold balance > max_money.
- Qt GUI limitation may help prevent issue (eg, send field limitations), but assumedly command line send may exceed the GUI limitation


..

issue revealed itself in Stronghands.
a fix to limit max spend to (MAX_MONEY / 2) is a quick answer to the problem
needs to include fees into the initial check,
https://github.com/bumbacoin/stronghands/commit/817da6efb8410579f940be4270e823463ee981b0

if MAX_MONEY is 2 billion,
adding 1 to either MAX_MONEY, or to error checks will allow neat send values of 1 billion.
..

💦☔️🐳💚💖💛
go to
cryptobetfair.com
ask for a voucher

████████████████
██████████████
█████████████
██████████████
██████████████
███████████
█████████
███████████
████████████
████████████
███████████
█████████████
██████████████
███████████████
████████████████
████████████████
🐠👻🍗🌳🐵
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
Limx Dev
Legendary
*
Offline Offline

Activity: 1162


www.bitsend.info


View Profile
February 15, 2017, 08:27:15 AM
 #2

Do you have the problem with a new coin or peercoin directly?

BitSend ◢◤Clients | Source
www.bitsend.info
█▄
█████▄
████████▄
███████████▄
██████████████
███████████▀
████████▀
█████▀
█▀












Segwit | Core 0.14 | Masternodes
XEVAN | DK3 | Electrum soon
Bitcore - BTX/BTC -Project












BSD -USDT | Bittrex | C.Gather | S.Exchange
Cryptopia | NovaExchange | Livecoin
Litebit.eu | Faucet | Bitsend Airdrop













████
 ████
  ████
   ████
    ████
     ████
      ████
       ████
        ████
       ████
      ████
     ████
    ████
   ████
  ████
 ████
████

████
 ████
  ████
   ████
    ████
     ████
      ████
       ████
        ████
       ████
      ████
     ████
    ████
   ████
  ████
 ████
████
bumbacoin
Legendary
*
Offline Offline

Activity: 1190



View Profile
February 15, 2017, 10:04:09 AM
 #3

Do you have the problem with a new coin or peercoin directly?

I came across it in Stronghands,
(a clone with 90billion coinsupply, one owner having 18 billion coins, and a 2billion MAX_MONEY )

then decided to check up stream and found same problem in Peerunity.
i'm not that familiar with PPC rewards, but i doubt it will have a problem for some time.

💦☔️🐳💚💖💛
go to
cryptobetfair.com
ask for a voucher

████████████████
██████████████
█████████████
██████████████
██████████████
███████████
█████████
███████████
████████████
████████████
███████████
█████████████
██████████████
███████████████
████████████████
████████████████
🐠👻🍗🌳🐵
Limx Dev
Legendary
*
Offline Offline

Activity: 1162


www.bitsend.info


View Profile
February 15, 2017, 10:49:40 AM
 #4

Do you have the problem with a new coin or peercoin directly?

I came across it in Stronghands,
(a clone with 90billion coinsupply, one owner having 18 billion coins, and a 2billion MAX_MONEY )

then decided to check up stream and found same problem in Peerunity.
i'm not that familiar with PPC rewards, but i doubt it will have a problem for some time.

Do you test with a new chain?

BitSend ◢◤Clients | Source
www.bitsend.info
█▄
█████▄
████████▄
███████████▄
██████████████
███████████▀
████████▀
█████▀
█▀












Segwit | Core 0.14 | Masternodes
XEVAN | DK3 | Electrum soon
Bitcore - BTX/BTC -Project












BSD -USDT | Bittrex | C.Gather | S.Exchange
Cryptopia | NovaExchange | Livecoin
Litebit.eu | Faucet | Bitsend Airdrop













████
 ████
  ████
   ████
    ████
     ████
      ████
       ████
        ████
       ████
      ████
     ████
    ████
   ████
  ████
 ████
████

████
 ████
  ████
   ████
    ████
     ████
      ████
       ████
        ████
       ████
      ████
     ████
    ████
   ████
  ████
 ████
████
bumbacoin
Legendary
*
Offline Offline

Activity: 1190



View Profile
February 15, 2017, 11:26:44 AM
 #5

Do you have the problem with a new coin or peercoin directly?

I came across it in Stronghands,
(a clone with 90billion coinsupply, one owner having 18 billion coins, and a 2billion MAX_MONEY )

then decided to check up stream and found same problem in Peerunity.
i'm not that familiar with PPC rewards, but i doubt it will have a problem for some time.

Do you test with a new chain?

i tested on teh stronghands chain (took the wallet off line)
and on peerunity testnet.


💦☔️🐳💚💖💛
go to
cryptobetfair.com
ask for a voucher

████████████████
██████████████
█████████████
██████████████
██████████████
███████████
█████████
███████████
████████████
████████████
███████████
█████████████
██████████████
███████████████
████████████████
████████████████
🐠👻🍗🌳🐵
Blockchain Mechanic
Full Member
***
Offline Offline

Activity: 224

www.patreon.com/blockmechanic


View Profile WWW
February 15, 2017, 11:34:02 AM
 #6

1 COIN == 100 000 000 CENT

so 2 B coins == 200 000 000 000 000 000 CENT.

It could be a result of overflow, can you link me the source ? Or if you already have a built one, add some debug lines to print out the values.

Equality vs Equity...
bumbacoin
Legendary
*
Offline Offline

Activity: 1190



View Profile
February 15, 2017, 11:55:53 AM
 #7


i'm testing using a modified peerunity copy, (but it also appears in Stronghands code)
tweaked to make it easier,
short block time, and coinbase maturity (make it easy to mine), and MAX_MONEY=10000
https://github.com/Peerunity/Peerunity


static const int64 COIN = 1000000;
static const int64 CENT = 10000;
https://github.com/Peerunity/Peerunity/blob/master/src/util.h#L42

it seems to be fee related,
error checking without passes,
then error checking with fails.


tbh, i'm not sure how to enter such debugging Smiley
the error is
https://github.com/Peerunity/Peerunity/blob/master/src/wallet.h#L206

💦☔️🐳💚💖💛
go to
cryptobetfair.com
ask for a voucher

████████████████
██████████████
█████████████
██████████████
██████████████
███████████
█████████
███████████
████████████
████████████
███████████
█████████████
██████████████
███████████████
████████████████
████████████████
🐠👻🍗🌳🐵
Blockchain Mechanic
Full Member
***
Offline Offline

Activity: 224

www.patreon.com/blockmechanic


View Profile WWW
February 15, 2017, 12:27:30 PM
 #8


i'm testing using a modified peerunity copy, (but it also appears in Stronghands code)
tweaked to make it easier,
short block time, and coinbase maturity (make it easy to mine), and MAX_MONEY=10000
https://github.com/Peerunity/Peerunity


static const int64 COIN = 1000000;
static const int64 CENT = 10000;
https://github.com/Peerunity/Peerunity/blob/master/src/util.h#L42

it seems to be fee related,
error checking without passes,
then error checking with fails.


tbh, i'm not sure how to enter such debugging Smiley
the error is
https://github.com/Peerunity/Peerunity/blob/master/src/wallet.h#L206

print out the error and values either to console or debug.log

it is likely a negative value

Equality vs Equity...
bumbacoin
Legendary
*
Offline Offline

Activity: 1190



View Profile
February 15, 2017, 03:06:18 PM
 #9

finally got it to do something that looks useful Smiley

using this code
Code:
   int64 GetDebit(const CTransaction& tx) const
    {
        int64 nDebit = 0;
        BOOST_FOREACH(const CTxIn& txin, tx.vin)
        {
            nDebit += GetDebit(txin);
            if (!MoneyRange(nDebit))
                {
                printf(" Value=%llu, Max Money=%llu, Coin=%llu, Cent=%llu unsigned int", nDebit, MAX_MONEY, COIN, CENT);
                throw std::runtime_error("CWallet::GetDebit() : value out of range");
                }
        }
        return nDebit;

getting this output
Code:
Value=15721280000, Max Money=10000000000, Coin=1000000, Cent=10000

output / COIN
Value=15721.28, Max Money=10000

so the issue is not a negative value, but rather checking the combined value of all inputs?
(all mined blocks were ~8400)


💦☔️🐳💚💖💛
go to
cryptobetfair.com
ask for a voucher

████████████████
██████████████
█████████████
██████████████
██████████████
███████████
█████████
███████████
████████████
████████████
███████████
█████████████
██████████████
███████████████
████████████████
████████████████
🐠👻🍗🌳🐵
bumbacoin
Legendary
*
Offline Offline

Activity: 1190



View Profile
February 15, 2017, 03:55:25 PM
 #10

I was going to do this tomorrow but i couldnt wait Smiley


I set up a wallet with two inputs of 5001,
Then testing it by sending 5002 coins broke it.

Code:
# ./peerunityd sendtoaddress mxXeyDPTix9KQVcwDnDkSUcPvzskF5xNfS 5002
error: {"code":-1,"message":"CWallet::GetDebit() : value out of range"}

error output
Code:
nDebit Value=10002000000, Max Money=10000000000, Coin=1000000, Cent=10000
output /coin
Code:
nDebit Value=10002, Max Money=10000

💦☔️🐳💚💖💛
go to
cryptobetfair.com
ask for a voucher

████████████████
██████████████
█████████████
██████████████
██████████████
███████████
█████████
███████████
████████████
████████████
███████████
█████████████
██████████████
███████████████
████████████████
████████████████
🐠👻🍗🌳🐵
Blockchain Mechanic
Full Member
***
Offline Offline

Activity: 224

www.patreon.com/blockmechanic


View Profile WWW
February 15, 2017, 04:16:54 PM
 #11

I was going to do this tomorrow but i couldnt wait Smiley


I set up a wallet with two inputs of 5001,
Then testing it by sending 5002 coins broke it.

Code:
# ./peerunityd sendtoaddress mxXeyDPTix9KQVcwDnDkSUcPvzskF5xNfS 5002
error: {"code":-1,"message":"CWallet::GetDebit() : value out of range"}

error output
Code:
nDebit Value=10002000000, Max Money=10000000000, Coin=1000000, Cent=10000
output /coin
Code:
nDebit Value=10002, Max Money=10000

code does not lie

Let's confirm some things.

1 coin == 100 cent

max money == 10000 coin

2 x Inputs of 5002 == 10004

which is greater than 10000 and hence is out of range

........?

Equality vs Equity...
bumbacoin
Legendary
*
Offline Offline

Activity: 1190



View Profile
February 15, 2017, 04:30:35 PM
 #12

I was going to do this tomorrow but i couldnt wait Smiley


I set up a wallet with two inputs of 5001,
Then testing it by sending 5002 coins broke it.

Code:
# ./peerunityd sendtoaddress mxXeyDPTix9KQVcwDnDkSUcPvzskF5xNfS 5002
error: {"code":-1,"message":"CWallet::GetDebit() : value out of range"}

error output
Code:
nDebit Value=10002000000, Max Money=10000000000, Coin=1000000, Cent=10000
output /coin
Code:
nDebit Value=10002, Max Money=10000

code does not lie

Let's confirm some things.

1 coin == 100 cent

max money == 10000 coin

2 x Inputs of 5002 == 10004

which is greater than 10000 and hence is out of range

........?

i agree yes.

💦☔️🐳💚💖💛
go to
cryptobetfair.com
ask for a voucher

████████████████
██████████████
█████████████
██████████████
██████████████
███████████
█████████
███████████
████████████
████████████
███████████
█████████████
██████████████
███████████████
████████████████
████████████████
🐠👻🍗🌳🐵
bumbacoin
Legendary
*
Offline Offline

Activity: 1190



View Profile
February 16, 2017, 01:20:54 AM
 #13

with the goal of allowing tx of 2 billion coins,


i was thinking to modify vout checks to ((MAX_MONEY * 2) + 1) = 4,000,000,001
this would allow two large inputs (up to 1,999,999,999 each) plus small fee to join into a 2billion input

a fee of over 1 in the extreme instance would break it still, but pre error checks seem to catch that.
checking vin + fee > MAX_MONEY


.
this would create a couple of possible values of over 32bit integer limit of 2,147,483,647

💦☔️🐳💚💖💛
go to
cryptobetfair.com
ask for a voucher

████████████████
██████████████
█████████████
██████████████
██████████████
███████████
█████████
███████████
████████████
████████████
███████████
█████████████
██████████████
███████████████
████████████████
████████████████
🐠👻🍗🌳🐵
Blockchain Mechanic
Full Member
***
Offline Offline

Activity: 224

www.patreon.com/blockmechanic


View Profile WWW
February 16, 2017, 03:20:39 AM
 #14

with the goal of allowing tx of 2 billion coins,


i was thinking to modify vout checks to ((MAX_MONEY * 2) + 1) = 4,000,000,001
this would allow two large inputs (up to 1,999,999,999 each) plus small fee to join into a 2billion input

a fee of over 1 in the extreme instance would break it still, but pre error checks seem to catch that.
checking vin + fee > MAX_MONEY


.
this would create a couple of possible values of over 32bit integer limit of 2,147,483,647



I usually just solve most large number issues by type-def-ing int64_t

But is you don't mind my asking, what is the true benefit of coins with such huge amounts of coins ?

Equality vs Equity...
bumbacoin
Legendary
*
Offline Offline

Activity: 1190



View Profile
February 16, 2017, 04:36:21 AM
 #15


I usually just solve most large number issues by type-def-ing int64_t

But is you don't mind my asking, what is the true benefit of coins with such huge amounts of coins ?

well one obvious benefit is that it exposed a flaw in current coding.

as i involve myself with numerous clones with questionable heritage i occasionally ask myself something similar.

without any serious discussion on political matters, it is a political answer for me.
i have come to a personal understanding that in times of bad governance, civil disobedience is necessary.
the more alternative options the merrier, and each variation is another possible choice.

and as much as the shitcoin megasphere is full of bad ideas, the long term benefit has yet to be revealed.

💦☔️🐳💚💖💛
go to
cryptobetfair.com
ask for a voucher

████████████████
██████████████
█████████████
██████████████
██████████████
███████████
█████████
███████████
████████████
████████████
███████████
█████████████
██████████████
███████████████
████████████████
████████████████
🐠👻🍗🌳🐵
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!