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


Python bitcoin.wallet方法代码示例

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


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

示例1: getreceivedbyaddress

# 需要导入模块: import bitcoin [as 别名]
# 或者: from bitcoin import wallet [as 别名]
def getreceivedbyaddress(self, addr, minconf=1):
        """Return total amount received by given a (wallet) address

        Get the amount received by <address> in transactions with at least
        [minconf] confirmations.

        Works only for addresses in the local wallet; other addresses will
        always show zero.

        addr    - The address. (CBitcoinAddress instance)

        minconf - Only include transactions confirmed at least this many times.
        (default=1)
        """
        r = self._call('getreceivedbyaddress', str(addr), minconf)
        return int(r * COIN) 
开发者ID:petertodd,项目名称:checklocktimeverify-demos,代码行数:18,代码来源:rpc.py

示例2: listunspent

# 需要导入模块: import bitcoin [as 别名]
# 或者: from bitcoin import wallet [as 别名]
def listunspent(self, minconf=0, maxconf=9999999, addrs=None):
        """Return unspent transaction outputs in wallet

        Outputs will have between minconf and maxconf (inclusive)
        confirmations, optionally filtered to only include txouts paid to
        addresses in addrs.
        """
        r = None
        if addrs is None:
            r = self._call('listunspent', minconf, maxconf)
        else:
            addrs = [str(addr) for addr in addrs]
            r = self._call('listunspent', minconf, maxconf, addrs)

        r2 = []
        for unspent in r:
            unspent['outpoint'] = COutPoint(lx(unspent['txid']), unspent['vout'])
            del unspent['txid']
            del unspent['vout']

            unspent['address'] = CBitcoinAddress(unspent['address'])
            unspent['scriptPubKey'] = CScript(unhexlify(unspent['scriptPubKey']))
            unspent['amount'] = int(unspent['amount'] * COIN)
            r2.append(unspent)
        return r2 
开发者ID:petertodd,项目名称:checklocktimeverify-demos,代码行数:27,代码来源:rpc.py

示例3: get_wallet

# 需要导入模块: import bitcoin [as 别名]
# 或者: from bitcoin import wallet [as 别名]
def get_wallet(cls, private_key: str=None, encrypted_private_key: bytes=None, password: str=None) ->BitcoinWallet:
        '''
        Returns wallet object.

        Args:
            private_key (str): hex string with wallet's secret key
            encrypted_private_key (bytes): private key encrypted with password
            password (str): password for decrypting an encrypted private key

        Returns:
            BitcoinWallet: wallet object

        Example:
            >>> from clove.network import BitcoinTestNet
            >>> network = BitcoinTestNet()
            >>> wallet = network.get_wallet('cV8FDJu3JhLED2D7q5L7FwLCus69TajYGEnTWEbNqhzzV9WxMBE7')
            >>> wallet.address
            'mtUXc6UJTiwb5FdoEJ2hzR8R1yUrcj3hcn'

        Note:
            If private_key has not been provided then a new wallet will be generated just like via `get_new_wallet()`.
        '''
        return BitcoinWallet(private_key, encrypted_private_key, password) 
开发者ID:Lamden,项目名称:clove,代码行数:25,代码来源:base.py

示例4: is_valid_address

# 需要导入模块: import bitcoin [as 别名]
# 或者: from bitcoin import wallet [as 别名]
def is_valid_address(cls, address: str) -> bool:
        '''
        Checks if wallet address is valid for this network.

        Args:
            address (str): wallet address to check

        Returns:
            bool: True if address is valued, False otherwise

        Example:
            >>> from clove.network import Bitcoin
            >>> network = Bitcoin()
            >>> network.is_valid_address('13iNsKgMfVJQaYVFqp5ojuudxKkVCMtkoa')
            True
            >>> network.is_valid_address('msJ2ucZ2NDhpVzsiNE5mGUFzqFDggjBVTM')
            False
        '''
        try:
            CBitcoinAddress(address)
        except (CBitcoinAddressError, Base58ChecksumError, InvalidBase58Error):
            return False

        return True 
开发者ID:Lamden,项目名称:clove,代码行数:26,代码来源:base.py

示例5: getbalance

# 需要导入模块: import bitcoin [as 别名]
# 或者: from bitcoin import wallet [as 别名]
def getbalance(self, account='*', minconf=1):
        """Get the balance

        account - The selected account. Defaults to "*" for entire wallet. It
        may be the default account using "".

        minconf - Only include transactions confirmed at least this many times.
        (default=1)
        """
        r = self._call('getbalance', account, minconf)
        return int(r*COIN) 
开发者ID:petertodd,项目名称:checklocktimeverify-demos,代码行数:13,代码来源:rpc.py

示例6: gettransaction

# 需要导入模块: import bitcoin [as 别名]
# 或者: from bitcoin import wallet [as 别名]
def gettransaction(self, txid):
        """Get detailed information about in-wallet transaction txid

        Raises IndexError if transaction not found in the wallet.

        FIXME: Returned data types are not yet converted.
        """
        try:
            r = self._call('gettransaction', b2lx(txid))
        except JSONRPCError as ex:
            raise IndexError('%s.getrawtransaction(): %s (%d)' %
                    (self.__class__.__name__, ex.error['message'], ex.error['code']))
        return r 
开发者ID:petertodd,项目名称:checklocktimeverify-demos,代码行数:15,代码来源:rpc.py

示例7: importaddress

# 需要导入模块: import bitcoin [as 别名]
# 或者: from bitcoin import wallet [as 别名]
def importaddress(self, addr, label='', rescan=True):
        """Adds an address or pubkey to wallet without the associated privkey."""
        addr = str(addr)

        r = self._call('importaddress', addr, label, rescan)
        return r 
开发者ID:petertodd,项目名称:checklocktimeverify-demos,代码行数:8,代码来源:rpc.py

示例8: get_new_wallet

# 需要导入模块: import bitcoin [as 别名]
# 或者: from bitcoin import wallet [as 别名]
def get_new_wallet(cls) -> BitcoinWallet:
        '''
        Generates a new wallet.

        Example:
            >>> wallet = network.get_new_wallet()
            >>> wallet.address
            'mrkLKxgzfQk4dgFrfaoVYjeTkXxCfKyz1q'
        '''
        return cls.get_wallet() 
开发者ID:Lamden,项目名称:clove,代码行数:12,代码来源:base.py

示例9: atomic_swap

# 需要导入模块: import bitcoin [as 别名]
# 或者: from bitcoin import wallet [as 别名]
def atomic_swap(
        self,
        sender_address: str,
        recipient_address: str,
        value: float,
        solvable_utxo: list=None,
        secret_hash: str=None,
    ) -> Optional[BitcoinAtomicSwapTransaction]:
        '''
        Creates atomic swap unsigned transaction object.

        Args:
            sender_address (str): wallet address of the sender
            recipient_address (str): wallet address of the recipient
            value (float): amount to swap
            solvable_utxo (list): optional list of UTXO objects. If None then it will try to find UTXO automatically
                by using the `get_utxo` method.
            secret_hash (str): optional secret hash to be used in transaction. If None then the new hash
                will be generated.

        Returns:
            BitcoinAtomicSwapTransaction, None: unsigned Atomic Swap transaction object or None if something went wrong

        Example:
            >>> from clove.network import BitcoinTestNet
            >>> network = BitcoinTestNet()
            >>> network.atomic_swap('msJ2ucZ2NDhpVzsiNE5mGUFzqFDggjBVTM', 'mmJtKA92Mxqfi3XdyGReza69GjhkwAcBN1', 2.4)
            <clove.network.bitcoin.transaction.BitcoinAtomicSwapTransaction at 0x7f989439d630>
        '''
        if not solvable_utxo:
            solvable_utxo = self.get_utxo(sender_address, value)
            if not solvable_utxo:
                logger.error(f'Cannot get UTXO for address {sender_address}')
                return
        transaction = BitcoinAtomicSwapTransaction(
            self, sender_address, recipient_address, value, solvable_utxo, secret_hash
        )
        transaction.create_unsigned_transaction()
        return transaction 
开发者ID:Lamden,项目名称:clove,代码行数:41,代码来源:base.py

示例10: _as_any_address

# 需要导入模块: import bitcoin [as 别名]
# 或者: from bitcoin import wallet [as 别名]
def _as_any_address(address):
        try:
            result = colorcore.addresses.Base58Address.from_string(address)
            return result.address
        except (bitcoin.wallet.CBitcoinAddressError, bitcoin.base58.Base58ChecksumError):
            raise colorcore.routing.ControllerError("The address {} is an invalid address.".format(address)) 
开发者ID:OpenAssets,项目名称:colorcore,代码行数:8,代码来源:operations.py

示例11: _as_openassets_address

# 需要导入模块: import bitcoin [as 别名]
# 或者: from bitcoin import wallet [as 别名]
def _as_openassets_address(self, address):
        try:
            result = colorcore.addresses.Base58Address.from_string(address)
            if result.namespace != self.configuration.namespace:
                raise colorcore.routing.ControllerError("The address {} is not an asset address.".format(address))
            return result.address
        except (bitcoin.wallet.CBitcoinAddressError, bitcoin.base58.Base58ChecksumError):
            raise colorcore.routing.ControllerError("The address {} is an invalid address.".format(address)) 
开发者ID:OpenAssets,项目名称:colorcore,代码行数:10,代码来源:operations.py

示例12: script_to_address

# 需要导入模块: import bitcoin [as 别名]
# 或者: from bitcoin import wallet [as 别名]
def script_to_address(script):
        """
        Converts an output script to an address if possible, or None otherwise.

        :param bytes script: The script to convert.
        :return: The converted value.
        :rtype: CBitcoinAddress | None
        """
        try:
            return bitcoin.wallet.CBitcoinAddress.from_scriptPubKey(bitcoin.core.CScript(script))
        except bitcoin.wallet.CBitcoinAddressError:
            return None 
开发者ID:OpenAssets,项目名称:colorcore,代码行数:14,代码来源:operations.py

示例13: getbalance

# 需要导入模块: import bitcoin [as 别名]
# 或者: from bitcoin import wallet [as 别名]
def getbalance(self, account='*', minconf=1, include_watchonly=False):
        """Get the balance

        account - The selected account. Defaults to "*" for entire wallet. It
        may be the default account using "".

        minconf - Only include transactions confirmed at least this many times.
        (default=1)

        include_watchonly - Also include balance in watch-only addresses (see 'importaddress')
        (default=False)
        """
        r = self._call('getbalance', account, minconf, include_watchonly)
        return int(r*COIN) 
开发者ID:petertodd,项目名称:replace-by-fee-tools,代码行数:16,代码来源:rpc.py

示例14: gettransaction

# 需要导入模块: import bitcoin [as 别名]
# 或者: from bitcoin import wallet [as 别名]
def gettransaction(self, txid):
        """Get detailed information about in-wallet transaction txid

        Raises IndexError if transaction not found in the wallet.

        FIXME: Returned data types are not yet converted.
        """
        try:
            r = self._call('gettransaction', b2lx(txid))
        except InvalidAddressOrKeyError as ex:
            raise IndexError('%s.getrawtransaction(): %s (%d)' %
                    (self.__class__.__name__, ex.error['message'], ex.error['code']))
        return r 
开发者ID:petertodd,项目名称:replace-by-fee-tools,代码行数:15,代码来源:rpc.py

示例15: do_mesh_sendtoaddress

# 需要导入模块: import bitcoin [as 别名]
# 或者: from bitcoin import wallet [as 别名]
def do_mesh_sendtoaddress(self, rem) :
        """ 
        Create a signed transaction and broadcast it over the connected mesh device. The transaction 
        spends some amount of satoshis to the specified address from the local bitcoind wallet and selected network. 

        Usage: mesh_sendtoaddress ADDRESS SATS NETWORK(m|t)

        eg. txTenna> mesh_sendtoaddress 2N4BtwKZBU3kXkWT7ZBEcQLQ451AuDWiau2 13371337 t
        """
        try:

            proxy = bitcoin.rpc.Proxy()
            (addr, sats, network) = rem.split()

            # Create the txout. This time we create the scriptPubKey from a Bitcoin
            # address.
            txout = CMutableTxOut(sats, CBitcoinAddress(addr).to_scriptPubKey())

            # Create the unsigned transaction.
            unfunded_transaction = CMutableTransaction([], [txout])
            funded_transaction = proxy.fundrawtransaction(unfunded_transaction)
            signed_transaction = proxy.signrawtransaction(funded_transaction["tx"])
            txhex = b2x(signed_transaction["tx"].serialize())
            txid = b2lx(signed_transaction["tx"].GetTxid())
            print("sendtoaddress_mesh (tx, txid, network): " + txhex + ", " + txid, ", " + network)

            # broadcast over mesh
            self.do_mesh_broadcast_rawtx( txhex + " " + txid + " " + network)

        except Exception: # pylint: disable=broad-except
            traceback.print_exc()

        try :
            # lock UTXOs used to fund the tx if broadcast successful
            vin_outpoints = set()
            for txin in funded_transaction["tx"].vin:
                vin_outpoints.add(txin.prevout)
            ## json_outpoints = [{'txid':b2lx(outpoint.hash), 'vout':outpoint.n}
            ##              for outpoint in vin_outpoints]
            ## print(str(json_outpoints))
            proxy.lockunspent(False, vin_outpoints)
            
        except Exception: # pylint: disable=broad-except
            ## TODO: figure out why this is happening
            print("RPC timeout after calling lockunspent") 
开发者ID:remyers,项目名称:txtenna-python,代码行数:47,代码来源:txtenna.py


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