Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add KIP-10 Mutual Transaction Opcodes and Hard Fork Support #487

Open
wants to merge 24 commits into
base: master
Choose a base branch
from

Conversation

biryukovmaxim
Copy link
Collaborator

@biryukovmaxim biryukovmaxim commented Jun 16, 2024

Overview

This pull request introduces four new opcodes to the Kaspa scripting language: OpInputSPK, OpOutputSpk, OpInputAmount, and OpOutputAmount. These additions require a hard fork. The new opcodes are specifically designed to support KIP-10 mutual transactions

Features

  • New Opcodes:
    • OpInputSpk: Retrieves the script public key of the input.
    • OpOutputSpk: Retrieves the script public key of the output.
    • OpInputAmount: Retrieves the amount of the input.
    • OpOutputAmount: Retrieves the amount of the output.

Example Usage

The example provided demonstrates common logic that should be used with the new opcodes. The script allows for two main scenarios:

  1. Owner Scenario: The script checks if the input is used by the owner and verifies the owner's signature.
  2. Borrower Scenario: The script allows the input to be consumed if the output with the same index has a value of input + threshold and goes to the P2SH of the script itself. This scenario also includes a check where the threshold is not reached, demonstrating the validation of input and output values.

For detailed code, refer to the example

Motivation

The introduction of these new opcodes and the hard fork support enhances the flexibility and functionality of the Kaspa scripting language.

These changes are part of the implementation of the KIP-10 proposal.

For more information, refer to the KIP-10 research document.

@biryukovmaxim biryukovmaxim marked this pull request as ready for review June 16, 2024 12:04
@michaelsutton michaelsutton deleted the branch kaspanet:master September 11, 2024 18:34
@michaelsutton michaelsutton reopened this Sep 11, 2024
@michaelsutton michaelsutton changed the base branch from dev to master September 11, 2024 18:42
# Conflicts:
#	consensus/src/processes/transaction_validator/transaction_validator_populated.rs
#	crypto/txscript/Cargo.toml
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.

2 participants