Skip to content
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

[Docs] Correct sendmany curl example #12077

Merged

Conversation

l2a5b1
Copy link
Contributor

@l2a5b1 l2a5b1 commented Jan 2, 2018

The example curl command in the sendmany RPC help results in an error:

{"result":null,"error":{"code":-1,"message":"JSON value is not an object as expected"},"id":"curltest"}

because - as reported in #12067 - the second element in the params array should be a JSON object.

This PR removes the escaped backslash and quote characters that serialize the JSON object to a string and make it a plain JSON object:

curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "sendmany", "params": ["", {"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX":0.01,"1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz":0.02}, 6, "testing"] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/

which (when executed with valid addresses) yields the expected result:

{"result":"c446213f06ee4489660ed5dc47d65daca27345d0b5fc5bd344ebca78b2d87356","error":null,"id":"curltest"}

This commit removes the escaped backslash and quote characters from the keys in the JSON object to make it a plain JSON object.
@meshcollider
Copy link
Contributor

Concept ACK, thanks for helping out :)

It'd be better to move the "Fixes #12067" text into the body of the PR not the title or the commit message though

@fanquake fanquake changed the title Fixes issue #12067 sendmany curl example is wrong. [Docs] Correct sendmany curl example Jan 3, 2018
@laanwj
Copy link
Member

laanwj commented Jan 3, 2018

tested ACK 0d663f8, looks good to me, IMO the commit message is clear enough.

@laanwj laanwj merged commit 0d663f8 into bitcoin:master Jan 3, 2018
laanwj added a commit that referenced this pull request Jan 3, 2018
0d663f8 Fixes issue #12067 `sendmany` curl example is wrong. (251)

Pull request description:

  The example curl command in the `sendmany` RPC help results in an error:
  ```
  {"result":null,"error":{"code":-1,"message":"JSON value is not an object as expected"},"id":"curltest"}
  ```
  because - as reported in #12067 - the second element in the `params` array should be a JSON object.

  This PR removes the escaped backslash and quote characters that serialize the JSON object to a string and make it a plain JSON object:

  ```
  curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "sendmany", "params": ["", {"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX":0.01,"1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz":0.02}, 6, "testing"] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/
  ```

  which (when executed with valid addresses) yields the expected result:

  ```
  {"result":"c446213f06ee4489660ed5dc47d65daca27345d0b5fc5bd344ebca78b2d87356","error":null,"id":"curltest"}
  ```

Tree-SHA512: 9be055515175f633d21cbe2f6735e08709af306639b31e9f2bf83d9eb1cf4dbbf807951728649f3c091fde96dbf4ea732ee903dec9589f90ea1e046b832b90d0
@l2a5b1 l2a5b1 deleted the patch/12067/fixes-sendmany-curl-example branch January 4, 2018 22:42
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 29, 2020
Summary:
0d663f8 Fixes issue #12067 `sendmany` curl example is wrong. (251)

Pull request description:

  The example curl command in the `sendmany` RPC help results in an error:
  ```
  {"result":null,"error":{"code":-1,"message":"JSON value is not an object as expected"},"id":"curltest"}
  ```
  because - as reported in #12067 - the second element in the `params` array should be a JSON object.

  This PR removes the escaped backslash and quote characters that serialize the JSON object to a string and make it a plain JSON object:

  ```
  curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "sendmany", "params": ["", {"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX":0.01,"1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz":0.02}, 6, "testing"] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/
  ```

  which (when executed with valid addresses) yields the expected result:

  ```
  {"result":"c446213f06ee4489660ed5dc47d65daca27345d0b5fc5bd344ebca78b2d87356","error":null,"id":"curltest"}
  ```

---

Backport of Core [[bitcoin/bitcoin#12077 | PR12077]]

Test Plan:
  ninja all check check-functional

Run:
  curl --user bitcoinrpc --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "sendmany", "params": ["", {"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl":0.01,"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9":0.02}, 6, "testing"] }' -H 'content-type: text/plain;' http://127.0.0.1:18332/

and get:
  {"result":"d7844d45ca4f54b165976a7477c89def1352f8d17d2f148c0b07a660a6f9c25e","error":null,"id":"curltest"}

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D8164
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants