首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Bitcoinlib库中使用getblocktemplate模板方法

如何在Bitcoinlib库中使用getblocktemplate模板方法
EN

Stack Overflow用户
提问于 2020-07-31 05:02:10
回答 1查看 171关注 0票数 0

我正在使用bitcoinlib与比特币通信-qt

这是我尝试过的代码:

代码语言:javascript
复制
 Dim BitcoinService As Services.RpcServices.RpcService.IRpcService = New Services.Coins.Bitcoin.BitcoinService("http://localhost:8332", "Username", "Password", "wallet password", 200)

对于getblocktemplate,这是调用

代码语言:javascript
复制
   Dim seg As JToken = "{""rules"": [""segwit""]}"

        RichTextBox5.Text = BitcoinService.GetBlockTemplate(seg).PreviousBlockHash

它给出了这个错误

代码语言:javascript
复制
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问题。

感谢您的帮助,谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-07-31 15:22:39

试一试

代码语言:javascript
复制
 Dim seg As JToken = JToken.Parse("{""rules"": [""segwit""]}")

因为将字符串分配给JToken不会将字符串解析为json,所以它只生成一个json字符串,该字符串将给定的字符串作为其值

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63181355

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档