private static void ExecuteConnected(int number) { if (number < 0 && number > 2) { MenuHelper.DisplayError("Please enter an option between [1-3]"); } switch (number) { case 1: // getrawmempool. var result = _rpcClient.GetRawMemPool().Result; Console.WriteLine(result); ExecuteMenu(); return; case 2: // mempool. _nodeLauncher.Broadcast(new MemPoolMessage(_nodeLauncher.GetNetwork())); break; case 3: Console.WriteLine("Bye bye"); Console.ReadLine(); return; } ExecuteMenu(); }
private static void ExecuteConnectedWallet(int number) { if (number < 0 && number > 6) { MenuHelper.DisplayError("Please enter an option between [1-6]"); } switch (number) { case 1: // BROADCAST A UTXO TRANSACTION. Console.WriteLine("Please enter the address"); var receivedHash = Console.ReadLine(); var deserializedAdr = BlockChainAddress.Deserialize(receivedHash); Console.WriteLine("How much do-you want to send ?"); var value = MenuHelper.EnterNumber(); var blockChain = BlockChainStore.Instance().GetBlockChain(); var builder = new TransactionBuilder(); var transaction = builder.NewNoneCoinbaseTransaction() // .Spend(0, ) .AddOutput(value, Script.CreateP2PKHScript(deserializedAdr.PublicKeyHash)) .Build(); var serializedTransaction = transaction.Serialize(); // SEND UTXO. _nodeLauncher.Broadcast(transaction); ExecuteMenu(); return; case 2: // GENERATE A NEW BITCOIN ADDRESS. var key = Key.Genererate(); var h = new BigInteger(key.GetPublicKeyHashed()); var blockChainAddress = new BlockChainAddress(ScriptTypes.P2PKH, _nodeLauncher.GetNetwork(), key); var hash = blockChainAddress.GetSerializedHash(); Console.WriteLine($"Give the bitcoin address to the person {hash}"); Console.WriteLine("Please enter a password to protect your wallet"); var password = Console.ReadLine(); _keyRepository.Load(password); _keyRepository.Keys.Add(key); _keyRepository.Save(password); break; case 3: DisplayWalletInformation(); ExecuteMenu(); return; case 4: _nodeLauncher.RefreshBlockChain(); ExecuteMenu(); break; case 5: _nodeLauncher.RefreshConnectedPeers(); ExecuteMenu(); break; case 6: Console.WriteLine("Bye bye"); Console.ReadLine(); return; } ExecuteMenu(); }