Servant API of Cardano


#1

Hello!

Tinkering on the Servant API of Cardano, using documentation for Software Version cardano-sl:0, Git Revision 07e1b7860fec59f94844a3f424603af07da54978
Just unable to connect using simple commandline tools like wget or curl (samples below).
Tried fetching /api/v1/node-info but getting ERROR 404: Not Found
And ./scripts/tls-files/ca.crt got supplied. By the way the ca.crt and 127.0.0.1 versus localhost seems to cause effects.

Any suggestions? Do I somehow have to launch the API first, when starting “stack exec – cardano-node” ?
This was set to defaults: --wallet-address IP:PORT IP and port for backend wallet API. (default: (“127.0.0.1”,8090))

ANOTHER minor ISSUE:
# du -hs db-mainnet-staging
3.9M db-mainnet-staging
… the daemon got launched from it’s source tree, writing data into that directory. Those will be lost on next release and rebuilt, resulting into a fresh network sync.
Honestly a really well documented script for starting the daemon should exist somewhere.

# wget -O - https://localhost:8090/api/v1/node-info
--2018-03-18 14:51:13--  https://localhost:8090/api/v1/node-info
Resolving localhost (localhost)... ::1, 127.0.0.1, 127.0.0.1
Connecting to localhost (localhost)|::1|:8090... failed: Connection refused.
Connecting to localhost (localhost)|127.0.0.1|:8090... connected.
WARNING: cannot verify localhost's certificate, issued by 'CN=Daedalus Self-Signed Root CA,OU=Daedalus Self-Signed Root CA,O=Input Output HK,DC=iohk,DC=io':
  Self-signed certificate encountered.
HTTP request sent, awaiting response... 404 Not Found
2018-03-18 14:51:13 ERROR 404: Not Found.


# curl --cacert ./scripts/tls-files/ca.crt --url https://127.0.0.1:8090/api/v1/node-info --verbose
*   Trying ::1...
* connect to ::1 port 8090 failed: Connection refused
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8090 (#0)
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: ./scripts/tls-files/ca.crt
  CApath: none
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server accepted to use http/1.1
* Server certificate:
*  subject: DC=io; DC=iohk; O=Input Output HK; OU=Cardano Settlement Layer Server Node; CN=localhost
*  start date: Jul 19 17:31:34 2017 GMT
*  expire date: Jul 19 17:31:34 2027 GMT
*  common name: localhost (matched)
*  issuer: DC=io; DC=iohk; O=Input Output HK; OU=Daedalus Self-Signed Root CA; CN=Daedalus Self-Signed Root CA
*  SSL certificate verify ok.
> GET /api/v1/node-info HTTP/1.1
> Host: localhost:8090
> User-Agent: curl/7.49.1
> Accept: */*
> 
< HTTP/1.1 404 Not Found
< Transfer-Encoding: chunked
< Date: Sun, 18 Mar 2018 14:02:35 GMT
< Server: Warp/3.2.13
< 


# curl --cacert ./scripts/tls-files/ca.crt --url https://127.0.0.1:8090/api/v1/node-info --verbose
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8090 (#0)
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: ./scripts/tls-files/ca.crt
  CApath: none
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server accepted to use http/1.1
* Server certificate:
*  subject: DC=io; DC=iohk; O=Input Output HK; OU=Cardano Settlement Layer Server Node; CN=localhost
*  start date: Jul 19 17:31:34 2017 GMT
*  expire date: Jul 19 17:31:34 2027 GMT
* SSL: certificate subject name 'localhost' does not match target host name '127.0.0.1'
* Closing connection 0
* TLSv1.2 (OUT), TLS alert, Client hello (1):
curl: (51) SSL: certificate subject name 'localhost' does not match target host name '127.0.0.1'

#2

My 46dadcc4bf334bbe8b51a1e9e63fc383e76dfbb7 build is a little behind yours. I haven’t any issue. I always build the code following the instruction stack build mode

$ curl --cacert ./scripts/tls-files/ca.crt  https://localhost:8090/api/v1/node-info
{"data":{"syncProgress":{"quantity":69,"unit":"percent"},"blockchainHeight":{"quantity":759583,"unit":"blocks"},"localBlockchainHeight":{"quantity":525950,"unit":"blocks"},"localTimeDifference":{"quantity":0,"unit":"microseconds"}},"status":"success","meta":{"pagination":{"totalPages":1,"page":1,"perPage":1,"totalEntries":1}}}
]

#3

Used stack too, but Step 3 for connecting states to use

  1. To build a script that will contain everything needed to connect to mainnet: $ nix-build -A connectScripts.mainnetWallet -o connect-to-mainnet

So I have no nix-build available, to create something similar like scripts/launch/connect-to-cluster/mainnet-staging.sh which I used to launch the cardano daemon process. Meanwhile I can connect to it, utilising curl. Just the syncing process sticks to 0 percent forever, wrong network as it seems from logs. staging.sh was meant for a local demonstration cluster.