BitnetClient getConnection() { BitnetClient bc = new BitnetClient(textBox10.Text); bc.Credentials = new NetworkCredential(getUserName(), getPassword()); return(bc); }
void ThreadFunc() { while (true) { try { if (mURL != null && mPort != 0 && mUser != null && mPass != null) { BitnetClient bc = new BitnetClient("http://" + mURL + ":" + mPort); bc.Credentials = new NetworkCredential(mUser, mPass); int blockCount = bc.GetBlockCount(); if (blockCount > mBlockCount) { mBlockCount = blockCount; mNewBlockReady = true; } } } catch (Exception) { } Thread.Sleep(1000 * 10); } }
private static void CheckMnSendMoney() { var valuesSection = Configuration.GetSection("Nodes").GetChildren(); Console.WriteLine("----------------------------------------------------"); foreach (var item in valuesSection) { var bc = new BitnetClient("http://" + Configuration[item.Path + ":Server"] + ":" + Configuration[item.Path + ":Port"]) { Credentials = new NetworkCredential(Configuration[item.Path + ":RpcUser"], Configuration[item.Path + ":RpcPasword"]) }; try { Console.WriteLine("БАЛАНС {0} РАВЕН {1}", Configuration[item.Path + ":Symbol"], bc.GetBalance() + "\n"); } catch (Exception e) { Console.WriteLine("ЗАПИСАЛ ОШИБКУ ЗАПРОСА В ЛОГ"); } if (bc.GetBalance() > 1001) { var sendmoney = bc.GetBalance() - 1001; Console.WriteLine("Отправка денег на биржу {0} монет", sendmoney); bc.SendToAddress(Configuration[item.Path + ":WalletAddress"], sendmoney, "MNManager", ""); } } Console.WriteLine("----------------------------------------------------"); }
public override WorkBlock GetWorkBlock() { WorkBlock work = null; JObject obj = null; try { // Get block from bitcoin BitnetClient bc = new BitnetClient("http://" + mURL + ":" + mPort); bc.Credentials = new NetworkCredential(mUser, mPass); mBlockCount = bc.GetBlockCount(); obj = bc.GetWork(); mNewBlockReady = false; } catch (Exception e) { Console.WriteLine("Failed to get work!"); Console.WriteLine(e.Message); } if (obj != null) { work = new WorkBlock(obj); } return(work); }
WorkBlock GetWork() { /* * HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://127.0.0.1:8332/"); * req.TransferEncoding = ""; * req.ServicePoint.UseNagleAlgorithm = false; * req.Method = "POST"; * req.ContentType = "application/json"; * req.Expect = ""; * req.Credentials = new NetworkCredential("rpcuser", "rpcpass"); * * StreamWriter sw = new StreamWriter(req.GetRequestStream()); * sw.Write("{\"method\": \"getwork\", \"params\": [], \"id\":0}\r\n"); * sw.Close(); * * HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); * StreamReader sr = new StreamReader(resp.GetResponseStream(), Encoding.Default); * * string str = sr.ReadToEnd(); * Console.WriteLine(str); * WorkBlock work = new WorkBlock(str); * * sr.Close(); */ BitnetClient bc = new BitnetClient("http://127.0.0.1:8332"); bc.Credentials = new NetworkCredential("rpcuser", "rpcpass"); JObject obj = bc.GetWork(); WorkBlock work = new WorkBlock(obj); return(work); }
static void Main() { BitnetClient bc = new BitnetClient("http://127.0.0.1:8332"); bc.Credentials = new NetworkCredential("user", "pass"); var p = bc.GetDifficulty(); Console.WriteLine(p); }
void SubmitWork(WorkBlock work) { //string dataStr = HashToString(work.data) BitnetClient bc = new BitnetClient("http://127.0.0.1:8332"); bc.Credentials = new NetworkCredential("rpcuser", "rpcpass"); //bc. }
public MainForm() { InitializeComponent(); client = new BitnetClient("http://127.0.0.1:22823"); client.Credentials = new NetworkCredential("user", "password"); known_addresses = new List <string>() { textBox_address.Text }; known_transactions = new List <string>() { }; }
public override bool SubmitWork(WorkBlock work, uint solution) { // Submit this solution to bitcoin string data = work.GetSolutionString(solution); Console.WriteLine("Trying solution: " + data); BitnetClient bc = new BitnetClient("http://" + mURL + ":" + mPort); bc.Credentials = new NetworkCredential(mUser, mPass); bool success = bc.GetWork(data); if (!success) { data = work.GetSolutionString((uint)IPAddress.HostToNetworkOrder((int)solution)); success = bc.GetWork(data); } return(success); }
bool walletConnect() { //TODO: грузить данные для подключения из .conf файла //TODO: сделать генерацию .conf файлов со случайными данными BitnetClient client = new BitnetClient("http://127.0.0.1:22823"); client.Credentials = new NetworkCredential("user", "password"); bool result = true; //проверка try { client.GetBalance(); bc = client; } catch (Exception ex) { result = false; Debug.Print("Отловлено исключение: " + ex.Message); } return(result); }
public static void InitializeNewBitnet(string sNetworkID) { mBitnetUseCount += 1; try { if (mBitnetNewClient == null || mBitnetUseCount < 5) { mBitnetNewClient = new BitnetClient(AppSetting("RPCURL" + sNetworkID, "")); string sPass = AppSetting("RPCPass" + sNetworkID, ""); NetworkCredential Cr = new NetworkCredential(AppSetting("RPCUser" + sNetworkID, ""), sPass); mBitnetNewClient.Credentials = Cr; } } catch (Exception) { mBitnetNewClient = new BitnetClient(AppSetting("RPCURL" + sNetworkID, "")); string sPass = AppSetting("RPCPass" + sNetworkID, ""); NetworkCredential Cr = new NetworkCredential(AppSetting("RPCUser" + sNetworkID, ""), sPass); mBitnetNewClient.Credentials = Cr; } }
private static void TestSignVerifyMessage(string privatekey, string walletaddr, Keys.PrivateKeyHelpInfo info, Keys.WalletAddrHelpInfo walletInfo, BitnetClient client) { // local sign message string checkRet = Keys.sign_message_shp( privatekey, "Hdac Technology, Solution Dev Team, Test Text.", ref info, ref walletInfo); Console.WriteLine("\n4. Test for sign message"); Console.WriteLine("[" + checkRet + "]"); // rpc sign message var s1 = client.SignMessage(privatekey, "Hdac Technology, Solution Dev Team, Test Text."); Console.WriteLine("RPC signmessage result : {0}", s1); // local verify message int Ret = Keys.verify_message_shp( walletaddr, checkRet, "Hdac Technology, Solution Dev Team, Test Text.", ref walletInfo); Console.WriteLine("\n5. Test for verify message"); Console.WriteLine("true(1) or false(0) : [" + Ret + "]"); // rpc verify message var v1 = client.VerifyMessage(walletaddr, checkRet, "Hdac Technology, Solution Dev Team, Test Text."); Console.WriteLine("RPC verifymessage result : {0}", v1); }
public static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine(@"Usage: earlzplorer coin.conf rpcport command Commands: summarizeblocks begin-end summarizeblocktransactions blocknum getblockbynumber blocknum dumpblockswithtx begin-end dumpblockwithtx blocknum richlist [untilblock] richminers [begin-end] (defaults to last 10,000 blocks) note: The best time can be had by redirecting output to a file, and then using a text editor to skim the file "); return; } var config = File.ReadAllLines(args[0]); string username = null; string password = null; int? port = null; foreach (var eachline in config) { var line = eachline; line = line.Trim(); if (line.StartsWith("rpcuser="******"rpcuser="******"rpcpassword="******"rpcpassword="******"rpcport=")) { port = int.Parse(line.Substring("rpcport=".Length)); } } if (!port.HasValue) { port = int.Parse(args[1]); } var bc = new BitnetClient("http://127.0.0.1:" + port.Value, username, password); var s = new Summarizer(bc); Range r; int num; switch (args[2]) { case "summarizeblocks": r = ParseRange(args); s.SummarizeBlocks(r.Begin, r.End); break; case "dumpblockswithtx": r = ParseRange(args); s.DumpBlocksWithTx(r.Begin, r.End); break; case "dumpblockwithtx": num = int.Parse(args[3]); s.DumpBlocksWithTx(num, num + 1); break; default: Console.WriteLine("Unknown command"); return; } }
public Summarizer(BitnetClient bc) { Bit = bc; }
static void Main(string[] args) { //Keys.TestStruct result = new Keys.TestStruct(); //Keys.test_return_mashal(ref result); //Console.WriteLine("result : {0}, {1}", result.ulongData, result.intData); //Console.WriteLine("result string : {0}, {1}", result.stringData1, result.stringData2); BitnetClient client = new BitnetClient("http://13.125.145.98:4260"); client.Credentials = new NetworkCredential("hdacrpc", "1234"); var p1 = client.GetBlockchainParams(); Keys.PrivateKeyHelpInfo info = new Keys.PrivateKeyHelpInfo(); info.addrChecksum = p1["address-checksum-value"].ToString(); info.privateKeyPrefix = p1["private-key-version"].ToString(); Keys.WalletAddrHelpInfo walletInfo = new Keys.WalletAddrHelpInfo(); walletInfo.addrChecksum = p1["address-checksum-value"].ToString(); walletInfo.pubKeyAddrPrefix = p1["address-pubkeyhash-version"].ToString(); walletInfo.scriptAddrPrefix = p1["address-scripthash-version"].ToString(); Keys.Keypairs keypairs = new Keys.Keypairs(); Keys.create_key_pairs_shp(ref info, ref walletInfo, ref keypairs); Console.WriteLine("1. Test for creating key-pairs"); Console.WriteLine("private key: {0}, \npublic key: {1}, \npublic hash: {2}, \nwallet addr: {3}", keypairs.privateKey, keypairs.pubKey, keypairs.pubKeyHash, keypairs.walletAddr); // wallet address "1WCRNaPb3jAjb4GE9t34uLiLtPseA8JKEvdtg5" is from the private key, "V6X4NaaDQSTgXdAcCzUrSxWqAuFcd53TRXRqmSafUYEbY5DgGMitPEzk" var unspents = client.ListUnspent("1WCRNaPb3jAjb4GE9t34uLiLtPseA8JKEvdtg5"); JToken selected = null; foreach (var unspent in unspents) { if (unspent["assets"].Count() == 0) { selected = unspent; } } if (selected == null) { Console.WriteLine("unspent not founc"); return; } string scriptPubKey = selected["scriptPubKey"].ToString(); string txid = selected["txid"].ToString(); uint vout = UInt32.Parse(selected["vout"].ToString()); string createTxid = null; String streamName = "stream9"; var streamInfos = client.ListStreams(streamName); foreach (var stream in streamInfos) { if (stream["name"].ToString() == streamName) { createTxid = stream["createtxid"].ToString(); } } if (createTxid == null) { Console.WriteLine("createTxid not found"); return; } String checkRet = Keys.create_stream_publish_tx_shp("key1", "tested by moony", createTxid, scriptPubKey, txid, vout, "", "V6X4NaaDQSTgXdAcCzUrSxWqAuFcd53TRXRqmSafUYEbY5DgGMitPEzk", ref info); Console.WriteLine("\n2. Test for publishing stream"); Console.WriteLine("raw-tx: {0}", checkRet); checkRet = Keys.create_asset_send_tx_shp("1WCRNaPb3jAjb4GE9t34uLiLtPseA8JKEvdtg5", 10, "44fdb8103f4e13d6ef2011d54933f2747b455c613b3cfe4886d187330d50b640", 10, "76a9143ab53060d41b5fa662a2d4575a69464b5759839588ac1c73706b7174f23349d51120efd6134e3f10b8fd44ac2600000000000075", "030374d736a70c5faf5d16887d2263e812cb896938bedeefd44c128417e2460a", 1, 990.0, "", "VHXjccrTPdRXG8asyos5oqvw6mhWtqASkbFsVuBnkpi4WXn2jr8eMwwp", ref info, ref walletInfo ); Console.WriteLine("\n3. Test for create asset send tx"); Console.WriteLine("raw-tx: {0}", checkRet); TestSignVerifyMessage(keypairs.privateKey, keypairs.walletAddr, info, walletInfo, client); Console.WriteLine("end"); }