public static bool gobject_submit(bool fTestNet, string sID, int nProposalTimeStamp, string sHex, string sPrepareTXID) { try { if (sPrepareTXID == "") { return(false); } // Submit the gobject to the network - gobject submit parenthash revision time datahex collateraltxid string sArgs = "0 1 " + nProposalTimeStamp.ToString() + " " + sHex + " " + sPrepareTXID; string sCmd1 = "gobject submit " + sArgs; object[] oParams = new object[6]; oParams[0] = "submit"; oParams[1] = "0"; oParams[2] = "1"; oParams[3] = nProposalTimeStamp.ToString(); oParams[4] = sHex; oParams[5] = sPrepareTXID; NBitcoin.RPC.RPCClient n = fTestNet ? WebRPC.GetTestNetRPCClient() : WebRPC.GetLocalRPCClient(); dynamic oOut = n.SendCommand("gobject", oParams); string sSubmitTXID = oOut.Result.ToString(); if (sSubmitTXID.Length > 20) { // Update the record allowing us to know this has been submitted string sql = "Update Proposal set Submitted=GetDate(),SubmitTXID='" + sSubmitTXID + "' where id = '" + sID + "'"; Common.gData.Exec(sql); return(true); } return(false); } catch (Exception ex) { return(false); } }
public static int GetHeight() { object[] oParams = new object[1]; NBitcoin.RPC.RPCClient n = GetLocalRPCClient(); dynamic oOut = n.SendCommand("getmininginfo"); int nBlocks = (int)GetDouble(oOut.Result["blocks"]); return(nBlocks); }
public static void SyncFastlyNicknames() { try { string path = GetFolderUnchained("nicknames.dat"); DateTime diMod = System.IO.File.GetLastWriteTime(path); TimeSpan tsElapsed = System.DateTime.Now - diMod; if (dicNicknames.Count() == 0) { MemorizeNickNames(); } if (tsElapsed.TotalSeconds < (60 * 30)) { return; } NBitcoin.RPC.RPCClient c = WebRPC.GetLocalRPCClient(); object[] oParams = new object[2]; oParams[0] = "cpk"; oParams[1] = "9999999"; dynamic j = c.SendCommand("datalist", oParams); JObject j1 = j.Result; JArray ja = (JArray)j.Result.ChildrenTokens; string data = ""; foreach (var jcpk in j1) { string skey = jcpk.Key; string sValue = jcpk.Value.ToString(); string sType = GetEle(skey, "[-]", 0); string sPriKey = GetEle(skey, "[-]", 1); string sCPK = GetEle(sValue, "|", 0); string sNN = GetEle(sValue, "|", 1); if (sType == "CPK" && sCPK != "" && sNN != "") { string sRow = sType + "|" + sCPK + "|" + sNN + "\r\n"; data += sRow; } } Unchained.WriteToFile(path, data); MemorizeNickNames(); } catch (Exception ex) { Log("SyncFastlyNicknames " + ex.Message); } }
public static string SendRawTx(string hex) { try { object[] oParams = new object[1]; oParams[0] = hex; NBitcoin.RPC.RPCClient n = GetLocalRPCClient(); dynamic oOut = n.SendCommand("sendrawtransaction", oParams); string result = oOut.Result.Value; // To do return binary response code here; check response for fail and success if (result == null) { return(""); } return(result); } catch (Exception ex) { Common.Log("SendRawTx:: " + ex.Message); return(""); } }
public static void gobject_prepare(bool fTestNet, string sID, int StartTimeStamp, string sHex) { // gobject prepare string sArgs = "0 1 " + StartTimeStamp.ToString() + " " + sHex; string sCmd1 = "gobject prepare " + sArgs; object[] oParams = new object[5]; oParams[0] = "prepare"; oParams[1] = "0"; oParams[2] = "1"; oParams[3] = StartTimeStamp.ToString(); oParams[4] = sHex; NBitcoin.RPC.RPCClient n = fTestNet ? WebRPC.GetTestNetRPCClient() : WebRPC.GetLocalRPCClient(); dynamic oOut = n.SendCommand("gobject", oParams); string sPrepareTXID = oOut.Result.ToString(); string sql4 = "Update Proposal Set PrepareTxId='" + sPrepareTXID + "',Updated=getdate() where id = '" + sID + "'"; Common.gData.Exec(sql4); }