kaspanet / rusty-kaspa

Kaspa full-node and related libraries in the Rust programming language. This is a stable version at the initial rollout phases.
ISC License
371 stars 118 forks source link

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

Open biryukovmaxim opened 1 week ago

biryukovmaxim commented 1 week ago

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

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.