我正在使用bitcoinlib与比特币通信-qt
这是我尝试过的代码:
Dim BitcoinService As Services.RpcServices.RpcService.IRpcService = New Services.Coins.Bitcoin.BitcoinService("http://localhost:8332", "Username", "Password", "wallet password", 200)对于getblocktemplate,这是调用
Dim seg As JToken = "{""rules"": [""segwit""]}"
RichTextBox5.Text = BitcoinService.GetBlockTemplate(seg).PreviousBlockHash它给出了这个错误
BitcoinLib.ExceptionHandling.Rpc.RpcInternalServerErrorException
HResult=0x80131500
Message=JSON value is not an object as expected
Source=BitcoinLib
Arborescence des appels de procédure :
à BitcoinLib.RPC.Connector.RpcConnector.MakeRequest[T](RpcMethods rpcMethod, Object[] parameters)
à BitcoinLib.Services.CoinService.GetBlockTemplate(Object[] parameters)
à WindowsApp3.Form1.Button2_Click(Object sender, EventArgs e) dans C:\Users\Hama\source\repos\WindowsApp3\WindowsApp3\Form1.vb :ligne 76
à System.Windows.Forms.Control.OnClick(EventArgs e)
à System.Windows.Forms.Button.OnClick(EventArgs e)
à System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
à System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
à System.Windows.Forms.Control.WndProc(Message& m)
à System.Windows.Forms.ButtonBase.WndProc(Message& m)
à System.Windows.Forms.Button.WndProc(Message& m)
à System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
à System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
à System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
à System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
à System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
à System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
à System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
à Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
à Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
à Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
à WindowsApp3.My.MyApplication.Main(String[] Args) dans :ligne 81
Cette exception a été levée à l'origine dans cette pile des appels :
System.Net.HttpWebRequest.GetResponse()
BitcoinLib.RPC.Connector.RpcConnector.MakeRequest<T>(BitcoinLib.RPC.Specifications.RpcMethods, object[])
Exception interne 1 :
WebException : Le serveur distant a retourné une erreur : (500) Erreur interne du serveur.我不明白我做错了什么,它适用于其他方法,我认为这是一个json问题。
感谢您的帮助,谢谢
发布于 2020-07-31 15:22:39
试一试
Dim seg As JToken = JToken.Parse("{""rules"": [""segwit""]}")因为将字符串分配给JToken不会将字符串解析为json,所以它只生成一个json字符串,该字符串将给定的字符串作为其值

https://stackoverflow.com/questions/63181355
复制相似问题