#!/usr/bin/env python
# -*- coding: utf-8 -*-

from bottle import route, request, run, response
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException

import urllib,json
import pprint
import decimal, simplejson

#fix json type
class DecimalJSONEncoder(simplejson.JSONEncoder):
    def default(self, o):
        if isinstance(o, decimal.Decimal):
            return str(o)
        return super(DecimalJSONEncoder, self).default(o)

#./gcoin/gcoin.conf type rpcuser; rpcpassword; rpcport
RPC_USER = 'bitcoinrpc'
RPC_PASSWORD = '6SWniYid45ph9VFhVPepSzin2oJSsyepWiZKnJitZELD'
rpc_connection = AuthServiceProxy("http://%s:%s@192.168.186.128:58345"%(RPC_USER, RPC_PASSWORD))

LENGTH_CHECK = 64

#listwalletaddress
@route('/listwalletaddress', method='GET')
def listwalletaddress():
        listwalletaddress = rpc_connection.listwalletaddress()
        response.add_header("Access-Control-Allow-Origin", "*")
        return json.dumps(listwalletaddress)

#get tx_id
@route('/tx/<tx_id>', method='GET')
def tx(tx_id=''):
        if len(tx_id) != LENGTH_CHECK:
                return "no tx_id "
        raw_tx = rpc_connection.getrawtransaction(tx_id,1)
        response.add_header("Access-Control-Allow-Origin", "*")
        return raw_tx

#get block_hash
@route('/block/<block_hash>', method='GET')
def block(block_hash=''):
        if len(block_hash) != LENGTH_CHECK:
                return "no block_hash "
        block_hash = rpc_connection.getblock(block_hash)
        block_hash = simplejson.dumps(block_hash,cls=DecimalJSONEncoder)
        response.add_header("Access-Control-Allow-Origin", "*")
        return block_hash

#get blockindex
@route('/blockindex/<block_hash_index>', method='GET')
def blockindex(block_hash_index=''):
        block_hash = rpc_connection.getblockhash(int(block_hash_index))
        block_hash = {"blockhash " + str(block_hash_index) : block_hash}
        response.add_header("Access-Control-Allow-Origin", "*")
        return json.dumps(block_hash)

#get fixedaddress
@route('/getfixedaddress', method='GET')
def getfixedaddressr():
        getfixedaddress = rpc_connection.getfixedaddress()
        response.add_header("Access-Control-Allow-Origin", "*")
        return json.dumps(getfixedaddress)

#get memberlist
@route('/getmemberlist', method='GET')
def getmemberlist():
        getmemberlist = rpc_connection.getmemberlist()
        response.add_header("Access-Control-Allow-Origin", "*")
        return getmemberlist

#get info
@route('/getinfo', method='GET')
def getinfo():
        getinfo = rpc_connection.getinfo()
        response.add_header("Access-Control-Allow-Origin", "*")
        return getinfo

run(host='0.0.0.0',port=8091,debug='true')

@@ -639,14 +639,13 @@
 168.
+3
 1
-86
 .1
-2
+5
 8:58
@@ -696,16 +696,26 @@
  = 64%0A%0A#
+gcoin-cli 
 listwall
@@ -971,16 +971,34 @@
 %0A%0A#g
-et tx_id
+coin-cli getrawtransaction
 %0A@ro
@@ -1273,22 +1273,26 @@
 x%0A%0A#
+gcoin-cli 
 get
- 
 block
-_hash
 %0A@ro
@@ -1668,22 +1668,30 @@
 h%0A%0A#
+gcoin-cli 
 get
- 
 block
-index
+hash
 %0A@ro
@@ -1873,17 +1873,17 @@
 hash = %7B
-%22
+'
 blockhas
@@ -1884,17 +1884,17 @@
 ockhash 
-%22
+'
  + str(b
@@ -2028,20 +2028,29 @@
 hash)%0A%0A#
+gcoin-cli 
 get
- 
 fixedadd
@@ -2287,20 +2287,29 @@
 ress)%0A%0A#
+gcoin-cli 
 get
- 
 memberli
@@ -2525,12 +2525,21 @@
 t%0A%0A#
+gcoin-cli 
 get
- 
 info
@@ -2718,16 +2718,1003 @@
 etinfo%0A%0A
+#gcoin-cli getpeerinfo%0A@route('/getpeerinfo', method='GET')%0Adef getpeerinfo():%0A        getinfo = rpc_connection.getpeerinfo()%0A        response.add_header(%22Access-Control-Allow-Origin%22, %22*%22)%0A        return getinfo%0A%0A#gcoin-cli getnetworkinfo%0A@route('/getnetworkinfo', method='GET')%0Adef getnetworkinfo():%0A        getnetworkinfo = rpc_connection.getnetworkinfo()%0A        response.add_header(%22Access-Control-Allow-Origin%22, %22*%22)%0A        return getnetworkinfo%0A%0A#gcoin-cli getmininginfo%0A@route('/getmininginfo', method='GET')%0Adef getmininginfo():%0A        getmininginfo = rpc_connection.getmininginfo()%0A        response.add_header(%22Access-Control-Allow-Origin%22, %22*%22)%0A        return getmininginfo%0A%0A#gcoin-cli getblockcount%0A@route('/getblockcount', method='GET')%0Adef getblockcount():%0A        getblockcount = rpc_connection.getblockcount()%0A        getblockcount = %7B'blockcount':getblockcount%7D%0A        response.add_header(%22Access-Control-Allow-Origin%22, %22*%22)%0A        return json.dumps(getblockcount)%0A%0A
 run(host

add some api