### Get Help with Node Command Line Arguments Source: https://github.com/block-core/blockcore/blob/master/Documentation/getting-started.md Displays a list of available command-line arguments for the Stratis node. This is useful for understanding advanced configuration options. This command assumes you are in the Stratis.StratisD directory. ```bash cd Stratis.StratisD dotnet run -help ``` -------------------------------- ### Clone Repository and Navigate Source: https://github.com/block-core/blockcore/blob/master/Documentation/getting-started.md Clones the StratisBitcoinFullNode repository from GitHub and navigates into the source directory. This is the initial step for building the node. ```bash git clone https://github.com/stratisproject/StratisBitcoinFullNode.git cd StratisBitcoinFullNode/src ``` -------------------------------- ### Run Stratis Node on TestNet Source: https://github.com/block-core/blockcore/blob/master/Documentation/getting-started.md Builds and runs a Stratis node connected to the Stratis TestNet. This command assumes you are in the Stratis.StratisD directory. ```bash cd Stratis.StratisD dotnet run -testnet ``` -------------------------------- ### Example Stratis PoA Node Console Output Source: https://github.com/block-core/blockcore/blob/master/Documentation/Features/PoA/PoA_set_up_manual.md An example of the console output expected when the Stratis PoA network node starts successfully. This output includes initialization messages, chain loading status, and federation member information. ```text info: Stratis.Bitcoin.FullNode[0] Full node initialized on PoAMain. info: Stratis.Bitcoin.FullNode[0] Starting node. info: Stratis.Bitcoin.Base.BaseFeature[0] Loading finalized block height. info: Stratis.Bitcoin.Base.BaseFeature[0] Loading chain. info: Stratis.Bitcoin.Base.BaseFeature[0] Chain loaded at height 51759. info: Stratis.Bitcoin.FullNode[0] FlushChain starting in 60 seconds. info: Stratis.Bitcoin.Base.BaseFeature[0] Loading peers from : C:\Users\user\AppData\Roaming\StratisNode\poa\PoAMain. info: Stratis.Bitcoin.FullNode[0] Periodic peer flush starting in 300 seconds. info: Stratis.Bitcoin.Features.PoA.FederationManager[0] Federation contains 3 members. Their public keys are: 03e6f19ea3dc6c145d98a0e0838af952755798e5bc3950bbca4f9485aa23873d7f 02ddebcf18207072bdd172a25f85f2ea12e2de1d9d794f136722634aad08400fcb 02067b38d777690aaaf23a5b371a819e6ddc6d2aae734b0199fe59df28dc056dd7 ... ``` -------------------------------- ### Cold Staking ScriptPubKey and ScriptSig Examples Source: https://github.com/block-core/blockcore/blob/master/Documentation/Features/ColdStaking.md Provides examples of the ScriptPubKey for a cold staking output and the corresponding ScriptSigs required to spend this output for either creating another coinstake transaction using a hot wallet or canceling the setup using a cold storage private key. ```APIDOC ScriptPubKey for cold staking output: OP_DUP OP_HASH160 OP_ROT OP_IF OP_CHECKCOLDSTAKEVERIFY OP_ELSE OP_ENDIF OP_EQUALVERIFY OP_CHECKSIG ScriptSig to spend for coinstake creation (hot wallet): 1 ScriptSig to spend for setup cancellation (cold storage): 0 ``` -------------------------------- ### Run Stratis Node on MainNet Source: https://github.com/block-core/blockcore/blob/master/Documentation/getting-started.md Builds and runs a Stratis node connected to the Stratis MainNet. This command assumes you are in the Stratis.StratisD directory. ```bash cd Stratis.StratisD dotnet run ``` -------------------------------- ### Run Bitcoin Node on TestNet Source: https://github.com/block-core/blockcore/blob/master/Documentation/getting-started.md Builds and runs a Bitcoin node connected to the Bitcoin TestNet. This command assumes you are in the Stratis.BitcoinD directory. ```bash cd Stratis.BitcoinD dotnet run -testnet ``` -------------------------------- ### Run Bitcoin Node on MainNet Source: https://github.com/block-core/blockcore/blob/master/Documentation/getting-started.md Builds and runs a Bitcoin node connected to the Bitcoin MainNet. This command assumes you are in the Stratis.BitcoinD directory. ```bash cd Stratis.BitcoinD dotnet run ``` -------------------------------- ### C# Method Exit Log Example (Simple Return) Source: https://github.com/block-core/blockcore/blob/master/Documentation/logging-style.md Illustrates a basic exit log in C#, showing how to log the return value of a method. ```csharp this.logger.LogTrace("(-):{0}", res); return res; } ``` -------------------------------- ### C# Method Entry Log Example Source: https://github.com/block-core/blockcore/blob/master/Documentation/logging-style.md Demonstrates the standard format for an entry log in C#, capturing input arguments like 'node' and 'message' for tracing object flow. ```csharp private void AttachedNode_MessageReceived(Node node, IncomingMessage message) { this.logger.LogTrace("({0}:'{1}',{2}:'{3}')", nameof(node), node.RemoteSocketEndpoint, nameof(message), message.Message.Command); } ``` -------------------------------- ### Hashing Examples Source: https://github.com/block-core/blockcore/blob/master/src/Tests/Blockcore.Tests/NBitcoin/data_pos/determiniticECDSA.txt Provides examples of hash outputs for the message 'test' using SHA-256, SHA-384, and SHA-512. ```APIDOC With SHA-256, message = "test": k = 193649CE51F0CFF0784CFC47628F4FA854A93F7A2 r = 0354D5CD24F9C41F85D02E856FA2B0001C83AF53E s = 020B200677731CD4FE48612A92F72A19853A82B65 With SHA-384, message = "test": k = 37C73C6F8B404EC83DA17A6EBCA724B3FF1F7EEBA r = 11B6A84206515495AD8DBB2E5785D6D018D75817E s = 1A7D4C1E17D4030A5D748ADEA785C77A54581F6D0 With SHA-512, message = "test": k = 331AD98D3186F73967B1E0B120C80B1E22EFC2988 r = 148934745B351F6367FF5BB56B1848A2F508902A9 s = 36214B19444FAB504DBA61D4D6FF2D2F9640F4837 ``` -------------------------------- ### SHA Hashing Examples Source: https://github.com/block-core/blockcore/blob/master/src/Tests/Blockcore.Tests/NBitcoin/data/determiniticECDSA.txt Provides examples of SHA-256, SHA-384, and SHA-512 hashing for a given message. Shows the resulting hash values. ```APIDOC SHA Hashing Examples: With SHA-256, message = "test": k = 193649CE51F0CFF0784CFC47628F4FA854A93F7A2 r = 0354D5CD24F9C41F85D02E856FA2B0001C83AF53E s = 020B200677731CD4FE48612A92F72A19853A82B65 With SHA-384, message = "test": k = 37C73C6F8B404EC83DA17A6EBCA724B3FF1F7EEBA r = 11B6A84206515495AD8DBB2E5785D6D018D75817E s = 1A7D4C1E17D4030A5D748ADEA785C77A54581F6D0 With SHA-512, message = "test": k = 331AD98D3186F73967B1E0B120C80B1E22EFC2988 r = 148934745B351F6367FF5BB56B1848A2F508902A9 s = 36214B19444FAB504DBA61D4D6FF2D2F9640F4837 ``` -------------------------------- ### SHA-256 Hashing Example Source: https://github.com/block-core/blockcore/blob/master/src/Tests/Blockcore.Tests/NBitcoin/data/determiniticECDSA.txt Demonstrates the output of SHA-256 hashing for a given message. ```text With SHA-256, message = "test": k = 0B585A7A68F51089691D6EDE2B43FC4451F66C10E65F134B963D4CBD4EB844B0 E1469A6 r = 158FAEB2470B306C57764AFC8528174589008449E11DB8B36994B607A65956A5 9715531 s = 0521BC667CA1CA42B5649E78A3D76823C678B7BB3CD58D2E93CD791D53043A6F 83F1FD1 ``` -------------------------------- ### SHA-512 Hashing Example (Second Instance) Source: https://github.com/block-core/blockcore/blob/master/src/Tests/Blockcore.Tests/NBitcoin/data/determiniticECDSA.txt Demonstrates the output of SHA-512 hashing for a different message. ```text With SHA-512, message = "test": k = 00E5F24A223BD459653F682763C3BB322D4EE75DD89C63D4DC61518D543E7658 5076BBA r = 1E7912517C6899732E09756B1660F6B96635D638283DF9A8A11D30E008895D7F 5C9C7F3 s = 0887E75CBD0B7DD9DE30ED79BDB3D78E4F1121C5EAFF5946918F594F88D36364 4789DA7 ``` -------------------------------- ### SHA-512 Hashing Example Source: https://github.com/block-core/blockcore/blob/master/src/Tests/Blockcore.Tests/NBitcoin/data/determiniticECDSA.txt Demonstrates the output of SHA-512 hashing for a given message. ```text With SHA-512, message = "sample": k = 00F3B59FCB5C1A01A1A2A0019E98C244DFF61502D6E6B9C4E957EDDCEB258EF4 DBEF04A r = 1D0008CF4BA4A701BEF70771934C2A4A87386155A2354140E2ED52E18553C35B 47D9E50 s = 0D15F4FA1B7A4D41D9843578E22EF98773179103DC4FF0DD1F74A6B5642841B9 1056F78 ``` -------------------------------- ### SHA-256 Hash Example Source: https://github.com/block-core/blockcore/blob/master/src/Tests/Blockcore.Tests/NBitcoin/data/determiniticECDSA.txt Demonstrates the SHA-256 hash output for the message 'test', including the key, random, and signature components. ```text With SHA-256, message = "test": k = 328E02CF07C7B5B6D3749D8302F1AE5BFAA8F239398459AF4A2C859C7727A812 3A7FE9BE8B228413FC8DC0E9DE16AF3F8F43005107F9989A5D97A5C4455DA895 E81336710A3FB2C r = 184BC808506E11A65D628B457FDA60952803C604CC7181B59BD25AEE1411A66D 12A777F3A0DC99E1190C58D0037807A95E5080FA1B2E5CCAA37B50D401CFFC34 17C005AEE963469 s = 27280D45F81B19334DBDB07B7E63FE8F39AC7E9AE14DE1D2A6884D2101850289 D70EE400F26ACA5E7D73F534A14568478E59D00594981ABE6A1BA18554C13EB5 E03921E4DC98333 ``` -------------------------------- ### SHA-1 Hashing Example Source: https://github.com/block-core/blockcore/blob/master/src/Tests/Blockcore.Tests/NBitcoin/data/determiniticECDSA.txt Demonstrates the output of SHA-1 hashing for a given message. ```text With SHA-1, message = "test": k = 168B5F8C0881D4026C08AC5894A2239D219FA9F4DA0600ADAA56D5A1781AF81F 08A726E r = 140932FA7307666A8CCB1E1A09656CC40F5932965841ABD5E8E43559D93CF231 1B02767 s = 16A2FD46DA497E5E739DED67F426308C45C2E16528BF2A17EB5D65964FD88B77 0FBB9C6 ``` -------------------------------- ### SHA-512 Hash Example Source: https://github.com/block-core/blockcore/blob/master/src/Tests/Blockcore.Tests/NBitcoin/data/determiniticECDSA.txt Demonstrates the SHA-512 hash output for the message 'test', including the key, random, and signature components. ```text With SHA-512, message = "test": k = 21CE6EE4A2C72C9F93BDB3B552F4A633B8C20C200F894F008643240184BE57BB 282A1645E47FBBE131E899B4C61244EFC2486D88CDBD1DD4A65EBDD837019D02 628D0DCD6ED8FB5 r = 2AA1888EAB05F7B00B6A784C4F7081D2C833D50794D9FEAF6E22B8BE728A2A90 BFCABDC803162020AA629718295A1489EE7ED0ECB8AAA197B9BDFC49D18DDD78 FC85A48F9715544 s = 0AA5371FE5CA671D6ED9665849C37F394FED85D51FEF72DA2B5F28EDFB2C6479 CA63320C19596F5E1101988E2C619E302DD05112F47E8823040CE540CD3E90DC F41DBC461744EE9 ``` -------------------------------- ### Running the PoA Network Daemon Source: https://github.com/block-core/blockcore/blob/master/Documentation/Features/PoA/PoA_set_up_manual.md Instructions on how to run the newly created Proof-of-Authority network daemon. This includes starting the node from Visual Studio or via the command line, and how to stop it. ```bash // Run from Visual Studio by setting MyPoAChainD as the startup project and hitting F5. // Or, run from the command line: dotnet exec MyPoAChainD.dll ``` ```bash // To stop the node, press Ctrl+C. ``` -------------------------------- ### Stratis PoA Network Project Setup Source: https://github.com/block-core/blockcore/blob/master/Documentation/Features/PoA/PoA_set_up_manual.md This section details the initial steps for setting up a new Proof-of-Authority (PoA) network project. It involves cloning the Stratis Bitcoin Full Node repository, creating a new .NET Core console application, and referencing essential Stratis projects. ```bash git clone https://github.com/stratisproject/StratisBitcoinFullNode.git ``` ```csharp // Create a new .NET Core console application project // Example: dotnet new console -n MyPoAChainD // Reference the following projects in your new project file (.csproj): // Stratis.Bitcoin.Features.Api // Stratis.Bitcoin.Features.Apps // Stratis.Bitcoin.Features.BlockStore // Stratis.Bitcoin.Features.Consensus // Stratis.Bitcoin.Features.MemoryPool // Stratis.Bitcoin.Features.Miner // Stratis.Bitcoin.Features.PoA // Stratis.Bitcoin.Features.RPC // Stratis.Bitcoin.Features.Wallet // Stratis.Bitcoin ``` ```csharp // Enable latest C# features: // Go to MyPoAChainD's properties => Build => Advanced... // Set Language Version to 'C# latest minor version (latest)' ``` ```csharp // Copy content from Stratis.PoAChainD.Program.cs to Program.cs // Ensure to change the namespace accordingly. ``` -------------------------------- ### C# Method Exit Log Example (With Context) Source: https://github.com/block-core/blockcore/blob/master/Documentation/logging-style.md Demonstrates how to use context identifiers in exit logs in C# to differentiate between various exit paths within a method. ```csharp if (!BlockStake.IsProofOfStake(block)) { this.logger.LogTrace("(-)[NOT_POS]"); return; } // Verify hash target and signature of coinstake tx. BlockStake prevBlockStake = this.stakeChain.Get(chainTip.HashBlock); if (prevBlockStake == null) { this.logger.LogTrace("(-)[NO_PREV_STAKE]"); ConsensusErrors.PrevStakeNull.Throw(); } ``` -------------------------------- ### Get Repository and Dependencies Source: https://github.com/block-core/blockcore/blob/master/src/Features/Blockcore.Features.Dns/README.md Clones the StratisBitcoinFullNode repository and initializes its submodules, which is the first step to building the Stratis DNS Crawler. ```bash git clone https://github.com/stratisproject/StratisBitcoinFullNode.git cd StratisBitcoinFullNode git submodule update --init --recursive ``` -------------------------------- ### C# Method Exit Log Example (Complex Return) Source: https://github.com/block-core/blockcore/blob/master/Documentation/logging-style.md Shows how to log specific properties of a complex return object in C#, using '*' to represent the object and specifying relevant fields. ```csharp FetchCoinsResponse result = null; ... this.logger.LogTrace("(-):*.{0}='{1}',*.{2}.{3}={4}", nameof(result.BlockHash), result.BlockHash, nameof(result.UnspentOutputs), nameof(result.UnspentOutputs.Length), result.UnspentOutputs.Length); return result; } ``` -------------------------------- ### Basic NLog.config Example Source: https://github.com/block-core/blockcore/blob/master/Documentation/using-logging.md Provides a basic NLog.config file structure for setting up file logging. It defines targets for writing logs to a file and rules for directing log messages. ```xml ``` -------------------------------- ### Conditional Logging for Abnormal Cases Source: https://github.com/block-core/blockcore/blob/master/Documentation/logging-style.md Illustrates logging only for abnormal execution paths to keep logs concise. In this example, a log is generated only when a node's PeerVersion is not initialized, implying that normal cases (where PeerVersion is initialized) do not produce logs. ```csharp VersionPayload version = node.PeerVersion; if (version != null) { TimeSpan timeOffset = version.Timestamp - this.dateTimeProvider.GetUtcNow(); if (timeOffset != null) this.state.AddTimeData(address, timeOffset, node.Inbound); } else this.logger.LogTrace("Node '{0}' does not have an initialized time offset.", node.RemoteSocketEndpoint); ``` -------------------------------- ### Blockcore Cold Staking API Source: https://github.com/block-core/blockcore/blob/master/Documentation/cold-staking-setup.md This section details the Blockcore API methods used for setting up and managing cold staking. It includes methods for converting wallets, retrieving staking addresses, and managing staking transactions. ```APIDOC cold-staking-account: description: Converts a wallet account to be enabled for cold staking. parameters: isColdWalletAccount: boolean - Set to 'true' for cold wallet, 'false' for hot wallet. cold-staking-address: description: Retrieves the cold staking address for a wallet. parameters: IsColdWalletAddress: boolean - Set to 'true' to get the cold address, 'false' to get the hot address. setup-cold-staking: description: Builds a transaction to link cold wallet funds to a hot wallet address. requestBody: type: object properties: coldWalletAddress: string - The cold staking address obtained from 'cold-staking-address'. hotWalletAddress: string - The hot staking address obtained from 'cold-staking-address'. walletName: string - The name of the cold wallet. walletPassword: string - The password for the cold wallet. walletAccount: string - The account within the cold wallet (typically 'account 0'). amount: string - The amount of coins to stake. fees: string - The transaction fees. returns: hex: string - The transaction hex to be broadcast. send-transaction: description: Broadcasts a transaction to the network. parameters: hex: string - The transaction hex obtained from a previous API call (e.g., setup-cold-staking). cold-staking-withdrawal: description: Builds a transaction to return staked coins from the hot wallet to the cold wallet. requestBody: type: object properties: receivingAddress: string - The cold wallet address or account 0. walletName: string - The name of the hot wallet. walletPassword: string - The password for the hot wallet. amount: string - The amount of coins to return. fees: string - The transaction fees. returns: hex: string - The transaction hex to be broadcast. ``` -------------------------------- ### Running Node with Bootstrap Flag Source: https://github.com/block-core/blockcore/blob/master/Documentation/Features/PoA/PoA_set_up_manual.md Demonstrates the command to run the node with the `-bootstrap` flag, which is necessary for mining when the node is in IBD or not connected to other nodes. ```bash MyPoAChainD.exe -bootstrap ``` -------------------------------- ### SHA-224 Hashing Examples Source: https://github.com/block-core/blockcore/blob/master/src/Tests/Blockcore.Tests/NBitcoin/data/determiniticECDSA.txt Provides examples of SHA-224 hashing for messages 'sample' and 'test', detailing the 'k', 'r', and 's' values. ```plaintext With SHA-224, message = "sample": k = 323E7B28BFD64E6082F5B12110AA87BC0D6A6E159 r = 38A2749F7EA13BD5DA0C76C842F512D5A65FFAF32 s = 064F841F70112B793FD773F5606BFA5AC2A04C1E8 With SHA-224, message = "test": k = 091DD986F38EB936BE053DD6ACE3419D2642ADE8D r = 110F17EF209957214E35E8C2E83CBE73B3BFDEE2C ``` -------------------------------- ### Custom Network Class Example Source: https://github.com/block-core/blockcore/blob/master/Documentation/Features/PoA/PoA_set_up_manual.md Illustrates how to define a custom network class by inheriting from `Network` and overriding key parameters for a Proof-of-Authority chain. ```csharp public class MyPoANetwork : Network { public MyPoANetwork() { // Override network parameters here // Example: // MessageStart = ...; // GenesisTime = DateTimeOffset.UtcNow; // FederationPublicKeys = new[] { "pubkey1", "pubkey2" }; // TargetSpacingSeconds = 60; // PremineReward = 10000000000000000; // Base58Prefixes = new Base58Prefixes // { // AddressBase58Prefix = 0, // ScriptBase58Prefix = 5 // }; // Genesis.Header.HashMerkleRoot = ...; // Consensus.HashGenesisBlock = ...; } } ``` -------------------------------- ### Blockcore Node Stats Output Source: https://github.com/block-core/blockcore/blob/master/Documentation/Features/PoA/PoA_set_up_manual.md Example output showing the status of a running Blockcore node, including block heights, consensus information, and network connections. ```text info: Stratis.Bitcoin.FullNode[0] ======Node stats====== 10/27/2018 14:05:35 Headers.Height: 0 Headers.Hash: 564655bb087dd49164a03542475c7038be0bcb958696811cff1a6a8433f60a1c Consensus.Height: 0 Consensus.Hash: 564655bb087dd49164a03542475c7038be0bcb958696811cff1a6a8433f60a1c BlockStore.Height: 0 BlockStore.Hash: 564655bb087dd49164a03542475c7038be0bcb958696811cff1a6a8433f60a1c Wallet.Height: No Wallet ======Connection====== agent StratisBitcoin:1.2.3 ======Consensus Manager====== Unconsumed blocks: 0 -- (0 / 209 715 200 bytes). Cache is filled by: 0% ======Block Puller====== Blocks being downloaded: 0 Queued downloads: 0 Average block size: 0 KB Total download speed: 0 KB/sec Average time to download a block: NaN ms Amount of blocks node can download in 1 second: NaN ======BlockStore====== Batch Size: 0 kb / 5000 kb (0 blocks) ======PoA Miner====== Mining information for the last 20 blocks. MISS means that miner didn't produce a block at the timestamp he was supposed to. ... =======Mempool======= MempoolSize: 0 DynamicSize: 0 kb OrphanSize: 0 ``` -------------------------------- ### SHA-224 Hashing Examples Source: https://github.com/block-core/blockcore/blob/master/src/Tests/Blockcore.Tests/NBitcoin/data_pos/determiniticECDSA.txt Provides examples of SHA-224 hashing for messages 'sample' and 'test', detailing the 'k', 'r', and 's' values. ```plaintext With SHA-224, message = "sample": k = 323E7B28BFD64E6082F5B12110AA87BC0D6A6E159 r = 38A2749F7EA13BD5DA0C76C842F512D5A65FFAF32 s = 064F841F70112B793FD773F5606BFA5AC2A04C1E8 With SHA-224, message = "test": k = 091DD986F38EB936BE053DD6ACE3419D2642ADE8D r = 110F17EF209957214E35E8C2E83CBE73B3BFDEE2C ```