Skip to content

Latest commit

 

History

History
144 lines (122 loc) · 4.89 KB

bip-0ZZZ.mediawiki

File metadata and controls

144 lines (122 loc) · 4.89 KB

  BIP: ZZZ
  Layer: Consensus (soft fork)
  Title: OP_PUSHTXDATA
  Author: Johnson Lau <jl2012@xbt.hk>
  Comments-Summary: No comments yet.
  Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP-0ZZZ
  Status: Draft
  Type: Standards Track
  Created: 2017-07-19
  License: BSD-3-Clause
           CC0-1.0

Table of Contents

Abstract

This BIP defines a new operation OP_PUSHTXDATA in Merklized Script Version 0.

Motivation

Covenant: outputs must follow a pre-specified pattern

Vault: require an extra step to spend deep cold storage

Fine-tuned transaction signing, e.g. "fees must be at least 100 satoshis per weight unit", "number of outputs must not be bigger than number of inputs", "signing only 2 outputs", "values of outputs X and Y must not be the same"

(To be completed)

Specification

The following specification is applicable to scriptKeyCode of MSV0, and scriptWitCode for MSV0 and P2WPKV0.

A new operation OP_PUSHTXDATA is defined, with the value of 0xbb. The top stack item MUST be a CScriptNum from 0 to 15 or the evaluation fails. The value determines the type of TXDATA to be pushed. If the TXDATA type is smaller than 10, it is removed from the stack and a single value is returned to the top of stack. All values returned are CScriptNum.

TXDATA type Name Value returned to stack
0 TXDATA_THIS_VIN_INDEX Index of the current input
1 TXDATA_VIN_SIZE Number of inputs in the transaction
2 TXDATA_VOUT_SIZE Number of outputs in the transaction
3 TXDATA_THIS_VIN_VALUE Value of the current input (in satoshi)
4 TXDATA_FEE The fees paid by the transaction (in satoshi)
5 TXDATA_VERSION Transaction nVersion cast to an unsigned integer
6 TXDATA_LOCKTIME Transaction nLockTime
7 TXDATA_BASE_SIZE Transaction size without witness serialization (in bytes)
8 TXDATA_TOTAL_SIZE Transaction size with witness serialization (in bytes)
9 TXDATA_WEIGHT Transaction weight

If the TXDATA type is 10 or greater, the second highest stack item is a CScriptNum determining the index. The script MUST fail if the index value is smaller than -1. If the index value is -1, it is evaluated as index of the current input. The top two stack items are removed, and one or more items are returned to the stack according to the TXDATA type and index. If the specified input or output does not exist, the script MUST fail.

TXDATA type Name First returned value Second returned value Third returned value
10 TXDATA_VIN_PREVOUT prevout hash of the specified input prevout index of the specified input
11 TXDATA_VIN_SEQUENCE nSequence value of the specified input
12 TXDATA_VIN prevout hash of the specified input prevout index of the specified input nSequence value of the specified input
13 TXDATA_VOUT_VALUE Value of the specified output
14 TXDATA_VOUT_SCRIPTPUBKEY scriptPubKey of the specified output
15 TXDATA_VOUT Value of the specified output (in satoshi) scriptPubKey of the specified output

For example, if the type is TXDATA_VIN, 2 items are removed from and 3 items are returned to the stack, with the nSequence as the final top stack value.

prevout index, nSequence, and output value are returned as <code>CScriptNum. prevout hashes are returned as 32-byte little endian value, with the same byte sequence used in transaction serialization. scriptPubKey are returned as the actual script. For example, if the scriptPubKey is P2WSH, the returned vector size is 34 bytes (0x0020{32 bytes hash}). If the size of scriptPubKey is bigger than 520 bytes, the script MUST fail.

Rationale

Examples

Backward compatibility

As a soft fork, older software will continue to operate without modification. Non-upgraded nodes, however, will consider MSV0 and P2WPKV0 programs as anyone-can-spend scripts.

Deployment

Exact details TBD.

Reference Implementation

https://github.com/jl2012/bitcoin/commits/vault

Credits

References

Copyright

This document is dual licensed as BSD 3-clause, and Creative Commons CC0 1.0 Universal.