-
Notifications
You must be signed in to change notification settings - Fork 0
04 Development
Welcome to the NXTChain development guide! This document will help you understand how to use the functions for the three main components: Miner, Node, and Wallet. Let's dive in! ๐
The miner component is responsible for creating new blocks and validating transactions. Below are the key functions and their usage:
This function starts the mining process. It initializes the miner, waits for peers to sync, and then enters the main mining loop.
This function initializes the miner with the necessary configurations. It sets up the debugger, loads the configuration file, and applies the settings.
The node component handles peer-to-peer communication and blockchain synchronization. Below are the key functions and their usage:
This function starts the node and handles peer-to-peer communication. It waits for peers to sync and then enters the main node loop, where it processes user commands and broadcasts messages.
This function initializes the node with the necessary configurations. It sets up the debugger, loads the configuration file, and applies the settings.
The wallet component handles user interactions such as sending and receiving transactions. Below are the key functions and their usage:
This function starts the wallet and provides a menu for user interactions. It allows users to send transactions, receive funds, check balances, view transactions, create wallets, and exit the application.
This function requests unspent transaction outputs (UTXOs) for a given wallet address. It broadcasts a request to the network and waits for a response.
This function calculates the balance of a wallet by summing the amounts of its UTXOs.
This function retrieves UTXOs from a JSON string. It parses the JSON and returns a list of UTXOs.
This function retrieves transactions from a JSON string. It parses the JSON and returns a list of transactions.
- Select Wallet: Choose a wallet to send from.
- Enter Details: Provide the recipient address, amount, and optional fee.
- Confirm: Review and confirm the transaction details.
- Broadcast: The transaction is prepared and broadcasted to the network.
// Example snippet for sending a transaction
fmt.Println("CHOOSE A WALLET TO SEND:")
for i, addr := range walletAddresses {
fmt.Printf("%d | %s\n", i+1, addr)
}
fmt.Print("> ")
var walletIndex int
fmt.Scanln(&walletIndex)
walletIndex--
if walletIndex < 0 || walletIndex >= len(walletAddresses) {
fmt.Println("Invalid wallet index")
start(Peer)
return
}
fmt.Println("SET: " + walletAddresses[walletIndex])
fmt.Print("TO: ")
var to string
fmt.Scanln(&to)
fmt.Print("AMOUNT: ")
var amount float64
fmt.Scanln(&amount)
fmt.Print("FEE (OPTIONAL > 0) IN % 0-100: ")
var fee int64
fmt.Scanln(&fee)This guide provides an overview of the key functions and their usage in the NxtChain project. For more detailed information, refer to the source code and comments within each function.