當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。