Tweeted twitter.com/StackBitcoin/status/660016645054820352
2 edited body
source | link

Transactions have 2 ways to get into blockchain in bitcoind:

  • mempool -> newblock

  • newblock no in mempool

lets check AcceptToMemoryPool function

https://github.com/bitcoin/bitcoin/blob/c719cefc417cc578f48b33069b764339a61054ce/src/main.cpp#L876

CAmount nFees = nValueIn-nValueOut;

in case outs > ins

nFees<0

if (mempoolRejectFee > 0 && nFees < mempoolRejectFee) {
        return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "mempool min fee not met", false, strprintf("%d < %d", nFees, mempoolRejectFee));

negative nFees will be rejected all is good in this point

ok lets check Connectblock function

https://github.com/bitcoin/bitcoin/blob/c719cefc417cc578f48b33069b764339a61054ce/src/main.cpp#L1805

for each tx in block we do:

nFees += view.GetValueIn(tx)-tx.GetValueOut();

https://github.com/bitcoin/bitcoin/blob/c719cefc417cc578f48b33069b764339a61054ce/src/main.cpp#L1826

 CAmount blockReward = nFees + GetBlockSubsidy(pindex->nHeight, chainparams.GetConsensus());
if (block.vtx[0].GetValueOut() > blockReward)
    return state.DoS(100,
                     error("ConnectBlock(): coinbase pays too much (actual=%d vs limit=%d)",
                           block.vtx[0].GetValueOut(), blockReward),
                           REJECT_INVALID, "bad-cb-amount");

At this point we calculate max possible reward for this block: all tx fees + mining reward

then we check that coinbase reward not more then this value

what if same miner create and include transaction that have inputs for 1 btc nadand have outputs for 2 btc, so fee for this tx will be -1 btc

then miner can set reward for coinbase transaction to 25 btc + all fees - 1 btc.

so this (block.vtx[0].GetValueOut() > blockReward) return True

as result we have Transaction, that create more coins then received, inside blockchain

Where is my error?

Transactions have 2 ways to get into blockchain in bitcoind:

  • mempool -> newblock

  • newblock no in mempool

lets check AcceptToMemoryPool function

https://github.com/bitcoin/bitcoin/blob/c719cefc417cc578f48b33069b764339a61054ce/src/main.cpp#L876

CAmount nFees = nValueIn-nValueOut;

in case outs > ins

nFees<0

if (mempoolRejectFee > 0 && nFees < mempoolRejectFee) {
        return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "mempool min fee not met", false, strprintf("%d < %d", nFees, mempoolRejectFee));

negative nFees will be rejected all is good in this point

ok lets check Connectblock function

https://github.com/bitcoin/bitcoin/blob/c719cefc417cc578f48b33069b764339a61054ce/src/main.cpp#L1805

for each tx in block we do:

nFees += view.GetValueIn(tx)-tx.GetValueOut();

https://github.com/bitcoin/bitcoin/blob/c719cefc417cc578f48b33069b764339a61054ce/src/main.cpp#L1826

 CAmount blockReward = nFees + GetBlockSubsidy(pindex->nHeight, chainparams.GetConsensus());
if (block.vtx[0].GetValueOut() > blockReward)
    return state.DoS(100,
                     error("ConnectBlock(): coinbase pays too much (actual=%d vs limit=%d)",
                           block.vtx[0].GetValueOut(), blockReward),
                           REJECT_INVALID, "bad-cb-amount");

At this point we calculate max possible reward for this block: all tx fees + mining reward

then we check that coinbase reward not more then this value

what if same miner create and include transaction that have inputs for 1 btc nad have outputs for 2 btc, so fee for this tx will be -1 btc

then miner can set reward for coinbase transaction to 25 btc + all fees - 1 btc.

so this (block.vtx[0].GetValueOut() > blockReward) return True

as result we have Transaction, that create more coins then received, inside blockchain

Where is my error?

Transactions have 2 ways to get into blockchain in bitcoind:

  • mempool -> newblock

  • newblock no in mempool

lets check AcceptToMemoryPool function

https://github.com/bitcoin/bitcoin/blob/c719cefc417cc578f48b33069b764339a61054ce/src/main.cpp#L876

CAmount nFees = nValueIn-nValueOut;

in case outs > ins

nFees<0

if (mempoolRejectFee > 0 && nFees < mempoolRejectFee) {
        return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "mempool min fee not met", false, strprintf("%d < %d", nFees, mempoolRejectFee));

negative nFees will be rejected all is good in this point

ok lets check Connectblock function

https://github.com/bitcoin/bitcoin/blob/c719cefc417cc578f48b33069b764339a61054ce/src/main.cpp#L1805

for each tx in block we do:

nFees += view.GetValueIn(tx)-tx.GetValueOut();

https://github.com/bitcoin/bitcoin/blob/c719cefc417cc578f48b33069b764339a61054ce/src/main.cpp#L1826

 CAmount blockReward = nFees + GetBlockSubsidy(pindex->nHeight, chainparams.GetConsensus());
if (block.vtx[0].GetValueOut() > blockReward)
    return state.DoS(100,
                     error("ConnectBlock(): coinbase pays too much (actual=%d vs limit=%d)",
                           block.vtx[0].GetValueOut(), blockReward),
                           REJECT_INVALID, "bad-cb-amount");

At this point we calculate max possible reward for this block: all tx fees + mining reward

then we check that coinbase reward not more then this value

what if same miner create and include transaction that have inputs for 1 btc and have outputs for 2 btc, so fee for this tx will be -1 btc

then miner can set reward for coinbase transaction to 25 btc + all fees - 1 btc.

so this (block.vtx[0].GetValueOut() > blockReward) return True

as result we have Transaction, that create more coins then received, inside blockchain

Where is my error?

1
source | link

Transactions that have outputs value more then inputs value possible?

Transactions have 2 ways to get into blockchain in bitcoind:

  • mempool -> newblock

  • newblock no in mempool

lets check AcceptToMemoryPool function

https://github.com/bitcoin/bitcoin/blob/c719cefc417cc578f48b33069b764339a61054ce/src/main.cpp#L876

CAmount nFees = nValueIn-nValueOut;

in case outs > ins

nFees<0

if (mempoolRejectFee > 0 && nFees < mempoolRejectFee) {
        return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "mempool min fee not met", false, strprintf("%d < %d", nFees, mempoolRejectFee));

negative nFees will be rejected all is good in this point

ok lets check Connectblock function

https://github.com/bitcoin/bitcoin/blob/c719cefc417cc578f48b33069b764339a61054ce/src/main.cpp#L1805

for each tx in block we do:

nFees += view.GetValueIn(tx)-tx.GetValueOut();

https://github.com/bitcoin/bitcoin/blob/c719cefc417cc578f48b33069b764339a61054ce/src/main.cpp#L1826

 CAmount blockReward = nFees + GetBlockSubsidy(pindex->nHeight, chainparams.GetConsensus());
if (block.vtx[0].GetValueOut() > blockReward)
    return state.DoS(100,
                     error("ConnectBlock(): coinbase pays too much (actual=%d vs limit=%d)",
                           block.vtx[0].GetValueOut(), blockReward),
                           REJECT_INVALID, "bad-cb-amount");

At this point we calculate max possible reward for this block: all tx fees + mining reward

then we check that coinbase reward not more then this value

what if same miner create and include transaction that have inputs for 1 btc nad have outputs for 2 btc, so fee for this tx will be -1 btc

then miner can set reward for coinbase transaction to 25 btc + all fees - 1 btc.

so this (block.vtx[0].GetValueOut() > blockReward) return True

as result we have Transaction, that create more coins then received, inside blockchain

Where is my error?