Giter Club home page Giter Club logo

Comments (12)

xeniacx avatar xeniacx commented on May 27, 2024

Thanks for reporting this issue. It's very strange that you get this error, though, as the signature for GetBlockTemplate is: String GetBlockTemplate(params object[] parameters); so the response is being cast to a string and not to a strongly-typed structure.

Could you please provide me with the request's details? Are you on testnet?

from bitcoinlib.

jflecool2 avatar jflecool2 commented on May 27, 2024

I am. Crash at RpcConnector.cs:80. Heres the code I made
ICoinService CoinService = new BitcoinService(useTestnet:true);
CoinService.GetBlockTemplate();
The value of result on RpcConnector.cs:74 is:
{"result":{"version":2,"previousblockhash":"0000000000000257c44b592540c7ca1ca58338c8b411dae12e2e93d11d880c55","transactions":[{"data":"0100000001b8c34c37ee59123cb6e4088d4d3e5edc3b228df82dd5182ff7100ecb0c4e1ba3010000006a4730440220416c35df2bf0a7f406ffee16048201d2d5d6330e406e1f1330cca7513658fb52022042d9eb7eb1733c085a9bb9f3c07b2b93fca01a62e951291c521c3ae6a8206d940121025f54676f21f33f8eadcf4d452bf5df7875343bcd5f5d7cc68c92a18163623458ffffffff0200000000000000002a6a28466163746f6d21216aab8a1a621dced9b12521883aaa3ba43d0d01caaf9ee1749626529403b6dc980029fc02000000001976a914bd1a23d1afaede2e77a5004975f811592cc5bfac88ac00000000","hash":"ba9accfce030ea5cdd0d49945e51b02e0c99825877773450f1a9c76cc98996f3","depends":[],"fee":10000,"sigops":1},{"data":"01000000010ea0a388ddb17fc9e9029d8fb13f62abbaf47df5b6da9a541d97c579f89ade89000000008b4830450220692396185005aabd5ebee2d8c6f1d3b6c34cbc0fbff71ff70b96f582b53f5aa9022100fcdbf41127e8a89ff59e9b5b309521d1e355f9717be896941d69e022ee5979a90141047d14d722337adee31654b76e5f9ba6bf90d9457cae909a67c037f2f5db5012ba238615fffd0bd278c7484931006b495a6c9df3a7c07d1fe5ce218ace04f89f10ffffffff02ece90600000000001976a914cd2b1563d37f40a33588298a5e95c5760f9e1b2188acf87d0700000000001976a91442357b32aa40b7692bc97edf1812ee18fd4504d288ac00000000","hash":"bc18769ada0b8861e3503ff5ee5cc2f1bb5b89a86b4c234fc4fa0c3eb3922a3c","depends":[],"fee":100000,"sigops":2}],"coinbaseaux":{"flags":"062f503253482f"},"coinbasevalue":2500110000,"target":"00000000000002b9e90000000000000000000000000000000000000000000000","mintime":1427567985,"mutable":["time","transactions","prevblock"],"noncerange":"00000000ffffffff","sigoplimit":20000,"sizelimit":1000000,"curtime":1427567985,"bits":"1a02b9e9","height":329366},"error":null,"id":1}

from bitcoinlib.

xeniacx avatar xeniacx commented on May 27, 2024

I guess it's the : on column 11 that causes this issue.

Here is the JsonConvert.DeserializeObject Method specifications. Perhaps a JsonSerializerSettings should be deployed for the GetBlockTemplate case.

Ideas?

from bitcoinlib.

jflecool2 avatar jflecool2 commented on May 27, 2024

First, I don't understand why the : would break the deserialize method. This is perfecly valid Json data. No?
Second, Is there a reason GetWork has not been put into this library ? Is it because it has been "replaced" by GetBlockTemplate?

from bitcoinlib.

xeniacx avatar xeniacx commented on May 27, 2024

GetWork was removed in v.0.10 (commit: cf0c47b), this is why it was also removed by this library.

Well according to the exception thrown this is what breaks the deserialization: "Error reading string. Unexpected token: StartObject. Path 'result', line 1, position 11.".

More people have come across similar issues:
https://www.google.com/search?q=newtonsoft.json+Error+reading+string.+Unexpected+token:+StartObject

from bitcoinlib.

jflecool2 avatar jflecool2 commented on May 27, 2024

I have no experience in csharp json deserialization ... :(
I'm on something else, when i'll be done i'll come back and try to find a hack to fix it.

from bitcoinlib.

xeniacx avatar xeniacx commented on May 27, 2024

Maybe it's something simple, or maybe not. My time is also very limited at the moment so I would appreciate it if you could take a closer look whenever you find some time.

from bitcoinlib.

jflecool2 avatar jflecool2 commented on May 27, 2024

Will not make a pull request right now because my code is ugly but I figured it out: It was needed to make a Response object like you did in the Responses folder. It now work like a charm. Will attempt to make a pull request soon, but got stuff on my plate, such as finishing this project for university (bitcoin miner in csharp) :)

from bitcoinlib.

jflecool2 avatar jflecool2 commented on May 27, 2024

Can you tell me if I should put JsonProperty on my Response object or they are useless? It worked with them here, but none of your response object has it. or at least, a very few.

Also, does the variable name has to match ? (noncerange VS NonceRange VS Nonce_Range)?

Thanks

from bitcoinlib.

xeniacx avatar xeniacx commented on May 27, 2024

That's great news, well done.

You should only use JsonProperty in the case that you need to assign a different name to your class member, for example take a look at the GetInfoResponse class, the RPC API returns a unlocked_until field which doesn't match the camelcase naming convention used throughout the project so JsonProperty is enforced to create a match between RPC API's unlocked_until and the local field UnlockedUntil.

from bitcoinlib.

jflecool2 avatar jflecool2 commented on May 27, 2024

What do you think ?

from bitcoinlib.

xeniacx avatar xeniacx commented on May 27, 2024

Fixed with #22

from bitcoinlib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.