-
Notifications
You must be signed in to change notification settings - Fork 38.7k
[REST] Post-Merge overhaul of the REST API #5326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/rest.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the second '<< binaryTx'. The response is sent twice now (but the Content-Length only covers the first).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops. was to quick.
Now it seams to be okay:
curl -v http://localhost:18332/rest/tx/3cfe5051f7efe2702c5720b1ce6f5984181b9172a399935ff22a3e08df143c91/dat > test.bin
< Content-Length: 109
ls -la test.bin
-rw-r--r-- 1 jonasschnelli staff 109 20 Nov 14:13 test.bin
80783e2 to
f3d52fb
Compare
src/rest.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the point of using HTTPReply with headersOnly=true here was to avoid an extra string copy.
You could use HTTPReplyHeader(HTTP_OK, fRun, binaryBlock.size(), "application/octet-stream") << binaryBlock
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. That makes sense.
|
just changed.
|
src/rest.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't indent cases please.
9d79530 to
c273e11
Compare
|
I'm not sure how useful .format is. .extension would be more natural. Of course, you could add dat as equivalent for binary, and .txt as equivalent for hex... |
c273e11 to
6f38f6d
Compare
|
As said on IRC my preference would be to use ?format=hex and restore json as the default. |
|
No, it's not too late. Now would be the time for wider criticism of the API, and the fixing of any API bugs. |
6f38f6d to
eb1cbe5
Compare
|
utACK |
src/init.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO better: Accept public REST requests (default: 0)
Can you add the default for -server, too?
See e.g. -forcednsseed style to be able to use %d in the string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now i think it make sense to just change the -rest command. Changing the -server command in this pull would mix things up.
1e1868e to
4820cae
Compare
src/rpcserver.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although in practice updates of booleans are likely atomic, this needs a LOCK(cs_rpcWarmup) for completeness' sake
|
Code looks good to me, and I've done some basic testing and it works as expected. I am still in doubt whether we should expose the
|
|
So maybe a format arg (?format=hex) and binary as default?
|
|
The JSON mirrors the RPC format output, when possible. However, the non-native argument is somewhat persuasive. If you wanted to follow the "convert client side" logic to its conclusion, then removing JSON and hex would result. That certainly keeps in the in-bitcoind code at a minimum. However, two counterpoints:
|
|
The fix + flag should be separate from the output format pull request. We can go ahead and merge the fix and -rest flag, IMO. |
|
Okay. I will separate the pulls. |
No, that was IMO addressed by putting the functionality behind an option. Even without JSON, XSS fingerprinting may be possible by checking for absence/presence of errors. BTW I recently learnt that Tor Browser Bundle explicltly works around this kind of local fingerprinting, that's nice:
I don't have anything against returning well-defined JSON data. If there are multiple things to return they need to be packed into a structure, and However that is entirely different from bitcoind's lossy RPC format for blocks, which is here used because the code happens to be available.
Let's not have a default. People can specify the format that they want. |
4820cae to
5dc713b
Compare
|
Just updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@laanwj Here is another new translation string ;)? Still hoping you merge the others ^^.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know, but this one is unavoidable, and not just some cosmetic change.
No description provided.