kaspad Documentation

repository·master·Indexed 19 days ago

https://github.com/kaspanet/kaspad

The deprecated Go reference implementation of a full node for the Kaspa proof-of-work cryptocurrency, based on the PHANTOM protocol. This repository includes the kaspad node, kaspactl RPC client, kaspaminer, and the txscript package for transaction scripting. Note: New development has moved to the Rust implementation (rusty-kaspa), though kaspawallet remains maintained.

Tokens
36.1K
Snippets
133
Records
174
Agent score
68%

What's inside kaspad

  1. Important: kaspad Go implementation is deprecated

    master

    The Go implementation of the kaspad full node is deprecated. The reference implementation has been rewritten in Rust.

    Action required:

    • For all new development, usage, or issues, please use the Rust implementation (rusty-kaspa).
    • Pull requests or issues opened in this repository will be closed without treatment, unless they specifically relate to kaspawallet (which remains maintained).
  2. Use the util package for Kaspa-specific convenience functions

    master
    The util package provides a collection of convenience functions and types specifically designed for working with the Kaspa ecosystem. It is intended to simplify common tasks and provide standardized types used across Kaspa-related projects.
  3. How the Kaspa wire protocol works

    master

    The Kaspa protocol operates by exchanging messages between peers. Every message is prefixed with a header that specifies:

    • The target Kaspa network
    • The message type
    • The message size
    • A checksum for validity verification.

    The wire package handles all header encoding and decoding. It provides a generic Message interface that allows different message types to be passed through channels or functions uniformly. Most concrete message implementations are provided by the package, abstracting away the complexities of marshalling and unmarshalling via Kaspa encoding.

  4. Configure DAG parameters for different Kaspa networks

    master

    The dagconfig package provides predefined configuration parameters for standard Kaspa networks. Developers can switch between networks by selecting the appropriate parameter set, such as MainnetParams or TestnetParams. These parameters are required when performing network-specific operations like generating addresses via util.NewAddressPubKey.

    package main
    
    import (
    	"flag"
    	"fmt"
    	"log"
    
    	"github.com/kaspanet/kaspad/util"
    	"github.com/kaspanet/kaspad/domain/dagconfig"
    )
    
    var testnet = flag.Bool("testnet", false, "operate on the testnet Kaspa network")
    
    // By default (without --testnet), use mainnet.
    var dagParams = &dagconfig.MainnetParams
    
    func main() {
    	flag.Parse()
    
    	// Modify active network parameters if operating on testnet.
    	if *testnet {
    		dagParams = &dagconfig.TestnetParams
    	}
    
    	// later...
    
    	// Create and print new payment address, specific to the active network.
    	pubKey := make([]byte, 32)
    	addr, err := util.NewAddressPubKey(pubKey, dagParams)
    	if err != nil {
    		log.Fatal(err)
    	}
    	fmt.Println(addr)
    }
  5. Run the Simple Sync Stability Tester

    master

    The Simple Sync Stability Tester is a tool used to verify that two connected nodes remain synchronized while one of the nodes is actively mining a chain.

    To run the test, follow these steps:

    1. Install kaspad and simple-sync using go install.
    2. Navigate to the run directory.
    3. Execute the run.sh script.
    go install <path_to_kaspad>
    go install <path_to_simple-sync>
    cd run
    ./run.sh
  6. Run the Orphans stability test

    master

    The orphans tool is used to verify that orphan resolution works correctly and does not cause kaspad to crash. To run the stability tests, you must first install both kaspad and orphans using go install, then execute the provided shell script in the run directory.

    go install
    cd run
    ./run.sh
  7. Install kaspad from source

    master

    To build and install kaspad from source, you must have Go 1.23 or later installed on your system. After installing Go, follow these steps:

    1. Verify your Go version:
      go version
    2. Clone the repository and install the binaries:
      git clone https://github.com/kaspanet/kaspad
      cd kaspad
      go install . ./cmd/...
    3. The kaspad binary and associated utilities will be located in $(go env GOPATH)/bin. Ensure this directory is in your system PATH to run the commands directly.
    $ git clone https://github.com/kaspanet/kaspad
    $ cd kaspad
    $ go install . ./cmd/...
  8. Run the Infra Level Garbage Generator

    master

    The Infra Level Garbage Generator is a stability testing tool designed to send invalid messages to a kaspad node to ensure the node handles malformed data without crashing.

    To run the generator, you must first install both kaspad and infra-level-garbage using go install, then execute the provided shell script within the run directory.

    go install kaspad
    go install infra-level-garbage
    cd run
    ./run.sh
  9. Run the Application Level Garbage Generator

    master

    The Application Level Garbage Generator is a tool designed to test node stability by sending invalid blocks to a node. Its purpose is to verify that the node correctly responds with a reject and does not crash when encountering malformed data.

    # 1. Install kaspad and the garbage generator
    go install kaspad@latest
    go install application-level-garbage@latest
    
    # 2. Navigate to the run directory
    cd run
    
    # 3. Execute the run script
    ./run.sh