I am using bitcoinlib to communicate with bitcoin-qt
This is the code i tried:
Dim BitcoinService As Services.RpcServices.RpcService.IRpcService = New Services.Coins.Bitcoin.BitcoinService("http://localhost:8332", "Username", "Password", "wallet password", 200)
for getblocktemplate
this is the call
Dim seg As JToken = "{""rules"": [""segwit""]}"
RichTextBox5.Text = BitcoinService.GetBlockTemplate(seg).PreviousBlockHash
It gives me this error
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.
I dont understand what i am doing wrong, it works with other methods, i think it's a json problem
Help is appreciated, thank you
Try
Dim seg As JToken = JToken.Parse("{""rules"": [""segwit""]}")
because assigning a string to a JToken doesn't parse the string as json, it just makes a json string that has the given string as its value
User contributions licensed under CC BY-SA 3.0