Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: RangerK on July 26, 2013, 04:07:56 PM



Title: How to miners decide which transactions to include in a block?
Post by: RangerK on July 26, 2013, 04:07:56 PM
Forgive me if this is a beginner question.  I'm still relatively new.  The answer to this question wasn't apparent to me from reading Stoshi's famous whitepaper (http://bitcoin.org/bitcoin.pdf).

Here's my guess based on what I've already learned:

Whenever a bloc emerges which the miner agrees is valid, it simply accepts it, and adds to it all the currently-recorded transactions which have happened since then.

Is this accurate?  Is there more to it?


Title: Re: How to miners decide which transactions to include in a block?
Post by: Remember remember the 5th of November on July 26, 2013, 04:10:26 PM
I am not greatly familiar with the source, but there is transactions priority related to coin age, tx size and fee size. But generally, the higher the fee, the higher the incentive to include a transaction in a block.


Title: Re: How to miners decide which transactions to include in a block?
Post by: TierNolan on July 26, 2013, 04:21:09 PM
Here's my guess based on what I've already learned:

Whenever a bloc emerges which the miner agrees is valid, it simply accepts it, and adds to it all the currently-recorded transactions which have happened since then.

Is this accurate?  Is there more to it?

Miners can put whatever transactions they want into the block.  The only mandatory transaction is the one that pays themselves their fee (and there is no reason to leave that one out anyway).

If any of the transactions are invalid, then the block would be rejected.

Since they can only put a certain number of transactions in a block, they should pick the ones that pay the most fees.

However, mostly they don't care about fees, since the mint reward is much higher.

The standard miner software won't add your transactions into blocks unless they fit into one of these sections.  Normal clients won't forward them unless they would mine them.

High Priority

A transaction counts as high priority if it spends mostly old coins and/or spends a lot of coins value.

Basically, each input coin has a priority = (age * value) and they all get added up.

If the transaction is above a certain priority, then it gets into this section.

There are no fees for this section.  This is the only way to get free transactions confirmed.

Fee paying

About half the block is used for fee paying transactions.  There is a minimum fee you must pay to get into this section.

Unused

The default client mostly leaves the other half of the block unused.


Title: Re: How to miners decide which transactions to include in a block?
Post by: steeev on July 27, 2013, 04:35:03 AM
...is there a way for me to know how old my coins are ?

and will older coins be more desired over time ? like rare or collectible coins...?


Title: Re: How to miners decide which transactions to include in a block?
Post by: DannyHamilton on July 27, 2013, 03:23:22 PM
...is there a way for me to know how old my coins are ?

The previous information about priority failed to mention that priority also takes into account the size of the transaction.  Priority is actually calculated as:
priority = sum(input_value_in_base_units * input_age)/transaction_size_in_bytes

For the purposes of calculating priority, input_age is determined by the number of confirmations received since the bitcoins were received in a transaction. input_value_in_base_unite is determined as the number of "satoshi".

So, If you received 2.3 BTC in a transaction that now has 72 confirmations, then those bitcoins would contribute the following to the sum in the numerator of the calculation:

230,000,000 satoshi * 72 confirmations = 16,560,000,000

If that was the only input in the transaction and the transaction was a total of 276 bytes in size, then the transaction priority would be:

16,560,000,000 / 276 = 60,000,000

If a transaction has a priority less than 57,600,000, then most miners will refuse to add it to a block unless it also includes a transaction fee of at least 0.0001 BTC per kilobyte.

and will older coins be more desired over time ? like rare or collectible coins...?

No way to predict what others might choose to value in the future, but I generally find it unlikely since the act of sending them the bitcoin would immediately reduce its age back to 0.

I suppose you could give them the private key associated with the address that the old coins are associated with, but that seems VERY insecure. Since you also know the private key, you could steal the bitcoins as soon as you parted ways.


Title: Re: How to miners decide which transactions to include in a block?
Post by: Trongersoll on July 27, 2013, 05:03:02 PM
so, for a solo miner using bitcoin-qt, that decides what goes into a block? is it configurable? ???


Title: Re: How to miners decide which transactions to include in a block?
Post by: Remember remember the 5th of November on July 27, 2013, 06:28:31 PM
so, for a solo miner using bitcoin-qt, that decide what goes into a block? is it configurable? ???
It's not. You need to modify the client from the source.


Title: Re: How to miners decide which transactions to include in a block?
Post by: TierNolan on July 27, 2013, 08:03:09 PM
so, for a solo miner using bitcoin-qt, that decides what goes into a block? is it configurable? ???

It is slightly difficult to do, so miners generally don't bother.

When transaction fees are a larger portion of the block rewards, then miners might implement more profit orientated changes to the source.


Title: Re: How to miners decide which transactions to include in a block?
Post by: Gavin Andresen on July 29, 2013, 12:16:49 AM
so, for a solo miner using bitcoin-qt, that decide what goes into a block? is it configurable? ???
It's not. You need to modify the client from the source.

That's incorrect. The following command-line or bitcoin.conf configuration parameters let miners set their transaction acceptance policy:

Quote
-blockminsize=<n>      Set minimum block size in bytes (default: 0)
 -blockmaxsize=<n>      Set maximum block size in bytes (default: 250000)
 -blockprioritysize=<n> Set maximum size of high-priority/low-fee transactions in bytes (default: 27000)
 

The -mintxfee / -minrelaytxfee options currently control how large a fee-per-kilobyte is needed for a transaction to be considered "fee paying" versus "free".