Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- donations LTC LWffnmX32ersnjGyPTNjpYhadk8YM84eb9
- donations BTC 1FrankZ7t5Wbf5uTMxMtCiQy9eKDsj1fUn
- insert onto form
- button1 'button named button1
- txtrate 'txt box to input ur price
- txtamount 'txt box to imput the coins
- lstmeth 'listbox collective data =getInfo Trade TradeHistory
- lstType 'listbox collective data = buy sell
- lstpair 'listbox collective data = btc_usd ltc_btc ltc_usd
- you can ofcourse change it so that the postdata grabs from other objects instead of listboxes
- but this is just a quick example, leaving you the fun to play around after remember to add in your key and secret into the place where it asks (inside the button sub). you will see the only web address it links to is BTC-E.com
- -copy code below this line into form coding and insert button1 onto form to test-
- Imports System.Net
- Imports System.Text
- Imports System.IO
- Imports System.Security.Cryptography
- Public Class Form1
- Private Sub Form1_Load_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- LstType.Items.Add("buy")
- LstType.Items.Add("sell")
- LstPair.Items.Add("ltc_usd")
- LstPair.Items.Add("ltc_btc")
- LstPair.Items.Add("btc_usd")
- LstMeth.Items.Add("Trade")
- end sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim postData As String
- Dim postReq As HttpWebRequest = DirectCast(WebRequest.Create("https://btc-e.com/tapi"), HttpWebRequest)
- Dim randomn As String
- Dim keyer As String = LCase("YOUR_KEY") 'your key goes here
- Dim secret As String = "Y0urS3cR3tC0de" 'your secret goes here
- randomn = GetUnixTimestamp(Now)
- postData = "method=" & Lstmeth.SelectedItem & "&nonce=" & randomn & "&pair=" & Lpair.SelectedItem & "&type=" & lstType.selecteditem & "&rate=" & Txtrate.Text & "&amount=" & TxtAmount.Text
- Dim KeyByte() As Byte = Encoding.ASCII.GetBytes(secret)
- Dim HMAcSha As New HMACSHA512(Encoding.ASCII.GetBytes(secret))
- Dim messagebyte() As Byte = Encoding.ASCII.GetBytes(postData)
- Dim hashmessage() As Byte = HMAcSha.ComputeHash(messagebyte)
- Dim Sign As String = BitConverter.ToString(hashmessage)
- Sign = Sign.Replace("-", "")
- postReq.Method = "POST"
- postReq.KeepAlive = False
- postReq.Headers.Add("Key", keyer)
- postReq.Headers.Add("Sign", LCase(Sign))
- postReq.ContentType = "application/x-www-form-urlencoded"
- postReq.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2.3) Gecko/20100401 Firefox/4.0 (.NET CLR 3.5.30729)"
- postReq.ContentLength = messagebyte.Length
- Dim postreqstream As Stream = postReq.GetRequestStream()
- postreqstream.Write(messagebyte, 0, messagebyte.Length)
- postreqstream.Close()
- Dim postresponse As HttpWebResponse
- postresponse = DirectCast(postReq.GetResponse(), HttpWebResponse)
- Dim postreqreader As New StreamReader(postresponse.GetResponseStream())
- Dim thepage As String = postreqreader.ReadToEnd
- thepage = thepage.Replace(Chr(34), Chr(39))
- MsgBox(thepage)
- End Sub
- Private Function StringToSHA512(ByVal content As String) As String
- Dim M5 As New SHA512Managed
- Dim bytestring() As Byte = Encoding.UTF8.GetBytes(content)
- bytestring = M5.ComputeHash(bytestring)
- Dim signer As String = Nothing
- For Each bt As Byte In bytestring
- signer &= bt.ToString("x2")
- Next
- Return signer
- End Function
- Private Function GetUnixTimestamp(ByVal currDate As DateTime) As Double
- 'create Timespan by subtracting the value provided from the Unix Epoch
- Dim span As TimeSpan = (currDate - New DateTime(2012, 1, 1, 0, 0, 0, 0).ToLocalTime())
- 'return the total seconds (which is a UNIX timestamp)
- Return span.TotalSeconds
- End Function
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement