Author Topic: web wallet based python flask  (Read 4773 times)

0 Members and 1 Guest are viewing this topic.

Offline Thom

I took a glance at github and saw BM's commits related to websockets, some posted 11 days ago, so I figured it was in the 0.9.2 already. That's why I assumed as you did xeroc alt was using it.

If I understand alt's reply tho, he is using a different websocket interface, one related to python <---> flask not bitshares_client <---> python. FOr that he's still using the standard RPC interface.

I can tell you that from my experience working with wackou's bts_tools the flask / python stack has excellent performance. It would be even better with the direct websocket into the bitshares_client. It would just replace the RPC layer alt is currently using, and with a bit of tweaking could eliminate the 10 second polling he is now using, since the websocket provides an open channel, two way continuous comm; no need for all the open/close connections of RPC.
« Last Edit: May 23, 2015, 06:26:04 pm by Thom »
Injustice anywhere is a threat to justice everywhere - MLK |  Verbaltech2 Witness Reports: https://bitsharestalk.org/index.php/topic,23902.0.html

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
To both of you: .. websockets will be implemented in the core client .. foundations have been layed out already in the fc library .. and i guess that websocket us already functional .in 0.9.0 .. but i havent tries around yet ...

@alt .. checkout the fc library .. somewhere in net/http .. there should the ws code ... no idea what exactly it does though .. not a coder ...

Offline Thom

Thx alt, for your reply. The difficulties of communication can indeed be an obstacle to overcome at times, not always due to language differences.

@xeroc:
thx for your reply, this seems to be exactly what I needed. Bytemaster's approach is definitely superior to my first crack at an authentication design, so I will pursue that avenue instead. His blog post looks to supply everything I need.

We'll see if it's as easy to implement as he says it is. I don't anticipate any issues actually, it looks pretty well documented.

Thanks again everyone!
Injustice anywhere is a threat to justice everywhere - MLK |  Verbaltech2 Witness Reports: https://bitsharestalk.org/index.php/topic,23902.0.html

Offline alt

  • Hero Member
  • *****
  • Posts: 2821
    • View Profile
  • BitShares: baozi
sorry, my English is not family, maybe I misunderstand xeroc.
I run a python task at backend, call client's API every 10 seconds, get the data, publish to my websocket server(based flask-ext-socketIO)

@alt:
if the new websocket (not webService) I/F is not in the current 0.9.2 release yet, then how are you doing this? Do you have inside access to the private code base the dev team is working on now before the release? And if it is out now, my original question stands, how did you figure out how to use it, by looking at the code or some other way?

Since you published the src code I could look at it and try to reverse engineer it, but that is prone to mistakes and is far more difficult (in most cases) than talking to the author (or reading API docs if they exist).

Your original post mentioned both "web socket" and rpc, tho I took that to mean a generic use of rpc. Then xeroc said it was the first public use of the new websocket I/F, and you didn't correct him. Thus my presumption is based on that.

I see you're using python & flask, which I have some (limited) familiarity with, since wackou's bts_tools is based on that stack as well, coupled with the ngnix webserver. Low overhead, fast response.

Offline Thom

I haven't read your post in full (I appologize) but you may want to read
http://bytemaster.bitshares.org/article/2014/12/22/BitShares-Login/
If you haven't already

@xeroc:
I don't recall that post in BM's blog, but I have been in contact with gamey about the SMF login.
From my quick perusal and gamey's into the SMF side is not well structured, so it's difficult to understand the client / server flow of things.

I took a quick look at the code, but haven't gotten around to ask gamey for the user's use case scenario. Perhaps BM's blog will provide that. I do know that gamey's implementation was based on Oauth somewhere, perhaps only as a starting point.

I'll (re)read BM's blog on it. I'm pretty sure I read it back in December, but I'm not sure.

@alt:
if the new websocket (not webService) I/F is not in the current 0.9.2 release yet, then how are you doing this? Do you have inside access to the private code base the dev team is working on now before the release? And if it is out now, my original question stands, how did you figure out how to use it, by looking at the code or some other way?

Since you published the src code I could look at it and try to reverse engineer it, but that is prone to mistakes and is far more difficult (in most cases) than talking to the author (or reading API docs if they exist).

Your original post mentioned both "web socket" and rpc, tho I took that to mean a generic use of rpc. Then xeroc said it was the first public use of the new websocket I/F, and you didn't correct him. Thus my presumption is based on that.

I see you're using python & flask, which I have some (limited) familiarity with, since wackou's bts_tools is based on that stack as well, coupled with the ngnix webserver. Low overhead, fast response.

Injustice anywhere is a threat to justice everywhere - MLK |  Verbaltech2 Witness Reports: https://bitsharestalk.org/index.php/topic,23902.0.html

Offline CLains

  • Hero Member
  • *****
  • Posts: 2606
    • View Profile
  • BitShares: clains
wow, that looks really great alt!  +5%

Offline mangou007

BitShares French ConneXion, le portail francophone de BitShares
BitShares French ConneXion, the BitShares French gateway
www.bitsharesfcx.com

Offline alt

  • Hero Member
  • *****
  • Posts: 2821
    • View Profile
  • BitShares: baozi
demo site is live now, you can see the balance, transaction history, order book, trade history, place order history
and you can transfer , but pay attention, you can only transfer to the account at contact list,
for this demo site, the contact list is fixed, can't add new. so if you transfer fund in, you can't transfer out.
please transfer small amount.

https://wallet.btsbots.com
« Last Edit: May 24, 2015, 01:17:17 pm by alt »

Offline alt

  • Hero Member
  • *****
  • Posts: 2821
    • View Profile
  • BitShares: baozi
this web socket service is not provied  by bts client. when the client is ready I will switch to client's web socket.
Excellent work alt! Where did you find the info for the websocket interface, from reading the code?


Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
Excellent work alt! Where did you find the info for the websocket interface, from reading the code?

I'm just starting to design a BitShares authentication plugin for the Joomla CMS, and was going to use the standard RPC interface to the BitShares client. That will work, but since I'm starting from scratch it may make more sense to utilize the new websockets I/F.

I basically just need to validate a BitShares account name and perhaps later I'll get into obtaining account balances or other info to facilitate shopping cart transactions. If you could point me to any info about the websocket I/F I would greatly appreciate it.

Here are my initial thoughts:

Basic BitShares authentication scheme for Joomla

NOTE: the credentials of Joomla and BitShares use separate passwords but share the account name. A Joomla account must be created with its own password. The common binding is the Joomla username == a valid, authenticated BitShares account name. This avoids sending wallet password across the Internet, and allows for normal Joomla authentication without BitShares but provides an isolated integration of the BitShares ecosystem if the BitShares wallet is active and unlocked.

Prerequisite: BitShares config.json must be edited to enable RPC / websocket interface on localhost for access by javascript code in web browser.

Use case: (client side | Joomla server side)

1) User starts the BitShares wallet (either GUI or CMD Line version).

2) User interacts with BitShares (opens and unlocks the wallet or just logs into GUI).

3) User clicks the "login" link on Joomla website.

4) User enters username / password credentials into input fields of Joomla form and clicks submit.


5) Joomla server response back to browser is a block of client-side javascript code that will use RPC (or websocket?) calls to the local BitShares wallet (via AJAX) to validate the username is a valid BitShares account. Only the username is passed to the client from Joomla.

6) The client code in the browser will basically return validation TRUE or FALSE to Joomla. It may also return other info to Joomla, such as account balances (TBD).

7) If the username entered in the Joomla login form is verified to be a valid BitShares account, the Joomla BitShares authentication plugin will query the Joomla DB for the username. If it exists authentication is complete and the user is logged into Joomla. If not the plugin  prompts the user for minimal Joomla account info (an email address or the std Joomla user registration form for the user to complete, but with username provided in step 4 as a read only field). If the form validates correctly a Joomla account now exists and authentication is complete for both Joomla and BitShares.

8 ) If the credentials are rejected the joomla BitShares plugin cascades down to the next active joomla auth plugin (if any). If there are no other auth methods configured, an "authentication failed" error message is displayed to user.

I haven't read your post in full (I appologize) but you may want to read
http://bytemaster.bitshares.org/article/2014/12/22/BitShares-Login/
If you haven't already

Offline Thom

Excellent work alt! Where did you find the info for the websocket interface, from reading the code?

I'm just starting to design a BitShares authentication plugin for the Joomla CMS, and was going to use the standard RPC interface to the BitShares client. That will work, but since I'm starting from scratch it may make more sense to utilize the new websockets I/F.

I basically just need to validate a BitShares account name and perhaps later I'll get into obtaining account balances or other info to facilitate shopping cart transactions. If you could point me to any info about the websocket I/F I would greatly appreciate it.

Here are my initial thoughts:

Basic BitShares authentication scheme for Joomla

NOTE: the credentials of Joomla and BitShares use separate passwords but share the account name. A Joomla account must be created with its own password. The common binding is the Joomla username == a valid, authenticated BitShares account name. This avoids sending wallet password across the Internet, and allows for normal Joomla authentication without BitShares but provides an isolated integration of the BitShares ecosystem if the BitShares wallet is active and unlocked.

Prerequisite: BitShares config.json must be edited to enable RPC / websocket interface on localhost for access by javascript code in web browser.

Use case: (client side | Joomla server side)

1) User starts the BitShares wallet (either GUI or CMD Line version).

2) User interacts with BitShares (opens and unlocks the wallet or just logs into GUI).

3) User clicks the "login" link on Joomla website.

4) User enters username / password credentials into input fields of Joomla form and clicks submit.


5) Joomla server response back to browser is a block of client-side javascript code that will use RPC (or websocket?) calls to the local BitShares wallet (via AJAX) to validate the username is a valid BitShares account. Only the username is passed to the client from Joomla.

6) The client code in the browser will basically return validation TRUE or FALSE to Joomla. It may also return other info to Joomla, such as account balances (TBD).

7) If the username entered in the Joomla login form is verified to be a valid BitShares account, the Joomla BitShares authentication plugin will query the Joomla DB for the username. If it exists authentication is complete and the user is logged into Joomla. If not the plugin  prompts the user for minimal Joomla account info (an email address or the std Joomla user registration form for the user to complete, but with username provided in step 4 as a read only field). If the form validates correctly a Joomla account now exists and authentication is complete for both Joomla and BitShares.

8 ) If the credentials are rejected the joomla BitShares plugin cascades down to the next active joomla auth plugin (if any). If there are no other auth methods configured, an "authentication failed" error message is displayed to user.

Injustice anywhere is a threat to justice everywhere - MLK |  Verbaltech2 Witness Reports: https://bitsharestalk.org/index.php/topic,23902.0.html

Offline BunkerChainLabs-DataSecurityNode

wallet balance and market



Looks like moonstone goes themselves some competition.. and inside of a day or two you seem to have gone even further in your development!

Keep us posted on your dev!
+-+-+-+-+-+-+-+-+-+-+
www.Peerplays.com | Decentralized Gaming Built with Graphene - Now with BookiePro and Sweeps!
+-+-+-+-+-+-+-+-+-+-+

Tuck Fheman

  • Guest

Offline alt

  • Hero Member
  • *****
  • Posts: 2821
    • View Profile
  • BitShares: baozi
this is from mobile


Offline alt

  • Hero Member
  • *****
  • Posts: 2821
    • View Profile
  • BitShares: baozi
wow .. you really know how to create a slick an nicely looking User interface .. +5% !!! definitely alot better than all webpages I ever created!
I just got a good frame work  :D