nochowderforyou / clams

Clam Project
MIT License
62 stars 58 forks source link

Using -staketo without -splitsize... #240

Closed dooglus closed 8 years ago

dooglus commented 8 years ago

... was causing invalid stake transactions to be created if an output staked twice quickly

This fixes the issue.

dooglus commented 8 years ago

I guess it might be useful to add a note about how this bug came to light.

Staking a 20 CLAM output, with staketo= specified, but everything else at default, the debug log showed:

CheckStake() : new proof-of-stake block found
  hash: c8ea61f8b973d9d08d8a7bd1689feac352f7327bd9e68247673ee4a9321f8d36
proofhash: 000028411a7be69b3fce5cd8d00ab6e4de8f7e1b760292a923fe604118e9006d
target: 0000719726812c00000000000000000000000000000000000000000000000000
CBlock(hash=c8ea61f8b973d9d08d8a7bd1689feac352f7327bd9e68247673ee4a9321f8d36, ver=7, hashPrevBlock=5f37524c705e96bdaa357d4eeb0804e81da26e7615fdc5d69a7519f497e3a33c, hashMerkleRoot=5f5f
26045a62c85095682954fc2c7d22198e665f2a32857e8b3602c48772beae, nTime=1448397360, nBits=1b00f3ef, nNonce=0, vtx=2, vchBlockSig=304402201b0a78a28e18d31fa1f9d986d06039e1297ef3117ad5d327ad3
9580b6041b02d0220493c30455b8974a3084424b5725a95629fde00a6af61eae5d0b384c061485873)
  Coinbase(hash=9785a0db0f, nTime=1448397360, ver=2, vin.size=1, vout.size=1, nLockTime=0, strCLAMSpeech=)
    CTxIn(COutPoint(0000000000, 4294967295), coinbase 03805b0b)
    CTxOut(empty)

  Coinstake(hash=d09e4204ce, nTime=1448397360, ver=2, vin.size=1, vout.size=4, nLockTime=0, strCLAMSpeech=Expression of Religious Freedo)
    CTxIn(COutPoint(79f143b5e3, 74), scriptSig=3045022100b8b26f54b96d95)
    CTxOut(empty)
    CTxOut(nValue=0.00, scriptPubKey=03bb7405edfbe345f1ecb9bd270efe6b5c50974ef1efd3c952b3e7c2702c70dceb OP_CHECKSIG)
    CTxOut(nValue=10.50, scriptPubKey=OP_DUP OP_HASH160 7c24dbfad25af6c4c1a63a4099bda3a9042cf54e OP_EQUALVERIFY OP_CHECKSIG)
    CTxOut(nValue=21.00, scriptPubKey=OP_DUP OP_HASH160 7c24dbfad25af6c4c1a63a4099bda3a9042cf54e OP_EQUALVERIFY OP_CHECKSIG)

  vMerkleTree:  9785a0db0fe6f54ff044cc9f87d1f4b159f88c933e3c779d1b62a32b615d8f04 d09e4204cef07ed3b57178f1b195dff8ad06c39b3e91b468f5466be01d2ecc2b 5f5f26045a62c85095682954fc2c7d22198e66
5f2a32857e8b3602c48772beae

out 31.50
ERROR: ConnectBlock() : coinstake pays too much(actual=11.50000000 vs calculated=1.00000000)

ie. it tried to split the 21 CLAM output into two 10.5's, but made a 10.5 and a 21.0 instead, in effect trying to award itself 11.5 CLAMs as the stake reward.