text:
ScriptSig (coinbase) structure of the Genesis Block
From original bitcoin c++ source code:
// Genesis Block:
        // CBlock(hash=000000000019d6, ver=1, hashPrevBlock=00000000000000, hashMerkleRoot=4a5e1e, nTime=1231006505, nBits=1d00ffff, nNonce=2083236893, vtx=1)
        //   CTransaction(hash=4a5e1e, ver=1, vin.size=1, vout.size=1, nLockTime=0)
        //     CTxIn(COutPoint(000000, -1), coinbase 04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73)
        //     CTxOut(nValue=50.00000000, scriptPubKey=0x5F1DF16B2B704C8A578D0B)
        //   vMerkleTree: 4a5e1e

...
txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));

We could see that scriptSig is: 04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73
Let's see closer:
04 - ?
ffff001d - 486604799 aka 0x1d00ffff
010445 - ?
5468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73 - The Times 03/Jan/2009 Chancellor on brink of second bailout for banks
I don't understand what are 04 and 010445. How can I get them?
At wiki page of Genesis Block (https://en.bitcoin.it/wiki/Genesis_block) in ScriptSig line there is nothting about 010445.

Update. I have found that coinbase has a prefix with a byte indicating the length of nBits. In the Genesis Block length of Nbits are 4: 0x1d, 0x00, 0xff, 0xff. So, I know what is 04 but i stil don't know about 010445((

Here is a breakdown of the entire genesis block:
01000000 - version
0000000000000000000000000000000000000000000000000000000000000000 - prev block
3BA3EDFD7A7B12B27AC72C3E67768F617FC81BC3888A51323A9FB8AA4B1E5E4A - merkle root
29AB5F49 - timestamp
FFFF001D - bits
1DAC2B7C - nonce
01 - number of transactions
01000000 - version
01 - input
0000000000000000000000000000000000000000000000000000000000000000FFFFFFFF - prev output
4D - script length
04FFFF001D0104455468652054696D65732030332F4A616E2F32303039204368616E63656C6C6F72206F6E206272696E6B206F66207365636F6E64206261696C6F757420666F722062616E6B73 - scriptsig
FFFFFFFF - sequence
01 - outputs
00F2052A01000000 - 50 BTC
43 - pk_script length
4104678AFDB0FE5548271967F1A67130B7105CD6A828E03909A67962E0EA1F61DEB649F6BC3F4CEF38C4F35504E51EC112DE5C384DF7BA0B8D578A4C702B6BF11D5FAC - pk_script
00000000 - lock time

Decoding the ScriptSig:
04 - push the next 4 bytes to stack
FFFF001D - 4 bytes pushed, they appear to be the same as bits
01 - push the next 1 byte to stack
04 - 1 byte pushed
45 - push the next 69 bytes to stack
5468652054696D65732030332F4A616E2F32303039204368616E63656C6C6F72206F6E206272696E6B206F66207365636F6E64206261696C6F757420666F722062616E6B73 - pushed bytes, "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks"

So 010445 are in fact part of 2 operations - 01 pushes 04 to the stack, 45 pushes the message to the stack. As to why push 04, beats me, maybe it was just testing to make sure something works? Some internal counter used by Satoshi during Genesis block creation? Since the script of a coin generation transaction is really meaningless, we might never know.

Thanks for the answer but I still don't know what is 010445 because there is no explanation in breakdown about 010445. 010445 is simply part of the sequence in breakdown.

@VitaliGrabovski Sorry about that, I broke things down a bit more. I explained 010445.

The meaning of FFFF01D and 04 that are pushed onto the stack before de the famous string is explained here :
https://en.bitcoin.it/wiki/Transaction#Generation
As you notice, FFFF01D repeats the Bits field that appears in the header. And 04 is (I quote) "the arbitrary-precision "extraNonce" number there, which increments every time the Nonce field in the block header overflows".
If you wonder what is the nonce, it means "number once only used". The nonce is some data in the block header that you may tweak until the hash of the header fits the target.

Please Check Out Here
Sigscript :

04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73

Genesis Block Coinbase Transaction:
04:-

length of nbits: [0x1d, 0x00, 0xff, 0xff]

ffff001d:-

little_endian version of hexadecimel nbits

010445:-

if you convert this little piece of sh*t from hex to ascii
you will get this "E" (im not sure if its important or not). now as you can see at coinbase message it has the "E" before the message

5468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73:

message : The Times 03/Jan/2009 Chancellor on brink of second bailout for banks

so when you combine all the str? idk, you will get this

(nbits length) + (hex value of nbits in little_endian) + (the f*ck you want to call this) + (message)

04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73


text:
What is proofOfWorkLimit?
Look at the code below from android bitcoin wallet:
proofOfWorkLimit = Utils.decodeCompactBits(0x1d00ffffL);

And look at the code from bitcoin qt wallet:
static CBigNum bnProofOfWorkLimit(~uint256(0) >> 32);

I assume that in second case ProofOfWorkLimit is 32 "0" and 224 "1" (000000...000111111111....11111111)?
So I don't have an idea how to get first case "0x1d00ffffL" from second case?
In binary "0x1d00ffffL" is 11101000000001111111111111111.
P.S. I have looked in uint256.h. It wasn't helpful.

The first byte, 1D, is the length. The next three bytes are the high bytes of the hash. So we have 00ffff, then we add ff bytes onto the end to get to 29 bytes. Then we're done.
We wind up with 3 bytes of leading zeroes because 32-29 is 3. And we get one byte of zeroes from the second byte of the compact bits. So the final result is 00,00,00,00,ff,ff,ff...

Thanks for reply. I am still confused. Can your answer how to get "first case" from "static CBigNum bnProofOfWorkLimit(~uint256(0) >> 27);" ?

~0 means all bits set. >> 32 means to shift the bits left by 32 bits, shifting in zeroes in their place.

Thanks again. Sorry for insistence but can you answer what exactly should I put here "Utils.decodeCompactBits(0x1d00ffffL);" in case "~uint256(0) >> 27" ?

You want 27 zero bits. That's 3 bytes of all zero bits, followed by 3 more zero bits. 00011111 is 1F. Since the whole thing is 32 bytes, and we need 3 zero bytes, the length of the non-zero segment is 29 bytes, which in hex is 1D. So unless I made a mistake, I get 0x1D1FFFFF.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
How many addresses does bitcoind use for Bitcoin generation?
When bitcoind is generating Bitcoins, does it change the addresses that are used for receiving the block reward? That is, if I mine two blocks with the same bitcoind wallet.dat, will the same address be credited with both of the rewards?

If you generate a new block with "getwork" then bitcoind will always use a new address each time.
If you generate a new block with "getmemorypool", then you decide. You can do whatever you want because you are creating the block data yourself. "getmemorypool" is new with bitcoind 0.5.

Each block reward will be credited to a different address. No more than one address per block is used in the generation process.

Hmm, is there any way to suppress this behaviour and use one and the same address every time?

You'd need to change the code, though I think it'd be a pretty easy change to make.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Two blocks, two transactions, same hash
Would a block containing a transaction with an identical hash as a previous transaction be considered valid? That is, if someone made a transaction for generating Bitcoins and solve two blocks with the same coinbase transaction, would the second block using that transaction valid?

Related: https://bitcoin.stackexchange.com/questions/26910/duplicated-hash-values-in-mining-reward

That's valid (and has happened) for coinbase transactions and transactions built off of coinbase transactions. Other than those strange cases, putting the same transaction in the chain twice isn't allowed.
Coinbase duplicates are only allowed due to an oversight. It will be corrected soon.

"Other than those strange cases ... isn't allowed" -> It is allowed, just incredibly hard to do (preimage attack on SHA256).

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
What is TxIn's sequence?
I'm currently trying to generate the genesis block with my code and I've stumbled upon the TxIn sequence field that is not explained in the Protocol Specification wiki page, nor does it seem to appear in the block explorer. What is the way the value of this field is calculated, and what was its value for the genesis block?

Sequence numbers aren't shown on the Bitcoin Block Explorer HTML pages because they are not used by the network currently. Non-default sequence numbers would be shown on raw block/tx pages, but I'm not sure whether this has ever happened.
Sequence numbers are intended to be used for replacement. Replacement is currently disabled, but how it would work is:

You send a transaction with a LockTime in the future and a sequence number of 0. The transaction is then not considered by the network to be "final", and it can't be included in a block until the specified LockTime is reached.
Before LockTime expires, you can replace the transaction with as many new versions as you want. Newer versions have higher sequence numbers.
If you ever want to lock the transaction permanently, you can set the sequence number to UINT_MAX. Then the transaction is considered to be final, even if LockTime has not been reached.

This is useful in several cases. For example, two parties can use it to set up a "prepared transaction". Once the prepared transaction is created, the parties can move money between each other instantly, securely, and without fees. So you could set one of these up with an exchange and withdraw and deposit without waiting for confirmations.
Since replacement is not used currently, all transactions Bitcoin creates have LockTime = 0 and Sequence = UINT_MAX. This is the case with the genesis block's generation transaction.

How does the network determine whether to accept a new version as a replacement transaction? Could an attacker replace transactions maliciously?

Non-default sequence numbers have happened.  Once in January 2011 and 6 times in February 2011.  The sequence number was zero in each case.  See transaction c99c49da4c38af669dea436d3e73780dfdb6c1ecf9958baa52960e8baee30e73 for an example.  http://blockexplorer.com/rawtx/c99c49da4c38af669dea436d3e73780dfdb6c1ecf9958baa52960e8baee30e73

For reference UINT_MAX = 4294967295U

Your answer seems to assume that a transaction has a single sequence number, but according to the protocol specification, a transaction will have a sequence number per each input. In this case, I'm not sure how replacement would work. Consider a transaction with two inputs: input #0 has seqno 1 and input #1 has seqno 2. How would this transaction be compared to one where input #0 has seqno 2 and input #1 has seqno 1?

UINT_MAX is a 32 bit value. In hex it is "FFFFFFFF".

This answer seems to be outdated.  See the answer of https://bitcoin.stackexchange.com/a/55113/47528

Note that the accepted answer is outdated.
Currently, sequence numbers are mainly used for signaling RBF - replace-by-fee - that allows you to resend a transaction with a higher fee.
See https://bitcoincore.org/en/faq/optin_rbf/ , https://github.com/bitcoin/bips/blob/master/bip-0125.mediawiki


text:
Why does the Bitcoin protocol use the little-endian notation?
Why does the Bitcoin use the litte-endian notation? It is less common than big-endian notation, thus when programming low-level applications working with Bitcoin protocol, one quite often has to create custom operations for handling the endianness switching. Is there some specific reason why this notation was chosen?

Most likely it is a small design error, but there is big argument about it at bitcointalk.org:What would you change about the Bitcoin protocol?.

Modern computers almost always use little-endian internally, so this choice improves speed. If Bitcoin used network byte order, then order conversions would be necessary for every message sent or received.
Hashes are defined by the standards as being big-endian, and crypto libraries deal with them in that form, so hashes are transmitted in big-endian. Bitcoin displays hashes in little-endian because Bitcoin sometimes considers hashes to be little-endian integers instead of strings.

When you say Bitcoin displays hashes, do you mean how it's commonly displayed on Bitcoin software, tools, and websites? Or are you talking about something actually in the bitcoin core code for displays hashes a certain way?

Modern CPUs also typically have byte-swapping load and store instructions, or at least a byte swap register instruction, so that effective programmers (and optimizing compilers) may eliminate, or nearly eliminate, the overhead of endianness compensation.
This "small design error" may be a simple case of "premature optimization".

Well, a premature optimization is a design error ^^


text:
Can't send raw transaction. Bitcoind error: {"code":-22,"message":"TX rejected"}
I have this raw transaction:
01000000024ae83382c185ba9a2fcaf0092bed4e8f74d31ca8eb234513c308b615fb9e3e3a000000006b48304502203ac946b370ecb43a32c3bf67598ca3ddc9818cb9efd0c6a6e68aca6e20d95b06022100841f3eed93cb955f9e1cbd26d23da3b80866872852ec5920d6ff794bd218bee40121035dea6c0ecb52807e2b7a9864c3212451e836eb0fd7cc6ba3369748825e2606f9ffffffffa3d6dc0d21402967de9431fde06d6b1cb458260d7852038035a79ec7554efcd9000000006b4830450220644bbf5a711243f679655e7ce7c193a8dde5fd110252dfdb4dd2d05d21e1b0a4022100a22c656b1e897bac71bf2d89e385eda4bdade16ca04957537fc73f903cb614d001210395676e88fe9ae950d40915df040a3610e1f42368f4a842692c24b29fd9d78a7bffffffff0330750000000000001976a9143fcf3750b81fad1cd27bae9c34feeefc278360ee88acbc0d0000000000001976a91483c1b13e99ccfc66405ef2ecb76deefca165097588ac204e0000000000001976a9147e69b1309dde4be2e39e1956ace0fa95db0d01b488ac00000000
It signed and ready to go
{
    "txid" : "adae77fd1c5cc3ae4429217ea0d84e67ac6f198543374356cc531350b3ad217b",
    "version" : 1,
    "locktime" : 0,
    "vin" : [
        {
            "txid" : "3a3e9efb15b608c3134523eba81cd3748f4eed2b09f0ca2f9aba85c18233e84a",
            "vout" : 0,
            "scriptSig" : {
                "asm" : "304502203ac946b370ecb43a32c3bf67598ca3ddc9818cb9efd0c6a6e68aca6e20d95b06022100841f3eed93cb955f9e1cbd26d23da3b80866872852ec5920d6ff794bd218bee401 035dea6c0ecb52807e2b7a9864c3212451e836eb0fd7cc6ba3369748825e2606f9",
                "hex" : "48304502203ac946b370ecb43a32c3bf67598ca3ddc9818cb9efd0c6a6e68aca6e20d95b06022100841f3eed93cb955f9e1cbd26d23da3b80866872852ec5920d6ff794bd218bee40121035dea6c0ecb52807e2b7a9864c3212451e836eb0fd7cc6ba3369748825e2606f9"
            },
            "sequence" : 4294967295
        },
        {
            "txid" : "d9fc4e55c79ea735800352780d2658b41c6b6de0fd3194de672940210ddcd6a3",
            "vout" : 0,
            "scriptSig" : {
                "asm" : "30450220644bbf5a711243f679655e7ce7c193a8dde5fd110252dfdb4dd2d05d21e1b0a4022100a22c656b1e897bac71bf2d89e385eda4bdade16ca04957537fc73f903cb614d001 0395676e88fe9ae950d40915df040a3610e1f42368f4a842692c24b29fd9d78a7b",
                "hex" : "4830450220644bbf5a711243f679655e7ce7c193a8dde5fd110252dfdb4dd2d05d21e1b0a4022100a22c656b1e897bac71bf2d89e385eda4bdade16ca04957537fc73f903cb614d001210395676e88fe9ae950d40915df040a3610e1f42368f4a842692c24b29fd9d78a7b"
            },
            "sequence" : 4294967295
        }
    ],
    "vout" : [
        {
            "value" : 0.00030000,
            "n" : 0,
            "scriptPubKey" : {
                "asm" : "OP_DUP OP_HASH160 3fcf3750b81fad1cd27bae9c34feeefc278360ee OP_EQUALVERIFY OP_CHECKSIG",
                "hex" : "76a9143fcf3750b81fad1cd27bae9c34feeefc278360ee88ac",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "16pPoiDcGU8P9PcqBqnZGc6SJqeuyLEDEX"
                ]
            }
        },
        {
            "value" : 0.00003516,
            "n" : 1,
            "scriptPubKey" : {
                "asm" : "OP_DUP OP_HASH160 83c1b13e99ccfc66405ef2ecb76deefca1650975 OP_EQUALVERIFY OP_CHECKSIG",
                "hex" : "76a91483c1b13e99ccfc66405ef2ecb76deefca165097588ac",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "1D1fZ7SPBtDZ4iVy9Ut5Dg5rv7PChc6PHv"
                ]
            }
        },
        {
            "value" : 0.00020000,
            "n" : 2,
            "scriptPubKey" : {
                "asm" : "OP_DUP OP_HASH160 7e69b1309dde4be2e39e1956ace0fa95db0d01b4 OP_EQUALVERIFY OP_CHECKSIG",
                "hex" : "76a9147e69b1309dde4be2e39e1956ace0fa95db0d01b488ac",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "1CXQknoy7hvc4sVnQxCL2LnGZQ6C8H4yU8"
                ]
            }
        }
    ]
}

But when I try to broadcast it to blockchain through sendrawtransaction it doesn't work: error: {"code":-22,"message":"TX rejected"}
Why? What's wrong with transaction? If you take a look on inputs and outputs you can see everything is look correct. I really don't understand why...
Please advise how to fix it and make it works.
Update: Wait a minute! I just found this post Why is a transaction with outputs of less than ฿0.00005460 rejected? ... It means if my change below then some "dust" value in BTC I can't send it???
But this is not dust. This is my change!
So how to keep my change less then 5460 satoshis? What is solution?

Looks like your tx is in blockchain now http://blockchain.info/tx/a4739fd533c2dd619954d76e9d9f0b159b1aa0827919b06208ef6d85d6e48fc2

Yes but output values is different if you noticed.

@GeorgeKimionis I never use unspent output and first time hear it from you. Would you mind to give me some example how to use it properly?

@GeorgeKimionis  thanks, I got it. But what if I don't have anymore unspent output? And dust is my last balance, what to do in this case?


text:
How can I create a transaction that collects inputs from many addresses and sends them to one address in bitcoind?
I'm using bitcoind and would like to understand how to create transactions that send inputs from many specifically selected addresses (from my wallet) to one destination address. I want to do manually what the sendtoaddress command does automatically.
If this operation requires me to create a raw transaction could you please provide a working example? I already read bitcoin.it:raw_transactions, but it is hard to understand without an example and unfortunately the wiki article doesn't provide any.
I would appreciate help greatly.

Please be careful, I have seen many people accidently mess up with raw transactions. Such as sending hundreads of BTC as a miners fee or the likes.

I will plan to test dipply with small amounts first.

There is also the "testnet" which is made for testing

Please check rpc documentation before use it (https://developer.bitcoin.org/reference/rpc/).

When you have a bitcoin balance, that balance is actually unspent outputs from transactions your addresses have already received.
So when you want to send a raw transaction, what you include in that is the transactions and unspent outputs from those transactions... these can be from any address in your wallet.
The basic idea is;
createrawtransaction
signrawtransaction
sendrawtransaction
If you google around, you'll find plenty of examples of their use.

Coinbin seem to require internet/blockchain access in order to create a raw transaction. Is this true with all methods of creating raw transactions?

If this operation requires me to create a raw transaction, here's a working example assuming you have UTXOs:

UTXO 1: "txid1", Index 0, Amount 0.01 BTC
UTXO 2: "txid2", Index 1, Amount 0.02 BTC
Destination: "your_destination_address"

# Calculate transaction fee estimate (adjust the fee rate as needed)
TRANSACTION_FEE=$(bitcoin-cli estimatesmartfee 6 "CONSERVATIVE")

# Calculate total input amount from UTXOs
TOTAL_INPUT=0.03

# Calculate the desired output amount
OUTPUT_AMOUNT=0.02

# Calculate the change amount
CHANGE_AMOUNT=$(echo "$TOTAL_INPUT - $OUTPUT_AMOUNT - $TRANSACTION_FEE" | bc)

# Create the raw transaction with change output
RAW_TRANSACTION_HEX=$(bitcoin-cli createrawtransaction '[
   {"txid":"txid1", "vout":0},
   {"txid":"txid2", "vout":1}
]' '{
   "your_destination_address": '$OUTPUT_AMOUNT',
   "your_change_address": '$CHANGE_AMOUNT'
}')

# Sign the raw transaction
SIGNED_TRANSACTION_HEX=$(bitcoin-cli signrawtransactionwithwallet "$RAW_TRANSACTION_HEX")

# Broadcast the transaction
bitcoin-cli sendrawtransaction "$SIGNED_TRANSACTION_HEX"

Please correct me if I was wrong.

This might work, because estimatesmartfee returns a feerate in sat/kvB, and your transaction likely is less than 1 kvB. You are however deducting a feerate from an amount, and for a larger transaction that might be too little to achieve a confirmation. Why did you post a second answer instead of editing your first?

Assuming you have UTXOs:

UTXO 1: "txid1", Index 0, Amount 0.01 BTC
UTXO 2: "txid2", Index 1, Amount 0.02 BTC
Destination: "your_destination_address"

# Create raw transaction
raw_tx=$(bitcoin-cli createrawtransaction '[{"txid":"txid1","vout":0}, {"txid":"txid2","vout":1}]' '{"your_destination_address": 0.03}')

# Sign raw transaction
signed_tx=$(bitcoin-cli signrawtransactionwithwallet "$raw_tx")

# Broadcast signed transaction
bitcoin-cli sendrawtransaction "${signed_tx["hex"]}"

Replace "your_destination_address" with your actual destination address. Run these commands in your terminal with your Bitcoin Core node running.
Maybe test on Bitcoin testnet before using real funds.

Hi Mani, this is on the way to be a much better answer than the one from ten years ago, but could you please expand on two issues: 1) createrawtransaction does not automatically create a change output. Could you please include a warning to that effect and add some instructions on how to send change back to yourself. 2) The transaction in your example does not pay any fees, so it will not propagate on the network or get mined. Do you have an idea how to fix that? :)


text:
Why is this transaction referred to as "low fee"?
Why does Blockchain.info refer to this transaction as "low fee", when it has the normal fee? What is wrong with it? Its size is less than 1000 bytes, with a fee of 0.1 mBTC – yet, this transaction just got stuck?
Could anyone please explain please what happened and why it got stuck?

Finally it confirmed. But confirmation time for only one confirmation took almost 24 hours. I never faced case like this before.

It is 1343 bytes, larger than 1000 bytes, so you should have paid 0.2mBTC.
You have too many inputs in this transactions. If you had used a compressed public key, you might be able to save some bytes and shrink the transaction size down to under 1kB.


text:
What happens to non-standard transactions in the case of a blockchain reorg?
Blockchain
[m1]-> [m2] -> [m3] -> [m4]

         |  -> [f1] -> [f2] -> [new]

m - mainchain blocks
f - fork blocks
new - tip of the fork that is at greater height than the previous mainchain

In this case we must switch from the mainchain to the fork, due to the height of forkchain being greater than the mainchain.
My question is about transactions in blocks [m3], [m4]. In the case a transaction was in [m3] but not included in either the blocks [f1],[f2]. Since that transaction is not confirmed in the new mainchain (the forkchain) after the switch, would this tx be available for miners again to include for next block? Would this transactions be returned to the rawmempool?
And what if this transaction was added without isStandard check (in case adding in block), should we process isStandard check for this transaction?

This question appears to be based on a misunderstanding of what sidechains are. Possibly, the author confuses it with blockchain forks, but it is hard to tell, because the text of the question is hard to follow. Please improve the phrasing of your question, correct spelling, and then flag for reopening.

Much better, but sidechains are not the product of a blockchain fork: Sidechains are separate blockchains that are pegged to the Bitcoin chain.

related: Transaction fees when a block chain is discarded

what is the correct name of bitcoin chain fork?

Each of the blockchain forks assumes itself to be the only valid blockchain. They do not change their behavior due to a competing chain. They will require checks and confirm transactions completely independently from each other. It is likely that the same transactions are confirmed in both competing chains, just in different order and perhaps also at different heights. If a chain reorganization happens, and some transactions were not confirmed in the new best chain yet, they are still in the pool of unconfirmed transactions for that chain.
So, if you actually switch from [m4] to [new], and a transaction was not confirmed in the [new] chain that had been confirmed in the chain containing [m4], yes of course it would be in pool of unconfirmed transactions for that chain.
isStandard() is performed by every node when it learns about a transaction. Each miner decides whether to confirm transactions that don't pass isStandard() by themselves. It is irrelevant whether a competitor would include it or not for this process. If the forkchain is extended by a miner that doesn't confirm non-standard transactions, it will only be confirmed later when someone else chooses to do so.

What about transactions that was in block and skip isStandart check?

I've extended my answer to address that part of your question more explicitly. I hope that it is clear now.

miner add nonstandard transaction X to block A, we have reveived this block and add to mainchain. After we receive blocks B, C  block A no longer in mainchain. We should add all transaction that not exist in mainchain back to txmempool, should we add transaction X to mempool? or we need reject this transaction?

Essentially, nodes treat all unconfirmed transactions just like any unconfirmed transaction they just learned about for the first time. Those nodes that relay non-standard transactions will relay it, just like last time they saw it. Those that reject non-standard transactions will not. Why should it be treated any different, just because some orphaned chain had previously confirmed it?


text:
Why do bitcoin mining companies sell hardware if the hardware they are selling makes them money?
Why do bitcoin mining companies sell hardware and make ASICS if the hardware they are selling makes them money? Surely they would hold onto the profitable hardware and sell it when it's less profitable?
Does this actually happen?

they need to guarantee a profit, and cant risk going under due to negative market movements.

Why does somebody sell tomatoes instead eating them?

because when you eat a tomato it does not generate you money whereas utilizing money generating hardware does.

http://arstechnica.com/gadgets/2013/06/how-a-total-n00b-mined-700-in-bitcoins/3/

In fact, if it's so profitable, why on earth is Butterfly Labs selling these devices? Why not rent a warehouse, fill it with miners, and make infinity bitcoins?
The answer is two-fold. First, BFL required a great deal of capital in order to design and manufacture the ASICs that power its boxes and then to assemble the miners themselves. This capital was provided in no small part by pre-selling the miners; hanging onto them to do some BTC mining with them is sketchy at best and at worst illegal. Plus, there are practical considerations: a giant BTC warehouse adds overhead costs, and I can't even begin to take a guess at the bookkeeping implications of warehousing capital like that.
However, the second reason is far more practical: bitcoins, for all their current value, are still speculative. A large amount of US dollars is a large amount of US dollars no matter which way you cut it. It can be readily exchanged for goods and services. Bitcoins themselves don't necessarily hold value, and it's difficult to exchange them in large quantities for an equivalent amount of dollars. So selling Bitcoin miners for dollars guarantees a certain number of dollars; investing capital into mining a truly large number of bitcoins might work well as a short-term hedge, but the value of the trade is utterly impossible to predict.
This, I suppose, is part of the nature of high-risk investments. But in this case, Butterfly Labs can simply charge whatever it wants for its gear in order to make whatever margin it deems is sufficient. Why bet on the future of a relatively new virtual currency that may go up or down when you can simply get a bunch of real US dollars?

Good point well made Vijay I would credit your answer if I had enough reputation


text:
What are the advantages and disadvantages of pooled mining?
Is it better to mine solo? Is pooled mining what is recommended now? I've heard you get about the same back either way, but I am confused and would like some help.

This is basically a duplicate of Wouldn't the expected return of a mining pool be no more than solo mining?
http://bitcoin.stackexchange.com/questions/10760/wouldnt-the-expected-return-of-a-mining-pool-be-no-more-than-solo-mining/10773

@Dane I think this question could be useful when talking about a broader perspective on pooled mining, see my answer.

Pooled mining:

Low variance: you get paid every day.
Easy setup: leave most of the headaches to the pool admin(s).
Fees: It is possible to mine with low fees. But the offers you are presented with from pools can be tricky to understand. Currently mining income from transaction fees is about 1.5%. Many pools take this income from you and don't mention it. Merged mining of namecoins give you about 6% extra income at the time of writing this. Most pools don't do this. Paying 7.5% fee can actually mean earning 15% less than your potential (7.5 + 1.5 + 6 = 15). Some pools (proportional and "score" reward methods) are vulnerable to pool hoppers, which means you may end up with a smaller share of the coins than you should. Get some info on these things when choosing a pool. The frequently updated mining pools list at bitcointalk is a good resource: https://bitcointalk.org/index.php?topic=104664.0
Trust: someone else is handling your money. Don't leave large amounts of money at the pool. Check the pool's track record. This also goes for exchanges and anywhere else where you leave your coins with someone else. Read the neighborhood pool watch at http://organofcorti.blogspot.com and stay informed.

Solo mining:

High variance: you might get paid 25 BTC once a year. Or with some bad luck it might take 10 years. If you have fast hashpower maybe you get paid every month on average. And with bad luck it might take 6-12 months. If you mine for 12 months to get a block and then see it get orphaned you will probably not be a happy miner.
Complicated setup: you are your own pool admin. You will want to do merged mining otherwise you make much less than in a merged mining pool. You will find that namecoind crashes very often. You will find that publically available pool software is outdated, broken, inefficient and no longer maintained in most instances. To ensure your blocks are rarely orphaned you need good connectivity to the bitcoin peer-to-peer network, especially to the large pools. You don't want them to mine a competing block at the same height simply because they don't yet know that your block already exists.
No fees. Potentially the best earnings if you do merged mining and do the work to ensure orphan rates are low. Note that if you don't do merged mining or if you let your orphan rate slip, then this point turns into a negative: you make less than you would at a low-fee merged mining pool.
Trust: you can probably trust yourself, assuming you have the technical skills necessary.

TLDR; solo mining requires a lot of hashpower and is not for the faint of heart. Even then the benefit is questionable depending on which pool(s) you compare with.
Disclaimer: I run the BitMinter mining pool.

Thank you ! I think i got it now for the most part. I have one question though. If i join a pool will i be getting a higher payout using an ASIC then someone using a GPU in the pool or is it split out to everyone evenly ?

All pools pay more the more work you do, so fast miners get more. Compared with other miners in the pool you will get a fair share unless the pool is vulnerable to pool hopping.

Disadvantages of pooled mining:

Smaller expected earnings - pools usually charge a fee and sometimes use a reward system (like Pay Per Share) that can give you a lower payout.
Having to rely on third party system to earn your money - websites go down, and when they do, your miners can be idling.
Trust - you have to trust the pool owner not to swindle money from you, either by creating fake miners in the pool that do no work but still receive rewards or otherwise. Similarly, the pool owner can have an agenda of their own that they wish to further (for example, Eligius pool owner used their miners to attack an alt-chain, as well as putting prayers in the coinbase transactions).
Giving power to the pool owner - some important decisions regarding Bitcoin future are made by people voting with their blocks. Some time ago the Bitcoin community had to chose between two BIPs that fulfilled the same role. The voting was done by the coinbase transactions containing a vote for either one of the BIPs. By giving their computing powers to the pools, the miners essentially gave their votes to pool owners to vote as they chose.

Advantages of pooled mining:

More predictable payouts - pools usually pay you on a more regular schedule - be it once you reach a certain threshold, daily or the like. Solo mining only pays you when you find a block, which can take a few days, years, or never.
Extra features - Pools usually let you quickly check the status of your miners from anywhere, notify you of payouts and the like, which would take you a lot of extra setup time on your own.
Less space - If you are solo mining, you need to keep your own copy of the blockchain. Pools handle all that by themselves.
It is easier - There is a low less setup required to do pooled mining, especially when we are talking about merged mining and so forth.

If i dont join a pool its possible to never find a block even with an ASIC at the current difficulty ? Isnt it also possible that an entire pool of people never find a block ? So far i rather mine solo from what your saying but the never finding a coin part scares me lol.

This depends on your asic hashes/second. Use it to calculate your probability. Regarding the second question - knowing that mining pool already have big total mining power, this is highly unlikely that they will not be able to solve any block

While i agree with ThePiachu, here some additional thoughts.

Pool software

Beeing a solominer would create the need for a pool software. While very few are opensource, the majoritiy is proprietary.

Security

As a solominer youre solely responsible on your own for any serverside/softwareside security, dealing with ddos and exploit attempts. (However, i dont like to rely on others i barely know.)

Pool owner

This is already mentioned, but highly important.
Questions one should ask are:
What is the motivation of the pool owner to run the pool, how does he makes profit?
Has the pool owner been accused for scam or ben involved in other unethical behavour?
How are the coding skills, admin skills, security skills?
Is  he running his own software?
Is it a team or one man business, if a team, how does the team profit without your coins?

Payout & reward system.

Additional note: even as solominer you will be object for intrusion attempts (at least very likely), as bitcoin in its nature is transparent and will make your node appear to the public. (Diversify your bonds ;))

You don't need pool software to mine solo, you just need to run a bitcoind instance and point your rigs to it.

Pools seem a bit risky from what i am seeing. Though i do see some benefits.

If you just mine on a bitcoind instance then you won't have merged mining and you make much less coins than in a pool - then what's the point.

I must research some more it seems.


text:
What does the Bitcoin community need the most now?
The Bitcoin project has grown many-fold since its creation, but since we haven't taken over the world yet, there is still some room for growth;). Is there some consensus on what does the Bitcoin project need the most at the current moment? That is, if I had some manpower or money to spend, where would they be best applied to help it grow?
Be it contributing to the main client, developing alternative clients, miners, pools, exchanges, shops, or simply letting more and more people know about the Bitcoins, what are your thoughts on what is the best thing to do?

While I appreciate the spirit of the question, its answer is likely to be different in a month and so it is too temporally restrained for a StackExchange site.

Hmm, I guess it would work better on a forum, although then it would be harder to vote on the best answer.

Most forums (including SMF which bitcointalk.org uses) have polls available. Unfortunately this one is a) too time-constricted and b) more of a discussion-starter than an actual question to belong on a StackExchange site.

Moved the discussion here if anyone is interested: https://bitcointalk.org/index.php?topic=48299.0

PR is the most important thing for growth right now.  There's enough basic services that you can use with bitcoin, but not enough people to use them.


text:
Would the existance of other cryptocurrencies negatively effect Bitcoins?
Would the existence of other cryptocurrencies negatively effect Bitcoins? It seems that other forms of cryptocurrencies would be competition to Bitcoins. Alternately, would it be like having other currency units like real money where the English pound and US dollar do not compete?

Personally, I really doubt that every one of these coins you see now will survive. I think its possible that these separate currencies may not overlap as the truly unique ones have a different target audience. once again this is all a personal belief.

It depends a lot on the circumstances. If the use cases overlap significantly, then the currencies can compete. That could negatively affect Bitcoins. However, if the use cases don't overlap significantly, then the currencies likely won't compete. That could even positively affect Bitcoins.
Crypto-currencies aren't fighting over shares of a fixed-sized pie. Crypto-currencies are cooperating to enlarge the pie and bring their benefits to a much, much broader population.
In my opinion, near clones like Litecoin do affect Bitcoin negatively because they don't attract a new population and they do reduce the chances that Bitcoin will attain critical mass. However, I must stress that one shouldn't assume that anything that's bad for Bitcoin is bad for mankind. It's always possible a new crypto-currency will come along that's much better for humanity than Bitcoin is, and the weaker Bitcoin is at the time, possibly the better for that currency. Of course, on the flip side, the more Bitcoin has paved the way, perhaps the better for that currency.

There is the theory first described by Hal Finney that if an alt currency supplants bitcoin (in which Bitcoin's value goes down as coins are sod for transfer to another) then that is something that too can be repeated over and over, and thus crypto currencies lose their ability to be a good store of value.
So that happening harms, over the long term, not just bitcoin but all crypto currencies.
But Bitcoin is a proof-of-work (POW) based crypto currency, and thus it is susceptible to a 51% attack.   Thus it needs a sufficient level of hashing for the network to be protected.  This is what differentiates bitcoin from competing POW-based crypto coins which have a hashing capacity just a tiny fraction of Bitcoin's.
But there still could be multiple successes, since all that needs to remain protected from a 51% is sufficient hashing capacity and there might multiple POW currencies with a sufficient level.
At this moment, Litecoin may not yet have a sufficient level but it is the closest to Bitcoin to reaching that state.


text:
Why were BTC not accepted in the Humble Borderlands Bundle?
AFAIK, so far, BTC has been accepted in every Humble Bundle since they started accepting them… instead they weren't an available option with the Borderlands bundle.
Is there an official, semi-official, or educatedly speculated reason?
I asked but they didn't answer.
No "we can't read their mind" answer: if they didn't state the reason, I really don't see why anyone knowledgable enough couldn't make an educated guess.

Fraud.

Estrella (Humble Bundle) Jun 23, 15:46
Hi there,
Thanks for writing in to Humble Bundle Support!
Unfortunately, Bitcoin has been disabled for the Humble Borderlands
  Bundle. The individual payment options made available for a given
  bundle are determined when we finalize contracts with our development
  partners. In this case, it was 2K Games' wish to only support PayPal,
  and our native credit card processor, Stripe. I'm sorry for any
  disappointment this may cause.
In regards to the store, we've had to temporarily disable the Bitcoin
  payment option due to a sharp increase in fraudulent payments in that
  channel. While we do not have an ETA as to when the payment option
  will return, we are planning on bringing it back and we are working
  hard on getting things fixed as quickly as possible!
Again, I'm sorry for the inconvenience here. If you have any other
  questions or concerns, feel free to write us back!
-Estrella Humble Bundle http://support.humblebundle.com/

source

Oh, I'm surprised, I thought it was the bitcoin processor that ate the losses in case they reported a fraudulent transaction to be valid…

Given that a major design goal of Bitcoin is to be much less susceptible to fraudulent payments than credit cards, it would be interesting to know more specifically what kind of issues they are having.

@Lohoris That is surprising, but that's their officially stated reason.

Well, they accepted 0-confirmations transactions, so the issue is clearly that. But I'm really surprised they couldn't just add a few confirmations as requirement, instead of outright removing it.

The cause is not literal fraud… They received tons of orders using Bitcoin from "Unauthorized Resellers" that buy tons of keys.

Is that based on speculation or do you have a source for that?

Hi, Yep I know someone doing it.. Here's what you get on humble bundle when you order via bitcoin.. "Invalid amount. Unfortunately, the minimum allowed purchase amount for Bitcoin is $2.50 due to recent abuse."


text:
What if someone owns 51% of all bitcoins?
Would it be possible to manipulate the exchange rate of Bitcoin, if a single entity controlled the majority of all available currency?
http://en.wikipedia.org/wiki/Currency_intervention
http://www.nber.org/papers/w14600
http://ask.metafilter.com/38377/does-51-sharehold-mean-control

Well, everyone can manipulate the exchange value of a currency by trading large volumes.
Having 51% in particular does not really change that.
Besides, for lowering the price, he will have to sell a lot, probably losing his 51% position.
So basically, you can't manipulate the price just by having > 51% of the bitcoins, but by trading very large volumes. Someone with very much fiat currency can also manipulate the price by buying large volumes.
To see howmuch you will have to sell (buy) to make the price go down (up) a certain amount can be seen in the "market depth" of the exchange. For Bitstamp f.e. the market depth can be found here.
The steeper the market depth curve, the harder it is to move the price in that direction, so currently (see picture below) it is easier to make the price drop by selling bitcoins than it is to raise the price by buying.

The "51% attack" that is a known vulnerability impacting proof-of-work digital currencies like Bitcoin has to do with 51% of the mining capacity, not 51% of the currency.
There is a concept referred to as the "economic majority" but that describes how those who hold coins and buy newly mined coins are the parties who essentially have the final say on whether changes to the protocol will be accepted.
As far as a party with a lot of coins having the ability to impact the exchange rate, that is true.  This is true though whether the commodity is bitcoins, gold, pork bellies, or any other commodity.  With the ability to open a short position (borrowing bitcoins and selling them), the exchange rate can be manipulated without even owning bitcoins.  Now whether this activity is profitable or not is a completely different matter and has to do with liquidity, time frame, tolerance for risk and other factors specific to the speculator(s) attempting the manipulation.


text:
Is there a Bitcoin gadget for Windows 7?
Is there a Bitcoin gadget for Windows 7, which features conversion rate with EUR? (i.e. EUR/BTC)

A gadget meaning for translation from your own site, or a site that provides conversion, like http://preev.com

This is the one I'm using: http://www.domchi.cc/mybitcoins/

Well there is the minimalist Obi-Wan live EUR/BTC ticker app, hosted there: http://dre.tx0.org/
While not technically a Windows 7 gadget, it essentially does exactly what you are looking for and I've been using for a couple months with no issues.

The latest version of MultiBit (v0.3.3 at time of writing) has a ticker from the XChange project. While it is not currently a widget, it does offer a range of currencies from MtGox (with Intersango and others to follow later). I suppose you could resize it to fit your purpose until the "widget mode" makes it into an upcoming milestone release.

MyBitcoins gadget
You can download it here:
MyBitcoins gadget

You could embed the URL [MtGox] http://mtgoxlive.com/orders?currency=EUR (works for some other currencies too) into a Windows gadget but I know of no existing software.

Could you please link a gadget to embed urls, then?

I don't know of any. I was suggesting a possible course of action. Perhaps Windows has such a gadget included or available for download.


text:
What is the standard protocol for pools/miners?
The Bitcoin client protocol is well documented in the Bitcoin Wiki, but I can't find much on the protocol used by pools and miners. Is it described anywhere?

When there were no pools, all of the first mining clients interfaced directly with Bitcoin. They connected to Bitcoin's JSON-RPC interface and used the getwork RPC method to get the required work. Getting work from a pool is the same as getting work from Bitcoin. The client connects to the pool over HTTP, often using the same HTTP authentication that Bitcoin's JSON-RPC interface uses; the client sends a JSON-RPC getwork message; and the pool sends back a JSON-RPC getwork response.
Many pools nowadays support some extensions to the getwork protocol that Bitcoin does not.
See:
https://en.bitcoin.it/wiki/Getwork

Since this answer was written there are two new protocols; Stratum and gbt (getblocktemplate). Stratum seems the most popular, and getwork is being phased out by most clients and servers.


text:
What is the status on webminers?
Are there any ongoing projects trying to develop a widely accessible WebCL-powered mining software? I've heard of two in the past, but their websites don't seem to be working any more.

So let me summarize all the other answers:
Krad Miner used to be the first WebCL miner, but due to DDOS attacks it was not working for awhile. Later it was bought and open sourced as Tumen Miner.
BitMinter allows you to mine on their pool with OpenCL miner through Java Webstart.
www.coined.com has undefined status, WOT reports it as an abusive site.
WebCL bitcoin miner looks like a fully functional WebCL miner
Bitcoin Plus allows one to mine through a Java Applet, but it is a (highly inefficient) CPU miner.
And there are a couple other less notable web CPU miners.

bitcoin plus uses Java Applet for mining, not Javascript.

@otakun85 Edited accordingly.

While not directly a WebCL miner there is a miner which uses OpenCL via  Java Webstart so is accessible to any internet user with Java installed and apropriate hardware.
http://www.BitMinter.com
The site is both a pool and a custom java miner.
The pool can be used with other miners however the BitMinter miner works only with the BitMinter pool.

Would http://webcl.nokiaresearch.com/jsoclbm/ meet your needs?

There is a page claiming to be an OpenCL miner at coined.com but I'm not sure if it's functional or not.

Here's a current option for adding mining to your website: https://coinhive.com/


text:
How can I check whether a transaction spends the output of an RBF transaction?
A transaction can be RBF if itself is a RBF, or it spends outputs from a RBF transaction.
Is there a way to use bitcoin RPC node to check if a transaction is spending outputs from a RBF transaction?

The getrawmempool RPC command, in verbose mode, produces an output that contains all known mempool transactions for your nodes. This output contains a bip125-replaceable boolean field which you can use to determine if a tx is explicitly or implicitly replaceable by fee.

getrawmempool returns the tx ids only, not contains any tx info, I'm afraid. Reference: https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list

BTW, looks like gettransaction provides bip125-replaceable info, however it is no longer supported from 0.10.0. Unfortunately mine is newer, so it is useless too. https://chainquery.com/bitcoin-cli/gettransaction

@GiangNguyen If verbose is false, it returns only txids. If verbose is true, it returns a detailed JSON object for each transaction.

awesome! I didn't notice that. Thanks!!

Based on Raghav Sood's answer, I found the more specific answer to the OP would be using getmempoolentry, in order to get an individual transaction info. Otherwise you'll be flooded with tons of transactions. Documented here
You can also use gettransaction, it returns bip125-replaceable flag as well, however just for Bitcore prior to 0.10.0 according to this

Ah, good point, I didn't actually realize an option for a single tx was added in 0.13!

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
How long does it usually take to mine a bitcoin block?
I am quite new and wondering how long it would take with a single GTX 680? EDIT: I am using a pool.

possible duplicate of How much Bitcoin will I mine right now with hardware X?

Interestingly enough, using a pool wouldn't actually make a difference -- it would just allow you to get your rewards spread out over the 98 years instead of all at once. So, let's say you do mine an entire block that's now worth 25 bitcoins, over 98 years. That works out to be .000000485032112 bitcoins per minute, or approximately .00000485032112 bitcoins per block. In short, as @Murch points out, it's probably not worth it to mine using that hardware. Sorry. :/

For solo mining with a single GTX 680, which will produce 120 Mhashes/s, you would expect to find one block approximately every 98 years.
At the current difficulty, solo mining is inadvisable under practically all circumstances.  Pooled mining should be done instead.
Furthermore, mining utilizing graphics cards is rapidly losing viability with the release of FPGA and ASIC-based mining hardware, which operates at far greater efficiency.  Unless you have exceptionally cheap electricity or have a use for the heat output from the graphics card(s) (e.g. heating your house for winter), graphics card mining is unlikely to be profitable for you.
Additionally, mining with NVIDIA graphics cards has pretty much never been worthwhile, as they are far slower and less efficient than comparable ATI/AMD hardware, conflating the above issues with graphics card mining.

I am using a pool.

So if you make 0.000000485032112 bitcoin per minute, and let's say 1 bitcoin is $1000.  So your making $0.000485032112 per min, or $0.02910192672 per hour or ~$0.69 per day, but the power costs of running the PC don't make it worthwhile.

You will never mine your own block while in a pool. The owner of the pool owns all the blocks mined. Your best bet is to buy some ASIC (butterfly labs?) box and let it roll. You could get lucky.
Two years ago I solo'ed with a Raedon card and got luck after about 4 months.
I think with such a tiny amount of hashing power even being in a pool is not worth it.
But again, you will never mine a block while in a pool, only part of a block.

It took ages for me to mine bitcoins because of enormous competent people mining with excellent machines. You better get a Mining hardware to make your time worth since you will eventually end up paying your internet and electricity bills.

How does it make sense to recommend buying mining hardware, when the whole argument against mining was based on profitability? Assuming you have to "invest" a lot more than $1000 in hardware for this to make any real difference, when exactly do you think you will break even? Even if you would earn 0.50ct/day continuously - you'll need over 5 years (!) before you make ANY profit... better recommendation might be to take that $1000 and buy your bitcoins straight out ... it'll give you at least 2 right now - technically - they may be worth a lot more in 5 years ...

1) The time where GPU mining was financially profitable has been over for several months already. (Unless you don't pay for your electricity.)
2) Nvidia Cards are even less efficient than AMD cards for mining.
3) Solo-Mining is even more unlikely to succeed.
You might want to consider mining Litecoin or Altcoins, but even there the competition is slowly ramping up.

I am using a pool, not solo mining.

@user6663 Then why are you asking how long it will take to mine a block?

At USD 900 per BTC, has GPU mining returned to profitability?

Even if you are in solo or pool mining, for the current difficulty (2.4122720023e+11), you will need at least 12Ph/s to gather a full bitcoin block (12.5 bitcoins) in 24 hours.


text:
Bitcoin alternative designed for NVIDIA
Currently the best graphics cards to mine Bitcoins are all AMDs. What should be changed in the Bitcoin protocol to make the alternative version of Bitcoins better mined by NVIDIA graphics cards? Could there be a protocol that would support both of the graphics cards produces in more or less equal way?

The bitcoin protocol should not be changed to make NVIDIA happy.

Agreed, I was just wondering if an alternative currency could be designed to use NVIDIAs.

The specific reason that AMD cards are more efficient for Bitcoin mining is twofold and the answer to this question depends on both reasons:

AMD GPUs tend to have lower-end ALUs but make up for this by packing more ALUs onto the card overall. For most hash algorithms this is preferable.
AMD GPUs uses ALUs which can perform the 32-bit integer right rotate operation in a single instruction - Nvidia's ALUs take three processor cycles to perform the same operation. SHA256 uses this operation heavily, therefore Bitcoin mining uses this operation heavily.

Combining the two reasons above results in an overall 3x-5x faster generation of SHA256 checksums. However the two effects are not equal: Effect 1 leads to approximately 2x-3x Nvidia's performance all on its own, with Effect 2 accounting for about 1.7x performance advantage. Even if you were to choose a hashing algorithm that made less use of the BIT_ALIGN_INT instruction AMD cards would still be 2x-3x faster for hashing algorithms in general. This is because such algorithms are explicitly designed to be simple binary operations which AMD's simple ALUs can handle just as well as Nvidia's more complex ALUs.
In order to choose an algorithm which would perform better on Nvidia cards than AMD cards, you would not only have to eliminate scenarios such as #2 above where a specific instruction happens to be better implemented on one card than the other, you would also have to choose an algorithm with math complex enough that Nvidia's higher-end ALUs get the chance to individually shine. To my knowledge no such algorithm exists.
To back up my statements, here is some example data from oclHashcat's web site. The table below compares actual performance measurements from similarly priced AMD and Nvidia cards for the MD5, SHA1, MD4, NTLM and SHA256 algorithms, among others.

Keep in mind that in comparing PC1/2 and PC3/4 that the Nvidia cards actually have higher clock speeds in both cases and still perform worse. In no case did Nvidia's performance approach the performance of a similarly priced AMD card, and to my knowledge no currently implemented algorithm performs sufficiently complex mathematics to make use of the more advanced ALUs on Nvidia's cards.
In short, Nvidia cards are like a small room with several fairly intelligent people, each capable of complex mathematics while AMD's cards are like a sweatshop. Hash algorithms are the computing equivalent of mass-producing name-brand tennis shoes and so the AMD "sweatshop" card will always outperform.

And before someone asks me to add to the ridiculous analogy: A CPU is like a Nobel laureate with an un-measurable IQ sitting in an office by himself. If asked to sew a pair of tennis shoes he'll spend the next three hours at a whiteboard mathematically proving that shoes exist.

David Perry answer is solid I would just add that what will make NVidia cards more competitive isn't changing bitcoin or making an alternative but instead market forces will force NVidia to improve integer performance.
Nvidia is well aware their integer performance is abysmall and each generation AMD pulls further ahead.   In the past this wasn't very important because floating point math is used for graphics, physics, and most high performance computing work.  Still abysmal integer performance is a weak point in their lineup and as GPGPU becomes more mainstream it will matter more and more.  Over time expect GPGPU solutions for everything from speeding up SSL handshakes to whole hard drive encryption.  Unless Nvidia simply want to hand the entire crypto market to AMD on a silver platter they will be forced to improve integer performance.  How they do this isn't really material (unless you work for NVidia), market forces will require NVidia to do so or they face declining marketshare.

Nvidia and AMD are just different schools of design. Nvidia focuses on the power of each individual stream processor while AMD focuses on the quantity of processors on-die. From the standpoint of actual graphics performance, I personally prefer Nvidia cards.

I agree however NVidia will need to improve integer performance somehow. They may use complex shaders and invent instructions that can perform more complex integer work (bunldeds of existing OpenCL opcodes) or they may make their shaders slightly less complex or may improve internal integer handling. My hypothesis is that GPGPU cryptography acceleration will become more common in the future.  Everything from winzip to SSL to whole hard drive encryption to password stretching could be accelerated via GPU. NVidia risks losing marketshare without comptitive integer performance.

I agree they will probably need to address their integer performance issues in the future, the point I was trying to make is that an Nvidia card with lots of stream processors and high integer performance would be an exception to the rule - it's just not Nvidia's style, they prefer to have a few high-end processors while AMD prefers many low-end.

Agreed.  It is a deep philosphical split.  Prior to unified shaders both companies card were very similar.  When unified shaders were introduced both companies took radically different directions.  As you indicated AMD went with "more is more" model and NVidia went with "quality over quantity" model. Still AMD next gen architecture will use slightly more complex shaders (although not as complex as NVidia) to improve die efficiency.  It is possible (although I have no evidence to support it) that we will see a move to the center by both companies as GPGPU architectures develop.


text:
Will expensive mining equipement have any worth in the future?
With more and more people picking up advanced ASIC miners, the difficulty is going up while the remaining coins are going down. If miners continue joining at this or a faster rate, the limit might be reached much sooner than originally expected.
I worry about purchasing any mining equipment because I don't want to have a $2,000 investment that can not recoup its cost within say, 10 years - or at all.
So is it even worth buying newer mining equipment, or is it better to stick with whatever is around?
UPDATE: To clarify, I'm not asking about how an ASIC mining rig can be reused. I am well aware that it has a single purpose and cannot be reused. I'm asking if it is even worth spending a lot of money on such a thing.

possible duplicate of What other purposes can I use my [obsolete] hashing hardware for?

Upvoted; not a duplicate. At least of cited question.

I agree that the question is not a duplicate of the cited question, but it is similar to many of the [tag:profitability] questions that have been asked here. The answer is the same as always: Your investment in mining equipment will pay off if 1) the hardware's delivery isn't delayed too much 2) your electricity cost isn't too high 3) the bitcoin price remains favorable 4) the expected difficulty rise doesn't destroy your profitability too quickly. However, mining difficulty might be doubling every month for a few more months. Alas, who can tell the future.

possible duplicate of mining profitability understanding

TL;DR. Bitcoin profitability is about choosing between buying BTC outright (Coinbase, or Bitstamp) or buying hardware ASIC miners and paying the ongoing electrical fees.
Edit:
To keep mining expenses low, you will need the cheapest form of electricity.  This usually means coal in most regions. "Clean coal" doesn't exist.

10 years from now is a long time, and you should expect additional transaction fees by then, plus many more (different) incentives to mine.
As of late summer 2013 the ASIC market is saturated in my opinion, and the difficulty spikes will continue to reach into 2014.  That means the value of BTC must appreciate for most people on the network to get an ROI.
Either one or more of these things will happen:

People will mine coins, pay a lot for electricity, for years to come just to get a ROI
Sell the machine at a loss, invest in Bitcoin
People who buy Bitcoin will cause the price to increase, thus making mining profitable
Mining companies will go out of business (or sell a different product) and whatever ASICs are made now will be the only ones in the game for a while.

Example
Assume that the network hashrate (competition) is so high that in order to make a profit, miner #1 has to mine for 2 years and also wait for the BTC to be valued over 900 USD. (Note: BTC hit $1000 per coin on 11-27-13)  After a lot of time and expense (not to mention heat, noise, and an angry wife) he cuts even.
Now assume that in the same time period, person 2 buys BTC at the current Mt Gox rate: $140.  (Two thousand dollars worth of coins).  The price of BTC only has to increase for him to make a profit.
So the question is

Why are people buying mining machines when buying Bitcoin outright is lower risk and a better reward?

The answer is so they can ride the next mining wave... more on this in a second
The Good News
If you already purchased the miner, you should be fine if the market figures out that buying Bitcoins is "safer" than mining, and has a better chance at making a profit.
Once buying BTC becomes as popular as mining is today, then the price will increase.  If the price increases, demand for ASICs will increase as well.
Bitcoin is about riding the wave of either buying BTC outright or buying miners.  Each action perpetuates the other, so I'll bet the mining storm of 2013 will cause BTC to rise and everything will be alright in the end.

"As of late summer 2013 the ASIC market is oversold in my opinion"
You mean "overbought" here, as too many people have purchased ASICs at too high prices.

@Dust - yes, I was thinking in the shoes of the company that sells the miners.  I think it was a nefarious business plan to flood the market in the way it was done.

ASICs will depreciate very quickly unless a mining cartel decides to lock out new ASIC development. To some extent, if more efficient ASICs start costing more than any single person can afford, then existing cartels already have a leg up.
If your ASIC didn't depreciate (Merlin magically updates it for free), they still are only worth buying if you have access to very cheap electricity.
If you assume that Bitcoins will stick around and also assume there might be a period of expensive electricity between reduced oil supply (anyone's guess) and when fusion reactors come online (roll some dice), then any Bitcoins mined before that period are worth more during that period - as Bitcoins are an indirect form of the Hydrogen Economy*.
 * Unfortunately term 'Hydrogen Economy' has been clouded by the fact that such an energy currency can be put directly in a car's gas tank; and so the original futurology-driven term has been co-opted by people in the separate fossil fuel debate with a 20th century axe to grind. The Wikipedia article barely touches on the fundamentals of an energy currency.

Look at this graphic before you buy any ASIC:
http://bitcoindifficulty.com/
Currently it is very hard to make any forecast, especially for 10 years.
Hashspeed of bitcoin network now in the base of Singularity.
If you have no experience in bitcoin mining, I try to describe you this moment:
GPU mining brings from 100-200 bitcoins in 2011, in 2012 one GPU brings at least 30 bitcoins, in 2013 it is very hard to mine at least 3 bitcoin with ordinary GPU for the whole of year.
In 2014, one GPU would not mine even ONE Bitcoin!
The same picture you will meet with any current ASIC technology in 2014,2015,2016 respectively.
According to exponential function, this picture would be even worse for ASIC in the next three years, than it was for GPU in the previous three years.
Advice in this case may be such: "Keep you mining hardware up-to-date, and renew miners at least each 3-6 months". For your case, it means that you should for the whole of 10 years renew your hardware at minimum 20 tries.

My forecast(Updates):

month ~ My         ~ real
8.13 ~ 0.3 PH/s
9.13 ~ 0.7 PH/s
10.13 ~ 1.4 PH/s
11.13 ~ 2 PH/s  ~ real: 4PH/s !!!
12.13 ~ 3 PH/s
1.14 ~ 6 PH/s
2.14 ~ 12 PH/s
3.14 ~ 24 PH/s
4.14 ~ 48 PH/s

@Peter Micheal Lacey-Bordeaux, you may downvote as you wish, see, my forecast will become a reality after just a half year.

Downvote for talking about singularity nonsense.

Please, read my edit.

Haha, why didn't you just comment that?
I am not saying that your forecast is wrong, I am saying that it was needless to talk about 'the singularity' and I don't see how it is tied into what you are talking about. It's a shame because the rest of what you say is not that bad.

I'm talking about singularity, because it is exactly what happens with difficulty of bitcoin's block founding.

I also don't get the mention of "singularity". Do you mean that the curve is not well-behaved mathematically or are you talking about singularity in the artificial intelligence meaning? Neither really makes sense to me. I also find the advice strange, that one is supposed to renew the equipment every 3-6 months. Who could ever pay for that and get a ROI? Finally, your prediction has already been overtaken by reality, we passed 2PH/s last week according to TGB.

"singularity" in mathematical sense, of-course.

The ASIC chips are designed specifically for the work needed for Bitcoin mining (SHA256 midstate).  There's no commercial need for this anywhere else.  There's no secondary market for used ASIC mining hardware other than for re-use in Bitcoin mining.

I know that. that's part of the reason I would not want to buy one, in the even that the bitcoin system causes it to become useless before the hardware it's self physically wears out, there'd be nothing to do with it and the cost may or may not be offset. that's the real point of the question

Whatever mining rig you buy, it will eventually grow obsolete. This is because the algorithm behind Bitcoin is growing increasingly complex. Now, as more people buy mining rigs and mining pools grow in size, the algorithm will only begin to increase in difficult at a faster rate.
In my opinion, mining is a high-risk, high-reward investment. If you buy the right rig at the right time, and prices for Bitcoin stay up, you can make a great deal of money. If Bitcoin prices drop, however, you will lose money. That's the nature of the game.
If you are thinking about buying a Bitcoin rig, you need to plot out how many Bitcoins you can expect to mine with that rig (you'd have to use current and projected hashrates to computate that). Then you'd have to project how much money these Bitcoins would be work at current prices, and also project how much you'd earn if prices jumped by certain amounts (10% 25% 50%, etc.) or dropped by certain amounts.

Actually the complexity of the "algorithm behind Bitcoin" is not growing, what we see is that the target difficulty for blocks is growing. One important aspect is omitted completely in your answer, which is that a lot of the mining hardware manufacturers are missing their delivery promises. Buying the right rig at the right time doesn't cut it, when your delivery arrives a couple months later than anticipated which could easily push you from a profitable investment to a loss.

with the "growing" comment, no offense I think you're just getting a little overly nitpicky on terms. You know what I meant. You are right about the second point, however, and I should have mentioned that. I have also heard some miners claiming that machines are not performing as promised.

Of course I know what you meant, but other people that come here to read your answer might not – and the literal meaning of the discussed sentence is plain wrong. I downvoted your answer for that reason and as a courtesy to you, I pointed out why. That allows you to improve your answer. Bitcoin.SE is aiming to build a comprehensive collection of questions and expert answers. You might want to check out the About section to get a clearer understanding of how this site works.

You do know that one can edit his posts, right?


text:
litecoin mining very slow
I recently heard about litecoin and thought it would be a good alternative of bitcoin as it is "faster" with less requirement. however, I noticed that any attempt to mine litecoins is significantly slower than mining bitcoins.
why is the hashrate so much  lower?

Already? I would have thought BitCoin GPUs and FPGAs wouldn't migrated across to LiteCoin yet.

I don't have a FPGA, I'm using CPU. please elaborate.

Other people on the network are already using GPUs or FPGAs. I'll leave a formal answer to those more familiar with LiteCoin, but I'd guess according to this report that LiteCoin difficulty has increased faster than its developers anticipated (unless it was a speculative reboot/pump&dump instead of genuinely new cryptocurrency) - probably due to miners already familiar with BitCoin hashing moving across without the same implementation/popularity delays that BitCoin had.

oh... so I'm already too late for litecoin?

Unless you can steal electricity, yes I'd say so. You could still buy LiteCoin in the speculative sense, but I'm not how that differs from any other stock market gambling. Do want this as an answer so people can vote up or down on it?

hmm...I see litecoins haven't exploded the cost yet, I'll look into it.

Litecoin, by intentional design, uses a hashing algorithm that can't be made as efficient as Bitcoin's can. Computing a Litecoin block hash requires about 1,000 times more computations that a Bitcoin block hash.

The OP isn't using an ASIC but rather a CPU - hence LiteCoin's O(1) constant-time difference with BitCoin on a CPU. If a newer currency like LiteCoin is slower than BitCoin on a CPU then scrypt in-and-of itself isn't the reason. Either LiteCoin network difficulty spiked or the OP has config/internet latency problem.

I wonder how it is called litecoin if it is actually "heavier" to mine than a regular bitcoin.


text:
sometimes my miners aren't detected by pools?
from bitminter, and bigltc, both will often report my miners as not mining and inactive, although they are running and even generate work. the work is acknowledged by both sites but it lists the number of active workers as 0. why does this happen?

Mining pool servers and websites don't actually know your real hashrate. They try to estimate it based on how often you send in proofs of work (aka "shares"). If your hashrate is very low it won't be possible to make a good short-term estimate and it looks to the website as if you have stopped mining. That's what causes this issue.


text:
Slow but effective mining as a learning tool
Most discussion about mining is from the perspective of serious Bitcoin users who are trying to profit from it. I’m curious to try mining, only to experiment and become more familiar with cryptocurrencies. I’m not interested in being profitable over the long term, but I am interested in verifying success, namely in seeing my wallet balance nudge a tiny bit.
How can I best use my regular computer (~18Mhash/s GPU, via this) to mine Bitcoin or Litecoin? Specific questions:

If joining a pool, a centrally coordinated one or a P2P pool?
What mining pool payment system(s) would make the most sense?
I’ve got cgminer operating. Any parameters / tweaks I should use?

From what I’ve read, with a slow hash rate, it’s easy to just waste all your compute time on dead pool shares and whatnot. How can I avoid that? Is there anything else I should watch out for?

If it's for learning I recommend starting with the simplest options and then moving up to more elaborate settings.
Start with a centralized pool with PPS payments. Then you can move on to any other hopping-proof method such as PPLNS or DGM. Then you can try p2pool.
Having a low hashrate should have no affect on the relative portion of stale shares.

Thanks! I went with coinrelay.com, which has an anonymous PPS pool hosted near me. I can see why people don't mine on regular computers though; it'll be a month before I earn 1 LTC.

I created my mining pool, BitMinter, to be very easy to use but without hiding the details of bitcoin mining. It's designed to be easy for beginners to get going.
The pool has a miner that needs no installation beyond java from java.com. So you will be mining in no time. I see you have cgminer already set up - that works too. :)
The PPLNS reward system we use exposes you to the nature of bitcoin mining. You will see blocks being found and coins paid out when that happens. This way you can see how mining really works, whereas a PPS reward system hides this from you.


text:
Why does "???" replace some values in this p2pool output?
2013-07-09 00:46:43.467000 P2Pool: 17468 shares in chain (17472 verified/17472 total) Peers: 9 (3 incoming)
2013-07-09 00:46:43.467000  Local: 0H/s in last 0.0 seconds Local dead on arrival: ??? Expected time to share: ???
2013-07-09 00:46:43.468000  Shares: 0 (0 orphan, 0 dead) Stale rate: ??? Efficiency: ??? Current payout: 0.0000 BTC
2013-07-09 00:46:43.468000  Pool: 1202GH/s Stale rate: 16.9% Expected time to block: 21.2 hours

Why are a bunch of values just "???".

Can you please add some context? Where is this data from?

It says right in the tags and in the first line...p2pool

2013-07-09 00:46:43.467000  Local: 0H/s in last 0.0 seconds Local dead
  on arrival: ??? Expected time to share: ???

There is no miner attached to the pool, "0H/s" means zero hashes per second.  And since no hashing is being performed the dead on arrival and time to share cannot be calculated, and thus are unknown.

2013-07-09 00:46:43.468000  Shares: 0 (0 orphan, 0 dead) Stale rate:
  ??? Efficiency: ??? Current payout: 0.0000 BTC

Since mining is not occurring, the stale rate and the efficiency cannot be calculated, and thus are unknown.
You need to attach a miner to the p2pool to actually mine BitCoins.  Try something like GUIMiner.


text:
Is the 21 Bitcoin computer using Core or Classic?
The 21 Bitcoin computer is using Core, right? I can't find any information that says otherwise. Can someone please confirm this for me though?

I assumed so myself since the alternatives were not in a mature stage (technically and/or socially accepted) when 21 released their computer.
However, in their tutorial they do say that you will have a Bitcoin Core full node running at the end.

Ahh excellent, that was exactly the kind of link that I was looking for!

I was able to compile Bitcoin Classic from source and got it up and running with these steps: https://gist.github.com/redsquirrel/75b5192764b17c6ea265


text:
About traditional Bitcoin mining
I'm curious about traditional bitcoin mining, before pooling.  Did an older version of the bitcoin wallet found on sourceforge have a mining feature built in which worked on a simple macbook?  if so was this later removed in favor of pooling software?
From what I've read the traditional bitcoin wallet had a mining feature which could be used on a macbook, and I'm wondering if that code would still be possible to use, even if it never wins any bitcoin..

The official Bitcoin full node software always had the mining feature built in, and will probably always have. If you have the line gen=1 in your .conf file, then you will start confirming transactions when you open the wallet. Take a look at https://en.bitcoin.it/wiki/Running_Bitcoin


text:
When the last bitcoin is mined will everyone know it?
The total number of possible bitcoins is limited. This means that at some point the last bitcoin is mined and no more bitcoins will be mined after that moment.
When this happens will we notice it and how?

related: When will the last Bitcoin be mined?

Some time in around year 2100, blocks will only be worth 0.00000001 BTC or less. But a long time before this, miners will earn their bitcoins by the transaction fee. And when blocks no longer can generate bitcoins, then the miners will earn their bitcoins only from the transaction fee (versus earning 99.99% from the fee). Miners can still generate blocks, even though blocks no longer generate new bitcoins.
The bitcoin-qt client does not have any "popup window" when this happen, if that's what your asking?

We already know the complete Bitcoin reward schedule. The first block to create no new bitcoins will be at height 6,930,000. Therefore, anyway that wants to watch for the end of the mining reward can just look at the block height.


text:
What complexity class is Bitcoin's proof-of-work (hashcash) in?
To formulate this question precisely, I will define an idealized hypothetical "perfect" hash function H(n) which has nice scalability properties, and will formulate a problem PERFECT HASHCASH in terms of that, understanding that practical considerations may end up yielding only an approximation of this ideal.
To keep it simple, we will say that our hash function H(n) takes as input a single natural number n. Then we say that H(n) is a perfect hash function iff:

H(n) maps each natural number to an infinite binary sequence, of which the time complexity to compute any initial segment s is polynomial in the size of n and s, (making it a sponge function).
For any initial segment of length d, the set of all natural numbers n such that H(n) shares that initial segment has natural density = 1/(2^d).

The first thing formalizes the scalability of our function, and the second thing formalizes the idea that we want all hashes to appear roughly "equally often" as an output. Other than that, our perfect hash function is a black box, and we don't care much about exactly how it works, so long as it meets the above properties, as well as the usual desiderata applying to hash functions (easy to compute, hard to invert, hard to find collisions, etc).
Predicated on the assumption that a perfect hash function exists, we can now define the problem PERFECT HASHCASH as follows: PERFECT HASHCASH takes as input a perfect hash function H, a natural number n, and an all-zeroes vector 0^d of length d, which can be thought of as a unary representation of d. A solution to PERFECT HASHCASH consists of an n and d such that H(n) starts with 0^d.
Given those inputs, it is clear that PERFECT HASHCASH is in the complexity class TFNP, since this is a function problem and a solution is guaranteed to exist.
Can we also identify PERFECT HASHCASH as a member of any complexity class finer than TFNP?
Could it perhaps be in PPP? PPA? PPAD? Something else?
For background, see Complexity class on Wikipedia.

EDIT: the above question has been overhauled, as in the way that I originally formulated it I assumed that SHA256 is what I'm now calling a perfect hash function. Many people have noted in the comments that this may not be true, so rather than place the emphasis in this question on whether SHA256 specifically has the nice scaling properties we want, I defined an idealized hash function that we hope SHA256 at least approximates nicely enough for real-world purposes, and rephrased the question in terms of that.
As a final note to clear up any potential confusion, to make PERFECT HASHCASH resemble real Hashcash, we'd have to make one more assumption: that there exists some way to start with a block of data (an email, a Bitcoin block, etc) and somehow derive a characteristic perfect hash function from that, perhaps by "salting" a different perfect hash function in a way that the result is also another perfect hash function. So in the case of a "perfect Bitcoin," all of the miners on the bitcoin network would be working with their own unique perfect hash functions H'(n) which are somehow tied to the block they're working on, and each miner would simply try H'(0), H'(1), H'(2), ... in order until they find something starting with enough 0's. Each H' would be a different input to PERFECT HASHCASH.

+1 though not everyone on this site is a cryptographer; it may be beneficial to describe the acronyms (FNP, TFNP, etc) or to ask on crypto.stackoverflow.com

I think it is the responsibility of the asker to make his question understandable to potential experts answering the question, giving all background information shouldn't be necessary in every question, it would inflate questions too much.

Polynomial in what value? What's playing the role of input size here?

Nate: Difficulty.

The pigeonhole principle guarantees that there are an infinite number of solutions for some x. It does not guarantee an infinite number of solutions for every x - I'm not sure we can disprove that there is some x for which there is no solution.

I'm not sure it makes sense to consider difficulty (or its log) as input size. In particular because if the hash function is fixed as SHA-256, difficulty values above 2^256 are meaningless so you can't talk about asymptotics.

@pyramids: The pp guarantees there is a solution for some x. Not for every x.

Many of the questions here are particular to the real-world limitations of using SHA-256, so I overhauled the question to consider an idealized perfect hash function which scales perfectly and which we hope SHA-256 at least approximates decently in real-world situations.

@pyramids: My comments were a reply to the OP. The OP said there are infinitely many preimages, which results from the fact that the input string to SHA-256 can be arbitrarily long (it's not confined to any particular input size). This is true and I only contested the "for all x" part. The OP then said that the input size is difficulty, which I said makes no sense. I see no errors in my statement, so I expect an apology for your disrespectful comment and failure to follow the conversation.

@pyramids: I suggest you read https://en.wikipedia.org/wiki/Pigeonhole_principle. The PP definitely applies for sets of different size and infinite sets. In a bijection from an infinite set to a finite set, there must be an element in the output range with infinitely many preimages.
This argument is pointless - you're not engaging in the technical discussion, you ignore your own faults and you blame me for things I didn't do. "I see no errors" doesn't mean "there must be none", it means the onus on finding errors is on you if you wish to speak disrespectfully as you did.

@pyramids: Ok. PPP is an interesting read which I was not previously familiar with, but it's an esoteric concept. What I linked to is what is commonly known as the pigeonhole principle. PPP is so called because of its use of the PP. Note that a solution to PC is "either a preimage of 0, or two preimages of an output". The PP guarantees a solution to this because if there is no preimage of 0, the effective output range is reduced by 1 element - hence there are more input values than output values, the PP applies and there are two preimages to some output.

(PS - Where I said above "bijection" it should have been instead just "function")

@pyramids: We can agree that there were misunderstandings.


text:
Will there be 21 million bitcoins eventually?
Every x blocks the mining reward is halved. Will the reward be halved forever such that we never quite reach 21 million bitcoins, or will we reach 21 million bitcoins at some point and will the reward cease to exist altogether?
Extra points for pointing to the relevant code!

possible duplicate of How many bitcoins will there eventually be?. Related: What will happen to mining after the 20 999 999th Bitcoin?

People say the total will be 21000000 BTC.
... however:

The 1st 210000 blocks each allow creating 50 BTC.

The 2nd 210000 blocks each allow creating 25 BTC.

The 3rd 210000 blocks each allow creating 12.5 BTC.

...

The 10th 210000 blocks each allow creating 0.09765625 BTC.

The 11th 210000 blocks each allow creating 0.04882812 BTC, and not 0.048828125 BTC, because only 8 decimals of precision are supported.

...

The 33rd 210000 blocks each allow creating 0.00000001 BTC.

After that, the reward is 0.
If you sum all these numbers together, you get 20999999.9769 BTC.
... however, either due to an oversight or intentionally, the coins created in the genesis block cannot be spent.
This leaves us with 20999949.9769 BTC.
... however, due to an early problem in Bitcoin, fixed by BIP30, it was possible to create a coinbase transaction identical to a previous coinbase. This caused the coins created by that older coinbase to be irreversibly "overwritten". This happened in block 91842 (overwriting the coinbase of block 91812) and 91880 (overwriting the coinbase of block 91722). Each time, 50 BTC was lost.
This leaves us with 20999849.9769 BTC.
... however, the protocol rules allow creating up to the amounts listed above. Due to various bugs and miners experimenting with code, some blocks claim less than allowed. Those coins can never be recovered.

Block 124724 tried to intentionally claim 0.00000001 BTC less than allowed, but accidentally also failed to claim the fees, losing 0.01000001 BTC.
Between block 162705 and block 169899, 193 blocks claimed less than allowed due to a bug, resulting in a total loss of 9.66184623 BTC.
Between block 180324 and block 249185, another 836 blocks claimed less than allowed, resulting in a total loss of 0.52584193 BTC.
Block 501726 had no transaction outputs (except a 0-value commitment), losing the entire 12.5 BTC subsidy.
Block 526591 didn't claim half of the block reward, losing 6.25 BTC.

This leaves us with 20999821.02921183 BTC.
... however, since recently there is a concept of provably unspendable coins. Coins can be sent to an "address" which provably burns them (using OP_RETURN). Bitcoin Core tracks these and removes them from its database, so they are easily accounted for. At least 3.71612692 BTC were burned this way.
This leaves us with 20999817.31308491 BTC (taking everything up to block 528333 into account)
... However, various wallets have been lost or stolen, transactions have been sent to the wrong address, people forgot they owned bitcoin. The totals of this may well be millions. People have tried to tally known losses up here.
https://bitcoin-supply.com/ tracks provably lost bitcoin through publicly available logic.
As of 15 March 2022 they tracked 2,823.43062071 BTC lost
This leaves us with: ??? BTC.

What were the bugs that caused the 9.66184623 and 0.52584193 bitcoins to be lost?

Those were bugs in the (customized) software that the miners were running, so you'd have to ask the miners themselves.

I thought that OP_RETURN gave the money back to the miners.

Arturo: no. You can just create a transaction with a higher fee though, if you want to give money to miners.

Arturo: to clarify, typically an OP_RETURN output would have value 0, so it won't burn anything. It still increases the transaction size, so it increases the necessary fee for relay and mining.

The thread Pieter linked tallies up more than 130.000 bitcoins or about 0.6% of all lost. I wouldn't be surprised if it were a lot more than 1%.

@Murch I wouldn't be surprised if it's more than 10%.

Time to add Block 501726 bugged to not claim the 12.5 BTC block reward - https://bitcoin.stackexchange.com/questions/67009/can-someone-explain-this-weird-mining-activity/67012#67012

@AshishNitinPatil Done!

This related Reddit thread claims that 2700 BTC have been burned: https://www.reddit.com/r/Bitcoin/comments/7n3kzg/as_of_today_nearly_2700_bitcoin_have_been/

"This leaves us with: ??? BTC." Wouldn't be more precise to say "This leaves us with: <20999817.31308491 BTC."?

block explorer shows block 501726 as having fee reward of 184467440724.59550000 BTC but having no transactions. How can this be?

@PrinceM That sounds like a bug in whatever software/explorer you're using to look at that block. It's a block with 1 transaction (the coinbase), and that coinbase accidentally(?) claims 0.00000000 BTC subsidy. This explorer shows it correctly: https://blockstream.info/block/0000000000000000004b27f9ee7ba33d6f048f684aaeb0eea4befd80f1701126?expand

Thanks Pieter. I was looking here https://www.blockchain.com/btc/block/501726 . Likely a bug. Would like to get my own node running so I can see these things more concretely!

The general advice you will receive on this site: ignore blockchain.com/blockchain.info at all costs.

dunno if what these claim to have done makes it to this list

@Mercedes Yeah, that'd result in a tiny amount of additional unspendable outputs. I'll incorporate those if I update this answer again.

Neither. The reward eventually ceases, but not at 21 million Bitcoins.
Here's the code (edited for clarity and brevity):
int halvings = nHeight / 210000;
CAmount nSubsidy = 50 * COIN; // COIN is one Bitcoin
// Subsidy is cut in half every 210,000 blocks which will occur approximately every 4 years.
return nSubsidy >> halvings;

(Source.)
Note that it cuts the reward in half using the bit-shift operator, which means that eventually it won't be able to reduce the block reward by exactly half. So how many Bitcoins does it end up making in total?
20,999,999.9769 BTC, or 2,310,000 satoshis short of 21 million. (If you want to be a lot of fun at parties, bring this up whenever someone says that the maximum number of Bitcoins is 21 million.)
Then there are the various Bitcoins that aren't spendable due to various quirks of the Bitcoin protocol, like the genesis block coinbase, or the duplicated coinbase. [Edit: Or the many other instances of unspendable Bitcoins that Pieter mentions in his answer.]

Upvoting, as my own answer does not actually link to the code!

Note that the right-shift operator's behavior isn't defined for shifts of 64 or more bits. So block 13,440,000 will set 'halvings' to 64, and most compilers currently treat ">> 64" the same as ">> 0", so the reward goes back to 50 BTC per block after 64 halvings (in around 2272). Except that this bug was already fixed, hard-coding the reward to be 0 after 63 halvings.

Yes, it was replaced by this in 2014. Here's the pull request.

20997107.88801356 once you remove the 2709.42507135 BTC “burn addresses” i.e. the bitcoin addresses with almost assuredly no earthly known private keys and therefore unspent lost forever. There are ~400 burn addresses with a total balance of 2759.42507135 as of Dec 2017 (2709.42507135 excluding the genesis block). Last year the burn addresses balance grew by 8.97 BTC


text:
what should I do when CDF is really high?
I noticed today on Bitminter that the CDF is over 99% and the block session has been running for almost 12 hours now. what causes such a high CDF and is there anything that can be done about it?

CDF is a measure of the pool's (bad) luck in the near past. By the nature of randomness (and how it applies to the process of mining), every pool will have times of good and bad luck, and nothing can be done to fix that.
If you are mining at a pool using a hopping-proof method such as PPLNS or DGM, you don't need to do anything when the CDF is high. The CDF represents the pool's luck in the past, but your reward for continued mining depends only on the pool's luck in the future, and thus the CDF has no effect.

CDF will sometimes go high, indicating bad luck. Bad luck happens with all pools and miners, and there is really no cure for it, just like there is no cure for lottery tickets that aren't winners. Each hash is like a lottery ticket with a tiny chance of winning a block. If you have bad luck it will take a lot of lottery tickets before you find a winning one.
With more hashpower the bad luck rounds will pass faster. But there will always be rounds with high CDF that take a lot of hashes before the block is found.

Having a CDF of 99% just means that you've only had 1% to exceed such a long session. There is nothing exceptional about it - in particular, 1 in 100 sessions will inevitably take that long.

The should actually display the CCDF which is 1 - CDF because this is actually the semantics that one would be interested. c.f.: https://en.wikipedia.org/wiki/Cumulative_distribution_function#Complementary_cumulative_distribution_function_(tail_distribution)


text:
How do I communicate with the BTC network?
Some background: I'm looking into making my own miner. Even though there's some documentation out there, I find it hard to do without looking into loads of existing code, and while I do that, I prefer to look into some actual reference to learn from.
And here's my question: using the following JSON for GBT (the JSON copied from here), I'm trying to send it to some P2Pool IP and port, using my wallet ID as a user and a random password, as instructed. Here's the curl I'm using:

curl -u [ID:gibbrish] -d '{"id": 0, "method": "getblocktemplate", "params": [{"capabilities": ["coinbasetxn", "workid", "coinbase/append"]}]}' http://[P2Pool Node IP:Port]

However, that yields:

{"error": {"message": "Parse error", "code": -32700, "data": null}, "jsonrpc": "2.0", "id": null, "result": null}

What am I doing wrong?
Thanks ahead!

This sounds similar to this one: I want to create a plane. Completely from scratch, without studying anything, without looking how other planes are built.

So, what is the question? First you seem to be asking how one would create mining software then it looks like you need help with JSON. Please clarify what exactly your question is and make it specific enough that one can answer it without writing an essay. Check out [ask] for additional hints.

@salvador I think you're overreacting much. I've been reading the code, I've been reading the wikis, I've been googling forums, and for all I know, I've done it "right". I guess it's not phrased the best way. What I am looking for is where to start. When I want to build a new plane, I don't want to look at the production like of Boeing, first I'd like to figure out, you know, elevation forces by myself. Otherwise I have no context to those plans. That's my question: how to start? And why is my basic start not working?

@Murch I've edited my question, please tell me if it's clearer now.

I think I figured it out. "curl" doesn't add the "Content-Type" header, which seems important to the pool when parsing the JSON body. Adding that header fixed it.
So, a working curl command would be:

curl -H "Content-Type: application/json" -u [Wallet ID:gibbrish] -d '{"id": 0, "method": "getblocktemplate", "params": [{"capabilities": ["coinbasetxn", "workid", "coinbase/append"]}]}' http://[Pool IP:Port]