Basic Python 3 Rpc Client

Discussion in 'Technical Development' started by isuldor, Jun 2, 2017.

  1. 2017/12/15 - Decred v1.1.2 released! → Release Notes  → Downloads
  1. isuldor

    isuldor New Member

    May 13, 2017
    5
    2
    Male
    Los Angeles, CA
    #1 isuldor, Jun 2, 2017
    Last edited: Jun 3, 2017
    I wanted to send myself push notifications when my tickets voted, so I wrote a very basic python function for getting values from the wallet rpc server. Maybe someone else just getting started (like myself) will find it useful. Usage example:

    Code:
    $ python
    >>> from ask_wallet import ask_wallet
    >>> ask_wallet( 'getstakeinfo' )
    {'result': {'blockheight': 139050, 'poolsize': 42801, 'difficulty': 128.2224049, 'allmempooltix': 0, 'ownmempooltix': 0, 'immature': 0, 'live': 4, 'proportionlive': 9.345576037943039e-05, 'voted': 1,
    'totalsubsidy': 1.50375652, 'missed': 0, 'proportionmissed': 0, 'revoked': 0, 'expired': 0}, 'error': None, 'id': None}
    
    The main() function demonstrates how I use it:
    Code:
    ./ask_dcr.py getstakeinfo live
    4
    ./ask_dcr.py getbalance spendable
    31.739
    
    It requires the "requests" and jsonrpc modules, which I had to install
    Code:
    pip install requests json-rpc
    
    https://github.com/brianbaligad/quickdcr/blob/master/ask_wallet.py
     
    Dyrk likes this.
  2. jcv

    jcv Full Member
    Developer

    Cool. I've been thinking about doing some similar minimal tools but leaning more towards the grpc server (at least for wallet use). Not sure what the python grpc port is like (go one is great, the js one is kind of a pain since it isn't native js).
     
  3. Dyrk

    Dyrk Sr. Member
    Developer

    Jan 7, 2016
    518
    376
    Male
    Wonderland
    Nice @isuldor
    What app / provider do you use to send PUSH notifications?
    Some stakepool users asked me already about emails / push notifications on voted ticket.
     
  4. isuldor

    isuldor New Member

    May 13, 2017
    5
    2
    Male
    Los Angeles, CA
    I'm just using pushover.net. It cost five bucks, but saved me from having to actually figure out push notifications.
     
    Dyrk likes this.
  5. Dyrk

    Dyrk Sr. Member
    Developer

    Jan 7, 2016
    518
    376
    Male
    Wonderland
    Thank you ;) the service looks awesome, for sure I will give it a try.
     
  6. jcv

    jcv Full Member
    Developer

    Interesting that pushover has a one-time fee rather than monthly. Don't see that too often.
     

Share This Page