Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 通过json rpc将createrawtransaction发送到比特币qt时出现问题_Vb.net_Bitcoin_Json Rpc - Fatal编程技术网

Vb.net 通过json rpc将createrawtransaction发送到比特币qt时出现问题

Vb.net 通过json rpc将createrawtransaction发送到比特币qt时出现问题,vb.net,bitcoin,json-rpc,Vb.net,Bitcoin,Json Rpc,我试图通过json rpc发布到本地比特币qt,但从服务器收到错误500 我尝试了这段代码,但它给出了错误500,它与其他方法(如getblockcount或getnewaddress Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim jArray As JContainer = New JArray() '

我试图通过json rpc发布到本地比特币qt,但从服务器收到错误500

我尝试了这段代码,但它给出了错误500,它与其他方法(如
getblockcount
getnewaddress

 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Dim jArray As JContainer = New JArray()                  '

        Dim jToTx As New JObject
        jToTx.Add("Tbc1q5t4sexcufx9ecnepfd4v88j8fvq3q5ymzetmqt", "6.5")

        Dim jArray2 As JContainer = New JArray From {jToTx}

        Dim jFromTx As New JObject
        jFromTx.Add("txid", "0000000000000000000000000000000000000000000000000000000000000000")
        jFromTx.Add("vout", "0")

        jArray.Add(jFromTx)

        RichTextBox5.Text = RequestServer("createrawtransaction", New List(Of JToken) From {jArray, jArray2})

    End Sub

请求服务器功能:

 Public Shared Function RequestServer(ByVal methodName As String, ByVal parameters As List(Of JToken)) As JToken
        Dim ServerIp As String = "http://localhost:8332"
        Dim UserName As String = "hama"
        Dim Password As String = "hama"
        Dim webRequest As HttpWebRequest = CType(webRequest.Create(ServerIp), HttpWebRequest)
        webRequest.Credentials = New NetworkCredential(UserName, Password)

        webRequest.ContentType = "application/json-rpc"
        webRequest.Method = "POST"


        Dim respVal As String = String.Empty
        Dim joe As JObject = New JObject
        joe.Add(New JProperty("jsonrpc", 1))
        joe.Add(New JProperty("id", 1))
        joe.Add(New JProperty("method", methodName))
        Dim props As JArray = New JArray
        For Each parameter In parameters
            props.Add(parameter)
        Next
        joe.Add(New JProperty("params", props))
        ' serialize json for the request
        Dim s As String = JsonConvert.SerializeObject(joe)
        Dim byteArray() As Byte = Encoding.UTF8.GetBytes(s)
        webRequest.ContentLength = byteArray.Length
        Dim dataStream As Stream = webRequest.GetRequestStream
        dataStream.Write(byteArray, 0, byteArray.Length)
        dataStream.Close()
        Dim streamReader As StreamReader = Nothing
        Try
            Dim webResponse As WebResponse = webRequest.GetResponse
            streamReader = New StreamReader(webResponse.GetResponseStream, True)
            respVal = streamReader.ReadToEnd
            Dim data = JsonConvert.DeserializeObject(respVal).ToString
            Return data
        Catch exp As Exception
MsgBox(exp.ToString)

        Finally
            If (Not (streamReader) Is Nothing) Then
                streamReader.Close()
            End If

        End Try

        Return String.Empty


    End Function
我的比特币.conf

server=1
rpcuser=hama
rpcpassword=hama
rpcallowip=127.0.0.1
rpcport=8332

catch块中的错误代码:

System.Net.WebException
  HResult = 0x80131509
  Message = The remote server returned an error: (500) Internal server error.
  Source = WindowsApp3
  Procedure call tree:
   to WindowsApp3.Form1.RequestServer (String methodName, List`1 parameters) in C: \ Users \ Hama \ source \ repos \ WindowsApp3 \ WindowsApp3 \ Form1.vb: line 170
   to WindowsApp3.Form1.Button1_Click (Object sender, EventArgs e) in C: \ Users \ Hama \ source \ repos \ WindowsApp3 \ WindowsApp3 \ Form1.vb: line 40
   at System.Windows.Forms.Control.OnClick (EventArgs e)
   at System.Windows.Forms.Button.OnClick (EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp (MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp (Message & m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc (Message & m)
   at System.Windows.Forms.ButtonBase.WndProc (Message & m)
   at System.Windows.Forms.Button.WndProc (Message & m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage (Message & m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc (Message & m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback (IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW (MSG & msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop (IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner (Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop (Int32 reason, ApplicationContext context)
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun ()
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel ()
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run (String [] commandLine)
   to WindowsApp3.My.MyApplication.Main (String [] Args) in: line 81
谢谢你的帮助