本文整理汇总了Python中bitcoin.core.lx方法的典型用法代码示例。如果您正苦于以下问题:Python core.lx方法的具体用法?Python core.lx怎么用?Python core.lx使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bitcoin.core
的用法示例。
在下文中一共展示了core.lx方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: gettxout
# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import lx [as 别名]
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
示例2: listunspent
# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import lx [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
示例3: mock_listunspent
# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import lx [as 别名]
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
示例4: getbestblockhash
# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import lx [as 别名]
def getbestblockhash(self):
"""Return hash of best (tip) block in longest block chain."""
return lx(self._call('getbestblockhash'))
示例5: getblockhash
# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import lx [as 别名]
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']))
示例6: getrawmempool
# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import lx [as 别名]
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
示例7: getrawtransaction
# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import lx [as 别名]
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
示例8: sendrawtransaction
# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import lx [as 别名]
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)
示例9: sendmany
# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import lx [as 别名]
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)
示例10: sendtoaddress
# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import lx [as 别名]
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)
示例11: outpoint
# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import lx [as 别名]
def outpoint(self):
return COutPoint(lx(self.tx_id), self.vout)
示例12: make_unsigned
# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import lx [as 别名]
def make_unsigned(cls, outpoints, outputs, tx_fee=TRANSACTION_FEE, testnet=False, out_value=None):
"""
Build an unsigned transaction.
Args:
outpoints: A `list` of `dict` objects which contain a txid, vout, value, and scriptPubkey.
outputs: If a single address the full value of the inputs (minus the tx fee) will be sent there.
Otherwise it should be a `list` of `dict` objects containing address and value.
tx_fee: The Bitcoin network fee to be paid on this transaction.
testnet: Should this transaction be built for testnet?
out_value: used if you want to specify a specific output value otherwise the full value
of the inputs (minus the tx fee) will be used.
"""
# build the inputs from the outpoints object
SelectParams("testnet" if testnet else "mainnet")
txins = []
in_value = 0
for outpoint in outpoints:
in_value += outpoint["value"]
txin = CMutableTxIn(COutPoint(lx(outpoint["txid"]), outpoint["vout"]))
txin.scriptSig = CScript(x(outpoint["scriptPubKey"]))
txins.append(txin)
# build the outputs
txouts = []
if isinstance(outputs, list):
for output in outputs:
value = output["value"]
address = output["address"]
txouts.append(CMutableTxOut(value, CBitcoinAddress(address).to_scriptPubKey()))
else:
value = out_value if out_value is not None else (in_value - tx_fee)
txouts.append(CMutableTxOut(value, CBitcoinAddress(outputs).to_scriptPubKey()))
# make the transaction
tx = CMutableTransaction(txins, txouts)
return BitcoinTransaction(tx)
示例13: mock_broadcast
# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import lx [as 别名]
def mock_broadcast(self, transaction):
return lx('b59bef6934d043ec2b6c3be7e853b3492e9f493b3559b3bd69864283c122b257')
示例14: do_rpc_getrawtransaction
# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import lx [as 别名]
def do_rpc_getrawtransaction(self, tx_id) :
"""
Call local Bitcoin RPC method 'getrawtransaction'
Usage: rpc_sendtoaddress TX_ID
"""
try :
proxy = bitcoin.rpc.Proxy()
r = proxy.getrawtransaction(lx(tx_id), True)
print(str(r))
except:
traceback.print_exc()
示例15: setData
# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import lx [as 别名]
def setData(self, index, value, role = Qt.EditRole):
if not index.isValid() or not self.vin: return False
tx_input = self.vin[index.row()]
col = index.column()
if col == 0:
tx_input.prevout.hash = lx(str(value.toString()))
elif col == 1:
tx_input.prevout.n, _ = value.toUInt()
elif col == 2:
tx_input.scriptSig = x(Script.from_human(str(value.toString())).get_hex())
elif col == 3:
tx_input.nSequence, _ = value.toUInt()
self.dataChanged.emit(self.index(index.row(), col), self.index(index.row(), col))
return True