本文整理汇总了Python中bitcoin.core.b2lx方法的典型用法代码示例。如果您正苦于以下问题:Python core.b2lx方法的具体用法?Python core.b2lx怎么用?Python core.b2lx使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bitcoin.core
的用法示例。
在下文中一共展示了core.b2lx方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getblock
# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import b2lx [as 别名]
def getblock(self, block_hash):
"""Get block <block_hash>
Raises IndexError if block_hash is not valid.
"""
try:
block_hash = b2lx(block_hash)
except TypeError:
raise TypeError('%s.getblock(): block_hash must be bytes; got %r instance' %
(self.__class__.__name__, block_hash.__class__))
try:
r = self._call('getblock', block_hash, False)
except JSONRPCError as ex:
raise IndexError('%s.getblock(): %s (%d)' %
(self.__class__.__name__, ex.error['message'], ex.error['code']))
return CBlock.deserialize(unhexlify(r))
示例2: gettxout
# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import b2lx [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
示例3: check_for_funding
# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import b2lx [as 别名]
def check_for_funding(self, address):
"""
Check to see if any of the outputs pay the given address
Args:
address: base58check encoded bitcoin address
Returns: a `list` of `dict` outpoints if any of the outputs match
the address else None.
"""
outpoints = []
for i in range(len(self.tx.vout)):
addr = CBitcoinAddress.from_scriptPubKey(self.tx.vout[i].scriptPubKey)
if str(addr) == address:
o = {
"txid": b2lx(self.tx.GetHash()),
"vout": i,
"value": self.tx.vout[i].nValue,
"scriptPubKey": self.tx.vout[i].scriptPubKey.encode("hex")
}
outpoints.append(o)
return outpoints if len(outpoints) > 0 else None
示例4: recv_votes
# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import b2lx [as 别名]
def recv_votes(self, msg):
""" vote (transaction lock) collation """
txid = b2lx(msg.txlvote.hash)
vin = (b2lx(msg.txlvote.vin.prevout.hash) + "-" +
str(msg.txlvote.vin.prevout.n))
if txid not in self.mempool:
self.mempool[txid] = {}
if 'recv_time' not in self.mempool[txid]:
self.mempool[txid]['recv_time'] = int(time.time())
if 'locks' not in self.mempool[txid]:
self.mempool[txid]['locks'] = set()
self.mempool[txid]['locks'].add(vin)
# only print locks for target addresses
if 'processed' in self.mempool[txid]:
info(" LOCK: %s from %s" % (txid, vin))
self._check_ix_threshold(txid)
示例5: data
# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import b2lx [as 别名]
def data(self, index, role = Qt.DisplayRole):
if not index.isValid() or not self.vin: return QVariant(None)
if role not in [Qt.DisplayRole, Qt.ToolTipRole, Qt.EditRole, RawRole]:
return None
tx_input = self.vin[index.row()]
col = index.column()
data = None
if col == 0:
data = b2lx(tx_input.prevout.hash)
elif col == 1:
data = tx_input.prevout.n
if role == Qt.DisplayRole:
data = str(data)
elif col == 2:
if role == RawRole:
data = Script(tx_input.scriptSig).get_hex()
else:
data = Script(tx_input.scriptSig).get_human()
elif col == 3:
data = tx_input.nSequence
if role == Qt.DisplayRole:
data = str(data)
return QVariant(data)
示例6: set_tx
# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import b2lx [as 别名]
def set_tx(self, tx):
self.version_edit.setText(str(tx.nVersion))
self.inputs_tree.model.set_tx(tx)
self.outputs_tree.model.set_tx(tx)
self.locktime_edit.set_locktime(tx.nLockTime)
for name, w in self.field_widgets.items():
# We already handle these four.
if name in ['nVersion', 'vin', 'vout', 'nLockTime']:
continue
if not name in [field[0] for field in tx.fields]:
continue
value = getattr(tx, name)
w.setText(str(value))
self.tx_properties.set_tx(tx)
self.tx_id.setText(bitcoin.core.b2lx(tx.GetHash()))
示例7: getblock
# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import b2lx [as 别名]
def getblock(self, block_hash):
"""Get block <block_hash>
Raises IndexError if block_hash is not valid.
"""
try:
block_hash = b2lx(block_hash)
except TypeError:
raise TypeError('%s.getblock(): block_hash must be bytes; got %r instance' %
(self.__class__.__name__, block_hash.__class__))
try:
r = self._call('getblock', block_hash, False)
except InvalidAddressOrKeyError as ex:
raise IndexError('%s.getblock(): %s (%d)' %
(self.__class__.__name__, ex.error['message'], ex.error['code']))
return CBlock.deserialize(unhexlify(r))
示例8: __repr__
# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import b2lx [as 别名]
def __repr__(self):
return "CInv(type=%s hash=%s)" % (self.typemap[self.type], b2lx(self.hash))
示例9: getrawtransaction
# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import b2lx [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
示例10: gettransaction
# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import b2lx [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
示例11: address
# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import b2lx [as 别名]
def address(self):
return b2lx(self.tx.GetHash())
示例12: transaction_address
# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import b2lx [as 别名]
def transaction_address(self) -> str:
'''Returns transaction address.'''
return self.tx_address or b2lx(self.tx.GetHash())
示例13: create_signature
# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import b2lx [as 别名]
def create_signature(self, privkey, reedem_script):
"""
Exports a raw signature suitable for use in a multisig transaction
"""
seckey = CBitcoinSecret.from_secret_bytes(x(bitcointools.encode_privkey(privkey, "hex")))
signatures = []
for i in range(len(self.tx.vin)):
sighash = SignatureHash(CScript(x(reedem_script)), self.tx, i, SIGHASH_ALL)
signatures.append({
"index": i,
"signature": (seckey.sign(sighash) + struct.pack('<B', SIGHASH_ALL)).encode("hex"),
"outpoint": b2lx(self.tx.vin[i].prevout.hash) + b2lx(struct.pack(b"<I", self.tx.vin[i].prevout.n))
})
return signatures
示例14: get_hash
# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import b2lx [as 别名]
def get_hash(self):
return b2lx(self.tx.GetHash())
示例15: __repr__
# 需要导入模块: from bitcoin import core [as 别名]
# 或者: from bitcoin.core import b2lx [as 别名]
def __repr__(self):
return 'CTransactionLock(lx(%r), %r, lx(%r), %i)' % (
b2lx(self.hash), self.vin, b2lx(self.sig), self.height)