-
kalgecin commented at 5:40 pm on November 17, 2015: noneCurrently calling rpc commands does not return any values. They need to return at minimum true or false. true if the command was successful, false otherwise. For example, I have a script that imports private keys. I’d like to know whether the key i just tried importing imported or not, flag it if it hasn’t move on if it was.
-
sipa commented at 5:59 pm on November 17, 2015: memberThis seems very reasonable to me, but I’m not sure it’s worth changing the API over. Traditionally, RPCs that have a stateful effect return Null (or an error if they fail), and only RPCs that request data return actual values.
-
kalgecin commented at 6:41 pm on November 17, 2015: noneok, but there is no error returned if say the private key is wrong, it still returns null. there needs to be a way to know if the command you just sent was completed successfuly
-
sipa commented at 6:45 pm on November 17, 2015: member
No, an error should definitely be returned in that case: https://github.com/bitcoin/bitcoin/blob/v0.11.2/src/wallet/rpcdump.cpp#L115
If that isn’t working, there is definitely a bug.
-
sipa commented at 6:56 pm on November 17, 2015: memberNote that errors are returned as JSON-RPC errors, not as return values.
-
kalgecin commented at 7:35 pm on November 17, 2015: nonei receive null in either case
-
sipa commented at 7:37 pm on November 17, 2015: memberThe return value will be Null in both cases. But one should have a JSON-RPC error code and the other shouldn’t.
-
kalgecin commented at 7:42 pm on November 17, 2015: nonewhen using the client, yes, but when calling using external programs, it does not. try with the example using curl
-
luke-jr commented at 7:46 pm on November 17, 2015: member
Works for me
0$ curl -u 'bitcoinrpc' http://localhost:8332 -d '{"method":"importprivkey","params":["invalid"],"id":0}' 1Enter host password for user 'bitcoinrpc': 2{"result":null,"error":{"code":-5,"message":"Invalid private key encoding"},"id":0}
-
sipa commented at 7:46 pm on November 17, 2015: memberYou need to look at the returned header to see the error status. Curl is not a full JSON-RPC client.
-
jonasschnelli commented at 9:42 am on November 18, 2015: contributor
Works for me here:
0jonasschnelli$ curl -v --user bitcoin --data-binary '{"method":"importprivkey","params":["invalid"],"id":0}' -H 'content-type: text/plain;' http://127.0.0.1:18332/ 1 2* Trying 127.0.0.1... 3* Connected to 127.0.0.1 (127.0.0.1) port 18332 (#0) 4* Server auth using Basic with user 'bitcoin' 5> POST / HTTP/1.1 6> Host: 127.0.0.1:18332 7> Authorization: Basic Yml0Y29pbjp0ZXN0 8> User-Agent: curl/7.43.0 9> Accept: */* 10> content-type: text/plain; 11> Content-Length: 54 12> 13* upload completely sent off: 54 out of 54 bytes 14< HTTP/1.1 500 Internal Server Error 15< Content-Type: application/json 16< Date: Wed, 18 Nov 2015 09:42:12 GMT 17< Content-Length: 84 18< 19{"result":null,"error":{"code":-5,"message":"Invalid private key encoding"},"id":0}
-
laanwj commented at 2:20 pm on November 19, 2015: memberWorks fine for me.
-
laanwj closed this on Nov 19, 2015
-
MarcoFalke commented at 3:59 pm on November 19, 2015: member
Traditionally, RPCs that have a stateful effect return Null (or an error if they fail), and only RPCs that request data return actual values.
So
settxfee
etc. should not return true? -
MarcoFalke locked this on Sep 8, 2021
github-metadata-mirror
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-17 18:12 UTC
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-17 18:12 UTC
This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me
More mirrored repositories can be found on mirror.b10c.me