87

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 ...


48

I know this question is old, but I stumbled upon it looking how to teach myself how multisig addresses work, and I imagine others will to. So I’m going to try to explain the typical flow for creating, adding bitcoins to, and eventually spending a multisig address. This explanation is aimed at beginners, so please excuse my lack of brevity. First off, some ...


41

I'll try answering this again in a different way, using small numbers to keep it readable. convert the private key to binary representation, so decimal number 105, which is 0x69 in hex, becomes 01101001. calculate this list of points, by repeatedly doubling the Generator point G: 1*G 2*G = G+G 4*G = 2*G + 2*G 8*G = 4*G + 4*G 16*G = 8*G + 8*G 32*G = 16*G + ...


29

The Bitcoin P2P network The Bitcoin P2P network is a randomly-wired gossip network. This means that all nodes make arbitrary connections to other peers (using various ways to discover new addresses) using a custom TCP protocol, usually using port 8333. Typical nodes create 8 outgoing connections, and if publicly reachable, accept up to a few 100 incoming ...


26

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


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

I don't think it is possible. There are a few problems to incentivizing the operation of nodes. When you pay people to run nodes, people running multiple nodes provide less value but earn more for the same effort. In the worst case, you may be paying botnets to run nodes on other people's hardware. It's hard to prove that you're actually validating, because ...


18

While the other answers are slightly true, there's another reason. Addresses which have been spent are inherently less secure than unspent addresses. This is because, when spending on an address, you reveal the public key to the address. This means that in order to steal those funds, you only need to find the private key, whereas normally you'd need to break ...


18

The target section of the block header is called nBits in the code. nBits is a 32-bit compact encoding of a 256-bit target threshold. It works like scientific notation, except that it uses base-256 instead of base-10. For example, if nBits is equal to 0x181b8330, you would calculate it like this: Or, more simply, you'd use the same shorthand you use with ...


17

I am just guessing here given the little I know about bitcoin and distributed databases. This comes down to the how CAP theorem applies to the bitcoin blockchain DB. CAP theorem states that it is impossible for a distributed computer system to simultaneously provide all three of the following guarantees: Consistency (all nodes see the same data at the same ...


16

When developing Bitcoin, Satoshi had already come with the idea that no more than 21 million of them will ever be made. However, there was an unsolved issue: how to accomodate all bitcoins in case it was actually used as a worldwide currency? Comparing to the current (2008?) world's M1 supply, it was determined that 8 decimal places was enough to cover the ...


15

At the protocol level, there is no such thing as "balance of an address". There are individual unspent outputs (like coins in a wallet), which must be individually spent. You can't partially spend an output, but you can split/combine it. So for example, you have a 70 BTC output assigned to an address, and a 80 BTC output assigned to the same address. Some ...


15

Someone wrote a Bitcoin protocol decoder for Wireshark, several years ago. I assume it was included in the Wireshark distribution. Wireshark simply knows about the Bitcoin protocol. There is no magic involved.


12

The basic elliptic curve operation is addition of points. The operation of applying this addition repeatedly is called the scalar multiplication of a point by an integer. The private key is the 'scalar', the point being multiplied is the 'Generator' point, the result is the public key. Scalar multiplication is basically repeated addition. Multiplying the ...


12

If you want to write OP_RETURNs to the blockchain without getting into the internals of how transactions are built, an easy way is to use our libraries for PHP and Python: https://github.com/coinspark/php-OP_RETURN https://github.com/coinspark/python-OP_RETURN These support either sending individual transactions with one OP_RETURN attached, or else ...


11

There is no requirement that blocks have a timestamp after the previous block. The only requirement is that the timestamp is greater than the median timestamp of the last 11 blocks. So this means that a block can have a lower timestamp than its parent, within a certain bound. This happens because miners do not have perfectly in sync clocks. There can be ...


11

I had the same question as well and spent forever trying to understand it and finally cracked it. "The sender (A) only has the Bitcoin Address of the recipient (B), so how does he get the pubKeyHash from his Bitcoin Address?" The key is that sender (A) doesn't need to get the pubKeyHash from "his" Bitcoin Address because it's not relevant. (I also wondered ...


11

Here's a good interview by Gregory Maxwell himself who's a Bitcoin developer: Oh there is a “problem” in the Bitcoin protocol, known since at least 2011 (see the link I gave). But for normal applications, not involving unconfirmed transactions, it shouldn’t cause any severe problems because wallets can handle it locally. This has to do with ...


10

What malleability means is that you can't store the transaction ID that bitcoind returns from its sendtoaddress API call and expect that number to mean anything at all later. Instead, if you want to keep track of a high volume of outgoing transactions, you have to wait for the transactions to be fully confirmed and immune to blockchain reorganizations, and ...


9

David has already given a good explanation of the term coinbase, but I'd like to give further details on the coinbase transaction. The coinbase transaction is a special type of transaction. Every block must have a coinbase transaction, other transactions are optional. The coinbase transaction must be the first transaction of the block (it follows that ...


9

Bitcoin has its own custom wire protocol using TCP. Peer discovery is by address rumoring, where connected nodes gossip about other potential available peers. When a node is new and has nobody to gossip with, they make a DNS lookup of specific hostnames which provide a number of known-good peers to make an outgoing connection to. If DNS seeds fail and none ...


9

Technically, yes it's possible to do this. Practically, doing this would probably break everyone's trust in Bitcoin. One of Bitcoin's principle guarantees is that nobody can confiscate anyone else's bitcoins through the Bitcoin protocol. This protects all of us, but it also means that we're each responsible for keeping our private keys secure. If we fail ...


9

As with many things in Bitcoin, it is likely simply because it worked well enough, and such an attack was not immediately obvious. Several of the choices made in the early days of Bitcoin don't have a full justification behind them, and were simply made because it worked at the time without any major, obvious shortcomings. This is one such scenario, as far ...


9

Almost all CPUs these days work natively in little-endian. To operate on big-endian numbers, additional byteswap instructions are needed. For most things, I think this effect is negligible. Network protocols need a convention to represent things, and Bitcoin's creator picked one. The actual choice barely matters.


8

The idea of the change addresses is an attempt to make transactions anonymous. Unfortunately, bitcoin transactions are not anonymous, even with the use of change addresses: http://anonymity-in-bitcoin.blogspot.com/2011/07/bitcoin-is-not-anonymous.html http://motherboard.vice.com/blog/if-youre-not-careful-bitcoins-arent-as-anonymous-as-you-think When you ...


8

Each entity's weight in the economic majority is closely related to its ability to devalue the coins in the protocol version they are against. People (and their proxies) who are willing to offer goods or services (including traditional currencies) for Bitcoin can refuse to accept coins of the "wrong" protocol, while people who hold bitcoins can sell coins ...


8

In my opinion, it is one of the greatest misconceptions about Bitcoin that miners solve a "hard problem". Many news sources explain it like that, but in fact it's not true. All a miner does is guessing until he got something right. A miners takes his block of transactions (including the coinbase transaction that sends the fees and block reward to himself) ...


8

allowed by the protocol? Yes. It is possible to spend an output immediately. And two (three-four-etc) chaining transactions will be included in the same block. There are a lot of examples in blockchain. Note, that the their order in block is fixed. do any of the common clients allow spending unconfirmed Bitcoins Bitcoin-core client allows to send "raw ...


8

Transaction inputs use Unspent Transaction Outputs (UTXO). UTXO are created by transactions. They are uniquely identified by the transaction id and the output position in the transaction that created them. Once UTXO are used as inputs in another transaction, and that transaction is included in a block, nodes that parse the block will mark them as spent. So ...


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