当前位置: 首页>>代码示例>>Python>>正文


Python authproxy.AuthServiceProxy方法代码示例

本文整理汇总了Python中bitcoinrpc.authproxy.AuthServiceProxy方法的典型用法代码示例。如果您正苦于以下问题:Python authproxy.AuthServiceProxy方法的具体用法?Python authproxy.AuthServiceProxy怎么用?Python authproxy.AuthServiceProxy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bitcoinrpc.authproxy的用法示例。


在下文中一共展示了authproxy.AuthServiceProxy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __call__

# 需要导入模块: from bitcoinrpc import authproxy [as 别名]
# 或者: from bitcoinrpc.authproxy import AuthServiceProxy [as 别名]
def __call__(self, *args):
        name = self.name
        start = time.time()
        wait = 3
        rpc_lock.release()
        rpc_obj = AuthServiceProxy(self.url, None, self.timeout, None)
        while True:
            try:
                result = rpc_obj.__getattr__(name)(*args)
                break
            except JSONRPCException as e:
                if e.code == -5:
                    return None
            except Exception as e: # pylint:disable=broad-except
                log( 'RPC Error ' + str(e) + ' (retrying in %d seconds)' % wait )
                print "===>", name, args
                rpc_obj = AuthServiceProxy(self.url, None, self.timeout, None) # maybe broken, make new connection
                if time.time()-start > 300:  # max wait time
                    return None
                wait = min(wait*2,60)
                time.sleep(wait) # slow down, in case gone away
        return result 
开发者ID:neocogent,项目名称:sqlchain,代码行数:24,代码来源:util.py

示例2: do_RPC

# 需要导入模块: from bitcoinrpc import authproxy [as 别名]
# 或者: from bitcoinrpc.authproxy import AuthServiceProxy [as 别名]
def do_RPC(env, send_resp):
    _,args,cur = urlparse.parse_qs(env['QUERY_STRING']), env['PATH_INFO'].split('/')[2:], sqc.dbpool.get().cursor()
    send_resp('200 OK', [('Content-Type', 'application/json')])
    result = []
    if args[0] == "getblockcount":
        result = json.dumps(sqc.cfg['block'])
    elif args[0] == "getinfo":
        result = json.dumps( { 'blocks':sqc.cfg['block'], 'difficulty':bits2diff(gethdr(sqc.cfg['block'], sqc.cfg, 'bits')) } )
    elif args[0] == "getdifficulty":
        result = json.dumps( bits2diff(gethdr(sqc.cfg['block'], sqc.cfg, 'bits')) )
    else:
        rpc = AuthServiceProxy(sqc.cfg['rpc'])
        if args[0] == "getblock":
            result = json.dumps( rpc.getblock(args[1]), cls=btcEncoder )
        elif args[0] == "getblockhash":
            result = json.dumps( rpc.getblockhash(int(args[1])) )
        elif args[0] == "getrawtransaction":
            result = json.dumps( rpc.getrawtransaction(args[1], 1), cls=btcEncoder )
        elif args[0] == "gettxout":
            result = json.dumps( rpcTxOut(cur, args[1], args[2]) )
        elif args[0] == "getmempoolinfo":
            result = json.dumps( rpc.getmempoolinfo(), cls=btcEncoder )
        elif args[0] == "getrawmempool":
            result = json.dumps( rpc.getrawmempool(False), cls=btcEncoder )
    return result 
开发者ID:neocogent,项目名称:sqlchain,代码行数:27,代码来源:rpc.py

示例3: reload_address

# 需要导入模块: from bitcoinrpc import authproxy [as 别名]
# 或者: from bitcoinrpc.authproxy import AuthServiceProxy [as 别名]
def reload_address(address, rpconn, times=1):
    """
    Sends necessary satoshis for a Spool transaction.

    Args:
        address (str): receiving bitcoin address
        rpconn (AuthServiceProxy): JSON-RPC connection
            (:class:`AuthServiceProxy` instance) to bitcoin regtest

    """
    from spool import Spool
    for _ in range(times):
        rpconn.sendtoaddress(address, Spool.FEE/100000000)
        rpconn.sendtoaddress(address, Spool.TOKEN/100000000)
        rpconn.sendtoaddress(address, Spool.TOKEN/100000000)
        rpconn.sendtoaddress(address, Spool.TOKEN/100000000)
    rpconn.generate(1) 
开发者ID:ascribe,项目名称:pyspool,代码行数:19,代码来源:conftest.py

示例4: __init__

# 需要导入模块: from bitcoinrpc import authproxy [as 别名]
# 或者: from bitcoinrpc.authproxy import AuthServiceProxy [as 别名]
def __init__(self, uri):
        logger.debug("init")
        self.uri = uri
        self.rpc = AuthServiceProxy(uri,timeout=600)

        # wait for rpc to be ready
        last_exc = None
        for _ in xrange(30):
            try:
                logger.info("best block: %s"%self.rpc.getbestblockhash())
                #logger.info("block count: %s" % self.rpc.getblockcount())
                break
            except Exception, e:
                last_exc = e
            logger.info("trying to connect ...")
            time.sleep(2) 
开发者ID:tintinweb,项目名称:ecdsa-private-key-recovery,代码行数:18,代码来源:bitcrack.py

示例5: query_transactions

# 需要导入模块: from bitcoinrpc import authproxy [as 别名]
# 或者: from bitcoinrpc.authproxy import AuthServiceProxy [as 别名]
def query_transactions(ticker=None):
    if not ticker:
        for c in Currency.objects.all():
            query_transactions.delay(c.ticker)
        return

    currency = Currency.objects.select_for_update().get(ticker=ticker)
    coin = AuthServiceProxy(currency.api_url)
    current_block = coin.getblockcount()

    block_hash = coin.getblockhash(currency.last_block)
    transactions = coin.listsinceblock(block_hash)['transactions']

    for tx in transactions:
        if tx['category'] not in ('receive', 'generate', 'immature'):
            continue

        process_deposite_transaction(tx, ticker)

    currency.last_block = current_block
    currency.save()

    for tx in Transaction.objects.filter(processed=False, currency=currency):
        query_transaction(ticker, tx.txid) 
开发者ID:limpbrains,项目名称:django-cc,代码行数:26,代码来源:tasks.py

示例6: __init__

# 需要导入模块: from bitcoinrpc import authproxy [as 别名]
# 或者: from bitcoinrpc.authproxy import AuthServiceProxy [as 别名]
def __init__(self, conf_dir=None, rpcuser=None, rpcpassword=None, rpcport=None, rpchost='127.0.0.1', network="main"):
        if rpcport is None:
            rpcport = {'main':8332,'test':18332,'stn':9332, 'regtest':18332}[network]
        if conf_dir is None:
            if platform.system() == 'Darwin':
                conf_dir = os.path.expanduser('~/Library/Application Support/Bitcoin/')
            elif platform.system() == 'Windows':
                conf_dir = os.path.join(os.environ['APPDATA'], 'Bitcoin')
            else:
                conf_dir = os.path.expanduser('~/.bitcoin')

        if network == 'regtest':
            conf_dir = os.path.join(conf_dir, 'regtest')
        if network == 'test':
            conf_dir = os.path.join(conf_dir, 'testnet3')
        elif network == 'stn':
            conf_dir = os.path.join(conf_dir, 'stn')

        if rpcuser is None:
            cookie = os.path.join(conf_dir, '.cookie')
            with open(cookie) as f:
                rpcuserpass = f.read()

        # Use cookie if no rpcuser specified
        if rpcuser:
            uri = "http://{}:{}@{}:{}".format(rpcuser, rpcpassword, rpchost, rpcport)
        else:
            uri = "http://{}@{}:{}".format(rpcuserpass, rpchost, rpcport)

        self.network = network
        self.conf_dir = conf_dir
        self.uri = uri
        self.rpc = AuthServiceProxy(self.uri)
        self.rpcport = rpcport
        self.rpchost = rpchost
        self.network = network

        rpcnet = self.rpc.getblockchaininfo()['chain']
        if rpcnet != network:
            raise ValueError("rpc server is on '%s' network, you passed '%s'" % (rpcnet, network)) 
开发者ID:AustEcon,项目名称:bitsv,代码行数:42,代码来源:fullnode.py

示例7: rpc_connect

# 需要导入模块: from bitcoinrpc import authproxy [as 别名]
# 或者: from bitcoinrpc.authproxy import AuthServiceProxy [as 别名]
def rpc_connect(self):
        return AuthServiceProxy(self.uri) 
开发者ID:AustEcon,项目名称:bitsv,代码行数:4,代码来源:fullnode.py

示例8: rpc_reconnect

# 需要导入模块: from bitcoinrpc import authproxy [as 别名]
# 或者: from bitcoinrpc.authproxy import AuthServiceProxy [as 别名]
def rpc_reconnect(self):
        self.rpc = AuthServiceProxy(self.uri) 
开发者ID:AustEcon,项目名称:bitsv,代码行数:4,代码来源:fullnode.py

示例9: __init__

# 需要导入模块: from bitcoinrpc import authproxy [as 别名]
# 或者: from bitcoinrpc.authproxy import AuthServiceProxy [as 别名]
def __init__(self, window,
                 on_connection_initiated_callback=None,
                 on_connection_failed_callback=None,
                 on_connection_successful_callback=None,
                 on_connection_disconnected_callback=None):
        WndUtils.__init__(self, app_config=None)

        self.app_config = None
        self.db_intf = None
        self.connections = []
        self.cur_conn_index = 0
        self.cur_conn_def: Optional['DashNetworkConnectionCfg'] = None

        # below is the connection with which particular RPC call has started; if connection is switched because of
        # problems with some nodes, switching stops if we close round and return to the starting connection
        self.starting_conn = None

        self.masternodes = []  # cached list of all masternodes (Masternode object)
        self.masternodes_by_ident = {}
        self.masternodes_by_ip_port = {}
        self.protx_by_mn_ident: Dict[str, Dict] = {}

        self.ssh = None
        self.window = window
        self.active = False
        self.rpc_url = None
        self.proxy = None
        self.http_conn = None  # HTTPConnection object passed to the AuthServiceProxy (for convinient connection reset)
        self.on_connection_initiated_callback = on_connection_initiated_callback
        self.on_connection_failed_callback = on_connection_failed_callback
        self.on_connection_successful_callback = on_connection_successful_callback
        self.on_connection_disconnected_callback = on_connection_disconnected_callback
        self.last_error_message = None
        self.mempool_txes:Dict[str, Dict] = {}
        self.http_lock = threading.RLock() 
开发者ID:Bertrand256,项目名称:dash-masternode-tool,代码行数:37,代码来源:dashd_intf.py

示例10: connect_to_bitcoin_server

# 需要导入模块: from bitcoinrpc import authproxy [as 别名]
# 或者: from bitcoinrpc.authproxy import AuthServiceProxy [as 别名]
def connect_to_bitcoin_server(server_ip, port,user, password):
	global access 
	access = AuthServiceProxy("http://%s:%s@%s:%s"%(user,password,server_ip,port))
	pass 
开发者ID:adonley,项目名称:BitMeshPOC,代码行数:6,代码来源:bitcoind_server_interface.py

示例11: rpc_connection

# 需要导入模块: from bitcoinrpc import authproxy [as 别名]
# 或者: from bitcoinrpc.authproxy import AuthServiceProxy [as 别名]
def rpc_connection(self):
        return AuthServiceProxy("http://{0}:{1}@{2}:{3}".format(*self.creds)) 
开发者ID:dashpay,项目名称:sentinel,代码行数:4,代码来源:dashd.py

示例12: connect

# 需要导入模块: from bitcoinrpc import authproxy [as 别名]
# 或者: from bitcoinrpc.authproxy import AuthServiceProxy [as 别名]
def connect(self):
        protocol = 'http'
        if ('rpcssl' in self.config and
                bool(self.config['rpcssl']) and
                int(self.config['rpcssl']) > 0):
            protocol = 'https'
        serverURL = protocol + '://' + self.config['rpcuser'] + ':' + \
            self.config['rpcpassword'] + '@' + str(self.config['rpcbind']) + \
            ':' + str(self.config['rpcport'])
        self._proxy = AuthServiceProxy(serverURL)
        return self._proxy 
开发者ID:moocowmoo,项目名称:dashvend,代码行数:13,代码来源:dashrpc.py

示例13: bitcoind_agrees_on_transaction_validity

# 需要导入模块: from bitcoinrpc import authproxy [as 别名]
# 或者: from bitcoinrpc.authproxy import AuthServiceProxy [as 别名]
def bitcoind_agrees_on_transaction_validity(bitcoind_url, tx):
    connection = AuthServiceProxy(bitcoind_url)
    tx.check_unspents()
    unknown_tx_outs = [unspent_to_bitcoind_dict(tx_in, tx_out)
                       for tx_in, tx_out in zip(tx.txs_in, tx.unspents)]
    signed = connection.signrawtransaction(tx.as_hex(), unknown_tx_outs, [])
    is_ok = [tx.is_signature_ok(idx) for idx in range(len(tx.txs_in))]
    return all(is_ok) == signed.get("complete") 
开发者ID:moocowmoo,项目名称:dashman,代码行数:10,代码来源:bitcoind.py

示例14: apiRPC

# 需要导入模块: from bitcoinrpc import authproxy [as 别名]
# 或者: from bitcoinrpc.authproxy import AuthServiceProxy [as 别名]
def apiRPC(cmd, arg):
    rpc = AuthServiceProxy(sqc.cfg['rpc'])
    if cmd =='estimatefee':
        return int(rpc.estimatefee(int(arg)))
    if cmd =='send':
        return rpc.sendrawtransaction(arg) 
开发者ID:neocogent,项目名称:sqlchain,代码行数:8,代码来源:insight.py

示例15: rpconn

# 需要导入模块: from bitcoinrpc import authproxy [as 别名]
# 或者: from bitcoinrpc.authproxy import AuthServiceProxy [as 别名]
def rpconn(rpcurl):
    return AuthServiceProxy(rpcurl) 
开发者ID:ascribe,项目名称:pyspool,代码行数:4,代码来源:conftest.py


注:本文中的bitcoinrpc.authproxy.AuthServiceProxy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。