107

How Bitcoin Mining Works Bitcoin transactions are mined (processed) by Miners, and Miners want to benefit from their work. By mining transactions with higher fees, they make more money. Some miners can decide to mine all transactions no matter the fee but they still must compete with every other financially motivated miner. Why is it taking so long for my ...


88

In this answer, I will go through the steps necessary to redeem the second output of the transaction listed above. The answer will be limited to redeeming an output of the particular type present in this transaction (an output which requires providing a new transaction signed with a private key whose corresponding public key hashes to the hash in the script ...


73

Note: I went out and learned about how the OP_RETURN opcode works at the byte level in a bitcoin transaction. I’m writing it here so that others can learn quickly. First, a brief history of why we’re even talking about OP_RETURN. Back in 2013 different players in the bitcoin ecosystem were trying to include bits of information into transactions so that they ...


57

The idea (as I understand it) is that the Merkle tree allows for you to verify transactions as needed and not include the body of every transaction in the block header, while still providing a way to verify the entire blockchain (and therefore proof of work) on every transaction. To understand this, first understand the concept of a tree. Consider an 8 ...


45

A multi-signature address is an address that is associated with more than one ECDSA private key. The simplest type is an m-of-n address - it is associated with n private keys, and sending bitcoins from this address requires signatures from at least m keys. A multi-signature transaction is one that sends funds from a multi-signature address. The primary use ...


41

First of all two matching scripts are used in two different transactions, one that transfers funds to an address (Transaction A) and one that spends those funds (Transaction B). The scriptPubKey is created by the user that creates Transaction A. It basically adds a claiming condition to the output that is being created. A user may only claim and thus spend ...


40

Step-by-step description: We start creating a new transaction which we hash and sign. Add four-byte version field: 01000000 One-byte varint specifying the number of inputs: 01 32-byte hash of the transaction from which we want to redeem an output (reverse order): be66e10da854e7aea9338c1f91cd489768d1d6d7189f586d7a3613f2a24d5396 Four-byte field denoting the ...


39

The Finney attack is named after Hal Finney, who suggested it in this comment. (Hal happens to be the first recipient of a Bitcoin transaction, and the first person to comment on the release of the Bitcoin source code.) It is a double spending attack with the following features: It only works if the merchant accepts unconfirmed transactions. It still works,...


37

The input of every transaction refers to an output of a prior transaction. An input can't be defined by only the transaction hash. A transaction consists of 1 or more outputs if you only specify the transaction hash there is no way to know which output is being spent.** Since these types of questions often come from a larger misunderstanding of how the ...


35

I've been playing with Gavin's "bitcointools" (again) to track what happened to the famous "pizza" Bitcoins. It turns out that rather than being rare collector's items, the 10,000 BTC exchanged for two pizzas have spread out to over a million different Bitcoin addresses since buying the pizzas, not counting the dilute fragments that ended up in transaction ...


35

Taking the sha256 hash of that hash gives 3b a3 ed fd 7a 7b .............. But the real transaction hash according to blockexplorer.com is .............. 7b 7a fd ed a3 3b The answer I was getting was correct, but bytewise reversed. I need to get used to Bitcoin using little-endian storage.


35

147krm8yWUcVq9Ta25h679TCpsEznzgvRz is the change from the transaction. There was more than one output because you didn't have any previous transactions (sometimes thought of as "coins") that added up the exact amount of the transaction. So your client picked some coins that added up to at least that amount and then created a new address to receive the ...


31

The definition of dust is client-specific and not a network rule. Bitcoin Core considers a transaction output to be dust, when its value is lower than the cost of spending it at the dustRelayFee rate. The default value for dustRelayFee is 3,000 satoshi per kilobyte, which results in the same dust values as the dust definition used before Bitcoin Core 0.15.0. ...


30

Yes, there is a way to save a borked transmission. A restart of the wallet and some patience typically fixes the issue. How to stop/reverse a Bitcoin transaction without confirmations: Run bitcoind and with -zapwallettxes. This makes the wallet "forget" any unconfirmed transactions, thus enabling you to reuse their inputs. Create a new transaction to make ...


30

The fee goes to the miner who mines the block that includes your transaction. The fee is based on the size (in bytes) of the transaction and the age of its inputs (how long ago the coins spent were received). Transactions get big if they have to "pull in" a lot of outputs from previous transactions and that raises the fee. So if you got a lot of small ...


29

I calculated the answer by starting with Gavin's "bitcointools" and modifying it to track account balances. Here's what I found. Each line shows the number of addresses after the specified block was found, at the end of each month. So the 1st line is saying that after block 2543 was found at the end of Jan 2009, there were 2,439 funded addresses, and all ...


29

Most clients on the network have a transaction pool in their memory. The same basically applies to miners: they just dump the top 500KB (or some other value) transactions into a block, sorted by transaction fee (descending, of course). When there aren't many transactions, maybe because of a series of block in a short amount of time, it will be confirmed ...


28

I'm not sure there is an exact definition of dust. The Armory client wiki says: Sending less than 0.01 BTC to any recipient — The network considers these small outputs to be “dust,” and discourages them by requiring a fee. If it was not discouraged, someone could take 1.0 BTC, and create 1,000,000 transactions of 0.000001 BTC each, for free, which would ...


26

I couldn't find the results of the Coin Selection written out anywhere, and just finished piecing it together from the code. It works as David mentioned, but here are more details. The Coin Selection Algorithm logic to transfer Target amount If any of your UTXO² matches the Target¹ it will be used. If the "sum of all your UTXO smaller than the Target" ...


24

It is highly unlikely, you made a typo and were still able to send coins. There is a difference between an invalid address and an incorrect address. All bitcoin wallets/clients check if addresses are valid. Bitcoin addresses are the PubKeyHash encoded in Base58 with a version value and a checksum. The checksum is the leftmost 32 bits of a double hash of ...


24

"Figure 7-2. Calculating the nodes in a merkle tree" from Mastering Bitcoin shows the Merkle Root (HABCD) of a list of four transactions: Tx A, Tx B, Tx C, and Tx D: To verify that a transaction—for example, that with hash HK—is a valid transaction (i.e., part of a list of, in this example, 16 transactions with hashes HA, HB, … HP), one need only perform ...


24

You were probably trying to pay on the blockchain itself. That's like trying to pay for lunch by moving dollars through the Federal Reserve. You should use some system designed to move small quantities of bitcoins cheaply such as Coinbase. We don't yet have good decentralized payment systems for bitcoin, so currently bitcoin is primarily being used as a ...


23

In the case that your fee is too low: Now that child-pays-for-parent has been merged, you(or any of the recipients of your unconfirmed transaction) could spend the Bitcoin received and the fee associated with that second transaction will help prioritize the confirmation of the original transaction. This does require more fine grained control of which ...


23

Enable txindex=1 in your bitcoin.conf (You'll need to rebuild the database as the transaction index is normally not maintained, start using -reindex to do so), and use the getrawtransaction call to request information about any transaction (it won't work for the genesis block's coinbase transaction though, it's a special case). Note that this will only give ...


23

You can send any number of bitcoins to anyone, even 1 satoshi (see exceptions below), which is 0.00000001 BTC (about 0.00001031 USD) However for such small amounts you may not want to include a transaction fee. There is no minimum transaction fee. However if you send a transaction without any fee you can expect a significant delay in it getting into the ...


22

Spending money from a paper wallet is the hardest part. Making the wallets themselves is easy but spending the coins is harder than it should be. Here's a guide on how to do it safely: Create a NEW wallet on blockchain.info. Keep in mind that you will only use this wallet for the express purpose of emptying your paper wallet. You will not reuse the paper ...


21

A double spend is an attack where the given set of coins is spent in more than one transaction. There are a couple main ways to perform a double spend: Send two conflicting transactions in rapid succession into the Bitcoin network. This is called a race attack. Pre-mine one transaction into a block and spend the same coins before releasing the block to ...


20

If you want, you can pay $100 for the standard, ANSI X9.62. Or, you can cheat and look at RFC3278, section 8.2. It is in DER format consisting of a SEQUENCE of two INTEGERs. The first INTEGER is r, the second s. If you look at this transaction you can see that one of the signatures is: 3045 0220 ...


20

Bitcoin transactions have a transaction id (txid) formed as a hash over the data involved in the transaction. That suggests that it is a unique identifier for a transaction. However, the tx-id of a transaction is only unique once the exact data in the transaction has been finalized by being incorporated into the blockchain (and confirmed). Until then, there ...


19

The maximum transaction size is the size of the block. Source. // Size limits (this doesn't take the witness into account, as that hasn't been checked for malleability) if (::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * WITNESS_SCALE_FACTOR > MAX_BLOCK_WEIGHT) return state.DoS(100, false, REJECT_INVALID, "...


Only top voted, non community-wiki answers of a minimum length are eligible