Python bitcoin.core.lx() Examples
The following are 30
code examples of bitcoin.core.lx().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
bitcoin.core
, or try the search function
.
Example #1
Source File: test_connectors.py From cert-issuer with MIT License | 7 votes |
def mock_listunspent(self, addrs): output1 = {'outpoint': COutPoint(lx('34eb81bc0d1a822369f75174fd4916b1ec490d8fbcba33168e820cc78a52f608'), 0), 'confirmations': 62952, 'address': P2PKHBitcoinAddress('mz7poFND7hVGRtPWjiZizcCnjf6wEDWjjT'), 'spendable': False, 'amount': 49000000, 'solvable': False, 'scriptPubKey': CScript( [OP_DUP, OP_HASH160, x('cc0a909c4c83068be8b45d69b60a6f09c2be0fda'), OP_EQUALVERIFY, OP_CHECKSIG]), 'account': ''} output2 = {'address': P2PKHBitcoinAddress('mz7poFND7hVGRtPWjiZizcCnjf6wEDWjjT'), 'amount': 2750, 'account': '', 'spendable': False, 'solvable': False, 'confirmations': 62932, 'outpoint': COutPoint(lx('6773785b4dc5d2cced67d26fc0820329307a8e10dfaef50d506924984387bf0b'), 1), 'scriptPubKey': CScript( [OP_DUP, OP_HASH160, x('cc0a909c4c83068be8b45d69b60a6f09c2be0fda'), OP_EQUALVERIFY, OP_CHECKSIG])} output3 = {'address': P2PKHBitcoinAddress('mz7poFND7hVGRtPWjiZizcCnjf6wEDWjjT'), 'amount': 2750, 'account': '', 'spendable': False, 'solvable': False, 'confirmations': 62932, 'outpoint': COutPoint(lx('6773785b4dc5d2cced67d26fc0820329307a8e10dfaef50d506924984387bf0b'), 5), 'scriptPubKey': CScript( [OP_DUP, OP_HASH160, x('cc0a909c4c83068be8b45d69b60a6f09c2be0fda'), OP_EQUALVERIFY, OP_CHECKSIG])} unspent_outputs = [output1, output2, output3] return unspent_outputs
Example #2
Source File: rpc.py From checklocktimeverify-demos with GNU General Public License v3.0 | 6 votes |
def gettxout(self, outpoint, includemempool=True): """Return details about an unspent transaction output. Raises IndexError if outpoint is not found or was spent. includemempool - Include mempool txouts """ r = self._call('gettxout', b2lx(outpoint.hash), outpoint.n, includemempool) if r is None: raise IndexError('%s.gettxout(): unspent txout %r not found' % (self.__class__.__name__, outpoint)) r['txout'] = CTxOut(int(r['value'] * COIN), CScript(unhexlify(r['scriptPubKey']['hex']))) del r['value'] del r['scriptPubKey'] r['bestblock'] = lx(r['bestblock']) return r
Example #3
Source File: rpc.py From replace-by-fee-tools with GNU General Public License v3.0 | 6 votes |
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
Example #4
Source File: rpc.py From replace-by-fee-tools with GNU General Public License v3.0 | 6 votes |
def gettxout(self, outpoint, includemempool=True): """Return details about an unspent transaction output. Raises IndexError if outpoint is not found or was spent. includemempool - Include mempool txouts """ r = self._call('gettxout', b2lx(outpoint.hash), outpoint.n, includemempool) if r is None: raise IndexError('%s.gettxout(): unspent txout %r not found' % (self.__class__.__name__, outpoint)) r['txout'] = CTxOut(int(r['value'] * COIN), CScript(unhexlify(r['scriptPubKey']['hex']))) del r['value'] del r['scriptPubKey'] r['bestblock'] = lx(r['bestblock']) return r
Example #5
Source File: rpc.py From replace-by-fee-tools with GNU General Public License v3.0 | 6 votes |
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
Example #6
Source File: rpc.py From checklocktimeverify-demos with GNU General Public License v3.0 | 6 votes |
def gettxout(self, outpoint, includemempool=True): """Return details about an unspent transaction output. Raises IndexError if outpoint is not found or was spent. includemempool - Include mempool txouts """ r = self._call('gettxout', b2lx(outpoint.hash), outpoint.n, includemempool) if r is None: raise IndexError('%s.gettxout(): unspent txout %r not found' % (self.__class__.__name__, outpoint)) r['txout'] = CTxOut(int(r['value'] * COIN), CScript(unhexlify(r['scriptPubKey']['hex']))) del r['value'] del r['scriptPubKey'] r['bestblock'] = lx(r['bestblock']) return r
Example #7
Source File: rpc.py From checklocktimeverify-demos with GNU General Public License v3.0 | 6 votes |
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
Example #8
Source File: rpc.py From replace-by-fee-tools with GNU General Public License v3.0 | 5 votes |
def getbestblockhash(self): """Return hash of best (tip) block in longest block chain.""" return lx(self._call('getbestblockhash'))
Example #9
Source File: test_chainparams.py From hashmal with GNU General Public License v3.0 | 5 votes |
def test_init_with_field_keyword_args(self): ins = ( CTxIn(COutPoint(lx('537ecb89e5ed7e872f988447432e6791c0a58b069c4ec8647e1683a383e867a3'), 0), x('473044022043b9aee9187effd7e6c7bc444b09162570f17e36b4a9c02cf722126cc0efa3d502200b3ba14c809fa9a6f7f835cbdbbb70f2f43f6b30beaf91eec6b8b5981c80cea50121025edf500f18f9f2b3f175f823fa996fbb2ec52982a9aeb1dc2e388a651054fb0f')) ) outs = ( CTxOut(114263, x('76a91495efca2c6a6f0e0f0ce9530219b48607a962e77788ac')), CTxOut(2125893, x('76a914f28abfb465126d6772dcb4403b9e1ad2ea28a03488ac')) ) fields_data = {'Timestamp': 1432478808} tx = Transaction(ins, outs, 0, 2, peercoin_fields, fields_data) self.assertEqual(tx.fields, peercoin_fields) self.assertEqual(tx.Timestamp, 1432478808)
Example #10
Source File: rpc.py From replace-by-fee-tools with GNU General Public License v3.0 | 5 votes |
def getblockheader(self, block_hash, verbose=False): """Get block header <block_hash> verbose - If true a dict is returned with the values returned by getblockheader that are not in the block header itself (height, nextblockhash, etc.) Raises IndexError if block_hash is not valid. """ try: block_hash = b2lx(block_hash) except TypeError: raise TypeError('%s.getblockheader(): block_hash must be bytes; got %r instance' % (self.__class__.__name__, block_hash.__class__)) try: r = self._call('getblockheader', block_hash, verbose) except InvalidAddressOrKeyError as ex: raise IndexError('%s.getblockheader(): %s (%d)' % (self.__class__.__name__, ex.error['message'], ex.error['code'])) if verbose: nextblockhash = None if 'nextblockhash' in r: nextblockhash = lx(r['nextblockhash']) return {'confirmations':r['confirmations'], 'height':r['height'], 'mediantime':r['mediantime'], 'nextblockhash':nextblockhash, 'chainwork':x(r['chainwork'])} else: return CBlockHeader.deserialize(unhexlify(r))
Example #11
Source File: rpc.py From replace-by-fee-tools with GNU General Public License v3.0 | 5 votes |
def getblockhash(self, height): """Return hash of block in best-block-chain at height. Raises IndexError if height is not valid. """ try: return lx(self._call('getblockhash', height)) except InvalidParameterError as ex: raise IndexError('%s.getblockhash(): %s (%d)' % (self.__class__.__name__, ex.error['message'], ex.error['code']))
Example #12
Source File: rpc.py From replace-by-fee-tools with GNU General Public License v3.0 | 5 votes |
def getrawmempool(self, verbose=False): """Return the mempool""" if verbose: return self._call('getrawmempool', verbose) else: r = self._call('getrawmempool') r = [lx(txid) for txid in r] return r
Example #13
Source File: rpc.py From replace-by-fee-tools with GNU General Public License v3.0 | 5 votes |
def sendrawtransaction(self, tx, allowhighfees=False): """Submit transaction to local node and network. allowhighfees - Allow even if fees are unreasonably high. """ hextx = hexlify(tx.serialize()) r = None if allowhighfees: r = self._call('sendrawtransaction', hextx, True) else: r = self._call('sendrawtransaction', hextx) return lx(r)
Example #14
Source File: rpc.py From replace-by-fee-tools with GNU General Public License v3.0 | 5 votes |
def sendmany(self, fromaccount, payments, minconf=1, comment='', subtractfeefromamount=[]): """Send amount to given addresses. payments - dict with {address: amount} """ json_payments = {str(addr):float(amount)/COIN for addr, amount in payments.items()} r = self._call('sendmany', fromaccount, json_payments, minconf, comment, subtractfeefromamount) return lx(r)
Example #15
Source File: rpc.py From replace-by-fee-tools with GNU General Public License v3.0 | 5 votes |
def sendtoaddress(self, addr, amount, comment='', commentto='', subtractfeefromamount=False): """Send amount to a given address""" addr = str(addr) amount = float(amount)/COIN r = self._call('sendtoaddress', addr, amount, comment, commentto, subtractfeefromamount) return lx(r)
Example #16
Source File: rpc.py From replace-by-fee-tools with GNU General Public License v3.0 | 5 votes |
def getbestblockhash(self): """Return hash of best (tip) block in longest block chain.""" return lx(self._call('getbestblockhash'))
Example #17
Source File: rpc.py From replace-by-fee-tools with GNU General Public License v3.0 | 5 votes |
def getblockheader(self, block_hash, verbose=False): """Get block header <block_hash> verbose - If true a dict is returned with the values returned by getblockheader that are not in the block header itself (height, nextblockhash, etc.) Raises IndexError if block_hash is not valid. """ try: block_hash = b2lx(block_hash) except TypeError: raise TypeError('%s.getblockheader(): block_hash must be bytes; got %r instance' % (self.__class__.__name__, block_hash.__class__)) try: r = self._call('getblockheader', block_hash, verbose) except InvalidAddressOrKeyError as ex: raise IndexError('%s.getblockheader(): %s (%d)' % (self.__class__.__name__, ex.error['message'], ex.error['code'])) if verbose: nextblockhash = None if 'nextblockhash' in r: nextblockhash = lx(r['nextblockhash']) return {'confirmations':r['confirmations'], 'height':r['height'], 'mediantime':r['mediantime'], 'nextblockhash':nextblockhash, 'chainwork':x(r['chainwork'])} else: return CBlockHeader.deserialize(unhexlify(r))
Example #18
Source File: rpc.py From replace-by-fee-tools with GNU General Public License v3.0 | 5 votes |
def getblockhash(self, height): """Return hash of block in best-block-chain at height. Raises IndexError if height is not valid. """ try: return lx(self._call('getblockhash', height)) except InvalidParameterError as ex: raise IndexError('%s.getblockhash(): %s (%d)' % (self.__class__.__name__, ex.error['message'], ex.error['code']))
Example #19
Source File: rpc.py From replace-by-fee-tools with GNU General Public License v3.0 | 5 votes |
def getrawmempool(self, verbose=False): """Return the mempool""" if verbose: return self._call('getrawmempool', verbose) else: r = self._call('getrawmempool') r = [lx(txid) for txid in r] return r
Example #20
Source File: rpc.py From replace-by-fee-tools with GNU General Public License v3.0 | 5 votes |
def getrawtransaction(self, txid, verbose=False): """Return transaction with hash txid Raises IndexError if transaction not found. verbose - If true a dict is returned instead with additional information on the transaction. Note that if all txouts are spent and the transaction index is not enabled the transaction may not be available. """ try: r = self._call('getrawtransaction', b2lx(txid), 1 if verbose else 0) except InvalidAddressOrKeyError as ex: raise IndexError('%s.getrawtransaction(): %s (%d)' % (self.__class__.__name__, ex.error['message'], ex.error['code'])) if verbose: r['tx'] = CTransaction.deserialize(unhexlify(r['hex'])) del r['hex'] del r['txid'] del r['version'] del r['locktime'] del r['vin'] del r['vout'] r['blockhash'] = lx(r['blockhash']) if 'blockhash' in r else None else: r = CTransaction.deserialize(unhexlify(r)) return r
Example #21
Source File: rpc.py From replace-by-fee-tools with GNU General Public License v3.0 | 5 votes |
def sendrawtransaction(self, tx, allowhighfees=False): """Submit transaction to local node and network. allowhighfees - Allow even if fees are unreasonably high. """ hextx = hexlify(tx.serialize()) r = None if allowhighfees: r = self._call('sendrawtransaction', hextx, True) else: r = self._call('sendrawtransaction', hextx) return lx(r)
Example #22
Source File: rpc.py From replace-by-fee-tools with GNU General Public License v3.0 | 5 votes |
def sendmany(self, fromaccount, payments, minconf=1, comment='', subtractfeefromamount=[]): """Send amount to given addresses. payments - dict with {address: amount} """ json_payments = {str(addr):float(amount)/COIN for addr, amount in payments.items()} r = self._call('sendmany', fromaccount, json_payments, minconf, comment, subtractfeefromamount) return lx(r)
Example #23
Source File: rpc.py From replace-by-fee-tools with GNU General Public License v3.0 | 5 votes |
def sendtoaddress(self, addr, amount, comment='', commentto='', subtractfeefromamount=False): """Send amount to a given address""" addr = str(addr) amount = float(amount)/COIN r = self._call('sendtoaddress', addr, amount, comment, commentto, subtractfeefromamount) return lx(r)
Example #24
Source File: rpc.py From checklocktimeverify-demos with GNU General Public License v3.0 | 5 votes |
def sendrawtransaction(self, tx, allowhighfees=False): """Submit transaction to local node and network. allowhighfees - Allow even if fees are unreasonably high. """ hextx = hexlify(tx.serialize()) r = None if allowhighfees: r = self._call('sendrawtransaction', hextx, True) else: r = self._call('sendrawtransaction', hextx) return lx(r)
Example #25
Source File: rpc.py From checklocktimeverify-demos with GNU General Public License v3.0 | 5 votes |
def getblockhash(self, height): """Return hash of block in best-block-chain at height. Raises IndexError if height is not valid. """ try: return lx(self._call('getblockhash', height)) except JSONRPCError as ex: raise IndexError('%s.getblockhash(): %s (%d)' % (self.__class__.__name__, ex.error['message'], ex.error['code']))
Example #26
Source File: rpc.py From checklocktimeverify-demos with GNU General Public License v3.0 | 5 votes |
def getrawmempool(self, verbose=False): """Return the mempool""" if verbose: return self._call('getrawmempool', verbose) else: r = self._call('getrawmempool') r = [lx(txid) for txid in r] return r
Example #27
Source File: rpc.py From checklocktimeverify-demos with GNU General Public License v3.0 | 5 votes |
def getrawtransaction(self, txid, verbose=False): """Return transaction with hash txid Raises IndexError if transaction not found. verbose - If true a dict is returned instead with additional information on the transaction. Note that if all txouts are spent and the transaction index is not enabled the transaction may not be available. """ try: r = self._call('getrawtransaction', b2lx(txid), 1 if verbose else 0) except JSONRPCError as ex: raise IndexError('%s.getrawtransaction(): %s (%d)' % (self.__class__.__name__, ex.error['message'], ex.error['code'])) if verbose: r['tx'] = CTransaction.deserialize(unhexlify(r['hex'])) del r['hex'] del r['txid'] del r['version'] del r['locktime'] del r['vin'] del r['vout'] r['blockhash'] = lx(r['blockhash']) if 'blockhash' in r else None else: r = CTransaction.deserialize(unhexlify(r)) return r
Example #28
Source File: rpc.py From checklocktimeverify-demos with GNU General Public License v3.0 | 5 votes |
def sendrawtransaction(self, tx, allowhighfees=False): """Submit transaction to local node and network. allowhighfees - Allow even if fees are unreasonably high. """ hextx = hexlify(tx.serialize()) r = None if allowhighfees: r = self._call('sendrawtransaction', hextx, True) else: r = self._call('sendrawtransaction', hextx) return lx(r)
Example #29
Source File: rpc.py From checklocktimeverify-demos with GNU General Public License v3.0 | 5 votes |
def sendmany(self, fromaccount, payments, minconf=1, comment=''): """Sent amount to a given address""" json_payments = {str(addr):float(amount)/COIN for addr, amount in payments.items()} r = self._call('sendmany', fromaccount, json_payments, minconf, comment) return lx(r)
Example #30
Source File: rpc.py From checklocktimeverify-demos with GNU General Public License v3.0 | 5 votes |
def sendtoaddress(self, addr, amount): """Sent amount to a given address""" addr = str(addr) amount = float(amount)/COIN r = self._call('sendtoaddress', addr, amount) return lx(r)