Skip to content

KIP 17#32

Open
someone235 wants to merge 20 commits into
kaspanet:masterfrom
someone235:kip17
Open

KIP 17#32
someone235 wants to merge 20 commits into
kaspanet:masterfrom
someone235:kip17

Conversation

@someone235
Copy link
Copy Markdown
Contributor

No description provided.

@someone235 someone235 marked this pull request as ready for review December 26, 2025 11:59
@someone235 someone235 changed the title KIP 17 initial draft KIP 17 Dec 26, 2025
Comment thread kip-0017.md

#### Transaction Level Introspection Opcodes:

1. `OpTxVersion` (0xb2): Returns the version of the transaction.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from reference implementation, returned as script number. could be a general compact information valid for all returned number

Comment thread kip-0017.md Outdated

1. `OpTxVersion` (0xb2): Returns the version of the transaction.
2. `OpTxLockTime` (0xb5): Returns the locktime field of the transaction.
3. `OpTxSubnetId` (0xb6): Returns the subnetwork ID of the transaction.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from reference implementation, returned as raw bytes

Comment thread kip-0017.md Outdated
3. `OpTxSubnetId` (0xb6): Returns the subnetwork ID of the transaction.
4. `OpTxGas` (0xb7): Returns the gas field of the transaction.
5. `OpTxPayloadLen` (0xc4): Returns the payload length of the transaction.
6. `OpTxPayloadSubstr` (0xb8): Returns the payload substring of the transaction from `start` to `end`. Returns error for invalid ranges, or when `end-start > MAX_SCRIPT_ELEMENT_SIZE = 520`.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • invalid ranges implicitly means 1. out of bounds relative to provided bytes or 2. start > end, might be interesting to specify these two cases (implementation does a difference in term of returned error).
  • Substr could be confusing, implementation does more of a "slice" operated on bytes

Comment thread kip-0017.md Outdated

#### Input/Output Introspection Opcodes:

1. `OpTxInputSpkLen(idx)`: (0xc5) Returns the script public key length of the specified input.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from reference implementation, positive and 4-bytes script num encoded, valid for all index-like args, can be generalized maybe

Comment thread kip-0017.md
  Status: Draft
```

## Abstract
Copy link
Copy Markdown

@IzioDev IzioDev May 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion, add txscript engine minimal encoding relaxation on stack data consumption, with related PR: kaspanet/rusty-kaspa#813 (the PR contains multiple commits and they aren't all related to this addition, but I think PR link is sufficient)

Comment thread kip-0017.md Outdated
6. `OpTxInputScriptSigSubstr(idx, start, end)`: (0xca) Returns the script signature substring of the input from `start` to `end`. Returns error for invalid ranges, or when `end-start > MAX_SCRIPT_ELEMENT_SIZE = 520`.
7. `OpOutpointTxId(idx)` (0xba): Returns the transaction ID of the outpoint.
8. `OpOutpointIndex` (0xbb): Returns the index of the outpoint.
9. `OpTxInputSeq(idx)` (0xbd): Returns the sequence number of the input.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as LE raw bytes, not script num (maybe worth a motivation)

Comment thread kip-0017.md Outdated

1. `OpCat(str1, str2)`: (0x7e) Concatenates two byte strings. Returns error if the resulting string exceeds `MAX_SCRIPT_ELEMENT_SIZE = 520` [2].
2. `OpSubstr(str, start, end)`: (0x7f) Returns the substring of a byte string (from start (inclusive) until end (exclusive)). Returns error for invalid ranges, or when `end-start > MAX_SCRIPT_ELEMENT_SIZE = 520`.
3. `OpBlake2bWithKey(data, key)`: (0xa7) Returns the Blake2b hash of the data with the key used for domain separation.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we probably should specify fixed 32-bytes length

Comment thread kip-0017.md Outdated

### 2. Activation

The features introduced in this KIP are activated based on DAA score:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we mention based on consensus flag as of now and later controlled by DAA score?

Comment thread kip-0017.md Outdated

For example, we can implement a simple covenant that requires us to increase a counter stored in the transaction payload every time the UTXO is spent, and forces us to send the new transaction to the same scriptPubKey:

Given siganture script of the form: `<PREV_TX_REST> <PREV_TX_PAYLOAD>`, the scriptPubKey will be:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo signature

Comment thread kip-0017.md Outdated
}
```

In general, once we can encode some state transition function δ in script, we can validate that `δ(prev_payload,tx) = new_payload`, where δ can also introduce some constraints on `tx` using introspection opcodes (checking its signautre, enforcing a locktime, etc).
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo signature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants