Inheritance: IBitnetClient
Example #1
0
 public MainForm()
 {
     InitializeComponent();
     this.Config = new ConfigFile();
     this.Bitcoin = new BitnetClient();
     this.SSHConnection = new SSHCore();
 }
Example #2
0
        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;
        }
Example #3
0
 public ConfigForm(ConfigFile CF, BitnetClient RPC, SSHCore SSH)
 {
     InitializeComponent();
     this.Config = CF;
     this.Bitcoin = RPC;
     this.SSHConnection = SSH;
 }
Example #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            BitnetClient nmc = new BitnetClient("http://127.0.0.1:9332");
            nmc.Credentials = new NetworkCredential("enmaku", "nightowl");
            //bc.SendFrom("enmaku", "ms43w2uQ4nUerVRmTGRBvwxG1XY3B4uDST", 1, 1, "sent from Bitnet code", "");
            var p = nmc.GetBalance();

            BitnetClient btc = new BitnetClient("http://127.0.0.1:8332");
            btc.Credentials = new NetworkCredential("enmaku", "nightowl");
            var q = btc.GetBalance("mtred (multi)", 0);
        }
Example #5
0
 public EditAddress(BitnetClient RPC, string Address, bool RecvMode, bool New)
 {
     InitializeComponent();
     this.Bitcoin = RPC;
     this.ReceiveMode = RecvMode;
     AddressBox.Text = Address;
     if (!this.ReceiveMode)
     {
         this.GetDestAddresses();
     }
     if (New)
         this.ItemIndex = -1;
 }
Example #6
0
        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;
        }
Example #7
0
 public SendMoneyForm(BitnetClient RPC)
 {
     InitializeComponent();
     this.Bitcoin = RPC;
 }
 BitnetClient getConnection()
 {
     BitnetClient bc = new BitnetClient(textBox10.Text);
     bc.Credentials = new NetworkCredential(getUserName(), getPassword());
     return bc;
 }
Example #9
0
        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.
        }
Example #10
0
        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;
        }
Example #11
0
 public AddressBookForm(BitnetClient RPC)
 {
     InitializeComponent();
     this.Bitcoin = RPC;
 }
Example #12
0
        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;
            }
        }
Example #13
0
 public Transaction(BitnetClient RPC, string txid)
 {
     this.Bitcoin = RPC;
     this.Fetch(txid);
 }
Example #14
0
 public ConsoleForm(BitnetClient RPC)
 {
     InitializeComponent();
     this.Bitcoin = RPC;
 }
Example #15
0
        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);
            }
        }