This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Solution { | |
public ListNode ReverseList(ListNode head) { | |
ListNode curr = head; | |
ListNode prev = null; | |
ListNode temp = null; | |
while(curr != null) | |
{ | |
temp = curr.next; // next value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using NBitcoin; | |
using NBitcoin.Protocol; | |
using NBitcoin.Protocol.Behaviors; | |
// Create a private key for the sender | |
var privateKey = new Key(); | |
// Get the public address from the private key | |
var fromAddress = privateKey.PubKey.GetAddress(Network.TestNet); | |
Console.WriteLine("Sender address: " + fromAddress); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using BitcoinLib.Services.Coins.Bitcoin; | |
using BitcoinLib.Responses; | |
using BitcoinLib.Responses.Bases; | |
using BitcoinLib.Responses.Shared; | |
// Create an instance of the BitcoinService class | |
var bitcoinService = new BitcoinService(); | |
// Get the private key of the sender | |
var privateKey = "5J3mBbAH58CpQ3Y5RNJpUKPE62SQ5tfcvU2JpbnkeyhfsYB1Jcn"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using BitcoinRpc.Protocol; | |
using BitcoinRpc.Protocol.Methods; | |
using BitcoinRpc.Protocol.Models; | |
// Connect to the Bitcoin RPC | |
var rpc = new BitcoinRpcClient("http://user:[email protected]:8332/"); | |
// Get the private key of the sender | |
var privateKey = "5J3mBbAH58CpQ3Y5RNJpUKPE62SQ5tfcvU2JpbnkeyhfsYB1Jcn"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Block | |
{ | |
public int Index { get; set; } | |
public DateTime Timestamp { get; set; } | |
public string Data { get; set; } | |
public string PreviousHash { get; set; } | |
public string Hash { get; set; } | |
public Block(int index, DateTime timestamp, string data, string previousHash) | |
{ | |
Index = index; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Blockchain | |
{ | |
public List<Block> Chain { get; set; } | |
public Blockchain() | |
{ | |
Chain = new List<Block> { new Block(0, DateTime.Now, "Genesis Block", "0") }; | |
} | |
public void AddBlock(string data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void Main(string[] args) | |
{ | |
var blockchain = new Blockchain(); | |
blockchain.AddBlock("Block 1"); | |
blockchain.AddBlock("Block 2"); | |
blockchain.AddBlock("Block 3"); | |
Console.WriteLine("Is blockchain valid? " + blockchain.IsValid()); | |
Console.WriteLine("Latest block: " + blockchain.GetLatestBlock().Data); | |
Console.ReadKey(); |