Grinnode-live / 2020-grin-bug-bash-challenge

Finding bugs in Grin-Wallet & Grin-nodes for a bounty prior to Grin fork v5.
3 stars 1 forks source link

[GRIN-Wallet][Foreign API] test the build_coinbase API method #49

Closed marekyggdrasil closed 3 years ago

marekyggdrasil commented 3 years ago

Description Goal of this issue is to test the build_coinbase API method corresponding to the build_coinbase method

Prerequisites

  1. GRIN-Node
  2. GRIN-Wallet

Test procedure

  1. Run GRIN-Wallet in Foreign API listener mode
  2. Perform an API request using cURL to build_coinbase API method
  3. Record request payload, headers and all other relevant information. Same for the response.

Expected result:

Result should correspond to the example

Include the output of command

grin-wallet -V

and your environment

uname -a

Example API call

$ curl -v -d '{"jsonrpc": "2.0", "method": "check_version", "id": 1, "params":[]}' http://127.0.0.1:3415/v2/foreign
* Expire in 0 ms for 6 (transfer 0x56499d3faf50)
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Expire in 200 ms for 4 (transfer 0x56499d3faf50)
* Connected to 127.0.0.1 (127.0.0.1) port 3415 (#0)
> POST /v2/foreign HTTP/1.1
> Host: 127.0.0.1:3415
> User-Agent: curl/7.64.0
> Accept: */*
> Content-Length: 67
> Content-Type: application/x-www-form-urlencoded
> 
* upload completely sent off: 67 out of 67 bytes
< HTTP/1.1 200 OK
< access-control-allow-origin: *
< access-control-allow-headers: Content-Type, Authorization
< content-type: application/json
< content-length: 159
< date: Mon, 28 Dec 2020 13:28:51 GMT
< 
{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "Ok": {
      "foreign_api_version": 2,
      "supported_slate_versions": [
        "V4"
      ]
    }
  }
* Connection #0 to host 127.0.0.1 left intact
JitrZ commented 3 years ago

issue #49 Os: Windows 10 (Note that I'm using windows CMD and that's why cURL commands are a little different from linux!) Running Grin node: Version 5.0.0-rc.1 Running grin wallet listener Version v5.0.0-beta.4

grin-wallet listen

Password:
20201231 19:05:20.781 WARN grin_wallet_controller::controller - Starting TOR Hidden Service for API listener at address kytrc5ostwlzeu6aweaxv2liajo55w727f5uumgrgwe2dge62ag2iuid, binding to 127.0.0.1:3415
20201231 19:05:20.784 WARN grin_wallet_controller::controller - Unable to start TOR listener; Check that TOR executable is installed and on your path
20201231 19:05:20.785 WARN grin_wallet_controller::controller - Tor Error: Tor Process Error: Process("TOR executable (`tor.exe`) not found. Please ensure TOR is installed and on the path: Os { code: 2, kind: NotFound, message: \"The system cannot find the file specified.\" }")
20201231 19:05:20.785 WARN grin_wallet_controller::controller - Listener will be available via HTTP only
20201231 19:05:20.786 WARN grin_wallet_controller::controller - Starting HTTP Foreign listener API server at 127.0.0.1:3415.
20201231 19:05:20.786 WARN grin_wallet_controller::controller - HTTP Foreign listener started.

Perform the API request using cURL to _buildcoinbase API method according to the rust docs about ForeignApi; That gets three parameters, fees, height and _keyid, that described in this document:

So I send this command: curl http://127.0.0.1:3415/v2/foreign -v -d "{\"jsonrpc\":\"2.0\",\"method\":\"build_coinbase\",\"id\":1,\"params\":[{\"fees\":0,\"height\":0,\"key_id\":null}]}"

And get this result:

*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 3415 (#0)
> POST /v2/foreign HTTP/1.1
> Host: 127.0.0.1:3415
> User-Agent: curl/7.55.1
> Accept: */*
> Content-Length: 97
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 97 out of 97 bytes
< HTTP/1.1 200 OK
< access-control-allow-origin: *
< access-control-allow-headers: Content-Type, Authorization
< content-type: application/json
< content-length: 1940
< date: Thu, 31 Dec 2020 17:20:27 GMT
<
{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "Ok": {
      "kernel": {
        "excess": "08062fbb2e8d26f142d90f11a0ecb5db65eec72cacbbe1ff9f0791ef5e1f6b2b08",
        "excess_sig": "cc3224e93af30a267d0d5d166097748d6d6d393fd39f38be72ba388d751c0eac81269bedb30a2a9817aa474eef0fe8f637f6c0efc1a2d4a92f8b25ea63415635",
        "features": "Coinbase"
      },
      "key_id": "0300000000000000000000000000000000",
      "output": {
        "commit": "08d41a943a863399404c4c520ac934c6c5dc7814aae2c19c2747a11b9846313874",
        "features": "Coinbase",
        "proof": "0012be0dad65ea40096b184c613ee1bee28a5c48d116fc2f744bd46f453987bfc92616096c602a40320c915384bf857c7f84c560be5585082fb2a30bf68aebdc08b793f68c1016449d38ead76d237b21e9ff195611a18fae8aa3bf46d9c67bbc214921096c468909755e5555babb3eb74e1320e8849bc88f64a1e757a77ef17e6a720336ec2100057d929c18c7816b01d1c19f71879694582f5888c38b096e025fbc1dc55597a36f674f675bdb919b7af784fde28d7f174b4a3b3702f8058bdd4d58dfeb871b6046d5c7d3bcdfd3aecb937317ef57350bd18c72bfb14632df8963e6f37f2b0e8cc7a0751183192e7bc7afa770a5a7bfd3be0a877e447ce5c04223abc58f084dd5c70d9b38fa52f84f92d4d2293b9285b6f08a41ccead6f56d0881fa67c4b173137fdd20218627b0ed65135629f83818f58c1cd549ce30908ecd63887fcec58caaad71216b044e9db29ea690c49690856c4897f68ab59b35bcb1c97e00bffcd09f2d6988f4eb3807ef72fd7cc94ee3e5794e1baa14268bab49f591e24e5cfc888475bd18d6837b604cd0dc982e2fbd158dd213bb36ee5ac3376326de611eaaa2cdce0a03b34ca6f7ce3a47266e7e1cecfc2b147912d93ded07b2bcf15e9babd53d9ff82af1fe6e5ecbf2e36512aa0305bcf21b3217d26ea785156c2b8dd89a02a45c95aea7eb16b98a9d05dc791350c7f592bc22293eb8dd0e117ba4139ee88a9d11e38ef53101581b2efc0b12d310a522a6d4fe35ff1a383a09fa6dc9117a811f46bcbf5e61602241c6230b084ff23b1fbcd2f7111cea8fba7d9ec32ba0a48c7739d467887083e49d875e67bf68b8a69b11bf3d1fb13442888835e680479473b77bdacb9a6e6fc92cf724988f4da481433b9c29078198ccc7e07a43e0b939978e679251386dfb10860a41ac3f6a229e0ffd0a2685147e0079658f1a35"
      }
    }
  }
}* Connection #0 to host 127.0.0.1 left intact
marekyggdrasil commented 3 years ago

Looks good! Thanks for checking!