Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1WEI6h-0007lJ-RZ for bitcoin-development@lists.sourceforge.net; Fri, 14 Feb 2014 12:43:03 +0000 Received-SPF: pass (sog-mx-1.v43.ch3.sourceforge.com: domain of gmail.com designates 209.85.214.44 as permitted sender) client-ip=209.85.214.44; envelope-from=laanwj@gmail.com; helo=mail-bk0-f44.google.com; Received: from mail-bk0-f44.google.com ([209.85.214.44]) by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1WEI6g-0000b3-P2 for bitcoin-development@lists.sourceforge.net; Fri, 14 Feb 2014 12:43:03 +0000 Received: by mail-bk0-f44.google.com with SMTP id r7so195151bkg.31 for ; Fri, 14 Feb 2014 04:42:56 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.205.75.74 with SMTP id yz10mr103200bkb.43.1392381776392; Fri, 14 Feb 2014 04:42:56 -0800 (PST) Received: by 10.205.75.72 with HTTP; Fri, 14 Feb 2014 04:42:56 -0800 (PST) In-Reply-To: References: Date: Fri, 14 Feb 2014 13:42:56 +0100 Message-ID: From: Wladimir To: Denis Andrejew Content-Type: multipart/alternative; boundary=f46d041037372c9fc204f25d257a X-Spam-Score: -0.6 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (laanwj[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 1.0 HTML_MESSAGE BODY: HTML included in message -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-Headers-End: 1WEI6g-0000b3-P2 Cc: Bitcoin Dev Subject: Re: [Bitcoin-development] working with the blockchain: transaction fees & sum(inputs) != sum(outputs) (newbie questions) X-BeenThere: bitcoin-development@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Feb 2014 12:43:04 -0000 --f46d041037372c9fc204f25d257a Content-Type: text/plain; charset=UTF-8 > > Is there special code somewhere that keeps track of all the btc not spent > in all the transactions of a block and allows the miner's address (ie the > address in the first tx of that block) to spend that? > Something like that: Every block has a coinbase transaction at the beginning. The coinbase transaction is special, in that it can pay coins to its outputs without having to specify an input. The total value of the outputs of the coinbase transaction can be at most the block value (the fixed amount per block) + the fees (summed over all transactions in the block). This is checked in ConnectBlock in https://github.com/bitcoin/bitcoin/blob/master/src/main.cpp#L1711 The value of the coinbase transaction is being checked on line 1731. But if so, how would that work then? I should be finding transactions then > where the sum of the ouputs is higher than the sum of the inputs and one of > the inputs should have the miner's address attached to it or what? > The only transactions in which the sum of the outputs can be larger than the sum of the inputs are the aforementioned coinbase transactions (which cannot have inputs). The outputs from the coinbase transaction can be spent as any other output. Wladimir --f46d041037372c9fc204f25d257a Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Is there special code somewhere that keeps track of a= ll the btc not spent in all the transactions of a block and allows the mine= r's address (ie the address in the first tx of that block) to spend tha= t?

Something like that:
Every= block has a coinbase transaction at the beginning.
The coinbase = transaction is special, in that it can pay coins to its outputs without hav= ing to specify an input.

The total value of the outputs of the coinbase transact= ion can be at most the block value (the fixed amount per block) + the fees = (summed over all transactions in the block).

This = is checked in ConnectBlock in=C2=A0

But if so, how would = that work then? I should be finding transactions then where the sum of the = ouputs is higher than the sum of the inputs and one of the inputs should ha= ve the miner's address attached to it or what?

The only transactions in which the s= um of the outputs can be larger than the sum of the inputs are the aforemen= tioned coinbase transactions (which cannot have inputs).

The outputs from the coinbase transaction can be spent as any ot= her output.

Wladimir

--f46d041037372c9fc204f25d257a--