summaryrefslogtreecommitdiff
path: root/bip-noreplay.mediawiki
blob: efd1a2cb9158d661278e08223f824b0f7a387f46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<pre>
  BIP: ?
  Layer: Consensus (soft fork)
  Title: Generic anti-replay protection using Script
  Author: Luke Dashjr <luke+bip@dashjr.org>
  Comments-Summary: No comments yet.
  Comments-URI: FIXME
  Status: Draft
  Type: Standards Track
  Created: 2017-01-26
  License: BSD-2-Clause
</pre>

==Abstract==

This BIP describes a new opcode (OP_CHECKBLOCKATHEIGHT) for the Bitcoin scripting system that allows construction of transactions which are valid only on specific blockchains.

==Copyright==

This BIP is licensed under the BSD 2-clause license.

==Specification==

OP_CHECKBLOCKATHEIGHT redefines the existing NOP5 opcode.

When executed, if any of the following conditions are true, the script interpreter will terminate with an error:

* the stack has fewer than 2 elements; or
* the top item on the stack is not interpretable as a minimal-length CScriptNum; or
* the top item on the stack, when interpreted as a block height (see below) is not within the range of allowed blocks; or
* the second-to-top item on the stack, when interpreted as a block hash, has leading zeros; or
* the second-to-top item on the stack does not match the block hash of the block specified by the top item on the stack interpreted as a height.

Otherwise, script execution will continue as if a NOP had been executed.

FIXME: some way to mask out parts of the block hash for gambling/deterministic-random applications?

===Block height interpretation and limits===

The specified block height may be either a negative number to specify a relative height, or a positive number for an absolute height.
A value of -1 refers to the block immediately preceding the block the transaction is mined it (but this is not a valid value, note).

The specified height must not be more recent than the previous 100 blocks (that is, the largest negative value allowed is -101), nor older than 262144 blocks prior (ie, the smallest negative value is -262144).

===Deployment===

This BIP will be deployed by "version bits" BIP9 with the '''name''' TBD and using '''bit''' TBD.

For Bitcoin '''mainnet''', the BIP9 '''starttime''' will be TBD (Epoch timestamp TBD) and BIP9 '''timeout''' will be TBD (Epoch timestamp TBD).

For Bitcoin '''mainnet''', the BIP9 '''starttime''' will be TBD (Epoch timestamp TBD) and BIP9 '''timeout''' will be TBD (Epoch timestamp TBD).

==Motivation==

In the event of a permanent blockchain split, some mechanism is desired by which the UTXOs valid in either chain may be spent without the transaction being validly replayable on the other chain.

Additionally, there are some cases in normal Bitcoin operation wherein a wallet may need to respend a payment, but must guarantee its respend cannot be mined in the same block as a previous payment which has been recently conflicted by a double-spend.

==Reference Implementation==

TODO