Page MenuHomePhabricator

No OneTemporary

diff --git a/doc/release-notes/release-notes-0.22.6.md b/doc/release-notes/release-notes-0.22.6.md
index bc076226a..993da6818 100644
--- a/doc/release-notes/release-notes-0.22.6.md
+++ b/doc/release-notes/release-notes-0.22.6.md
@@ -1,58 +1,58 @@
# Bitcoin ABC 0.22.6 Release Notes
Bitcoin ABC version 0.22.6 is now available from:
<https://download.bitcoinabc.org/0.22.6/>
This release includes the following features and fixes:
P2P and network changes
-----------------------
#### Removal of reject network messages from Bitcoin ABC (BIP61)
This is a follow-up on the removal of BIP61 REJECT message support in
Bitcoin ABC version 0.22.5:
* Log messages that previously reported the REJECT code when a transaction was
not accepted to the mempool now no longer report the REJECT code. The verbal
reason for rejection is still reported.
Updated RPCs
------------
- `walletprocesspsbt` and `walletcreatefundedpsbt` now include BIP 32
derivation paths by default for public keys if we know them. This can be
disabled by setting `bip32derivs` to `false`.
New settings
------------
- A new `-asmap` configuration option has been added to enable IP-to-ASN mapping
for bucketing of the network peers to diversify the network connections. The
legacy /16 prefix mapping remains the default. See `bitcoind help` for more
information. This option is experimental and subject to changes or removal in
future releases.
- Importing blocks upon startup via the `bootstrap.dat` file no longer occurs
by default. The file must now be specified with `-loadblock=<file>`.
-
+
Utilities
---------
- The `bitcoin-cli` utility used with the `-getinfo` parameter now returns a
`headers` field with the number of downloaded block headers on the best
headers chain (similar to the `blocks` field that is also returned) and a
`verificationprogress` field that estimates how much of the best block chain
has been synced by the local node. The information returned no longer
includes the `protocolversion`, `walletversion`, and `keypoololdest` fields.
Build system changes
--------------------
The minimum supported miniUPnPc version is set to 1.9 (API version 10).
GUI changes
-----------
- The "Start Bitcoin Core on system login" option has been removed on macOS.
diff --git a/doc/standards/2019-05-15-upgrade.md b/doc/standards/2019-05-15-upgrade.md
index 6e42e5b20..bb5992200 100644
--- a/doc/standards/2019-05-15-upgrade.md
+++ b/doc/standards/2019-05-15-upgrade.md
@@ -1,47 +1,47 @@
---
layout: specification
title: 2019-MAY-15 Network Upgrade Specification
date: 2019-02-28
category: spec
activation: 1557921600
version: 0.5
---
## Summary
When the median time past [1] of the most recent 11 blocks (MTP-11) is greater than or equal to UNIX timestamp 1557921600, Bitcoin Cash will execute an upgrade of the network consensus rules according to this specification. Starting from the next block these consensus rules changes will take effect:
* Enable Schnorr signatures.
* Allow Segwit recovery.
The following are not consensus changes, but are recommended changes for Bitcoin Cash implementations:
* Automatic replay protection for future upgrade
## Enable Schnorr signatures
Support Schnorr signatures in CHECKSIG and CHECKDATASIG per [2019-05-15-schnorr.md](2019-05-15-schnorr.md).
## Allow Segwit recovery
-In the last upgrade, coins accidentally sent to Segwit P2SH addresses were made unspendable by the CLEANSTACK rule. This upgrade will make an exemption for these coins and return them to the previous situation, where they are spendable. This means that once the P2SH redeem script pre-image is revealed (for example by spending coins from the corresponding BTC address), any miner can take the coins.
+In the last upgrade, coins accidentally sent to Segwit P2SH addresses were made unspendable by the CLEANSTACK rule. This upgrade will make an exemption for these coins and return them to the previous situation, where they are spendable. This means that once the P2SH redeem script pre-image is revealed (for example by spending coins from the corresponding BTC address), any miner can take the coins.
Details: [2019-05-15-segwit-recovery.md](2019-05-15-segwit-recovery.md)
## Automatic Replay Protection
When the median time past [1] of the most recent 11 blocks (MTP-11) is less than UNIX timestamp 1573819200 (Nov 2019 upgrade) Bitcoin Cash full nodes MUST enforce the following rule:
* `forkid` [2] to be equal to 0.
When the median time past [1] of the most recent 11 blocks (MTP-11) is greater than or equal to UNIX timestamp 1573819200 (Nov 2019 upgrade) Bitcoin Cash full nodes implementing the May 2019 consensus rules SHOULD enforce the following change:
* Update `forkid` [2] to be equal to 0xFF0002. ForkIDs beginning with 0xFF will be reserved for future protocol upgrades.
This particular consensus rule MUST NOT be implemented by Bitcoin Cash wallet software. Wallets that follow the upgrade should not have to change anything.
## References
[1] Median Time Past is described in [bitcoin.it wiki](https://en.bitcoin.it/wiki/Block_timestamp). It is guaranteed by consensus rules to be monotonically increasing.
[2] The `forkId` is defined as per the [replay protected sighash](replay-protected-sighash.md) specification.
diff --git a/doc/standards/2019-11-15-upgrade.md b/doc/standards/2019-11-15-upgrade.md
index 334982cf5..42e65fd6c 100644
--- a/doc/standards/2019-11-15-upgrade.md
+++ b/doc/standards/2019-11-15-upgrade.md
@@ -1,66 +1,66 @@
---
layout: specification
title: 2019-NOV-15 Network Upgrade Specification
date: 2019-10-23
category: spec
activation: 1573819200
version: 0.4
---
## Summary
When the median time past [1] of the most recent 11 blocks (MTP-11) is greater than or equal to UNIX timestamp 1573819200,
Bitcoin Cash will execute an upgrade of the network consensus rules according to this specification.
Starting from the next block these consensus rules changes will take effect:
* Enable Schnorr signatures for OP_CHECKMULTISIG(VERIFY).
* Enforce minimal push and minimal number encoding rules in Script.
The following are not consensus changes, but are recommended changes for Bitcoin Cash implementations:
* Automatic replay protection for future upgrade
## Schnorr Signatures for OP_CHECKMULTISIG(VERIFY)
Use of Schnorr signatures is enabled in OP_CHECKMULTISIG(VERIFY). The dummy element is repurposed to flag
Schnorr mode when it is non-null, and the order of signatures in Schnorr mode is constrained according to
the bitfield encoded in the repurposed dummy element.
Details can be found in the [full specification: 2019-11-15-schnorrmultisig.md](2019-11-15-schnorrmultisig.md).
NOTE: The repurposing of the dummy element as a flag and bitfield supersedes the need for NULLDUMMY.
## Enforce MINIMALDATA in Script.
Enforce existing standardness checks that all executed data pushes use minimal push operators, and all numbers are encoded minimally,
together known as the "MINIMALDATA" rule. This goes into effect at the consensus layer.
Details can be found in the [full specification: 2019-11-15-minimaldata.md](2019-11-15-minimaldata.md).
## Automatic Replay Protection
-The purpose of Automatic Replay Protection is to serve as a full node version-deprecation mechanism. It is intended to cause
+The purpose of Automatic Replay Protection is to serve as a full node version-deprecation mechanism. It is intended to cause
full validating nodes which do not upgrade, to automatically separate themselves from the main network after the next
upgrade on 15 May 2020. Nodes which implement the next upgrade will remove this automatic replay protection, and thus all regular
wallets can continue using the default ForkID with no change to follow the main upgraded chain.
When the median time past [1] of the most recent 11 blocks (MTP-11) is less than UNIX timestamp 1589544000 (May 2020 upgrade)
Bitcoin Cash full nodes MUST enforce the following rule:
* `forkid` [2] to be equal to 0.
When the median time past [1] of the most recent 11 blocks (MTP-11) is greater than or equal to UNIX timestamp 1589544000
(May 2020 upgrade) Bitcoin Cash full nodes implementing the Nov 2019 consensus rules SHOULD enforce the following change:
* Update `forkid` [2] to be equal to `0xFFXXXX`, where `XXXX` is some arbitrary hex value.
ForkIDs beginning with 0xFF will be reserved for future protocol upgrades.
This particular consensus rule MUST NOT be implemented by Bitcoin Cash wallet software. Wallets that follow the upgrade
should not have to change anything.
## References
[1] Median Time Past is described in [bitcoin.it wiki](https://en.bitcoin.it/wiki/Block_timestamp).
It is guaranteed by consensus rules to be monotonically increasing.
[2] The `forkId` is defined as per the [replay protected sighash](replay-protected-sighash.md) specification.
diff --git a/doc/standards/2020-05-15-op_reversebytes.md b/doc/standards/2020-05-15-op_reversebytes.md
index 155260659..fb274ec92 100644
--- a/doc/standards/2020-05-15-op_reversebytes.md
+++ b/doc/standards/2020-05-15-op_reversebytes.md
@@ -1,165 +1,165 @@
---
layout: specification
title: OP_REVERSEBYTES Specification
category: spec
date: 2019-05-29
activation: 1589544000
version: 0.2
author: Tobias Ruck
---
OP_REVERSEBYTES
==========
OP_REVERSEBYTES reverses the bytes of the top stackitem.
Rationale
---------
Bitcoin's protocol almost exclusively uses little-endian encoding [8], and Script provides various tools for using integers encoded in little endian, such as `OP_NUM2BIN` and `OP_BIN2NUM` [11]. Using covenants [2], sophisticated smart contracts can be created, and Script already has a great arsenal of arithmetic operators (opcodes 139 to 165) to enforce e.g. how input and output amounts of transactions have to be related.
However, many protocols do not use little endian encoding, and it is by no means clear that one is superior to the other. Both AMQP [12] and Apache Thrift [13], for instance, use big-endian encoding. The Simple Ledger Protocol (SLP) uses big-endian encoding as well [1]. Bitdb, when using the `hN` elements, returns stack items in a format that can be directly interpreted as base16 big-endian encoded numbers, and to use this feature, it has to be possible to encode values as big-endian.
Further, now that oracles using OP_CHECKDATASIG are possible, likely used to retrieve numeric data, it would be unnecessarily limiting to assume all oracles will use little-endian encoding.
Among the mentioned protocols, SLP tokens are likely the most important ones. Various new use cases combining the power of covenants and looping transactions [5] emerge, among them:
* Decentralized exchanges (such as SLP Agora or SLPDEX) [3] [6] [4]
* Donation mintable tokens
* DAOs, which charge a fee for services and distribute revenue proportional to shares [7]
* Native tokens (not yet possible)
Note that values can be converted to big-endian encoding if the size of the encoding is both fixed and not too large. Currently, Script only supports 32-bit integers, and they can be encoded in big-endian using OP_SPLIT, OP_SWAP and OP_CAT:
```
// initial: // <value>
// convert to little-endian
PUSH 4 // <value> 4
OP_NUM2BIN // <value 4-byte little endian>
// split into individual bytes
PUSH 1 // <value 4-byte little endian> 1
OP_SPLIT // <value 1st byte> <value 2nd-4th byte>
PUSH 1 // <value 1st byte> <value 2nd-4th byte> 1
OP_SPLIT // <value 1st byte> <value 2nd byte> <value 3rd-4th byte>
PUSH 1 // <value 1st byte> <value 2nd byte> <value 3rd-4th byte> 1
OP_SPLIT // <value 1st byte> <value 2nd byte> <value 3rd byte> <value 4th byte>
// reverse individual bytes and concat
// results in 4-byte big endian
OP_SWAP // <value 1st byte> <value 2nd byte> <value 4th byte> <value 3rd byte>
OP_CAT // <value 1st byte> <value 2nd byte> <value 4th, 3rd byte>
OP_SWAP // <value 1st byte> <value 4th, 3rd byte> <value 2nd byte>
OP_CAT // <value 1st byte> <value 4th, 3rd, 2nd byte>
OP_SWAP // <value 4th, 3rd, 2nd byte> <value 1st byte>
OP_CAT // <value 4-byte big endian>
```
However, if with OP_REVERSEBYTES, this becomes trivial:
```
// convert to bytes
PUSH 4 // <SLP value> 4
OP_NUM2BIN // <SLP value 4-byte little endian>
OP_REVERSEBYTES // <SLP value 4-byte big endian>
```
-That's 11 bytes (9 operations and 3 pushdata) saved.
+That's 11 bytes (9 operations and 3 pushdata) saved.
There are multiple reasons why the second version would be preferable:
* Covenants and looping scripts usually take the script code of the preimage [9] as input, which means every operation counts twice: Once for the stack item containing the script code, and once for the P2SH script stack item [10]. For a conversion to 8-byte big-endian, this would save 32 bytes per conversion, and if there's, say, three of those conversions in a script, it would already amount to 96 bytes - a non-trivial number of bytes for a transaction.
* The cognitive load of developing scripts using the larger snippet above is increased unnecessarily. Developing scripts, by hand or by using tools such as macros or Spedn, already puts a lot of cognitive load on developers, and errors can be devastating to the community. A prominent example of such a failure is the contentious hard-fork on the Ethereum blockchain that was caused by a bug in The DAO smart contract.
* The first version assumes that Script uses 32-bit numbers, however, once integers with larger width are implemented, the script gets linearly longer (4 bytes/byte) with each additional byte. For 256-bit numbers, it would require a whopping 124 bytes (93 operations and 31 pushdata) to convert to big-endian. As the opcode limit currently is 201, that wouldn't leave much room for other operations. In contrast, `<N> OP_NUM2BIN OP_REVERSEBYTES` always encodes integers as N-byte big-endian number, with a constant script size independent of N.
Also, suppose an oracle returns an ordered list of 1-byte items (e.g. indices), however, if the script requires the bytes to be in the reversed order, then OP_REVERSEBYTES would allow to do this trivially.
### A Note On Signs
For unsigned integers, the behavior is always the expected one: the number will be encoded as unsigned big-endian integer. However, as integers in Script are encoded rather curiously, signed integers might result in unexpected behavior:
`-1 4 OP_NUM2BIN OP_REVERSEBYTES -> {0x80, 0x00, 0x00, 0x01}`
Here, the sign bit is the first bit of the resulting stackitem. Usually, negative numbers are encoded in two's complement, and the number should be `{0xff, 0xff, 0xff, 0xff}`. However, as long as developers are aware of this quite Script specific encoding, there's no issue at hand.
OP_REVERSEBYTES Specification
-----------------------------
This specification uses the same syntax for the stack/stackitems as [11].
### Semantics
`a OP_REVERSEBYTES -> b`.
OP_REVERSEBYTES fails immediately if the stack is empty.
Otherwise, the top stack item is removed from the stack, and a byte-reversed version is pushed onto the stack.
Examples:
* `{} OP_REVERSEBYTES -> {}`
* `{0x01} OP_REVERSEBYTES -> {0x01}`
* `{0x01, 0x02, 0x03, 0x04} OP_REVERSEBYTES -> {0x04, 0x03, 0x02, 0x01}`
### Opcode Number
-OP_REVERSEBYTES proposes to use the previously unused opcode with number 188 (0xbc in hex encoding), which comes after the most recently added opcode, `OP_CHECKDATASIGVERIFY`.
+OP_REVERSEBYTES proposes to use the previously unused opcode with number 188 (0xbc in hex encoding), which comes after the most recently added opcode, `OP_CHECKDATASIGVERIFY`.
### Name
The naming of this opcode turned out to become a bit of a bikeshed. In a previous proposal, this opcode has been named `OP_REVERSE`. After that, it has been renamed to `OP_BSWAP`, as that is a more technically accurate term, which is commonly used for reversing the byteorder of integers [14] [15]. However, after some more consideration, it has been renamed to `OP_ENDIAN_REVERSE` following Boost‘s nomenclature [16], then to `OP_REVERSEENDIAN` and finally to `OP_REVERSEBYTES`, which are both more consistent with Script‘s opcode naming system. However, as, “endian” is usually used for numbers which are a power of two—which isn‘t the case for this opcode—`OP_REVERSEBYTES` is the prefered choice here.
`OP_REVERSEBYTES` is preferable to `OP_BSWAP` because `OP_BSWAP` is lexically very similar to the already existing `OP_SWAP` and would make Script harder to read. Also, while the technical term for the instruction is indeed `bswap`, it isn‘t well known for developers of higher level languages and could thus spark confusion that would be avoided by using the name `OP_REVERSEBYTES`, which is more self-descriptive.
### Activation
The opcode will be activated during the 15th May 2020 hardfork.
### Unit Tests
The following unit tests are used by the ABC implementation of the opcode as of Feb 17th 2020.
- `<item> OP_REVERSEBYTES` fails if 15th May 2020 protocol upgrade is not yet activated.
- `OP_REVERSEBYTES` fails if the stack is empty.
- `{} OP_REVERSEBYTES -> {}`
- `{99} OP_REVERSEBYTES -> {99}`
- `{0xde, 0xad} OP_REVERSEBYTES -> {0xad, 0xde}`
- `{0xde, 0xad, 0xa1} OP_REVERSEBYTES -> {0xa1, 0xad, 0xde}`
- `{0xde, 0xad, 0xbe, 0xef} OP_REVERSEBYTES -> {0xef, 0xbe, 0xad, 0xde}`
- `{0x12, 0x34, 0x56} OP_REVERSEBYTES -> {0x56, 0x34, 0x12}`
- for all n ∈ [0; 520]: `{i mod 256 | i < n} OP_REVERSEBYTES -> {(n - i - 1) mod 256 | i < n}`
- for all n ∈ [0; 520]: `{(if (i < (n + 1) / 2) then (i) else (n - i - 1)) % 256) | i < n} OP_DUP OP_REVERSEBYTES OP_EQUAL -> OP_TRUE`
References
----------
[1] SLP Token specification: https://github.com/simpleledger/slp-specifications/blob/master/slp-token-type-1.md
[2] Spending constraints with OP_CHECKDATASIG: https://honest.cash/pein_sama/spending-constraints-with-op_checkdatasig-172
[3] SLP Agora: https://github.com/EyeOfPython/slpagora
[4] Sample SLPDEX transaction: https://blockchair.com/bitcoin-cash/transaction/2e69f47a985673c5a645e20ad09025a0892321f096224679657f98e6152c845c
[5] Let's play chess on the BCH Blockchain: https://tobiasruck.com/content/lets-play-chess-on-bch/
[6] SLPDEX (discontinued): slpdex.cash
[7] DAO: https://en.wikipedia.org/wiki/Decentralized_autonomous_organization
[8] Bitcoin protocol documentation, common structures: https://en.bitcoin.it/wiki/Protocol_documentation#Common_structures
[9] BIP143: https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki
[10] BIP16: https://github.com/bitcoin/bips/blob/master/bip-0016.mediawiki
[11] May 2018, reenabled opcodes: https://github.com/EyeOfPython/bitcoincash.org/blob/master/spec/may-2018-reenabled-opcodes.md
[12] AMQP specification, page 14: http://www.amqp.org/sites/amqp.org/files/amqp.pdf
[13] Apache Thrift binary protocol: https://github.com/apache/thrift/blob/master/doc/specs/thrift-binary-protocol.md
[14] https://docs.rs/bswap/1.0.0/bswap/
[15] https://www.npmjs.com/package/bswap
[16] https://www.boost.org/doc/libs/1_63_0/libs/endian/doc/conversion.html#endian_reverse
diff --git a/doc/standards/2020-05-15-upgrade.md b/doc/standards/2020-05-15-upgrade.md
index d292bd567..8d1828d43 100644
--- a/doc/standards/2020-05-15-upgrade.md
+++ b/doc/standards/2020-05-15-upgrade.md
@@ -1,72 +1,72 @@
---
layout: specification
title: 2020-MAY-15 Network Upgrade Specification
date: 2020-04-26
category: spec
activation: 1589544000
version: 0.4
---
## Summary
When the median time past [1] of the most recent 11 blocks (MTP-11) is greater than or equal to UNIX timestamp 1589544000 (May 15th, 2020, 12:00PM UTC),
Bitcoin Cash will execute an upgrade of the network consensus rules according to this specification.
Starting from the next block these consensus rules changes will take effect:
* Bitcoin Cash's SigOps counting and limiting system is replaced with a new system, referred to as SigChecks.
* A new opcode called OP_REVERSEBYTES has been added to the script system.
* Enforcement of the Infrastructure Funding Plan, subject to activation by [BIP 9](https://github.com/bitcoin/bips/blob/master/bip-0009.mediawiki) miner signalling.
The following are not consensus changes, but are recommended policy changes for Bitcoin Cash implementations:
* The default for max number of in-mempool ancestors is changed from 25 to 50.
* The default for max number of in-mempool descendants is changed from 25 to 50.
* Automatic replay protection for future upgrade.
## SigChecks
Enforcement of sigops limits is removed, and replaced with new limits based on the number of signature checks that are actually executed when running a script. This new system is called SigChecks.
Details can be found in the [full specification: SigChecks](https://github.com/bitcoincashorg/bitcoincash.org/blob/master/spec/2020-05-15-sigchecks.md).
## OP_REVERSEBYTES
This new opcode reverses the order of bytes in a string. It can be used to change endianness.
Details can be found in the [full specification: OP_REVERSEBYTES](https://github.com/bitcoincashorg/bitcoincash.org/blob/master/spec/2020-05-15-op_reversebytes.md).
## Infrastructure Funding Plan
-The purpose of the Infrastructure Funding Plan (IFP) is to provide funding to development projects working on common Bitcoin Cash infrastructure.
-If activated, it enforces that 5% of the block reward is spent to one of a set of specified addresses.
+The purpose of the Infrastructure Funding Plan (IFP) is to provide funding to development projects working on common Bitcoin Cash infrastructure.
+If activated, it enforces that 5% of the block reward is spent to one of a set of specified addresses.
Activation is triggered via [BIP 9](https://github.com/bitcoin/bips/blob/master/bip-0009.mediawiki) version bits signalling prior to the May 15 upgrade.
More detailed can be found in the [full specification](https://github.com/bitcoincashorg/bitcoincash.org/blob/master/spec/2020-05-15-ifp.md).
## Automatic Replay Protection
-The purpose of Automatic Replay Protection is to serve as a full node version-deprecation mechanism. It is intended to cause
+The purpose of Automatic Replay Protection is to serve as a full node version-deprecation mechanism. It is intended to cause
full validating nodes which do not upgrade, to automatically separate themselves from the main network after the next
upgrade on 15 May 2020. Nodes which implement the next upgrade will remove this automatic replay protection, and thus all regular
wallets can continue using the default ForkID with no change to follow the main upgraded chain.
When the median time past [1] of the most recent 11 blocks (MTP-11) is less than UNIX timestamp 1605441600 (Nov 2020 upgrade)
Bitcoin Cash full nodes MUST enforce the following rule:
* `forkid` [2] to be equal to 0.
When the median time past [1] of the most recent 11 blocks (MTP-11) is greater than or equal to UNIX timestamp 1605441600
(Nov 2020 upgrade) Bitcoin Cash full nodes implementing the May 2020 consensus rules SHOULD enforce the following change:
* Update `forkid` [2] to be equal to `0xFFXXXX`, where `XXXX` is some arbitrary hex value.
ForkIDs beginning with 0xFF will be reserved for future protocol upgrades.
This particular consensus rule MUST NOT be implemented by Bitcoin Cash wallet software. Wallets that follow the upgrade
should not have to change anything.
## References
[1] Median Time Past is described in [bitcoin.it wiki](https://en.bitcoin.it/wiki/Block_timestamp).
It is guaranteed by consensus rules to be monotonically increasing.
[2] The `forkId` is defined as per the [replay protected sighash](replay-protected-sighash.md) specification.
diff --git a/doc/standards/2020-11-15-upgrade.md b/doc/standards/2020-11-15-upgrade.md
index 5a377859d..6554d32db 100644
--- a/doc/standards/2020-11-15-upgrade.md
+++ b/doc/standards/2020-11-15-upgrade.md
@@ -1,67 +1,67 @@
---
layout: specification
title: 2020-NOV-15 Network Upgrade Specification
date: 2020-08-15
category: spec
activation: 1605441600
version: 0.1
---
## Summary
When the median time past [1] of the most recent 11 blocks (MTP-11) is greater than or equal to UNIX timestamp 1605441600 (Nov 15th, 2020, 12:00PM UTC),
Bitcoin Cash will execute an upgrade of the network consensus rules according to this specification.
Starting from the next block these consensus rules changes will take effect:
* Bitcoin Cash's Difficulty Adjustment Algorithm (DAA) is replaced with a new system, referred to as aserti3-2d.
* The addition of a new coinbase rule.
The following are not consensus changes, but are recommended policy changes for Bitcoin Cash implementations:
* Automatic replay protection for future upgrade.
## Difficulty Adjustment Algorithm
Bitcoin Cash's Difficulty Adjustment Algorithm (DAA) is replaced with a new algorithm called [ASERT](http://toom.im/files/da-asert.pdf).
The specific implementation is called aserti3-2d. Details can be found in the [full specification: ASERT](https://github.com/bitcoincashorg/bitcoincash.org/blob/master/spec/2020-11-15-asert.md).
## Coinbase Rule
The purpose of the new coinbase rule is to provide funding to development projects working on common Bitcoin Cash infrastructure.
-
+
The coinbase rule enforces that at least 8% of the block reward must be spent as a single output to the following Bitcoin Cash address:
`bitcoincash:pqnqv9lt7e5vjyp0w88zf2af0l92l8rxdgnlxww9j9`.
The amount of the output must be equal to or greater than the integer `required`, calculated as follows using integer math:
```
required = (8 * blockReward) / 100
```
## Automatic Replay Protection
-The purpose of Automatic Replay Protection is to serve as a full node version-deprecation mechanism. It is intended to cause
+The purpose of Automatic Replay Protection is to serve as a full node version-deprecation mechanism. It is intended to cause
full validating nodes which do not upgrade, to automatically separate themselves from the main network after the next
upgrade on 15 May 2021. Nodes which implement the next upgrade will remove this automatic replay protection, and thus all regular
wallets can continue using the default ForkID with no change to follow the main upgraded chain.
When the median time past [1] of the most recent 11 blocks (MTP-11) is less than UNIX timestamp 1621080000 (May 2021 upgrade)
Bitcoin Cash full nodes MUST enforce the following rule:
* `forkid` [2] to be equal to 0.
When the median time past [1] of the most recent 11 blocks (MTP-11) is greater than or equal to UNIX timestamp 1621080000
(May 2021 upgrade) Bitcoin Cash full nodes implementing the Nov 2020 consensus rules SHOULD enforce the following change:
* Update `forkid` [2] to be equal to `0xFFXXXX`, where `XXXX` is some arbitrary hex value.
ForkIDs beginning with 0xFF will be reserved for future protocol upgrades.
This particular consensus rule MUST NOT be implemented by Bitcoin Cash wallet software. Wallets that follow the upgrade
should not have to change anything.
## References
[1] Median Time Past is described in [bitcoin.it wiki](https://en.bitcoin.it/wiki/Block_timestamp).
It is guaranteed by consensus rules to be monotonically increasing.
[2] The `forkId` is defined as per the [replay protected sighash](replay-protected-sighash.md) specification.
diff --git a/doc/standards/block.md b/doc/standards/block.md
index 48cf978ad..1bb5f8efd 100644
--- a/doc/standards/block.md
+++ b/doc/standards/block.md
@@ -1,144 +1,144 @@
---
layout: specification
title: Block Spec for Bitcoin Cash ⚠️ out of date ⚠️
category: spec
date: 2017-08-26
activation: 1515888000
version: 1.0
---
This section of the Bitcoin Cash (BCH) specification ("spec") documents the **block data structure** for implementing a compatible BCH client, including the block header, block serialization, and coinbase transaction formats.
This spec is based on the Bitcoin ABC implementation of the [Bitcoin Cash](https://www.bitcoincash.org/) protocol.
Developer resources:
- [Bitcoin ABC source code](https://github.com/Bitcoin-ABC/bitcoin-abc)
- [Bitcoin ABC developer documentation](https://www.bitcoinabc.org/doc/dev/)
# Block
-A **block** is one of the two base primitives in the BCH system, the other being a **transaction**. Primitive in this context means it is one of the data structures for which the BCH software provides built-in support.
+A **block** is one of the two base primitives in the BCH system, the other being a **transaction**. Primitive in this context means it is one of the data structures for which the BCH software provides built-in support.
Nodes collect new transactions into a **block**, hash them into a hash tree (**merkle root hash**), and scan through **nonce** values to make the block's hash satisfy proof-of-work requirements.
When a miner solves the proof-of-work, it broadcasts the block to network nodes and if the block is valid it is added to the block chain. The first transaction in the block is the **coinbase transaction** that creates a new coin owned by the creator of the block. An algorithm ensures that a new block is generated every 10 minutes (600 seconds) on average.
-The block validation rules described here ensure that BCH nodes stay in consensus with other nodes. There are several rules that must be respected for a block to be valid. A node is responsible for processing, validating, and relaying the block and its transactions.
+The block validation rules described here ensure that BCH nodes stay in consensus with other nodes. There are several rules that must be respected for a block to be valid. A node is responsible for processing, validating, and relaying the block and its transactions.
A node is distinct on the network from miners and wallets. A BCH node is a piece of software that connects to other nodes in a network and communicates via peer-to-peer messages. Nodes use the `verack` protocol to communicate and perform full validation checks, including:
1. Connecting to the network and peers.
2. Acquiring block headers.
3. Validating all blocks.
4. Validating all transactions.
Block source code: https://github.com/Bitcoin-ABC/bitcoin-abc/blob/master/src/primitives/block.h.
## Block Header
Block headers are serialized in the 80-byte format comprising six fields: [version](#version), [previous block hash](#previous-block-hash), [merkle root hash](#merkle-root-hash), [timestamp](#time), [difficulty target](target), and [nonce](#nonce).
The block header is hashed as part of the proof-of-work algorithm, making the serialized header format part of the consensus rules. The hash of the block header is the unique signature of the block. The block header hash is included in the next block that is mined. The block header includes a pointer to the previous block that links them in the blockchain.
The block header requires the following six fields. Note that the hashes are in internal byte order; all other values are in little-endian order.
Field | Size (bytes) | Data type | Description
----------------|---------------|-----------|------------
`nVersion` | 4 | int32_t | The block version number indicates which set of block validation rules to follow.
`hashPrevBlock` | 32 | uint256 | The SHA256(SHA256(Block_Header)) message digest of the previous block’s header.
`hashMerkleRoot`| 32 | uint256 | The message digest of the Merkle root.
`nTime` | 4 | uint32_t | Current timestamp in seconds since 1970-01-01T00:00 UTC (Unix time).
`nBits` | 4 | uint32_t | Difficulty target for the proof-of-work for this block.
`nNonce` | 4 | uint32_t | 32-bit number (starts at 0) used to generate this block (the "nonce").
### Block Version
The block version number is a signed 4 byte integer (`int32_t`) that indicates which set of block validation rules to follow. BCH version >= 4 is valid.
### Previous Block Hash
-The SHA256(SHA256(Block_Header)) message digest (hash) of the previous block’s header in internal byte order. This ensures no previous block can be changed without also changing this block’s header.
+The SHA256(SHA256(Block_Header)) message digest (hash) of the previous block’s header in internal byte order. This ensures no previous block can be changed without also changing this block’s header.
### Merkle Root Hash
The Merkle tree is data structure that provides a record of all transactions in the block. Each transaction in the block is a leaf in the Merkle tree and includes a hash of the previous transaction hash. The Merkle root is derived from the hashes of all transactions included in this block. The hash of the Merkle root ensures that no transaction can be modified without modifying the block header.
The Merkle root is constructed from the list of transaction IDs in the order the transactions appear in the block.
* The coinbase transaction TXID is always placed first.
* Any input within this block can spend an output which also appears in this block (assuming the spend is otherwise valid). However, the TXID corresponding to the output must be placed at some point before the TXID corresponding to the input. This ensures that any program parsing block chain transactions linearly will encounter each output before it is used as an input.
If a block only has a coinbase transaction, the coinbase TXID is used as the Merkle root hash.
If a block only has a coinbase transaction and one other transaction, the TXIDs of those two transactions are placed in order, concatenated as 64 raw bytes, and then SHA256(SHA256()) hashed together to form the Merkle root.
If a block has three or more transactions, intermediate Merkle tree rows are formed. The TXIDs are placed in order and paired, starting with the coinbase transaction's TXID. Each pair is concatenated together as 64 raw bytes and SHA256(SHA256()) hashed to form a second row of hashes. If there are an odd (non-even) number of TXIDs, the last TXID is concatenated with a copy of itself and hashed. If there are more than two hashes in the second row, the process is repeated to create a third row (and, if necessary, repeated further to create additional rows). Once a row is obtained with only two hashes, those hashes are concatenated and hashed to produce the Merkle root.
TXIDs and intermediate hashes are always in internal byte order when they're concatenated, and the resulting Merkle root is also in internal byte order when it's placed in the block header.
Note that the Merkle root makes it possible in the future to securely verify that a transaction has been accepted by the network using just the block header (which includes the Merkle tree), eliminating the current requirement to download the entire blockchain.
Refer to the source code for more details on security issues: https://github.com/Bitcoin-ABC/bitcoin-abc/blob/master/src/consensus/merkle.cpp.
### Block Timestamp
The block timestamp is Unix epoch time when the miner started hashing the header according to the miner's clock. The block timestamp must be greater than the median time of the previous 11 blocks. Note that when validating the first 11 blocks of the chain, you will need to know how to handle arrays of less than length 11 to get a median. A node will not accept a block with a timestamp more than 2 hours ahead of its view of network-adjusted time.
### Difficulty Target
The difficulty target is a 256-bit unsigned integer which a header hash must be less than or equal to for that header to be a valid part of the block chain. The header field *nBits* provides only 32 bits of space, so the target number uses a less precise format called "compact" which works like a base-256 version of scientific notation. As a base-256 number, nBits can be parsed as bytes the same way you might parse a decimal number in base-10 scientific notation.
-Although the target threshold should be an unsigned integer, the class from which the original nBits implementation inherits properties from a signed data class, allowing the target threshold to be negative if the high bit of the significand is set.
+Although the target threshold should be an unsigned integer, the class from which the original nBits implementation inherits properties from a signed data class, allowing the target threshold to be negative if the high bit of the significand is set.
* When parsing nBits, the system converts a negative target threshold into a target of zero, which the header hash can equal (in
theory, at least).
* When creating a value for nBits, the system checks to see if it will produce an nBits which will be interpreted as negative; if so, it divides the significand by 256 and increases the exponent by 1 to produce the same number with a different encoding.
Difficulty is a measure of how difficult it is to find a hash below a given target. The BCH network has a global block difficulty. Valid blocks must have a hash below the difficulty target calculated from the `nBits` value. The current difficulty target is available here: https://blockexplorer.com/api/status?q=getDifficulty.
### Nonce
To be valid, a block include a **nonce** value that is the solution to the mining process. This proof-of-work is verified by other BCH nodes each time they receive a block.
**NOTE:** The original purpose of the nonce was to manipulate it to find a solution to the mining process. However, because mining devices now have hashrates in the terahash range, the `nonce` field is too small. In practice, most block headers do not include a solution to the mining process in the `nonce`. Instead, miners have try many different Merkle root hashes, which is typically done by changing the coinbase TX. A `nonce` value is nonetheless required.
The `nonce` is a 32-bit (4-byte) field whose value is arbitrarily set by miners to modify the header hash and produce a hash that is less than the difficulty target with the required number of leading zeros (currently 32) satisfies the proof-of-work.
-An arbitrary number miners change to modify the header hash in order to produce a hash less than or equal to the target threshold. If all 32-bit values are tested, the time can be updated or the coinbase transaction can be changed and the Merkle root updated.
+An arbitrary number miners change to modify the header hash in order to produce a hash less than or equal to the target threshold. If all 32-bit values are tested, the time can be updated or the coinbase transaction can be changed and the Merkle root updated.
The nonce is an arbitrarily changed by miners to modify the header hash and produce a hash less than the difficulty target. If all 32-bit values are tested, the time can be updated or the coinbase transaction can be changed and the Merkle root updated.
Any change to the nonce will make the block header hash completely different. Since it is virtually impossible to predict which combination of bits will result in the right hash, many different nonce values are tried, and the hash is recomputed for each value until a hash containing the required number of zero bits as set by the difficulty target is found. The resulting hash has to be a value less than the current difficulty and so will have to have a certain number of leading zero bits to be less than that. As this iterative calculation requires time and resources, the presentation of the block with the correct nonce value constitutes proof-of-work.
It is important to note that the proof-of-work can be verified by computing one hash with the proper content, and is therefore very cheap. The fact that the proof is cheap to verify is as important as the fact that it is expensive to compute.
## Coinbase Transaction
-The first transaction in the body of each block is a special transaction called the **coinbase transaction** which is used to pay miners of the block. The coinbase transaction is required, and must collect and spend any transaction fees paid by transactions included in the block.
+The first transaction in the body of each block is a special transaction called the **coinbase transaction** which is used to pay miners of the block. The coinbase transaction is required, and must collect and spend any transaction fees paid by transactions included in the block.
A valid block is entitled to receive a block subsidy of newly created bitcoincash value, and it must also be spent in the coinbase transaction. Together, the transaction fees and block subsidy are called the **block reward**. A coinbase transaction is invalid if it tries to spend more value than is available from the block reward. The subsidy plus fees is the maximum coinbase payout, but note that it is valid for the coinbase to pay less.
The coinbase transaction must have one input spending from 000000000000000. The field used to provide the signature can contain arbitrary data up to 100 bytes. The coinbase transaction must start with the block height to ensure no two coinbase transactions have the same transaction id (TXID).
The coinbase transaction has the following format:
| Bytes | Name | Data Type | Description
|----------|--------------------|----------------------|--------------
| 32 | hash (null) | char[32] | A 32-byte null, as a coinbase has no previous outpoint.
| 4 | index (UINT32_MAX) | uint32_t | 0xffffffff, as a coinbase has no previous outpoint.
| *Varies* | script bytes | compactSize uint | The number of bytes in the coinbase script, up to a maximum of 100 bytes.
| *Varies* (4) | height | script | The block height of this block. Required parameter. Uses the script language: starts with a data-pushing opcode that indicates how many bytes to push to the stack followed by the block height as a little-endian unsigned integer. This script must be as short as possible, otherwise it may be rejected. The data-pushing opcode is 0x03 and the total size is four bytes.
| *Varies* | coinbase script | *None* | The coinbase field and input parameter: Arbitrary data not exceeding 100 bytes minus the (4) height bytes. Miners commonly place an extra nonce in this field to update the block header Merkle root during hashing.
| 4 | sequence | uint32_t | Sequence number.
Although the coinbase script is arbitrary data, if it includes the bytes used by any signature-checking operations such as `OP_CHECKSIG`,
those signature checks will be counted as signature operations (sigops) towards the block's sigop limit. To avoid this, you can prefix all data with the appropriate push operation. See [Transaction format](#transaction) for details on opcodes.
## Block Serialization
Blocks must be serialized in binary format for transport on the network. Under current BCH consensus rules, a BCH block is valid if its serialized size is not more than 32MB (32,000,000 bytes). All fields described below count towards the serialized size limit.
| Bytes | Name | Data type | Description
|-----------|---------------|-------------------|------------
| 80 | block header | block_header | The block header in the proper format. See [Block Header](#block-header).
| Varies | txn_count | compactSize uint | Total number of transactions in this block, including the coinbase transaction.
| Varies | txns | raw transaction | Each transaction in this block in this block, one after another, in raw transaction format. Transactions must appear in the data stream in the same order their TXIDs appeared in the first row of the [Merkle tree](#merkle-root-hash).
The serialized (raw) form of each block header is hashed as part of the proof-of-work, making the serialized block header part of the BCH consensus rules. As part of the mining process, the block header is hashed repeatedly to create proof-of-work.
BCH uses SHA256(SHA256(Block_Header)) to hash the block header. You must ensure that the block header is in the proper byte-order before hashing. The following serialization rules apply to the block header:
- Both hash fields use double-hashing (`SHA256(SHA256(DATA))`) and are serialized in internal byte order, which means the standard order in which hash message digests are displayed as strings.
- The values for all other fields in the block header are serialized in little-endian order. Note that when displayed via a block browser or query, the ordering is big-endian.
diff --git a/doc/standards/may-2018-reenabled-opcodes.md b/doc/standards/may-2018-reenabled-opcodes.md
index a13e39aba..6b8aee108 100644
--- a/doc/standards/may-2018-reenabled-opcodes.md
+++ b/doc/standards/may-2018-reenabled-opcodes.md
@@ -1,425 +1,425 @@
---
layout: specification
title: Restore disabled script opcodes, May 2018
category: spec
date: 2018-04-05
activation: 1526400000
version: 0.4
updated: 2018-05-23
---
## Introduction
-In 2010 and 2011 the discovery of serious bugs prompted the deactivation of many opcodes in the Bitcoin script language.
+In 2010 and 2011 the discovery of serious bugs prompted the deactivation of many opcodes in the Bitcoin script language.
It is our intention to restore the functionality that some of these opcodes provided in Bitcoin Cash. Rather than simply
re-enable the opcodes, the functionality that they provide has been re-examined and in some cases the opcodes have been
re-designed or new opcodes have been added to address specific issues.
-This document contains the specifications for the opcodes that are to be added in the May 2018 protocol upgrade. We
+This document contains the specifications for the opcodes that are to be added in the May 2018 protocol upgrade. We
anticipate that additional opcodes will be proposed for the November 2018, or later, protocol upgrades.
The opcodes that are to be added are:
|Word |OpCode |Hex |Input |Output | Description |
|-----------|-------|----|--------------|--------|------------------------------------------------------------------|
|OP_CAT |126 |0x7e|x1 x2 |out |Concatenates two byte sequences |
|OP_SPLIT |127 |0x7f|x n |x1 x2 |Split byte sequence *x* at position *n* |
|OP_AND |132 |0x84|x1 x2 |out |Boolean *AND* between each bit of the inputs |
|OP_OR |133 |0x85|x1 x2 |out |Boolean *OR* between each bit of the inputs |
|OP_XOR |134 |0x86|x1 x2 |out |Boolean *EXCLUSIVE OR* between each bit of the inputs |
|OP_DIV |150 |0x96|a b |out |*a* is divided by *b* |
|OP_MOD |151 |0x97|a b |out |return the remainder after *a* is divided by *b* |
|OP_NUM2BIN |128 |0x80|a b |out |convert numeric value *a* into byte sequence of length *b* |
|OP_BIN2NUM |129 |0x81|x |out |convert byte sequence *x* into a numeric value |
Splice operations: `OP_CAT`, `OP_SPLIT`**
Bitwise logic: `OP_AND`, `OP_OR`, `OP_XOR`
Arithmetic: `OP_DIV`, `OP_MOD`
-New operations:
+New operations:
* `x OP_BIN2NUM -> n`, convert a byte sequence `x` into a numeric value
* `n m OP_NUM2BIN -> out`, convert a numeric value `n` into a byte sequence of length `m`
Further discussion of the purpose of these new operations can be found below under *bitwise operations*.
-** A new operation, `OP_SPLIT`, has been designed as a replacement for `OP_SUBSTR`, `OP_LEFT`and `OP_RIGHT`.
+** A new operation, `OP_SPLIT`, has been designed as a replacement for `OP_SUBSTR`, `OP_LEFT`and `OP_RIGHT`.
The original operations can be implemented with varying combinations of `OP_SPLIT`, `OP_SWAP` and `OP_DROP`.
## <a name="data-types"></a>Script data types
-It should be noted that in script operation data values on the stack are interpreted as either byte sequences
-or numeric values. **All data on the stack is interpreted as a byte sequence unless specifically stated as being interpreted
+It should be noted that in script operation data values on the stack are interpreted as either byte sequences
+or numeric values. **All data on the stack is interpreted as a byte sequence unless specifically stated as being interpreted
as a numeric value.**
For accuracy in this specification, a byte sequences is presented as {0x01, 0x02, 0x03}. This sequence is three bytes long, it begins
with a byte of value 1 and ends with a byte of value 3.
The numeric value type has specific limitations:
1. The used encoding is little endian with an explicit sign bit (the highest bit of the last byte).
2. They cannot exceed 4 bytes in length.
3. They must be encoded using the shortest possible byte length (no zero padding)
- 1. There is one exception to rule 3: if there is more than one byte and the most significant bit of the
+ 1. There is one exception to rule 3: if there is more than one byte and the most significant bit of the
second-most-significant-byte is set it would conflict with the sign bit. In this case a single 0x00 or 0x80 byte is allowed
to the left.
4. Zero is encoded as a zero length byte sequence. Single byte positive or negative zero (0x00 or 0x80) are not allowed.
-
+
The new opcode `x OP_BIN2NUM -> out` can be used convert a byte sequence into a numeric value where required.
-The new opcode `x n OP_NUM2BIN` can be used to convert a numeric value into a zero padded byte sequence of length `n`
+The new opcode `x n OP_NUM2BIN` can be used to convert a numeric value into a zero padded byte sequence of length `n`
whilst preserving the sign bit.
## Definitions
-* *Stack memory use*. This is the sum of the size of the elements on the stack. It gives an indication of impact on
+* *Stack memory use*. This is the sum of the size of the elements on the stack. It gives an indication of impact on
memory use by the interpreter.
-* *Operand order*. In keeping with convention where multiple operands are specified the top most stack item is the
+* *Operand order*. In keeping with convention where multiple operands are specified the top most stack item is the
last operand. e.g. `x1 x2 OP_CAT` --> `x2` is the top stack item and `x1` is the next from the top.
-* *empty byte sequence*. Throughout this document `OP_0` is used as a convenient representation of an empty byte
+* *empty byte sequence*. Throughout this document `OP_0` is used as a convenient representation of an empty byte
sequence. Whilst it is a push data op code, its effect is to push an empty byte sequence on to the stack.
## Specification
-Global conditions apply to all operations. These conditions must be checked by the implementation when
+Global conditions apply to all operations. These conditions must be checked by the implementation when
it is possible that they will occur:
* for all e : elements on the stack, `0 <= len(e) <= MAX_SCRIPT_ELEMENT_SIZE`
* for each operator, the required number of operands are present on the stack when the operand is executed
These unit tests should be included for every operation:
1. executing the operation with an input element of length greater than `MAX_SCRIPT_ELEMENT_SIZE` will fail
2. executing the operation with an insufficient number of operands on the stack causes a failure
Operand consumption:
In all cases where not explicitly stated otherwise the operand stack elements are consumed by the operation and replaced with the output.
## Splice operations
### OP_CAT
Opcode (decimal): 126
Opcode (hex): 0x7e
Concatenates two operands.
x1 x2 OP_CAT -> out
-
+
Examples:
* `{Ox11} {0x22, 0x33} OP_CAT -> 0x112233`
-
+
The operator must fail if `len(out) > MAX_SCRIPT_ELEMENT_SIZE`. The operation cannot output elements that violate the constraint on the element size.
Note that the concatenation of a zero length operand is valid.
Impact of successful execution:
* stack memory use is constant
* number of elements on stack is reduced by one
-The limit on the length of the output prevents the memory exhaustion attack and results in the operation having less
+The limit on the length of the output prevents the memory exhaustion attack and results in the operation having less
impact on stack size than existing OP_DUP operators.
Unit tests:
-1. `maxlen_x y OP_CAT -> failure`. Concatenating any operand except an empty vector, including a single byte value
+1. `maxlen_x y OP_CAT -> failure`. Concatenating any operand except an empty vector, including a single byte value
(e.g. `OP_1`), onto a maximum sized array causes failure
-3. `large_x large_y OP_CAT -> failure`. Concatenating two operands, where the total length is greater than
+3. `large_x large_y OP_CAT -> failure`. Concatenating two operands, where the total length is greater than
`MAX_SCRIPT_ELEMENT_SIZE`, causes failure
4. `OP_0 OP_0 OP_CAT -> OP_0`. Concatenating two empty arrays results in an empty array
-5. `x OP_0 OP_CAT -> x`. Concatenating an empty array onto any operand results in the operand, including when
+5. `x OP_0 OP_CAT -> x`. Concatenating an empty array onto any operand results in the operand, including when
`len(x) = MAX_SCRIPT_ELEMENT_SIZE`
-6. `OP_0 x OP_CAT -> x`. Concatenating any operand onto an empty array results in the operand, including when
+6. `OP_0 x OP_CAT -> x`. Concatenating any operand onto an empty array results in the operand, including when
`len(x) = MAX_SCRIPT_ELEMENT_SIZE`
7. `x y OP_CAT -> concat(x,y)`. Concatenating two operands generates the correct result
### OP_SPLIT
*`OP_SPLIT` replaces `OP_SUBSTR` and uses it's opcode.*
Opcode (decimal): 127
Opcode (hex): 0x7f
Split the operand at the given position. This operation is the exact inverse of OP_CAT
x n OP_SPLIT -> x1 x2
where n is interpreted as a numeric value
Examples:
* `{0x00, 0x11, 0x22} 0 OP_SPLIT -> OP_0 {0x00, 0x11, 0x22}`
* `{0x00, 0x11, 0x22} 1 OP_SPLIT -> {0x00} {0x11, 0x22}`
* `{0x00, 0x11, 0x22} 2 OP_SPLIT -> {0x00, 0x11} {0x22}`
* `{0x00, 0x11, 0x22} 3 OP_SPLIT -> {0x00, 0x11, 0x22} OP_0`
Notes:
* this operator has been introduced as a replacement for the previous `OP_SUBSTR`, `OP_LEFT`and `OP_RIGHT`. All three operators can be
simulated with varying combinations of `OP_SPLIT`, `OP_SWAP` and `OP_DROP`. This is in keeping with the minimalist philosophy where a single
primitive can be used to simulate multiple more complex operations.
* `x` is split at position `n`, where `n` is the number of bytes from the beginning
-* `x1` will be the first `n` bytes of `x` and `x2` will be the remaining bytes
+* `x1` will be the first `n` bytes of `x` and `x2` will be the remaining bytes
* if `n == 0`, then `x1` is the empty array and `x2 == x`
* if `n == len(x)` then `x1 == x` and `x2` is the empty array.
* if `n > len(x)`, then the operator must fail.
* `x n OP_SPLIT OP_CAT -> x`, for all `x` and for all `0 <= n <= len(x)`
-
+
The operator must fail if:
* `!isnum(n)`. Fail if `n` is not a numeric value.
* `n < 0`. Fail if `n` is negative.
* `n > len(x)`. Fail if `n` is too high.
Impact of successful execution:
* stack memory use is constant (slight reduction by `len(n)`)
* number of elements on stack is constant
Unit tests:
* `OP_0 0 OP_SPLIT -> OP_0 OP_0`. Execution of OP_SPLIT on empty array results in two empty arrays.
* `x 0 OP_SPLIT -> OP_0 x`
* `x len(x) OP_SPLIT -> x OP_0`
* `x (len(x) + 1) OP_SPLIT -> FAIL`
* include successful unit tests
## Bitwise logic
-The bitwise logic operators expect 'byte sequence' operands. The operands must be the same length.
+The bitwise logic operators expect 'byte sequence' operands. The operands must be the same length.
* In the case of 'byte sequence' operands `OP_CAT` can be used to pad a shorter byte sequence to an appropriate length.
-* In the case of 'byte sequence' operands where the length of operands is not known until runtime a sequence of 0x00 bytes
+* In the case of 'byte sequence' operands where the length of operands is not known until runtime a sequence of 0x00 bytes
(for use with `OP_CAT`) can be produced using `OP_0 n OP_NUM2BIN`
-* In the case of numeric value operands `x n OP_NUM2BIN` can be used to pad a numeric value to length `n` whilst preserving
+* In the case of numeric value operands `x n OP_NUM2BIN` can be used to pad a numeric value to length `n` whilst preserving
the sign bit.
### OP_AND
Opcode (decimal): 132
Opcode (hex): 0x84
Boolean *and* between each bit in the operands.
x1 x2 OP_AND -> out
Notes:
* where `len(x1) == 0` and `len(x2) == 0` the output will be an empty array.
The operator must fail if:
1. `len(x1) != len(x2)`. The two operands must be the same size.
Impact of successful execution:
* stack memory use reduced by `len(x1)`
* number of elements on stack is reduced by one
Unit tests:
1. `x1 x2 OP_AND -> failure`, where `len(x1) != len(x2)`. The two operands must be the same size.
2. `x1 x2 OP_AND -> x1 & x2`. Check valid results.
### OP_OR
Opcode (decimal): 133
Opcode (hex): 0x85
Boolean *or* between each bit in the operands.
x1 x2 OP_OR -> out
The operator must fail if:
1. `len(x1) != len(x2)`. The two operands must be the same size.
Impact of successful execution:
* stack memory use reduced by `len(x1)`
* number of elements on stack is reduced by one
Unit tests:
1. `x1 x2 OP_OR -> failure`, where `len(x1) != len(x2)`. The two operands must be the same size.
2. `x1 x2 OP_OR -> x1 | x2`. Check valid results.
### OP_XOR
Opcode (decimal): 134
Opcode (hex): 0x86
Boolean *xor* between each bit in the operands.
x1 x2 OP_XOR -> out
The operator must fail if:
1. `len(x1) != len(x2)`. The two operands must be the same size.
Impact of successful execution:
* stack memory use reduced by `len(x1)`
* number of elements on stack is reduced by one
Unit tests:
1. `x1 x2 OP_XOR -> failure`, where `len(x1) != len(x2)`. The two operands must be the same size.
2. `x1 x2 OP_XOR -> x1 xor x2`. Check valid results.
-
+
## Arithmetic
#### Note about canonical form and floor division
-Operands for all arithmetic operations are assumed to be numeric values and must be in canonical form.
+Operands for all arithmetic operations are assumed to be numeric values and must be in canonical form.
See [data types](#data-types) for more information.
**Floor division**
Note that when considering integer division and modulo operations with negative operands, the rules applied in the C language and most
languages (with Python being a notable exception) differ from the strict mathematical definition. Script follows the C language set of
rules. Namely:
1. Non-integer quotients are rounded towards zero
2. The equation `(a/b)*b + a%b == a` is satisfied by the results
3. From the above equation it follows that: `a%b == a - (a/b)*b`
4. In practice if `a` is negative for the modulo operator the result will be negative or zero.
### OP_DIV
Opcode (decimal): 150
Opcode (hex): 0x96
-
+
Return the integer quotient of `a` and `b`. If the result would be a non-integer it is rounded *towards* zero.
a b OP_DIV -> out
-
+
where a and b are interpreted as numeric values
-
+
The operator must fail if:
1. `!isnum(a) || !isnum(b)`. Fail if either operand is not a numeric value.
1. `b == 0`. Fail if `b` is equal to any type of zero.
Impact of successful execution:
* stack memory use reduced
* number of elements on stack is reduced by one
Unit tests:
1. `a b OP_DIV -> failure` where `!isnum(a)` or `!isnum(b)`. Both operands must be numeric values
-2. `a 0 OP_DIV -> failure`. Division by positive zero (all sizes), negative zero (all sizes), `OP_0`
+2. `a 0 OP_DIV -> failure`. Division by positive zero (all sizes), negative zero (all sizes), `OP_0`
3. `27 7 OP_DIV -> 3`, `27 -7 OP_DIV -> -3`, `-27 7 OP_DIV -> -3`, `-27 -7 OP_DIV -> 3`. Check negative operands.
*Pay attention to sign*.
4. check valid results for operands of different lengths `0..4`
-
+
### OP_MOD
Opcode (decimal): 151
Opcode (hex): 0x97
-Returns the remainder after dividing a by b. The output will be represented using the least number of bytes required.
+Returns the remainder after dividing a by b. The output will be represented using the least number of bytes required.
a b OP_MOD -> out
where a and b are interpreted as numeric values
The operator must fail if:
1. `!isnum(a) || !isnum(b)`. Fail if either operand is not a numeric value.
1. `b == 0`. Fail if `b` is equal to any type of zero.
Impact of successful execution:
* stack memory use reduced (one element removed)
* number of elements on stack is reduced by one
Unit tests:
1. `a b OP_MOD -> failure` where `!isnum(a)` or `!isnum(b)`. Both operands must be numeric values.
-2. `a 0 OP_MOD -> failure`. Division by positive zero (all sizes), negative zero (all sizes), `OP_0`
+2. `a 0 OP_MOD -> failure`. Division by positive zero (all sizes), negative zero (all sizes), `OP_0`
3. `27 7 OP_MOD -> 6`, `27 -7 OP_MOD -> 6`, `-27 7 OP_MOD -> -6`, `-27 -7 OP_MOD -> -6`. Check negative operands.
*Pay attention to sign*.
4. check valid results for operands of different lengths `0..4` and returning result zero
## New operations
### OP_NUM2BIN
*`OP_NUM2BIN` replaces `OP_LEFT` and uses it's opcode*
Opcode (decimal): 128
Opcode (hex): 0x80
Convert the numeric value into a byte sequence of a certain size, taking account of the sign bit.
The byte sequence produced uses the little-endian encoding.
a b OP_NUM2BIN -> x
-
+
where `a` and `b` are interpreted as numeric values. `a` is the value to be converted to a byte sequence,
it can be up to `MAX_SCRIPT_ELEMENT_SIZE` long and does not need to be minimally encoded.
`b` is the desired size of the result, it must be minimally encoded and <= 4 bytes long. It must be possible for the
value `a` to be encoded in a byte sequence of length `b` without loss of data.
See also `OP_BIN2NUM`.
Examples:
* `2 4 OP_NUM2BIN -> {0x02, 0x00, 0x00, 0x00}`
* `-5 4 OP_NUM2BIN -> {0x05, 0x00, 0x00, 0x80}`
The operator must fail if:
1. `b` is not a minimally encoded numeric value.
2. `b < len(minimal_encoding(a))`. `a` must be able to fit into `b` bytes.
3. `b > MAX_SCRIPT_ELEMENT_SIZE`. The result would be too large.
Impact of successful execution:
* stack memory use will be increased by `b - len(a) - len(b)`, maximum increase is when `b = MAX_SCRIPT_ELEMENT_SIZE`
* number of elements on stack is reduced by one
Unit tests:
1. `a b OP_NUM2BIN -> failure` where `!isnum(b)`. `b` must be a minimally encoded numeric value.
2. `256 1 OP_NUM2BIN -> failure`. Trying to produce a byte sequence which is smaller than the minimum size needed to
contain the numeric value.
3. `1 (MAX_SCRIPT_ELEMENT_SIZE+1) OP_NUM2BIN -> failure`. Trying to produce an array which is too large.
4. other valid parameters with various results
### OP_BIN2NUM
*`OP_BIN2NUM` replaces `OP_RIGHT` and uses it's opcode*
Opcode (decimal): 129
Opcode (hex): 0x81
Convert the byte sequence into a numeric value, including minimal encoding. The byte sequence must encode the value in little-endian encoding.
a OP_BIN2NUM -> x
See also `OP_NUM2BIN`.
Notes:
* if `a` is any form of zero, including negative zero, then `OP_0` must be the result
-
+
Examples:
* `{0x02, 0x00, 0x00, 0x00, 0x00} OP_BIN2NUM -> 2`. `0x0200000000` in little-endian encoding has value 2.
* `{0x05, 0x00, 0x80} OP_BIN2NUM -> -5` - `0x050080` in little-endian encoding has value -5.
The operator must fail if:
1. the numeric value is out of the range of acceptable numeric values (currently size is limited to 4 bytes)
Impact of successful execution:
* stack memory use is equal or less than before. Minimal encoding of the byte sequence can produce a result which is shorter.
* the number of elements on the stack remains constant
Unit tests:
-1. `a OP_BIN2NUM -> failure`, when `a` is a byte sequence whose numeric value is too large to fit into the numeric value
- type, for both positive and negative values.
+1. `a OP_BIN2NUM -> failure`, when `a` is a byte sequence whose numeric value is too large to fit into the numeric value
+ type, for both positive and negative values.
2. `{0x00} OP_BIN2NUM -> OP_0`. Byte sequences, of various lengths, consisting only of zeros should produce an OP_0 (zero
- length array).
+ length array).
3. `{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} OP_BIN2NUM -> 1`. A large byte sequence, whose numeric value would fit in the numeric value
type, is a valid operand.
4. The same test as above, where the length of the input byte sequence is equal to MAX_SCRIPT_ELEMENT_SIZE.
5. `{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80} OP_BIN2NUM -> -1`. Same as above, for negative values.
6. `{0x80} OP_BIN2NUM -> OP_0`. Negative zero, in a byte sequence, should produce zero.
7. `{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80} OP_BIN2NUM -> OP_0`. Large negative zero, in a byte sequence, should produce zero.
8. other valid parameters with various results
-
+
## Reference implementation
* OP_AND, OP_OR, OP_XOR: https://reviews.bitcoinabc.org/D1211
* OP_DIV and OP_MOD: https://reviews.bitcoinabc.org/D1212
* OP_CAT: https://reviews.bitcoinabc.org/D1227
* OP_SPLIT: https://reviews.bitcoinabc.org/D1228
* OP_BIN2NUM: https://reviews.bitcoinabc.org/D1220
* OP_NUM2BIN: https://reviews.bitcoinabc.org/D1222
## References
<a name="op_codes">[1]</a> https://en.bitcoin.it/wiki/Script#Opcodes
diff --git a/doc/standards/transaction.md b/doc/standards/transaction.md
index 4a6fb4e61..de2659469 100644
--- a/doc/standards/transaction.md
+++ b/doc/standards/transaction.md
@@ -1,235 +1,235 @@
---
layout: specification
title: Transaction Spec for Bitcoin Cash ⚠️ out of date ⚠️
category: spec
date: 2017-08-26
activation: 1515888000
version: 1.0
---
This section of the Bitcoin Cash (BCH) specification ("spec") documents the **transaction data structure** for implementing a compatible BCH client, including transaction format, opcodes, and examples.
This spec is based on the Bitcoin ABC implementation of the [Bitcoin Cash](https://www.bitcoincash.org/) protocol.
Developer resources:
- [Bitcoin ABC source code](https://github.com/Bitcoin-ABC/bitcoin-abc)
- [Bitcoin ABC developer documentation](https://www.bitcoinabc.org/doc/dev/)
## Transaction
A transaction is one of the two base primitives in the BCH system, the other being a block. Primitive in this context means that it is one of the data types for which the BCH spec provides built-in support.
A transaction is a transfer of BCH that is broadcast to the network and collected into blocks. A transaction typically references previous transaction outputs as new transaction inputs and dedicates all input Bitcoincash values to new outputs. Transactions are not encrypted, so it is possible to browse and view every transaction ever collected into a block. Once transactions are buried under enough confirmations they can be considered irreversible.
Transaction comprises a signature and redeem script pair, which provides flexibility in releasing outputs. A serialized transaction contains an input and an output.
Source code: https://github.com/Bitcoin-ABC/bitcoin-abc/blob/master/src/primitives/transaction.h.
### Transaction requirements
A transaction that meets the criteria documented here is said to be standard. Standard transactions are accepted into the mempool and relayed by nodes on the network. This ensures that nodes have a similar looking mempool so that the system behave predictably. Standard transaction outputs nominate addresses, and the redemption of any future inputs requires a relevant signature.
Transaction requirements:
- Transaction size: < 100k
- Version must be 1 or 2
- Signature script must be data push only
- Script size must be 1650 or less
NOTE: A BCH node should be able to process non-standard transactions as well. Even if a node cannot successfully relay a non-standard transaction, it should not crash if it ends up having to process one of those transactions.
### Transaction Input
Inputs to a transaction include the outpoint, signature script, and sequence.
An input is a reference to an output from a previous transaction. Multiple inputs are often listed in a transaction. All of the new transaction's input values (that is, the total coin value of the previous outputs referenced by the new transaction's inputs) are added up, and the total (less any transaction fee) is completely used by the outputs of the new transaction. Previous tx is a hash of a previous transaction. Index is the specific output in the referenced transaction. scriptSig is the first half of a script (discussed in more detail later).
### Transaction Output
Outputs from a transaction include the BCH amount and redeem script which is used to spend the output and sets up parameters for the signature script. Redeem scripts should not use OP_CODES.
## OpCodes
-The opcodes used in the pubkey scripts of standard transactions are as follows.
+The opcodes used in the pubkey scripts of standard transactions are as follows.
See also the source code: https://github.com/Bitcoin-ABC/bitcoin-abc/blob/master/src/script/script.h.
### 0x00 to 0x4e
-There are arious data pushing opcodes from 0x00 to 0x4e (1--78) that must be used must be used to push signatures and public keys onto the stack.
+There are arious data pushing opcodes from 0x00 to 0x4e (1--78) that must be used must be used to push signatures and public keys onto the stack.
### OP_TRUE/OP_1, OP_2 through OP_16
`OP_TRUE`/`OP_1` (0x51) and `OP_2` through `OP_16` (0x52--0x60) push the values 1 through 16 to the stack.
### OP_CHECKSIG
`OP_CHECKSIG` consumes a signature and a full public key, and pushes true onto the stack if the transaction data specified by the SIGHASH flag was converted into the signature using the same ECDSA private key that generated the public key. Otherwise, it pushes false onto the stack.
### OP_DUP
`OP_DUP` pushes a copy of the topmost stack item on to the stack.
### OP_HASH160
`OP_HASH160` consumes the topmost item on the stack, computes the RIPEMD160(SHA256()) hash of that item, and pushes that hash onto the stack.
-### OP_EQUAL
+### OP_EQUAL
`OP_EQUAL` consumes the top two items on the stack, compares them, and pushes true onto the stack if they are the same, false if not.
### OP_VERIFY
`OP_VERIFY` consumes the topmost item on the stack. If that item is zero (false) it terminates the script in failure.
### OP_EQUALVERIFY
`OP_EQUALVERIFY` runs `OP_EQUAL` and then `OP_VERIFY` in sequence.
### OP_CHECKMULTISIG
`OP_CHECKMULTISIG` consumes the value (n) at the top of the stack, consumes that many of the next stack levels (public keys), consumes the value (m) now at the top of the stack, and consumes that many of the next values (signatures) plus one extra value.
The "one extra value" it consumes is the result of an off-by-one error in the original Bitcoin implementation. This value is not used in Bitcoincash, so signature scripts prefix the list of secp256k1 signatures with a single OP_0 (0x00).
`OP_CHECKMULTISIG` compares the first signature against each public key until it finds an ECDSA match. Starting with the subsequent public key, it compares the second signature against each remaining public key until it finds an ECDSA match. The process is repeated until all signatures have been checked or not enough public keys remain to produce a successful result.
-Because public keys are not checked again if they fail any signature comparison, signatures must be placed in the signature script using the same order as their corresponding public keys were placed in the pubkey script or redeem script.
+Because public keys are not checked again if they fail any signature comparison, signatures must be placed in the signature script using the same order as their corresponding public keys were placed in the pubkey script or redeem script.
-The `OP_CHECKMULTISIG` verification process requires that signatures in the signature script be provided in the same order as their corresponding public keys in the pubkey script or redeem script.
+The `OP_CHECKMULTISIG` verification process requires that signatures in the signature script be provided in the same order as their corresponding public keys in the pubkey script or redeem script.
### OP_RETURN
`OP_RETURN` terminates the script in failure when executed.
## Address Conversion
The hashes used in P2PKH and P2SH outputs are commonly encoded as Bitcoincash addresses. This is the procedure to encode those hashes and decode the addresses.
First, get your hash. For P2PKH, you RIPEMD-160(SHA256()) hash a ECDSA public key derived from your 256-bit ECDSA private key (random data). For P2SH, you RIPEMD-160(SHA256()) hash a redeem script serialized in the format used in raw transactions.
Taking the resulting hash:
1. Add an address version byte in front of the hash. The version bytes commonly used by Bitcoincash are:
* 0x00 for P2PKH addresses on the main Bitcoincash network (mainnet)
* 0x6f for P2PKH addresses on the Bitcoincash testing network (testnet)
* 0x05 for P2SH addresses on mainnet
* 0xc4 for P2SH addresses on testnet
2. Create a copy of the version and hash; then hash that twice with SHA256: `SHA256(SHA256(version . hash))`
3. Extract the first four bytes from the double-hashed copy. These are used as a checksum to ensure the base hash gets transmitted
correctly.
4. Append the checksum to the version and hash, and encode it as a base58 string: <!--[-->`BASE58(version . hash . checksum)`<!--]-->
-
+
The code can be traced using the [base58 header file][core base58.h].
To convert addresses back into hashes, reverse the base58 encoding, extract the checksum, repeat the steps to create the checksum and compare it against the extracted checksum, and then remove the version byte.
## Raw Transaction Format
Bitcoincash transactions are broadcast between peers in a serialized byte format, called raw format. It is this form of a transaction which is SHA256(SHA256()) hashed to create the TXID and, ultimately, the merkle root of a block containing the transaction---making the transaction format part of the consensus rules.
Bitcoincash Core and many other tools print and accept raw transactions encoded as hex.
A raw transaction has the following top-level format:
| Bytes | Name | Data Type | Description
|----------|--------------|---------------------|-------------
| 4 | version | `uint32_t` | Transaction version number; currently version 1. Programs creating transactions using newer consensus rules may use higher version numbers.
| *Varies* | tx_in count | `compactSize uint` | Number of inputs in this transaction.
| *Varies* | tx_in | `txIn` | Transaction inputs. See description of txIn below.
| *Varies* | tx_out count | `compactSize uint` | Number of outputs in this transaction.
| *Varies* | tx_out | `txOut` | Transaction outputs. See description of txOut below.
-| 4 | lock_time | `uint32_t` | A time (Unix epoch time) or block number.
+| 4 | lock_time | `uint32_t` | A time (Unix epoch time) or block number.
A transaction may have multiple inputs and outputs, so the txIn and txOut structures may recur within a transaction. CompactSize unsigned
integers are a form of variable-length integers; they are described in CompactSize unsigned integer.
## TxIn: Transaction Input
Each non-coinbase input spends an outpoint from a previous transaction.
| Bytes | Name | Data Type | Description
|----------|------------------|----------------------|--------------
| 36 | previous_output | outpoint | The previous outpoint being spent. See description of outpoint below.
| *Varies* | script bytes | compactSize uint | The number of bytes in the signature script. Maximum is 10,000 bytes.
| *Varies* | signature script | char[] | Script that satisfies conditions in the outpoint's pubkey script. Should only contain data pushes.
| 4 | sequence | uint32_t | Sequence number. Default is 0xffffffff.
## Outpoint
The outpoint is a reference to an output from a previous transaction. Because a single transaction can include multiple outputs, the outpoint structure includes both a TXID and an output index number to refer to the specific part of a specific output.
| Bytes | Name | Data Type | Description
|-------|-------|-----------|--------------
| 32 | hash | char[32] | The TXID of the transaction holding the output to spend. The TXID is a hash provided here in internal byte order.
| 4 | index | uint32_t | The output index number of the specific output to spend from the transaction. The first output is 0x00000000.
-## TxOut: Transaction Output
+## TxOut: Transaction Output
Each output spends a certain number of Satoshis, placing them under control of anyone who can satisfy the provided pubkey script.
| Bytes | Name | Data Type | Description
|----------|-----------------|------------------|--------------
| 8 | value | int64_t | Number of Satoshis to spend. May be zero; the sum of all outputs may not exceed the sum of Satoshis previously spent to the outpoints provided in the input section. (Exception: coinbase transactions spend the block subsidy and collected transaction fees.)
| 1+ | pk_script bytes | compactSize uint | Number of bytes in the pubkey script. Maximum is 10,000 bytes.
| *Varies* | pk_script | char[] | Defines the conditions which must be satisfied to spend this output.
## CompactSize Unsigned Integers
The raw transaction format and several peer-to-peer network messages use a type of variable-length integer to indicate the number of bytes in a following piece of data.
The source code and this document refers to these variable length integers as compactSize. Because it's used in the transaction format, the format of compactSize unsigned integers is part of the consensus rules.
For numbers from 0 to 252, compactSize unsigned integers look like regular unsigned integers. For other numbers up to 0xffffffffffffffff, a byte is prefixed to the number to indicate its length---but otherwise the numbers look like regular unsigned integers in little-endian order. For example, the number 515 is encoded as 0xfd0302.
| Value | Bytes Used | Format
|-----------------------------------------|------------|-----------------------------------------
| >= 0 && <= 252 | 1 | uint8_t
| >= 253 && <= 0xffff | 3 | 0xfd followed by the number as uint16_t
| >= 0x10000 && <= 0xffffffff | 5 | 0xfe followed by the number as uint32_t
| >= 0x100000000 && <= 0xffffffffffffffff | 9 | 0xff followed by the number as uint64_t
## Signature Script
The purpose of the signature script (scriptSig) is to ensure that the spender is a legitimate spender, that is, evidence of private key held.
The scriptSig contains two components: a signature and a public key. The public key must match the hash given in the script of the redeemed output. The public key is used to verify the redeemers signature, which is the second component. More precisely, the second component is an ECDSA signature over a hash of a simplified version of the transaction. It, combined with the public key, proves the transaction was created by the real owner of the address in question.
Signature scripts are not signed, so anyone can modify them. This means signature scripts should only contain data and data-pushing opcodes which can't be modified without causing the pubkey script to fail. Placing non-data-pushing opcodes in the signature script currently makes a transaction non-standard, and future consensus rules may forbid such transactions altogether. (Non-data-pushing opcodes are already forbidden in signature scripts when spending a P2SH pubkey script.)
-
+
## Sequence
Check lock time verify (s4)
Check sequence verify (s4)
## Standard Transaction Format Examples
### P2SH
23-bytes
OP_HASH160
<reedem script hash>
OP_EQUAL
Use address version=1 and hash=<reedem script hash>
### P2PKH
25 bytes
OP_DUP
OP_HASH160
<public key hash>
OP_EQUALVERIFY
OP_CHECKSIG
- Use address version=0 and hash=<public key hash>
+ Use address version=0 and hash=<public key hash>
### P2PK
35 or 67 bytes
<public key>
OP_CHECKSIG
Use address version=0 and hash=HASH160(<public key>)
### Bare multisig
<n: [0-20]>
<pubkey 0>
<pubkey n>
<(null)>
OP_CHECKMULTISIG
NOTE: Bare multisig (which isn't wrapped into P2SH) is limited to 3-of-3.
### Data carrier
Limited to one per transaction
Limited to 223 bytes
OP_RETURN
<push data>
NOTE: Multiple pushes of data are allowed.

File Metadata

Mime Type
text/x-diff
Expires
Thu, May 22, 03:07 (15 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5866352
Default Alt Text
(80 KB)

Event Timeline