Commit graph

32 commits

Author SHA1 Message Date
Calin Culianu
c768323434
started impl. HttpConnection 2019-11-10 00:27:44 +02:00
Calin Culianu
20f4708aed
nits 2019-11-09 19:06:40 +02:00
Calin Culianu
6508ea1912
Refactored RPC::Connection to be a little bit transport agnostic
This allows it to talk to things like bitcoind. It still wants a tcp
socket as its transport -- but it can at least now be wrapped in HTTP
for bitcoin as well as re-use of the same code for ElectronX style
linefeed based JSON.

Our RPC lib is nowhere near 100% generic and re-usable but it's a good
first step here with this refactor job.
2019-11-09 17:06:40 +02:00
Calin Culianu
9014198aac
nit 2019-11-09 15:57:48 +02:00
Calin Culianu
e7323b854b
Try and return proper id to client on request failure
We were grabbing the message.id too late. We should grab it as soon as
possible for best json rpc error reporting as per the spec.
2019-11-09 14:39:52 +02:00
Calin Culianu
6d6ea91aa9
nits 2019-11-09 13:49:28 +02:00
Calin Culianu
e07f7be562
Added support for "named" (kwargs) params. Eg "params" : { .. }
This should hopefully fully complete our implementation to support
JSON-RPC 2.0 without batching.  We still are missing batching but at
least now we implement the non-batching portion of the spec more
completely.
2019-11-09 13:08:36 +02:00
Calin Culianu
20066bff04
Put the JSON RPC error codes in an enum, and used it 2019-11-09 03:26:21 +02:00
Calin Culianu
065a221977
More JSON RPC 2.0 spec conformance
It turns out server should always ignore notifications it wasn't
expecting and never respond to them.

What I was doing by returning errors was incorrect.

Instead we add to the error tally for unknown notifications and
eventually disconnect the client.

Also added preliminary support for param maps . . .
2019-11-09 02:33:16 +02:00
Calin Culianu
cd643e7323
Made Message::Id type a std::variant
I restricted the possible underlying types it can contain down to
qint64, QString, and nullptr_t. This should make it more type safe since
we don't want it to inadvertently end up holding lists or maps
(previously it was a straight up QVariant).

It has a conversion to QVariant so it should work nicely.
2019-11-09 01:55:48 +02:00
Calin Culianu
e5886820fa nit 2019-11-08 15:49:42 +02:00
Calin Culianu
cf975c555c refactored id check into Message::idIsValid 2019-11-08 15:41:25 +02:00
Calin Culianu
6633326f49 nit 2019-11-08 14:50:03 +02:00
Calin Culianu
b583089d0b comment nit 2019-11-08 14:48:06 +02:00
Calin Culianu
dbd65cc8c5
nits 2019-11-08 14:42:49 +02:00
Calin Culianu
27e2083b86
Got rid of that "Schema" system which was cumbersome and not useful
- It made the code potentially slower
- Made modifying/adding methods too complex
- Wasn't very beneficial.
- Instead, we just verify JSON-RPC 2.0 spec in the core Connection
class, then we pass on the method call to the subclass if it's found in
the methodlist, etc.
2019-11-08 14:14:38 +02:00
Calin Culianu
6e58170d43
Implemented more of JSON-RPC 2.0. Dummy subscribe method, etc
Our implementation is wayyy too complex.  We need to simplify this
massively.  Perhaps do away with the whole "schema" thing...?
2019-11-08 02:49:09 +02:00
Calin Culianu
43b7e915c4
Got rid of more ShuffleUp stuff, added CLI args 2019-11-07 23:55:13 +02:00
Calin Culianu
c2f6e5f3fe Some nits related to json rpc 2019-05-06 17:31:52 +03:00
Calin Culianu
386383d6d4 Made our JSON-RPC 2.0 implementation more closely match the spec
- It's still a little more restrictive than the spec allows -- doesn't
like non-positive-int 'id'
- We not made the shuffle.spec status report back 'notifications' to the
client rather than repeated 'result' messages (as those would be out of
spec). The first response to a 'shuffle.spec' request is either
result="pending", result="accepted", or an error response
- Subsequent shuffle.spec status changes come as a method notification
for "shuffle.spec" with params=["accepted"] or params=["some error
message"]

Overall I think our bare bones JSON-RPC will at least not break now as
interop with other impls.
2019-05-06 14:34:42 +03:00
Calin Culianu
113efda25a Added spec rpc command from clients to us.. still need to do listunspent 2019-05-03 17:28:51 +03:00
Calin Culianu
6e4db7eb67 nits 2019-05-03 10:24:29 +03:00
Calin Culianu
8a7e443b01 Made the TCP server be Json RPC 2019-05-02 23:01:43 +03:00
Calin Culianu
9e9a227469 added error json reply/sending specific signals/slots 2019-05-02 06:59:00 +03:00
Calin Culianu
faeb64207f Finally.. finished refactoring out the RPC bits.
Now we can re-use the RPC method<->result code in the TcpServer side
which will face wallets.  Phew!  Took me long enough!

It's a minimal JSON-RPC protocol impl.. but it'll do.

The 1 nice bit is the Schema spec I came up with which more-or-less
works well enough as a first-pass validatior.

Further passes are needed in interested client code, but the initial
pass validation can be done in a thread so as to not waste the main
thread's time validating json or dict key presence/absense. Yay.
2019-04-30 19:21:47 +03:00
Calin Culianu
5e4aa2d9f9 renamed boilerplate_disconnect to disconnect 2019-04-30 17:09:07 +03:00
Calin Culianu
463b3d00b9 intermediate commit 2019-04-30 13:18:05 +03:00
Calin Culianu
ae5237bb0f another step... 2019-04-30 10:37:45 +03:00
Calin Culianu
4bd954a390 intermediate commit.. about to refactor exclient more 2019-04-30 10:01:21 +03:00
Calin Culianu
64f80b1e02 schema and method stuff 2019-04-29 22:04:35 +03:00
Calin Culianu
dcb6e23c10 RPC Schema - fixed a bug in detecting extra keys
- Cleanup and nits, as well
2019-04-29 21:18:03 +03:00
Calin Culianu
24b8e992b5 initial schema impl 2019-04-29 10:01:58 +03:00