BitShares Forum

Main => General Discussion => Topic started by: alt on May 21, 2015, 05:56:37 am

Title: web wallet based python flask
Post by: alt on May 21, 2015, 05:56:37 am
I am writing a web wallet, based python flask,
it's not a light wallet.
it depend a wallet backend to provide rpc call.
it run a web server at local host,
update the browser in real time throw web socket.
I am not family with User interface.
please join me if you are good at web develop.

you can try the demo version now.
install:
Code: [Select]
pip install btsbots-wallet
config
Code: [Select]
cat > ~/.python-bts/bts_client.json
{
    "client_default": {
        "host": "localhost",
        "port": "3988",
        "user": "alt",
        "password": "alt"
    }
}
run
Code: [Select]
btsbots_wallet_cli
then visit http://localhost:5000

source code is here:
https://github.com/pch957/btsbots-wallet
Title: Re: web wallet based python flask
Post by: xeroc on May 21, 2015, 06:05:27 am
wow .. first public project I see that uses the websockets API .. +5% +5%!!
Title: Re: web wallet based python flask
Post by: alt on May 21, 2015, 06:27:48 am
wow .. first public project I see that uses the websockets API .. +5% +5%!!
it's really fast.
and flask is really good, the UI develop is totally seperate from backend.
Title: Re: web wallet based python flask
Post by: 麥可貓 on May 21, 2015, 07:09:50 am
I encounter some error when doing '$ sudo pip install btsbots-wallet':

Quote
Collecting wsgiref==0.1.2 (from btsbots-wallet)
  Using cached wsgiref-0.1.2.zip
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "/tmp/pip-build-cdh4x3j6/wsgiref/setup.py", line 5, in <module>
        import ez_setup
   
    ----------------------------------------
    Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-cdh4x3j6/wsgiref

I googled it and tried steps from this link (http://stackoverflow.com/questions/17886647/cant-install-via-pip-because-of-egg-info-error), but it didn;t work. Any suggestions?
Title: Re: web wallet based python flask
Post by: alt on May 21, 2015, 10:22:24 am
try install ez_setup, In fact I haven't install this package, but from the error message, you need it.
Code: [Select]
pip install ez_setup
I encounter some error when doing '$ sudo pip install btsbots-wallet':

Quote
Collecting wsgiref==0.1.2 (from btsbots-wallet)
  Using cached wsgiref-0.1.2.zip
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "/tmp/pip-build-cdh4x3j6/wsgiref/setup.py", line 5, in <module>
        import ez_setup
   
    ----------------------------------------
    Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-cdh4x3j6/wsgiref

I googled it and tried steps from this link (http://stackoverflow.com/questions/17886647/cant-install-via-pip-because-of-egg-info-error), but it didn;t work. Any suggestions?
Title: Re: web wallet based python flask
Post by: alt on May 22, 2015, 11:01:39 am
I have almost complete the UI frame work


(http://ww4.sinaimg.cn/large/5d9c0487gw1esd8czmjs5j211k0hpaeb.jpg)
Title: Re: web wallet based python flask
Post by: wuyanren on May 22, 2015, 12:13:44 pm
美元市场偏离达到30%,真的令人担忧
Title: Re: web wallet based python flask
Post by: alt on May 22, 2015, 05:46:56 pm
wallet balance and market
(http://ww2.sinaimg.cn/large/5d9c0487gw1esdk28svg5j211l0hnaf6.jpg)
(http://ww4.sinaimg.cn/large/5d9c0487gw1esdk28o4chj211k0hdafs.jpg)
Title: Re: web wallet based python flask
Post by: xeroc on May 22, 2015, 05:54:55 pm
wow .. you really know how to create a slick an nicely looking User interface .. +5% !!! definitely alot better than all webpages I ever created!
Title: Re: web wallet based python flask
Post by: alt on May 22, 2015, 06:17:38 pm
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
Title: Re: web wallet based python flask
Post by: alt on May 22, 2015, 06:18:56 pm
this is from mobile
(http://ww1.sinaimg.cn/large/5d9c0487jw1esdkuh3so1j20k00zkacb.jpg)
(http://ww2.sinaimg.cn/large/5d9c0487jw1esdkuhxcd2j20k00zkmzv.jpg)
Title: Re: web wallet based python flask
Post by: Tuck Fheman on May 22, 2015, 09:38:46 pm
 +5%
Title: Re: web wallet based python flask
Post by: BunkerChainLabs-DataSecurityNode on May 22, 2015, 09:53:42 pm
wallet balance and market
(http://ww2.sinaimg.cn/large/5d9c0487gw1esdk28svg5j211l0hnaf6.jpg)
(http://ww4.sinaimg.cn/large/5d9c0487gw1esdk28o4chj211k0hdafs.jpg)

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!
Title: Re: web wallet based python flask
Post by: Thom on May 23, 2015, 01:38:54 am
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.
Title: Re: web wallet based python flask
Post by: xeroc on May 23, 2015, 11:33:18 am
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
Title: Re: web wallet based python flask
Post by: alt on May 23, 2015, 02:01:17 pm
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?

Title: Re: web wallet based python flask
Post by: alt on May 23, 2015, 02:04:30 pm
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
Title: Re: web wallet based python flask
Post by: mangou007 on May 23, 2015, 02:21:08 pm
Nice work alt !!!
Title: Re: web wallet based python flask
Post by: CLains on May 23, 2015, 02:22:56 pm
wow, that looks really great alt!  +5%
Title: Re: web wallet based python flask
Post by: Thom on May 23, 2015, 03:01:14 pm
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.

Title: Re: web wallet based python flask
Post by: alt on May 23, 2015, 03:08:44 pm
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.
Title: Re: web wallet based python flask
Post by: Thom on May 23, 2015, 04:36:00 pm
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!
Title: Re: web wallet based python flask
Post by: xeroc on May 23, 2015, 05:18:51 pm
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 ...
Title: Re: web wallet based python flask
Post by: Thom on May 23, 2015, 06:15:05 pm
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.