### MariaDB Monitor Welcome Message (Bash) Source: https://github.com/signum-network/signum-node/blob/develop/DB_SETUP_MARIADB.md This is an example of the welcome message displayed when connecting to the MariaDB monitor. It shows the server version and copyright information, indicating a successful connection to the database server. The prompt 'MariaDB [(none)]>' signifies that you are ready to execute SQL commands. ```bash user@computer:~$ sudo mariadb [sudo] password for user: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 42 Server version: 11.2.2-MariaDB-1:11.2.2+maria~ubu2004 mariadb.org binary distribution Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> ``` -------------------------------- ### Install PostgreSQL on Linux (Ubuntu/Debian) Source: https://github.com/signum-network/signum-node/blob/develop/DB_SETUP_POSTGRESQL.md Installs PostgreSQL version 16.9 or higher on Ubuntu/Debian systems. It adds the PostgreSQL repository and then installs the package using apt-get. ```bash sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - sudo apt-get update sudo apt-get -y install postgresql ``` -------------------------------- ### Install Build Dependencies (npm) Source: https://github.com/signum-network/signum-node/blob/develop/openapi/README.md Installs the necessary build dependencies for editing the OpenAPI specification. Requires NodeJS 12+. ```bash npm i ``` -------------------------------- ### Command Pattern Example (Java) Source: https://github.com/signum-network/signum-node/blob/develop/CLAUDE.md Demonstrates the Command pattern where each API endpoint is treated as an executable command. This is typically seen in API request handlers, abstracting the execution logic. ```java public abstract class APIRequestHandler { protected abstract JSONStreamAware processRequest(HttpServletRequest req) throws SignumException; } ``` -------------------------------- ### Generate Local SSL Certificates with OpenSSL Source: https://github.com/signum-network/signum-node/blob/develop/SSL_SETUP.md Generates a private key, a self-signed SSL certificate, and a PKCS#12 keystore for local Signum Node HTTPS configuration. Requires OpenSSL to be installed. Outputs are PEM and P12 files. ```bash openssl genpkey -algorithm RSA -out localhost.pem openssl req -x509 -new -key localhost.pem -out localhost_chain.pem -days 365 openssl pkcs12 -export -inkey localhost.pem -in localhost_chain.pem -out localhost_keystore.p12 -name "localhost" -password pass:development ``` -------------------------------- ### Java Exception Handling Example Source: https://github.com/signum-network/signum-node/blob/develop/CLAUDE.md Demonstrates the use of specific and informative exceptions in Java for better error management. It shows how to throw exceptions for invalid arguments and non-existent accounts. ```java public void transferAsset(long fromId, long toId, long assetId, long quantity) { if (quantity <= 0) { throw new IllegalArgumentException("Transfer quantity must be positive: " + quantity); } Account fromAccount = accountStore.getAccount(fromId); if (fromAccount == null) { throw new AccountNotFoundException("Account not found: " + fromId); } // Continue with business logic... } ``` -------------------------------- ### Strategy Pattern Example (Java) Source: https://github.com/signum-network/signum-node/blob/develop/CLAUDE.md Shows the Strategy pattern for handling multiple algorithmic variants, such as in the Generator implementations. This pattern is useful when the same operation can be performed in several different ways. ```java Generator generator = mockMining ? new MockGenerator(...) : new GeneratorImpl(...); ``` -------------------------------- ### Start Signum Node Services Source: https://github.com/signum-network/signum-node/blob/develop/docker/DOCKER.md This command starts the Docker services defined in the `docker-compose.yml` file in detached mode. It is executed from the directory containing the `docker-compose.yml` file. ```bash docker-compose up -d ``` -------------------------------- ### Start Development Watcher (npm) Source: https://github.com/signum-network/signum-node/blob/develop/openapi/README.md Launches a file watcher in the 'openapi' folder that automatically bundles the API specification whenever a spec file is saved. This facilitates an iterative editing process. ```bash npm run dev ``` -------------------------------- ### Factory Pattern Example (Java) Source: https://github.com/signum-network/signum-node/blob/develop/CLAUDE.md Demonstrates the use of the Factory pattern for creating complex database instances with multiple variants. This pattern is employed when different types of database instances need to be instantiated based on a given type. ```java DatabaseInstance instance = DatabaseInstanceFactory.createInstance(databaseType); ``` -------------------------------- ### Template Method Pattern Example (Java) Source: https://github.com/signum-network/signum-node/blob/develop/CLAUDE.md Illustrates the Template Method pattern for common processing patterns, particularly in abstract test classes. It defines a skeleton of an algorithm, deferring some steps to subclasses. ```java public abstract class AbstractTransactionTest { // Template method with common test setup protected final void executeTransactionTest() { setupTest(); // Common createTransaction(); // Variable - implemented by subclasses validateTransaction(); // Common } } ``` -------------------------------- ### Class Design Example (Java) Source: https://github.com/signum-network/signum-node/blob/develop/CLAUDE.md An example of good class design following the Separation of Concerns principle, with clear responsibilities and dependency injection. It shows a service class depending on data access stores. ```java // GOOD: Clear separation, single responsibility public class AccountServiceImpl implements AccountService { private final AccountStore accountStore; // Data access private final AssetTransferStore transferStore; // Related data access public AccountServiceImpl(AccountStore accountStore, AssetTransferStore transferStore) { this.accountStore = accountStore; this.transferStore = transferStore; } @Override public Account getAccount(long id) { // Business logic only - no direct SQL return accountStore.getAccount(id); } } ``` -------------------------------- ### Configure PostgreSQL for Signum Node Mainnet Source: https://github.com/signum-network/signum-node/blob/develop/DB_SETUP_POSTGRESQL.md Sets up a PostgreSQL database and user for the Signum Node's mainnet. This involves creating a user with a password and a database owned by that user. ```sql -- Create the user (choose another password if you want) CREATE USER signumnode WITH PASSWORD 's1gn00m_n0d3'; -- Create the database CREATE DATABASE signum OWNER=signumnode; ``` -------------------------------- ### PostgreSQL Performance Optimizations Source: https://github.com/signum-network/signum-node/blob/develop/DB_SETUP_POSTGRESQL.md Provides recommended settings for the postgresql.conf file to optimize performance on servers with more than 8GB of RAM. These settings adjust memory allocation, buffer sizes, and checkpoint behavior. ```properties shared_buffers = 4GB work_mem = 64MB maintenance_work_mem = 512MB wal_writer_delay = 200ms wal_buffers = 16MB checkpoint_timeout = 15min checkpoint_completion_target = 0.9 synchronous_commit = off effective_cache_size = 8GB ``` -------------------------------- ### Configure Signum Node for MariaDB Source: https://github.com/signum-network/signum-node/blob/develop/README.md Switches the Signum Node's database from the default SQLite to MariaDB. Requires specifying the database URL, username, and password in the `node.properties` file. The example uses the standard MariaDB port 3306. ```properties #### DATABASE #### DB.Url=jdbc:mariadb://localhost:3306/signum DB.Username= DB.Password= ``` -------------------------------- ### Signum Node Configuration Properties Source: https://context7.com/signum-network/signum-node/llms.txt Example configuration file for the Signum Node, detailing settings for cash-back, database connections (SQLite, MariaDB, PostgreSQL), P2P networking, and API access. ```properties # conf/node.properties example # Cash-back for transaction fees (25% of fees go to this account) node.cashBackId = 8952122635653861124 # Database Configuration (SQLite default) DB.Url=jdbc:sqlite:file:./db/signum.sqlite.db DB.SqliteJournalMode = WAL # MariaDB alternative # DB.Url=jdbc:mariadb://localhost:3306/signum # DB.Username=signumnode # DB.Password=your_password # PostgreSQL alternative # DB.Url=jdbc:postgresql://localhost:5432/signum # DB.Username=signumnode # DB.Password=your_password # P2P Settings P2P.Port = 8123 P2P.UPnP = yes P2P.myPlatform = S-ABCD-EFGH-IJKL-MNOP # API Settings API.Listen = 127.0.0.1 API.Port = 8125 # Enable for public nodes # API.Listen = 0.0.0.0 # Testnet Configuration # node.network = signum.net.TestnetNetwork # Private/Mock Chain # node.network = signum.net.MockNetwork ``` -------------------------------- ### Observer Pattern Example (Java) Source: https://github.com/signum-network/signum-node/blob/develop/CLAUDE.md Illustrates the Observer pattern for decoupled event notifications within the blockchain processor. This pattern is used to allow multiple listeners to react to specific blockchain events without direct coupling. ```java blockchainProcessor.addListener(listener, BlockchainProcessor.Event.AFTER_BLOCK_APPLY); ``` -------------------------------- ### Unit Test Structure (Java - JUnit 5) Source: https://github.com/signum-network/signum-node/blob/develop/CLAUDE.md Provides an example of a unit test following the Arrange-Act-Assert (AAA) pattern using JUnit 5 annotations. This structure is mandatory for all new classes and methods. ```java @Test void calculateBalance_GivenValidAccount_ReturnsCorrectBalance() { // Arrange Account account = createTestAccount(); when(accountStore.getAccount(accountId)).thenReturn(account); // Act long balance = accountService.calculateBalance(accountId); // Assert assertEquals(expectedBalance, balance); verify(accountStore).getAccount(accountId); } ``` -------------------------------- ### Signum Node Testnet Database Configuration Source: https://github.com/signum-network/signum-node/blob/develop/DB_SETUP_POSTGRESQL.md Defines the database connection parameters for the Signum Node's testnet in the node.properties file. This includes the network type and the URL for the testnet database. ```properties node.network = signum.net.TestnetNetwork DB.Url=jdbc:postgresql://localhost:5432/signum_testnet DB.Username=signumnode DB.Password=s1gn00m_n0d3 ``` -------------------------------- ### Get Contract Details - Bash Source: https://context7.com/signum-network/signum-node/llms.txt Retrieves smart contract information, including state, balance, and data. Can optionally include full details or a reduced payload. Requires the contract's AT ID. ```bash # Get contract details curl "http://localhost:8125/api?requestType=getAT&at=16380523479488112662" # Get contract with reduced payload curl "http://localhost:8125/api?requestType=getAT&at=16380523479488112662&includeDetails=false" ``` -------------------------------- ### Get Token Details (Bash) Source: https://context7.com/signum-network/signum-node/llms.txt Retrieves comprehensive information about a specific token, including its supply, trading statistics, and holder count. It can also fetch data for a custom period by specifying start and end block heights. Requires the asset ID. ```bash # Get token details curl "http://localhost:8125/api?requestType=getAsset&asset=914948012239561046" # Get token with trading statistics for custom period curl "http://localhost:8125/api?requestType=getAsset&asset=914948012239561046&heightStart=440000&heightEnd=440500" ``` -------------------------------- ### Request SSL Certificate with Certbot Source: https://github.com/signum-network/signum-node/blob/develop/SSL_SETUP.md Obtains an SSL certificate for a custom domain using Certbot in standalone mode. This requires a publicly accessible domain and assumes Certbot is installed. The certificate and private key are stored in the Let's Encrypt directory. ```bash sudo certbot certonly --standalone -d yourdomain.com ``` -------------------------------- ### Get Transaction by Full Hash (cURL) Source: https://context7.com/signum-network/signum-node/llms.txt Retrieves transaction details using its full hash. This is a GET request. ```bash curl "http://localhost:8125/api?requestType=getTransaction&fullHash=6ce8970b66bf8360108df8d4675c275ab2acd549219928c4d0ae4a62a284b1c7" ``` -------------------------------- ### Initialize MariaDB for Signum Node (SQL) Source: https://github.com/signum-network/signum-node/blob/develop/DB_SETUP_MARIADB.md This SQL script creates the necessary database and user for the Signum Node. It ensures the database 'signum' exists, creates a user 'signumnode' with a specified password, and grants all privileges on the 'signum' database to this user. Finally, it flushes privileges to apply the changes. ```sql -- Create the database CREATE DATABASE IF NOT EXISTS signum; -- Create the user (choose another password if you want) CREATE USER IF NOT EXISTS 'signumnode'@'localhost' IDENTIFIED BY 's1gn00m_n0d3'; -- Grant ownership of the database to the user GRANT ALL PRIVILEGES ON signum.* TO 'signumnode'@'localhost'; FLUSH PRIVILEGES; ``` -------------------------------- ### Get Transaction by ID (cURL) Source: https://context7.com/signum-network/signum-node/llms.txt Fetches the details of a specific transaction using its unique ID. This is a GET request. ```bash curl "http://localhost:8125/api?requestType=getTransaction&transaction=6954612694592252012" ``` -------------------------------- ### Publish Smart Contract - Bash Source: https://context7.com/signum-network/signum-node/llms.txt Deploys a smart contract to the blockchain. Supports direct code deployment or referencing existing Green Contracts. Requires contract details, code/reference, pages, minimum activation amount, fee, deadline, and secret phrase. ```bash # Deploy a new smart contract curl -X POST "http://localhost:8125/api?requestType=createATProgram" \ -d "name=MyContract" \ -d "description=My first smart contract" \ -d "code=01000000000000003530..." \ -d "dpages=1" \ -d "cspages=1" \ -d "uspages=1" \ -d "minActivationAmountNQT=25000000" \ -d "feeNQT=50000000" \ -d "deadline=60" \ -d "secretPhrase=your_secret_passphrase" # Deploy using Green Contract (reuse existing code) curl -X POST "http://localhost:8125/api?requestType=createATProgram" \ -d "name=MyGreenContract" \ -d "description=Reusing existing contract code" \ -d "referencedTransactionFullHash=abc123..." \ -d "dpages=1" \ -d "cspages=1" \ -d "uspages=1" \ -d "minActivationAmountNQT=25000000" \ -d "feeNQT=10000000" \ -d "deadline=60" \ -d "secretPhrase=your_secret_passphrase" ``` -------------------------------- ### Get Blockchain Status (cURL) Source: https://context7.com/signum-network/signum-node/llms.txt Fetches the current status of the blockchain, including version, height, and synchronization state. This is a GET request. ```bash curl "http://localhost:8125/api?requestType=getBlockchainStatus" ``` -------------------------------- ### Get Mining Info (cURL) Source: https://context7.com/signum-network/signum-node/llms.txt Retrieves essential information for mining software, including block height, generation signature, and base target. This is a GET request. ```bash curl "http://localhost:8125/api?requestType=getMiningInfo" ``` -------------------------------- ### Get Constants (cURL) Source: https://context7.com/signum-network/signum-node/llms.txt Retrieves the network's constants, including parameters like network name, address prefix, block time, and fees for various transaction types. This is a GET request. ```bash curl "http://localhost:8125/api?requestType=getConstants" ``` -------------------------------- ### Get Token Source: https://context7.com/signum-network/signum-node/llms.txt Retrieves detailed information about a token including supply, trading statistics, and holder count. ```APIDOC ## GET /api?requestType=getAsset ### Description Retrieves detailed information about a token. ### Method GET ### Endpoint /api?requestType=getAsset ### Parameters #### Query Parameters - **asset** (string) - Required - The ID of the token to retrieve. - **heightStart** (string) - Optional - The starting block height for trading statistics. - **heightEnd** (string) - Optional - The ending block height for trading statistics. ### Request Example ```bash # Get token details curl "http://localhost:8125/api?requestType=getAsset&asset=914948012239561046" # Get token with trading statistics for custom period curl "http://localhost:8125/api?requestType=getAsset&asset=914948012239561046&heightStart=440000&heightEnd=440500" ``` ### Response #### Success Response (200) - **asset** (string) - The token ID. - **account** (string) - The account ID of the token issuer. - **accountRS** (string) - The RS address of the token issuer. - **name** (string) - The name of the token. - **description** (string) - The description of the token. - **decimals** (string) - The number of decimal places for the token. - **mintable** (boolean) - Indicates if the token is mintable. - **quantityQNT** (string) - The total supply of the token in quantum units. - **quantityCirculatingQNT** (string) - The circulating supply of the token in quantum units. - **quantityBurntQNT** (string) - The amount of tokens burnt in quantum units. - **numberOfTrades** (string) - The total number of trades for the token. - **numberOfTransfers** (string) - The total number of transfers for the token. - **numberOfAccounts** (string) - The number of accounts holding the token. - **volumeQNT** (string) - The total volume traded in quantum units. - **priceHigh** (string) - The highest price in the specified period (in NQT). - **priceLow** (string) - The lowest price in the specified period (in NQT). - **priceOpen** (string) - The opening price in the specified period (in NQT). - **priceClose** (string) - The closing price in the specified period (in NQT). ### Response Example ```json { "asset": "914948012239561046", "account": "16357368130745732388", "accountRS": "S-C5B6-NTGQ-KDA28", "name": "TTH", "description": "Test token", "decimals": 8, "mintable": false, "quantityQNT": "10000000000000", "quantityCirculatingQNT": "10000000000000", "quantityBurntQNT": "0", "numberOfTrades": 10, "numberOfTransfers": 1, "numberOfAccounts": 3, "volumeQNT": "5000000000", "priceHigh": "1000000", "priceLow": "500000", "priceOpen": "600000", "priceClose": "900000" } ``` ``` -------------------------------- ### Get Account Transactions Source: https://context7.com/signum-network/signum-node/llms.txt Retrieves transactions associated with a specific account. Supports filtering by transaction type and bidirectional search. ```APIDOC ## GET /api ### Description Retrieves transactions associated with a specific account. Supports filtering by transaction type and bidirectional search. ### Method GET ### Endpoint /api ### Query Parameters - **requestType** (string) - Required - Specifies the API request, e.g., `getAccountTransactions`. - **account** (string) - Optional - The account ID to retrieve transactions for. - **sender** (string) - Optional - The sender account ID for filtering. - **recipient** (type) - Optional - The recipient account ID for filtering. - **type** (integer) - Optional - Filters transactions by type (e.g., 0 for payment transactions). - **bidirectional** (boolean) - Optional - If true, includes transactions where the account is either sender or recipient. ### Request Example ``` http://localhost:8125/api?requestType=getAccountTransactions&account=S-QAJA-QW5Y-SWVP-4RVP4&type=0 http://localhost:8125/api?requestType=getAccountTransactions&sender=S-QAJA-QW5Y-SWVP-4RVP4&recipient=S-K37B-9V85-FB95-793HN&bidirectional=true ``` ### Response #### Success Response (200) - **transactions** (array) - An array of transaction objects. - **lastBlock** (string) - The ID of the last block. #### Response Example ```json { "transactions": [ { "type": 0, "sender": "S-QAJA-QW5Y-SWVP-4RVP4", "recipient": "S-ANOTHER-ACCOUNT", "amountNQT": "100000000", "feeNQT": "1000000", "timestamp": 1678886400, "confirmations": 100, "transaction": "...", "signature": "..." } ], "lastBlock": "1234567890123456789" } ``` ``` -------------------------------- ### Get Block by Height (cURL) Source: https://context7.com/signum-network/signum-node/llms.txt Retrieves detailed information about a specific block using its height. Can optionally include transaction details. ```bash curl "http://localhost:8125/api?requestType=getBlock&height=440000" curl "http://localhost:8125/api?requestType=getBlock&height=440000&includeTransactions=true" curl "http://localhost:8125/api?requestType=getBlock" ``` -------------------------------- ### Place Bid Order (Buy) - Bash Source: https://context7.com/signum-network/signum-node/llms.txt Places a buy order on the decentralized exchange. Requires asset ID, quantity, price per unit, fee, deadline, and secret phrase. ```bash # Buy 50 tokens at 0.05 Signa per token curl -X POST "http://localhost:8125/api?requestType=placeBidOrder" \ -d "asset=914948012239561046" \ -d "quantityQNT=5000000000" \ -d "priceNQT=5000000" \ -d "feeNQT=1000000" \ -d "deadline=60" \ -d "secretPhrase=your_secret_passphrase" ``` -------------------------------- ### Get Transactions Between Accounts Source: https://context7.com/signum-network/signum-node/llms.txt Retrieves transactions between a sender and a recipient account, supporting bidirectional searches. This is useful for tracking all communication between two parties. ```bash curl "http://localhost:8125/api?requestType=getAccountTransactions&sender=S-QAJA-QW5Y-SWVP-4RVP4&recipient=S-K37B-9V85-FB95-793HN&bidirectional=true" ``` -------------------------------- ### Create Optimized Spec File (npm) Source: https://github.com/signum-network/signum-node/blob/develop/openapi/README.md Generates the final, optimized API specification file after all edits are complete. This command should be run when ready to finalize the documentation changes. ```bash npm run dist ``` -------------------------------- ### Get Account Transactions (type=0) Source: https://context7.com/signum-network/signum-node/llms.txt Retrieves only payment transactions for a given account. This API call is useful for filtering specific transaction types. ```bash curl "http://localhost:8125/api?requestType=getAccountTransactions&account=S-QAJA-QW5Y-SWVP-4RVP4&type=0" ``` -------------------------------- ### Verify MariaDB Performance Variables (SQL) Source: https://github.com/signum-network/signum-node/blob/develop/DB_SETUP_MARIADB.md These SQL commands are used to verify the MariaDB performance tuning variables after a service restart. They display the current values of 'innodb_buffer_pool_size' and 'innodb_flush_log_at_trx_commit', allowing you to confirm that the optimizations have been applied correctly. ```sql SHOW VARIABLES LIKE 'innodb%buffer%'; SHOW VARIABLES LIKE 'innodb_flush_log_at_trx_commit'; ``` -------------------------------- ### Get Account Transactions (cURL) Source: https://context7.com/signum-network/signum-node/llms.txt Retrieves a list of transactions associated with a specific account. Supports pagination using firstIndex and lastIndex parameters. ```bash curl "http://localhost:8125/api?requestType=getAccountTransactions&account=S-QAJA-QW5Y-SWVP-4RVP4&firstIndex=0&lastIndex=50" ``` -------------------------------- ### Get Peers (cURL) Source: https://context7.com/signum-network/signum-node/llms.txt Lists known nodes (peers) on the network. Supports filtering for active peers and retrieving details of a specific peer. ```bash curl "http://localhost:8125/api?requestType=getPeers" curl "http://localhost:8125/api?requestType=getPeers&active=true" curl "http://localhost:8125/api?requestType=getPeer&peer=138.2.137.23" ``` -------------------------------- ### Configure MariaDB for Testnet (SQL) Source: https://github.com/signum-network/signum-node/blob/develop/DB_SETUP_MARIADB.md This SQL script sets up a separate database for the Signum Node's testnet. It creates a new database named 'signum_testnet' and grants the existing 'signumnode' user all privileges on this new database. This allows for easy switching between mainnet and testnet by modifying the node's properties. ```sql -- Create the database CREATE DATABASE signum_testnet; -- Grant ownership of the database to the user GRANT ALL PRIVILEGES ON signum_testnet.* TO 'signumnode'@'localhost'; FLUSH PRIVILEGES; ```