Skip to content

C Differences from Bitcoin

Decred’s code base descends from an implementation of Bitcoin, and much of its structure will be familiar to anyone who knows that protocol. The familiarity is a hazard: many details differ, and an implementation that assumes Bitcoin’s behavior where this document is silent will be wrong. This appendix is informative. It lists the differences that most often mislead, with a pointer to the chapter that specifies each one. It is a guide to the document, not a substitute for it.

C.1 Consensus Model

Table C.1. Consensus and governance
AspectBitcoinDecred
Block validityProof of work alone.Proof of work, and votes from a majority of the five tickets drawn for the block (Chapter 8).
Finality of a block’s transactionsFixed once the block is mined.The regular transaction tree of a block takes effect only if the votes in the next block approve it (Chapter 10).
Rule changesActivated by miner signaling or by a date or height chosen by developers.Decided by a stakeholder vote with a 75% threshold and a quorum, evaluated by a state machine in the consensus rules (Chapter 13).
Development fundingNone in the protocol.10% of every block reward accrues to a treasury spent only by stakeholder vote (Chapter 12).
Target block interval10 minutes.5 minutes on the main network (Chapter 14).
IssuanceHalves every 210000 blocks.Multiplied by 100/101 every 6144 blocks, and divided between miners, voters and the treasury (Chapter 11).
Proof-of-work functionDouble SHA-256 of the 80-byte header.BLAKE-256 of the 180-byte header originally; BLAKE3 since DCP-0011, computed separately from the block hash (Chapter 9).
Difficulty adjustmentEvery 2016 blocks, from the time taken by the previous 2016.Originally every 144 blocks from a weighted average over 20 windows; since DCP-0011 recomputed for every block by an exponential formula (Chapter 9).

C.2 Hashes and Identifiers

Table C.2. Hash functions and identifiers
AspectBitcoinDecred
General-purpose hashDouble SHA-256.A single BLAKE-256 with 14 rounds (Chapter 3).
Block identifierDouble SHA-256 of the header; also the proof-of-work hash.BLAKE-256 of the header. Since DCP-0011 it is distinct from the proof-of-work hash.
Transaction identifierHash of the transaction without witness data (since segregated witness).BLAKE-256 of the prefix serialization, which never included signature scripts (Chapter 4).
Merkle tree leavesTransaction identifiers, with a separate witness commitment in the coinbase.Full transaction hashes, which commit to prefix and witness together (Chapter 4).
HASH160RIPEMD-160 of SHA-256.RIPEMD-160 of BLAKE-256.
OP_HASH256Double SHA-256.Double BLAKE-256. SHA-256 is available through OP_SHA256 (Chapter 6).
Address checksumFirst four bytes of double SHA-256.First four bytes of double BLAKE-256, over a two-byte version prefix (Chapter 5).
P2P message checksumFirst four bytes of double SHA-256 (in the original, unencrypted transport).First four bytes of a single BLAKE-256 (Chapter 15).

C.3 Transactions and Blocks

Table C.3. Structures
AspectBitcoinDecred
Block header80 bytes, six fields.180 bytes, eighteen fields, including the vote tally, ticket counts, ticket pool size, ticket price and lottery state (Chapter 4).
Transactions in a blockOne list.Two lists: the regular tree and the stake tree (Chapter 4, Chapter 10).
Transaction version field32-bit version.16-bit version and 16-bit serialization type.
OutpointTransaction hash and output index.Transaction hash, output index and a tree byte.
Input witnessSignature script, or a witness stack.Signature script together with the amount, block height and block index of the output being spent, which are checked against the ledger (Chapter 7).
OutputAmount and script.Amount, 16-bit script version and script.
ExpiryNone.An optional height from which the transaction is no longer valid.
Maximum block sizeA weight limit of four million units.393216 bytes of serialized block on the main network (Chapter 10).
Coinbase maturity100 blocks.256 blocks on the main network.
Duplicate transaction checkEnforced (BIP 30). The check is skipped for most blocks since the coinbase began to carry the height (BIP 34), which makes duplicates impractical but not impossible.Unnecessary from the start: every coinbase from height 2 carries the block height (Chapter 10, Chapter 11).

C.4 Script

The script language has the same shape as Bitcoin’s, a stack machine with no loops, but differs in limits, in the set of enabled opcodes and in every detail of signature checking. Chapter 6 is the specification and Appendix A lists every opcode.

Table C.4. Script
AspectBitcoinDecred
Maximum script size10000 bytes.16384 bytes.
Maximum pushed element520 bytes.2048 bytes.
Maximum counted opcodes201.255.
Maximum stack depth1000.1024.
OP_CHECKMULTISIGPops one extra unused element.Pops no extra element.
OP_CODESEPARATORAffects the signed script.Disabled.
Splice, bitwise and arithmetic opcodes disabled in BitcoinDisabled: a script containing them is invalid.Most are enabled, with 32-bit semantics defined in Chapter 6; rotation opcodes are added.
Signature schemesECDSA, and BIP 340 Schnorr in Taproot outputs.ECDSA through OP_CHECKSIG; Ed25519 and a secp256k1 Schnorr scheme of Decred’s own definition through OP_CHECKSIGALT (Chapter 3).
Signature and key encodingStrict DER is consensus (BIP 66); low-S signatures and the rejection of hybrid public keys are relay policy for legacy scripts.Strict DER, low S and strict public key encoding (compressed or uncompressed only) are all consensus: a violation fails the script (Chapter 6).
Hash opcodes0xa8 is OP_SHA256; OP_HASH160 and OP_HASH256 are built on SHA-256.0xa8 is OP_BLAKE256; OP_HASH160 and OP_HASH256 are built on BLAKE-256; OP_SHA256 is 0xc0, specified by DCP-0002 and enabled by the lnfeatures vote (Chapter 6).
Bitwise opcodesOP_INVERT, OP_AND, OP_OR and OP_XOR operated on byte strings before they were disabled.They operate on 32-bit numbers.
Signed messagesDouble SHA-256 of the prefixed message.A single BLAKE-256 of the prefixed message (Chapter 5); not consensus.
Signature hashSeveral algorithms depending on output type.One algorithm, which hashes a prefix digest and a witness digest (Chapter 6).
Stake and treasury opcodesNone.Tag opcodes mark outputs that only tickets, votes, revocations and treasury transactions may create or spend (Chapter 8, Chapter 12).
Script upgradesNew witness versions and Tapscript leaf versions.A script version on every output. Versions above those enabled by vote are rejected (Chapter 13).
Lock-time featuresBIP 65, BIP 68, BIP 112 and BIP 113.The same concepts with Decred-specific encodings and rules (Chapter 7). OP_CHECKLOCKTIMEVERIFY (BIP 65) has been enforced since launch; the rest were activated by DCP-0003.

C.5 Network and Wallets

Table C.5. Network and wallet conventions
AspectBitcoinDecred
Light clientsCompact block filters (BIP 157 and BIP 158) that headers do not commit to.Version 2 filters with different parameters and contents, committed to by every header since DCP-0005 (Chapter 16).
Unknown P2P messagesIgnored.Treated as misbehavior by the reference node (Chapter 15).
Hierarchical deterministic keysBIP 32.The same construction with different version bytes and a small number of differences in edge cases (Chapter 5).
Coin mixingNot part of the node.A peer-to-peer mixing protocol is carried by the node’s P2P network (Chapter 18).