def getblock(self, hash):
     """
     """
     try:
         return self.proxy.getblock(hash)
     except JSONRPCException,e:
         raise _wrap_exception(e.error)
    def createrawtransaction(self, inputs, outputs):
        """
        Creates a raw transaction spending given inputs
        (a list of dictionaries, each containing a transaction id and an output number),
        sending to given address(es).

        Returns hex-encoded raw transaction.

        Example usage:
        >>> conn.createrawtransaction(
                [{"txid": "a9d4599e15b53f3eb531608ddb31f48c695c3d0b3538a6bda871e8b34f2f430c",
                  "vout": 0}],
                {"mkZBYBiq6DNoQEKakpMJegyDbw2YiNQnHT":50})


        Arguments:

        - *inputs* -- A list of {"txid": txid, "vout": n} dictionaries.
        - *outputs* -- A dictionary mapping (public) addresses to the amount
                       they are to be paid.
        """
        try:
            return self.proxy.createrawtransaction(inputs, outputs)
        except JSONRPCException as e:
            raise _wrap_exception(e.error)
Exemple #3
0
    def sendtoaddress(self,
                      bitcoinaddress,
                      amount,
                      comment=None,
                      comment_to=None):
        """
        Sends *amount* from the server's available balance to *bitcoinaddress*.
        
        Arguments:
        
        - *bitcoinaddress* -- Bitcoin address to send to.
        - *amount* -- Amount to send (float, rounded to the nearest 0.01).
        - *minconf* -- Minimum number of confirmations required for transferred balance.
        - *comment* -- Comment for transaction.
        - *comment_to* -- Comment for to-address.

        """
        try:
            if comment is None:
                return self.proxy.sendtoaddress(bitcoinaddress, amount)
            elif comment_to is None:
                return self.proxy.sendtoaddress(bitcoinaddress, amount,
                                                comment)
            else:
                return self.proxy.sendtoaddress(bitcoinaddress, amount,
                                                comment, comment_to)
        except JSONRPCException, e:
            raise _wrap_exception(e.error)
    def signrawtransaction(self,
                           hexstring,
                           previous_transactions=None,
                           private_keys=None):
        """
        Sign inputs for raw transaction (serialized, hex-encoded).

        Returns a dictionary with the keys:
            "hex": raw transaction with signature(s) (hex-encoded string)
            "complete": 1 if transaction has a complete set of signature(s), 0 if not

        Arguments:

        - *hexstring* -- A hex string of the transaction to sign.
        - *previous_transactions* -- A (possibly empty) list of dictionaries of the form:
            {"txid": txid, "vout": n, "scriptPubKey": hex, "redeemScript": hex}, representing
            previous transaction outputs that this transaction depends on but may not yet be
            in the block chain.
        - *private_keys* -- A (possibly empty) list of base58-encoded private
            keys that, if given, will be the only keys used to sign the transaction.
        """
        try:
            return dict(
                self.proxy.signrawtransaction(hexstring, previous_transactions,
                                              private_keys))
        except JSONRPCException as e:
            raise _wrap_exception(e.error)
 def listsinceblock(self, block_hash):
     try:
         res = self.proxy.listsinceblock(block_hash)
         res['transactions'] = [TransactionInfo(**x) for x in res['transactions']]
         return res
     except JSONRPCException as e:
         raise _wrap_exception(e.error)
    def createrawtransaction(self, inputs, outputs):
        """
        Creates a raw transaction spending given inputs
        (a list of dictionaries, each containing a transaction id and an output number),
        sending to given address(es).

        Returns hex-encoded raw transaction.

        Example usage:
        >>> conn.createrawtransaction(
                [{"txid": "a9d4599e15b53f3eb531608ddb31f48c695c3d0b3538a6bda871e8b34f2f430c",
                  "vout": 0}],
                {"mkZBYBiq6DNoQEKakpMJegyDbw2YiNQnHT":50})


        Arguments:

        - *inputs* -- A list of {"txid": txid, "vout": n} dictionaries.
        - *outputs* -- A dictionary mapping (public) addresses to the amount
                       they are to be paid.
        """
        try:
            print "EFE DEBUG: in:%s, out:%s" % (inputs, outputs)
            sys.stdout.flush()
            return self.proxy.createrawtransaction(inputs, outputs)
        except JSONRPCException as e:
            raise _wrap_exception(e.error)
    def sendfrom(self, fromaccount, tobitcoinaddress, amount, minconf=1, comment=None, comment_to=None):
        """
        Sends amount from account's balance to bitcoinaddress. This method will fail 
        if there is less than amount bitcoins with minconf confirmations in the account's 
        balance (unless account is the empty-string-named default account; it 
        behaves like the sendtoaddress method). Returns transaction ID on success.
        
        Arguments:
        
        - *fromaccount* -- Account to send from.
        - *tobitcoinaddress* -- Bitcoin address to send to.
        - *amount* -- Amount to send (float, rounded to the nearest 0.01).
        - *minconf* -- Minimum number of confirmations required for transferred balance.
        - *comment* -- Comment for transaction.
        - *comment_to* -- Comment for to-address.

        """
        try:
            if comment is None:
                return self.proxy.sendfrom(fromaccount, tobitcoinaddress, amount, minconf)
            elif comment_to is None:
                return self.proxy.sendfrom(fromaccount, tobitcoinaddress, amount, minconf, comment)
            else:
                return self.proxy.sendfrom(fromaccount, tobitcoinaddress, amount, minconf, comment, comment_to)
        except JSONRPCException,e:
            raise _wrap_exception(e.error)
Exemple #8
0
    def sendfrom(self, fromaccount, tobitcoinaddress, amount, minconf=1, comment=None, comment_to=None):
        """
        Sends amount from account's balance to bitcoinaddress. This method will fail 
        if there is less than amount bitcoins with minconf confirmations in the account's 
        balance (unless account is the empty-string-named default account; it 
        behaves like the sendtoaddress method). Returns transaction ID on success.
        
        Arguments:
        
        - *fromaccount* -- Account to send from.
        - *tobitcoinaddress* -- Bitcoin address to send to.
        - *amount* -- Amount to send (float, rounded to the nearest 0.01).
        - *minconf* -- Minimum number of confirmations required for transferred balance.
        - *comment* -- Comment for transaction.
        - *comment_to* -- Comment for to-address.

        """
        try:
            if comment is None:
                return self.proxy.sendfrom(fromaccount, tobitcoinaddress, amount, minconf)
            elif comment_to is None:
                return self.proxy.sendfrom(fromaccount, tobitcoinaddress, amount, minconf, comment)
            else:
                return self.proxy.sendfrom(fromaccount, tobitcoinaddress, amount, minconf, comment, comment_to)
        except JSONRPCException,e:
            raise _wrap_exception(e.error)
Exemple #9
0
 def getblock(self, hash):
     """
     """
     try:
         return self.proxy.getblock(hash)
     except JSONRPCException, e:
         raise _wrap_exception(e.error)
 def getblocktemplate(self):
     """
     Returns block template to work on. 
     """
     try:
         return self.proxy.getblocktemplate()
     except JSONRPCException as e:
         raise _wrap_exception(e.error)
 def signrawtransaction(self, txnHex):
     """
     Submits raw transaction (serialized, hex-encoded) to local node and network. 
     """
     try:
         return TransactionInfo(**self.proxy.signrawtransaction(txnHex))
     except JSONRPCException as e:
         raise _wrap_exception(e.error)
 def getbestblockhash(self):
     """
     Returns all transaction ids in memory pool
     """
     try:
         return self.proxy.getbestblockhash()
     except JSONRPCException as e:
         raise _wrap_exception(e.error)
 def getblock(self, hash):
     """
     Returns information about the given block hash.
     """
     try:
         return self.proxy.getblock(hash)
     except JSONRPCException as e:
         raise _wrap_exception(e.error)
Exemple #14
0
 def getblockcount(self):
     """
     Returns the number of blocks in the longest block chain.
     """
     try:
         return self.proxy.getblockcount()
     except JSONRPCException, e:
         raise _wrap_exception(e.error)
Exemple #15
0
 def getgenerate(self):
     """
     Returns :const:`True` or :const:`False`, depending on whether generation is enabled.
     """
     try:
         return self.proxy.getgenerate()
     except JSONRPCException,e:
         raise _wrap_exception(e.error)
Exemple #16
0
 def getdifficulty(self):
     """
     Returns the proof-of-work difficulty as a multiple of the minimum difficulty.
     """
     try:
         return self.proxy.getdifficulty()
     except JSONRPCException,e:
         raise _wrap_exception(e.error)
Exemple #17
0
 def stop(self):
     """
     Stop bitcoin server.
     """
     try:
         self.proxy.stop()
     except JSONRPCException,e:
         raise _wrap_exception(e.error)
Exemple #18
0
 def dumpprivkey(self, wid):
     """
     Dumps private key
     """
     try:
         return self.proxy.dumpprivkey(wid)
     except JSONRPCException as e:
         raise _wrap_exception(e.error)
Exemple #19
0
 def getdifficulty(self):
     """
     Returns the proof-of-work difficulty as a multiple of the minimum difficulty.
     """
     try:
         return self.proxy.getdifficulty()
     except JSONRPCException, e:
         raise _wrap_exception(e.error)
Exemple #20
0
 def getblocknumber(self):
     """
     Returns the block number of the latest block in the longest block chain.
     """
     try:
         return self.proxy.getblocknumber()
     except JSONRPCException, e:
         raise _wrap_exception(e.error)
Exemple #21
0
 def getconnectioncount(self):
     """
     Returns the number of connections to other nodes.
     """
     try:
         return self.proxy.getconnectioncount()
     except JSONRPCException, e:
         raise _wrap_exception(e.error)
Exemple #22
0
 def stop(self):
     """
     Stop bitcoin server.
     """
     try:
         self.proxy.stop()
     except JSONRPCException, e:
         raise _wrap_exception(e.error)
Exemple #23
0
 def gethashespersec(self):
     """
     Returns a recent hashes per second performance measurement while generating.
     """
     try:
         return self.proxy.gethashespersec()
     except JSONRPCException, e:
         raise _wrap_exception(e.error)
 def getblock(self, hash):
     """
     Returns information about the given block hash.
     """
     try:
         return self.proxy.getblock(hash)
     except JSONRPCException as e:
         raise _wrap_exception(e.error)
Exemple #25
0
 def getinfo(self):
     """
     Returns an :class:`~bitcoinrpc.data.ServerInfo` object containing various state info.
     """
     try:
         return ServerInfo(**self.proxy.getinfo())
     except JSONRPCException,e:
         raise _wrap_exception(e.error)
Exemple #26
0
 def getblockcount(self):
     """
     Returns the number of blocks in the longest block chain.
     """
     try:
         return self.proxy.getblockcount()
     except JSONRPCException,e:
         raise _wrap_exception(e.error)    
Exemple #27
0
 def getblocknumber(self):
     """
     Returns the block number of the latest block in the longest block chain.
     """
     try:
         return self.proxy.getblocknumber()
     except JSONRPCException,e:
         raise _wrap_exception(e.error)  
Exemple #28
0
 def getconnectioncount(self):
     """
     Returns the number of connections to other nodes.
     """
     try:
         return self.proxy.getconnectioncount()
     except JSONRPCException,e:
         raise _wrap_exception(e.error)
Exemple #29
0
 def getinfo(self):
     """
     Returns an :class:`~bitcoinrpc.data.ServerInfo` object containing various state info.
     """
     try:
         return ServerInfo(**self.proxy.getinfo())
     except JSONRPCException, e:
         raise _wrap_exception(e.error)
Exemple #30
0
 def getgenerate(self):
     """
     Returns :const:`True` or :const:`False`, depending on whether generation is enabled.
     """
     try:
         return self.proxy.getgenerate()
     except JSONRPCException, e:
         raise _wrap_exception(e.error)
Exemple #31
0
 def gethashespersec(self):
     """
     Returns a recent hashes per second performance measurement while generating.
     """
     try:
         return self.proxy.gethashespersec()
     except JSONRPCException,e:
         raise _wrap_exception(e.error)
Exemple #32
0
 def importprivkey(self, privkey, label="myprivkey"):
     """
     Imports private key
     """
     try:
         self.proxy.importprivkey(privkey, label)
         return "Your private key has been successfully imported"
     except JSONRPCException as e:
         raise _wrap_exception(e.error)
Exemple #33
0
 def __init__(self, user, password, host='localhost', port=8332):
     """
     Create a new bitcoin server connection.
     """
     url = 'http://%s:%s@%s:%s/' % (user, password, host, port)
     try:
         self.proxy = ServiceProxy(url)
     except JSONRPCException, e:
         raise _wrap_exception(e.error)
 def logmessage(self, msg):
     """
     Log a message to the bitcoin debug log. 
     """
     try:
         self.proxy.logmessage(msg)
         return True
     except JSONRPCException as e:
         raise _wrap_exception(e.error)
 def getmininginfo(self):
     """
     Returns an :class:`~bitcoinrpc.data.MiningInfo` object containing various
     mining state info.
     """
     try:
         return MiningInfo(**self.proxy.getmininginfo())
     except JSONRPCException as e:
         raise _wrap_exception(e.error)
Exemple #36
0
 def __init__(self, user, password, host="localhost", port=8332, protocol="http"):
     """
     Create a new bitcoin server connection.
     """
     url = "%s://%s:%s@%s:%s/" % (protocol, user, password, host, port)
     try:
         self.proxy = ServiceProxy(url)
     except JSONRPCException, e:
         raise _wrap_exception(e.error)
Exemple #37
0
 def listsinceblock(self, block_hash):
     try:
         res = self.proxy.listsinceblock(block_hash)
         res['transactions'] = [
             TransactionInfo(**x) for x in res['transactions']
         ]
         return res
     except JSONRPCException, e:
         raise _wrap_exception(e.error)
 def getmininginfo(self):
     """
     Returns an :class:`~bitcoinrpc.data.MiningInfo` object containing various
     mining state info.
     """
     try:
         return MiningInfo(**self.proxy.getmininginfo())
     except JSONRPCException as e:
         raise _wrap_exception(e.error)
    def getblockhash(self, index):
        """
        Returns hash of block in best-block-chain at index.

        :param index: index ob the block

        """
        try:
            return self.proxy.getblockhash(index)
        except JSONRPCException as e:
            raise _wrap_exception(e.error)
 def walletlock(self):
     """
     Removes the wallet encryption key from memory, locking the wallet.
     After calling this method, you will need to call walletpassphrase
     again before being able to call any methods which require the wallet
     to be unlocked.
     """
     try:
         return self.proxy.walletlock()
     except JSONRPCException as e:
         raise _wrap_exception(e.error)
 def walletlock(self):
     """
     Removes the wallet encryption key from memory, locking the wallet.
     After calling this method, you will need to call walletpassphrase
     again before being able to call any methods which require the wallet
     to be unlocked.
     """
     try:
         return self.proxy.walletlock()
     except JSONRPCException as e:
         raise _wrap_exception(e.error)
 def __init__(self, user, password, host='localhost', port=8332,
              use_https=False):
     """
     Create a new bitcoin server connection.
     """
     url = ('https' if use_https else 'http') \
           + '://%s:%s@%s:%s/' % (user, password, host, port)
     try:
         self.proxy = AuthServiceProxy(url)
     except JSONRPCException,e:
         raise _wrap_exception(e.error)
Exemple #43
0
 def __init__(self, user, password, host='localhost', port=8332):
     """
     Create a new bitcoin server connection.
     """
     url = 'http://%s:%s@%s:%s/' % (
         user, password, host, port
         )
     try:
         self.proxy = ServiceProxy(url)
     except JSONRPCException,e:
         raise _wrap_exception(e.error)
Exemple #44
0
    def getblockhash(self, index):
        """
        Returns hash of block in best-block-chain at index.

        :param index: index ob the block

        """
        try:
            return self.proxy.getblockhash(index)
        except JSONRPCException as e:
            raise _wrap_exception(e.error)
Exemple #45
0
    def backupwallet(self, destination):
        """
        Safely copies ``wallet.dat`` to *destination*, which can be a directory or a path with filename.
        
        Arguments:
        - *destination* -- directory or path with filename to backup wallet to.

        """
        try:
            return self.proxy.backupwallet(destination)
        except JSONRPCException, e:
            raise _wrap_exception(e.error)
    def decoderawtransaction(self, hexstring):
        """
        Produces a human-readable JSON object for a raw transaction.

        Arguments:

        - *hexstring* -- A hex string of the transaction to be decoded.
        """
        try:
            return dict(self.proxy.decoderawtransaction(hexstring))
        except JSONRPCException as e:
            raise _wrap_exception(e.error)
Exemple #47
0
 def getaddressesbyaccount(self, account):
     """
     Returns the list of addresses for the given account.
     
     Arguments:
     
     - *account* -- Account to get list of addresses for.
     """ 
     try:
         return self.proxy.getaddressesbyaccount(account) 
     except JSONRPCException,e:
         raise _wrap_exception(e.error)
Exemple #48
0
 def getaddressesbyaccount(self, account):
     """
     Returns the list of addresses for the given account.
     
     Arguments:
     
     - *account* -- Account to get list of addresses for.
     """
     try:
         return self.proxy.getaddressesbyaccount(account)
     except JSONRPCException, e:
         raise _wrap_exception(e.error)
Exemple #49
0
 def getaccount(self, bitcoinaddress):
     """
     Returns the account associated with the given address.
     
     Arguments:
     
     - *bitcoinaddress* -- Bitcoin address to get account for.
     """
     try:
         return self.proxy.getaccount(bitcoinaddress)
     except JSONRPCException, e:
         raise _wrap_exception(e.error)
Exemple #50
0
    def backupwallet(self, destination):
        """
        Safely copies ``wallet.dat`` to *destination*, which can be a directory or a path with filename.
        
        Arguments:
        - *destination* -- directory or path with filename to backup wallet to.

        """
        try:
            return self.proxy.backupwallet(destination)
        except JSONRPCException,e:
            raise _wrap_exception(e.error)
    def decoderawtransaction(self, hexstring):
        """
        Produces a human-readable JSON object for a raw transaction.

        Arguments:

        - *hexstring* -- A hex string of the transaction to be decoded.
        """
        try:
            return dict(self.proxy.decoderawtransaction(hexstring))
        except JSONRPCException as e:
            raise _wrap_exception(e.error)
Exemple #52
0
 def getaccount(self, bitcoinaddress):
     """
     Returns the account associated with the given address.
     
     Arguments:
     
     - *bitcoinaddress* -- Bitcoin address to get account for.
     """
     try:
         return self.proxy.getaccount(bitcoinaddress)
     except JSONRPCException,e:
         raise _wrap_exception(e.error)
 def __init__(self, user, password, host='localhost', port=8332,
              use_https=False):
     """
     Create a new bitcoin server connection.
     """
     url = 'http{s}://{user}:{password}@{host}:{port}/'.format(
         s='s' if use_https else '',
         user=user, password=password, host=host, port=port)
     self.url = url
     try:
         self.proxy = AuthServiceProxy(url)
     except JSONRPCException as e:
         raise _wrap_exception(e.error)
Exemple #54
0
    def getaccountaddress(self, account):
        """
        Returns the current bitcoin address for receiving payments to an account.
        
        Arguments:
        
        - *account* -- Account for which the address should be returned.

        """
        try:
            return self.proxy.getaccountaddress(account)
        except JSONRPCException, e:
            raise _wrap_exception(e.error)
Exemple #55
0
    def gettransaction(self, txid):
        """
        Get detailed information about transaction

        Arguments:

        - *txid* -- Transactiond id for which the info should be returned

        """
        try:
            return TransactionInfo(**self.proxy.gettransaction(txid))
        except JSONRPCException, e:
            raise _wrap_exception(e.error)
Exemple #56
0
 def listaccounts(self, minconf=1):
     """
     Returns a list of account names.
     
     Arguments:
     
     - *minconf* -- Minimum number of confirmations before payments are included.
     """
     try:
         #return [AccountInfo(**x) for x in self.proxy.listaccounts(minconf)]
         return [x for x in self.proxy.listaccounts(minconf)]
     except JSONRPCException, e:
         raise _wrap_exception(e.error)
Exemple #57
0
    def getaccountaddress(self, account):
        """
        Returns the current bitcoin address for receiving payments to an account.
        
        Arguments:
        
        - *account* -- Account for which the address should be returned.

        """
        try:
            return self.proxy.getaccountaddress(account)
        except JSONRPCException,e:
            raise _wrap_exception(e.error)
Exemple #58
0
 def listaccounts(self, minconf=1):
     """
     Returns a list of account names.
     
     Arguments:
     
     - *minconf* -- Minimum number of confirmations before payments are included.
     """
     try:
         #return [AccountInfo(**x) for x in self.proxy.listaccounts(minconf)]
         return [x for x in self.proxy.listaccounts(minconf)]
     except JSONRPCException,e:
         raise _wrap_exception(e.error)
Exemple #59
0
    def gettransaction(self, txid):
        """
        Get detailed information about transaction

        Arguments:

        - *txid* -- Transactiond id for which the info should be returned

        """
        try:
            return TransactionInfo(**self.proxy.gettransaction(txid))
        except JSONRPCException,e:
            raise _wrap_exception(e.error)
Exemple #60
0
    def setaccount(self, bitcoinaddress, account):
        """
        Sets the account associated with the given address.
        
        Arguments:

        - *bitcoinaddress* -- Bitcoin address to associate.
        - *account* -- Account to associate the address to.

        """
        try:
            return self.proxy.setaccount(bitcoinaddress, account)
        except JSONRPCException,e:
            raise _wrap_exception(e.error)