SegWit versus Bitcoin Unlimited

In the operation of Bitcoin, there is a crisis brewing. Bitcoin mining pools are restricted by a feedback-control loop which they defined, in the days of the inception of Bitcoin, only to be able to “mine” 1 Block every 10 minutes, which is inserted into the block-chain when that has been achieved, and which acts as a slate, onto which all Bitcoin transactions must be recorded. A block currently occupies 1MB of data, and the size of individual transactions to be recorded in it, can vary greatly, but averages 500 Bytes for the simplest types of transactions.

What this means, is that 1 Block can typically hold 2000 transactions, but will only be mined every 600 seconds, on the average, so that a global rate of available transactions of 3 /second would seem to follow. Because the world that uses Bitcoin is presently trying to conduct transactions at a faster pace – because in some parts of the world, Bitcoin is a currency – there have sometimes been escalations in the transaction fees, which are charged according to how many KB of one block the transaction consumes. Recently, the transaction fees were around 2 milliBits/kB, or 0.002 BTC/kB. That counts as extremely expensive, since 1 BTC is approximately worth CAD 2000 right now, meaning that the transaction fee could be around CAD 1.- . Many items and services people might want to buy, would not cost much more than the CAD 1.- of my country’s real currency.

Bitcoin operators recognize that a problem exists, and there exist two camps who are in conflict right now, over what to do about it:

  1. Bitcoin Unlimited
  2. Bitcoin Core

Out of these two groups, Bitcoin Core represents the status quo.

What Bitcoin Unlimited is proposing, sounds straightforward: Increase the block-size, and allow for it to be increased again, as the demand for transactions increases in the future. But there are some problems with what Bitcoin Unlimited is proposing. Changing the format of the blocks, and/or the protocol, would essentially create two types of currencies:

  • The legacy currency, which might be referred to as BTC -units, and
  • A new form of Bitcoins, which might be referred to as XBT -units.

If one mining pool was unilaterally to adopt a new Bitcoin block-format, this would be called a ‘Hard Fork’. In the event of a hard fork, people who held Bitcoin-amounts on the legacy block-chain, would see that that legacy block-chain has been imported into both newly-forming block-chains. Wallet-holders would therefore see, that they have a double-dipping; they’d have their present amounts both as BTC and as XBT. But, if they were to mix their Bitcoins into a new block, using a type of transaction that has more than one input, those Bitcoin-amounts would become invalid on the other, newly-differing chain.

There would be a bigger problem in the event of a hard fork, which is known as the risk of a Replay Attack. Because the legacy chain was not designed with the possibility of two future continuations in mind, after a hard fork, if a wallet-holder was to pay for a service in, say, XBT, then the payee – or somebody else – would be able to use the credentials the wallet-holder used in his own transactions, which worked for XBT, and could replay those transactions – actually signing the same inputs as before surreptitiously – but this time, pay out the amounts to another public address, as a BTC -amount. So the payer would see both his XBT and his BTC coins disappear, while only having authorized one of the two transactions himself, out of the legacy-chain.

As an alternative to a hard fork, Bitcoin Core is proposing a short-term solution named “SegWit”. This is a proposed solution, that will cause fewer bytes of data to be written to the block, per transaction, and which it is hoped, will allow the increased number of transactions to be served, that the world is asking for right this instant.

This is a video, which describes in storybook-form, what SegWit proposes. Essentially, a Bitcoin transaction possesses a list of inputs, and a list of outputs. No public address really owns the transaction, but the transaction proposes to use unspent outputs, made to the person who holds the private key, for the public key the outputs were made to – that constitute his Bitcoin balance – as an input or as inputs, and to state somebody else’s public address as the recipient of the outputs.

What Bitcoin experts know, is that the inputs-list of a transaction takes up much more space, on average, than the outputs list does. The reason for this, is the fact that in order to specify an input, Bitcoin is so restrictive, that one specific output must be identified, and not just one public address, to which the output was received. This means, that the complete Transaction ID must be stated in the inputs-list, as well as the sequence-number, the position of the output received, in the outputs-list, of the specified transaction, so that the current wallet-holder can use it as an input. This is expensive in the number of bytes used, because in addition to that, the public key of the recipient must be embedded in the inputs-list, as well as the signature with which the holder of the public address authorized the received output be unlocked.

  1. Transaction ID : 32 + 4 Bytes
  2. Sequence Number : 4 Bytes
  3. Public Key : 33 or 65 Bytes
  4. Signature : ~72 Bytes
  5. Additional Bytes used for script-instructions: (?)

But there is an added twist to how Bitcoin works. We might expect that this information is simply entered by software, into fields that belong to a transaction with a specific syntax. But as it stands, only the fields (1) and (2) above exist statically in a transaction. The rest is embedded as literal constants, in a very scaled-down forth-like language called “Script“.

The way script works in general, is that the piece of script in the inputs-list of the recipient, is executed before the piece of script in the outputs-list of the sender. The script of the output defines the conditions that need to be met, in order for the recipient – in another transaction than the transaction that states this script as an output – to be able to claim the amount. In order to satisfy those conditions, the script of the recipient – in his inputs-list – leaves a number of objects on a stack, which the script in the outputs-list of the sender can use as input.

According to the way Bitcoin has traditionally worked then, was that the input defined by the recipient, would place his public-key, and his signature onto the stack, in expectation that this is what the output of the sender requires. The input does this in the form of an embedded public key, and an embedded signature, in its actual script, which were placed there by software running normally on computers, and not running through script.

But the output script of the sender would then expect these data to be on the stack in a predefined order, and would verify that two conditions were met:

  1. When hashed, the public-key must equal the public address of the intended recipient (Those are not really the same thing), ( :1 )
  2. The signature must be decrypted by the same public key, to equal a hash of the transaction being claimed as input.

In order for the outputs-script to verify this, it must also receive the Transaction ID of the transaction it belongs to on the stack, but this is not the responsibility of the inputs-script of the recipient to place there.

What SegWit proposes, is that the inputs-script should neither need to state the public key of the recipient anymore, nor his actual signature, thus making the transaction shorter. Thereby, something needs to signal, that this public key should be taken ‘from the side’, from the “Extended Block”, but fed to an established output script.

While this is all very fascinating, it reveals two very serious problems of its own:

Continue reading SegWit versus Bitcoin Unlimited

Bitcoin: Replace-By-Fee

My friends may have noticed a peculiar pattern in my emails, that have been exploring Bitcoin. I have partially been asking questions, and tentatively finding wrong answers to them, until such a time as I have found the correct answers.

The most recent question had to do, with why, after I had sent some Bitcoin-amount from my Bitcoin Core wallet, to my Electrum wallet, that amount appeared as 'Pending' within 10 minutes, but took up to an hour to be Confirmed. It was specifically the speed with which it appeared as Pending, not how slowly the transaction was confirmed, which struck me as a mystery, given that the way the network is supposed to function, only the mining pool which has been given the request to send my transaction, should be in the process of solving the hash, for a block, which it is mining, and given the fact that the rate of 1 block every 10 minutes, is being shared between mining pools.

My next hypothesis was, that all the mining pools could have been working to mine the same transaction-list, which was an alarming idea for some obvious reasons. And that idea was false.

As it happens, this is completely normal behavior. The reason the receiving wallet sees the transaction as Pending so fast, is the fact that on the receiving end, the wallet connects to numerous nodes, and any one of those nodes could be the same node, belonging to the mining pool that I asked the amount to be sent from. So the appearance of the transaction as Pending, does not mean that the transaction has been inserted into the block-chain yet, its status as Confirmed does.

To top it off, I had 'RBF' enabled on the sending wallet.

'RBF' stands for "Replace By Fee", and is a special feature offered by Bitcoin Core. What it means, is that A could be sending an amount to B, which B sees as an Unconfirmed amount almost immediately. And then B can send funds from that Unconfirmed amount to C, provided that both A and B are clients of Bitcoin Core, and that A offered this ability when sending the amount to B.

- Bitcoin-Core Clients -
A  ->(RBF-enabled)  B  ->(unconfirmed-input)  C

A pays a slightly higher fee for this.

The reason this can exist, is the fact that Bitcoin Core is a large operator, and has confidence in the transaction sent by A. It therefore authorizes B to spend it again, even though (A -> B) is not in the block-chain yet.

Enabling this feature, given that Electrum is a 3rd-party wallet, and that some of the nodes it connects to are also Bitcoin Core nodes, virtually guaranteed that B would see the transaction, even though it was Unconfirmed, almost immediately. And in my case, there was no Party C (yet).

Also, Bitcoin Core could be making this feature an argument, not to increase the block-size, because as long as everybody has a Bitcoin Core -compatible client-program, the visibility of (A -> B) to party B, can act as an assurance that payment has been sent, even though it might currently take over an hour, for that payment to be Confirmed.

And, Party B need only be connected to a Bitcoin Core node for verification purposes, without having to use Bitcoin Core for sending, in order to be able to see the Transaction (A -> B) .

Actually, there is a partial admission, that this could lead to a double-expenditure somewhere. But Bitcoin Core is additionally confident, that this risk is minimal.


Dirk