Repository navigation
Conversation
|
I played around with this a little. I can successfully load a wallet generated both manually, and one created by Question: could the Angular client replace our Qt interface? |
Yeah, this is like level 0; as noted above, there is no state management and no access control in this yet. In fact I feel like this will be the most important thing to get right if we go forward with it. We can go with cookie file based authentication, a bit like in the Bitcoin Core RPC, I think that's fine, but the tricky thing will be to have this daemon manage access to specific wallets (possibly in parallel? but let's be less ambitious to start with), including state (is the wallet unlocked) and including possibly some granularity (read only access, signing access, etc).
Yes I think it would make sense to go down that road, but to get "one-click" like currently the Windows exe has, we'll also need to somehow package at least the python jmwalletd and all its dependencies. Not to mention of course actually writing the Angular (or similar) app. So that's a long way off. |
|
Rebased on master a663efd |
|
Ping @AdamISZ, still needs rebase! |
|
Thanks for reminder; as you know I was busy but I will do it now. |
|
Rebased on master as of b438b71 but a couple of points to note:
|
|
Thanks. I think there is also an error in that extra commit. I'll come back to this shortly, sorry for delay. |
|
I'm not able to run it, get errors from Tested on python 3.9 and 3.6 |
|
@tzawlxih so it appears from your traceback that you attempted to pass the password as a parameter in the url, but it should have been passed in the body of the POST request. See my Angular client code as an example (iirc it interprets |
|
I guess the natural follow-on comment is, even at this experimental stage, I should write a documentation of this RPC. Unfortunately I don't think I have the tooling to auto-generate it right now, but not too big of a deal, it should be fairly small. |
|
A couple of comments to record from the brief meeting last week. There was some general agreement that:
To that list, as per above comment, should be added: RPC documentation. |
|
So 8e4bf80 adds documentation of the RPC methods. It is definitely an incomplete document, but it should give enough information in order to be able to run successfully, using the existing methods (apart from the direct-send which is not yet in a complete state I think). |
|
Rebased on master as of c0491eb |
Hi, I've been checking on possible ways to go ahead with the next steps (session mgmt. , websockets) and I was wondering if it would make sense to use a Django based infrastructure that would wrap all of that more or less alright, in addition with the basics already covered (i.e. secure connection , endpoints exposed). Any thoughts? Ps. About session management, where you thinking in adding a user table for user control? That means we could do a basic user authentication and authorization on what wallets that user is allowed to access. Not sure we want that extra layer since any user providing the correct unlock password is already proof of the user being authorised. Django SSL/TLs Django REST api Django session management https://www.django-rest-framework.org/tutorial/4-authentication-and-permissions/#authenticating-with-the-api Django websockets |
Didn't want to ACK whole PR, needs more review / work, it was mistake.
|
@raulcano i'm sorry that i didn't answer this a few days ago, it slipped my mind with other things happening. So, django is an option I certainly thought about, but I didn't quite get to the point of figuring out how I could get it working properly with twisted. My guess is it's possible but it might be a little tricky, and it's hard to find documentation on this. If you could somehow replace the existing instance of
I mean, maybe, but for now just assume we are dealing with a single user accessing one wallet at a time, just because it's easier and it's unlikely we'll really need to address a more complex use case than that. Sorry I haven't read your links yet, but I will get round to it soon. |
|
Re: fragment mentioned above, it was this (from several months ago; I don't remember too much). To emphasize, I don't know if this works, so it may be useless, but: it was a result of me finding that autobahn was something that supported websockets in twisted, possibly. So with caveats, here: from autobahn.twisted.websocket import WebSocketServerProtocol, WebSocketServerFactory
class MyServerProtocol(WebSocketServerProtocol):
def onConnect(self, request):
print("Client connecting: {}".format(request.peer))
def onOpen(self):
print("WebSocket connection open.")
t = task.LoopingCall(self.sendDummyMessage)
t.start(5.0)
def onMessage(self, payload, isBinary):
if isBinary:
print("Binary message received: {} bytes".format(len(payload)))
else:
print("Text message received: {}".format(payload.decode('utf8')))
# echo back message verbatim
self.sendMessage(payload, isBinary)
def sendDummyMessage(self):
print('sending dummy message')
self.sendMessage(b"this is a dummy message")
def onClose(self, wasClean, code, reason):
print("WebSocket connection closed: {}".format(reason))
# allow websocket connections
websocketfactory = WebSocketServerFactory()
websocketfactory.protocol = MyServerProtocol
reactor.listenTCP(9001, websocketfactory) |
|
@AdamISZ Thanks for the answer. I have put on hold the idea of Django last days, to look for other more lightweight solutions. The discussion here sums it up pretty well: It seems that Flask could be an option. It is lightweight and has session management features and the option to work with websockets. https://www.tutorialspoint.com/flask/flask_quick_guide.htm In parallel to looking into this I'll keep searching if there's a good alternative to keep Klein with sessions and so on. |
|
@raulcano yes, good. I do remember seeing Flask and thinking it may be a sensible option here. Although my memory isn't clear, it may well be that I went with Klein just because it was the simplest to set up, but if Flask can offer us some kind of authentication framework then hopefully it will be a good idea. Your stackoverflow link at least suggests we might be able to drop-in replace it here. |
|
I'll get familiar with flask these days and try to see if I get somewhere. Will report back. |
Uses Klein to provide HTTP server support.
This commit adds a basic authorization method to all requests using a cookie stored by the client (so similar to what is done by Bitcoin RPC). This cookie is sent in a custom header 'JMCookie'. Additionally, preflight CORS requests are handled for all routes generically. Also more comments are added to the current main functions. Also a /lock route is added to allow the user to shut down the wallet service and close the wallet. Still very rudimentary of course.
This commit adds a JMShutdown command to the AMP protocol, allowing a clean shutdown of a long running bot (e.g. maker) by shutting down its message channel connections. The yield generator is now made a Service.
Access the port that was chosen (to avoid conflicting with other simultaneously running jmdaemon instances, especially in test scenarios) in the jmwalletd startup, and use that in starting the YieldGenerator service. Also fixes a bug in YieldGenerator service startup - self.yieldgen not maker.
|
Closing, at least for the time being, in favour of #996 . |

Just a first start in a basic form only suitable for testing.
Uses Klein to provide HTTP server support. The server is TLS and if you want to test it you must add
key.pemandcert.peminto thescripts/directory.provides
/wallet/walletname/unlockfor which the password is provided in POST, and/wallet/walletname/displayproviding the fulljmclient.wallet_utils.WalletViewserialization in a new json format.Note the
preflight/preflight2methods are for CORS, obviously that is not a final form.Apart from filling out the API, the most important outstanding issue is state/session management; we provide an unlock but have no access control linking the unlocking action with future permissible actions.
This code is an illustration of what is meant by this gist, also see this new repo for an Angular client for this RPC server.