本文整理匯總了Python中base58.b58encode_check方法的典型用法代碼示例。如果您正苦於以下問題:Python base58.b58encode_check方法的具體用法?Python base58.b58encode_check怎麽用?Python base58.b58encode_check使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類base58
的用法示例。
在下文中一共展示了base58.b58encode_check方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: export_to_wif
# 需要導入模塊: import base58 [as 別名]
# 或者: from base58 import b58encode_check [as 別名]
def export_to_wif(self, compressed=None):
"""Export a key to WIF.
:param compressed: False if you want a standard WIF export (the most
standard option). True if you want the compressed form (Note that
not all clients will accept this form). Defaults to None, which
in turn uses the self.compressed attribute.
:type compressed: bool
See https://en.bitcoin.it/wiki/Wallet_import_format for a full
description.
"""
# Add the network byte, creating the "extended key"
extended_key_hex = self.get_extended_key()
extended_key_bytes = unhexlify(extended_key_hex)
if compressed is None:
compressed = self.compressed
if compressed:
extended_key_bytes += '\01'
# And return the base58-encoded result with a checksum
return ensure_str(base58.b58encode_check(extended_key_bytes))
示例2: to_address
# 需要導入模塊: import base58 [as 別名]
# 或者: from base58 import b58encode_check [as 別名]
def to_address(self, compressed=None):
"""Create a public address from this key.
:param compressed: False if you want a normal uncompressed address
(the most standard option). True if you want the compressed form.
Note that most clients will not accept compressed addresses.
Defaults to None, which in turn uses the self.compressed attribute.
:type compressed: bool
https://en.bitcoin.it/wiki/Technical_background_of_Bitcoin_addresses
"""
key = unhexlify(self.get_key(compressed))
# First get the hash160 of the key
hash160_bytes = hash160(key)
# Prepend the network address byte
network_hash160_bytes = \
chr_py2(self.network.PUBKEY_ADDRESS) + hash160_bytes
# Return a base58 encoded address with a checksum
return ensure_str(base58.b58encode_check(network_hash160_bytes))
示例3: export_to_wif
# 需要導入模塊: import base58 [as 別名]
# 或者: from base58 import b58encode_check [as 別名]
def export_to_wif(self, compressed=None):
"""Export a key to WIF.
:param compressed: False if you want a standard WIF export (the most
standard option). True if you want the compressed form (Note that
not all clients will accept this form). Defaults to None, which
in turn uses the self.compressed attribute.
:type compressed: bool
See https://en.bitcoin.it/wiki/Wallet_import_format for a full
description.
"""
# Add the network byte, creating the "extended key"
extended_key_hex = self.get_extended_key()
extended_key_bytes = unhexlify(ensure_bytes(extended_key_hex))
if compressed is None:
compressed = self.compressed
if compressed:
extended_key_bytes += b'\01'
# And return the base58-encoded result with a checksum
return ensure_str(base58.b58encode_check(extended_key_bytes))
示例4: to_address
# 需要導入模塊: import base58 [as 別名]
# 或者: from base58 import b58encode_check [as 別名]
def to_address(self, compressed=None):
"""Create a public address from this key.
:param compressed: False if you want a normal uncompressed address
(the most standard option). True if you want the compressed form.
Note that most clients will not accept compressed addresses.
Defaults to None, which in turn uses the self.compressed attribute.
:type compressed: bool
https://en.bitcoin.it/wiki/Technical_background_of_Bitcoin_addresses
"""
key = unhexlify(ensure_bytes(self.get_key(compressed)))
# First get the hash160 of the key
hash160_bytes = hash160(key)
# Prepend the network address byte
network_hash160_bytes = \
chr_py2(self.network.PUBKEY_ADDRESS) + hash160_bytes
# Return a base58 encoded address with a checksum
return ensure_str(base58.b58encode_check(network_hash160_bytes))
示例5: address
# 需要導入模塊: import base58 [as 別名]
# 或者: from base58 import b58encode_check [as 別名]
def address(self, compressed=True, testnet=False):
""" Address property that returns the Base58Check
encoded version of the HASH160.
Args:
compressed (bool): Whether or not the compressed key should
be used.
testnet (bool): Whether or not the key is intended for testnet
usage. False indicates mainnet usage.
Returns:
bytes: Base58Check encoded string
"""
version = '0x'
return version + binascii.hexlify(self.keccak[12:]).decode('ascii')
# Put the version byte in front, 0x00 for Mainnet, 0x6F for testnet
# version = bytes([self.TESTNET_VERSION]) if testnet else bytes([self.MAINNET_VERSION])
# return base58.b58encode_check(version + self.hash160(compressed))
示例6: change_version_byte
# 需要導入模塊: import base58 [as 別名]
# 或者: from base58 import b58encode_check [as 別名]
def change_version_byte(address, new_version=None, new_crypto=None):
"""
Convert the passed in address (or any base58 encoded string), and change the
version byte to `new_version`.
"""
if not new_version and new_crypto:
try:
new_version = crypto_data[new_crypto]['address_version_byte']
except KeyError:
raise CurrencyNotSupported("Unknown currency symbol: " + new_crypto)
if not new_version:
raise CurrencyNotSupported("Can't yet make %s addresses." % new_crypto)
payload = b58decode_check(address)[1:]
if is_py2:
byte = chr(new_version)
else:
byte = bytes(chr(new_version), 'ascii')
return b58encode_check(byte + payload)
示例7: create
# 需要導入模塊: import base58 [as 別名]
# 或者: from base58 import b58encode_check [as 別名]
def create(cls, flagbyte, ownerentropy, factorb, derivedhalf1, derivedhalf2, addresshash):
pointb = compress(*fast_multiply(G, factorb))
pointbprefix = bytearray([ord(pointb[:1]) ^ (ord(derivedhalf2[-1:]) & 1)])
aes = AES.new(derivedhalf2)
block1 = long(hexlify(pointb[1:17]), 16) ^ long(hexlify(derivedhalf1[:16]), 16)
pointbx1 = aes.encrypt(unhexlify("%0.32x" % block1))
block2 = long(hexlify(pointb[17:]), 16) ^ long(hexlify(derivedhalf1[16:]), 16)
pointbx2 = aes.encrypt(unhexlify("%0.32x" % block2))
# 33 bytes 1 16 16
encryptedpointb = pointbprefix + pointbx1 + pointbx2
# 5 (cfrm38 prefix) 1 4 8 33
payload = b'\x64\x3B\xF6\xA8\x9A' + flagbyte + addresshash + ownerentropy + encryptedpointb
return cls(b58encode_check(payload))
示例8: b58encode
# 需要導入模塊: import base58 [as 別名]
# 或者: from base58 import b58encode_check [as 別名]
def b58encode(self) -> str:
""" Generates a Base58Check encoding of this key.
"""
return base58.b58encode_check(bytes(self)).decode('ascii')
示例9: b58encode
# 需要導入模塊: import base58 [as 別名]
# 或者: from base58 import b58encode_check [as 別名]
def b58encode(self) -> str:
"""
Generates a Base58Check encoding of this private key.
"""
return base58.b58encode_check(bytes(self)).decode('ascii')
示例10: b58xprv
# 需要導入模塊: import base58 [as 別名]
# 或者: from base58 import b58encode_check [as 別名]
def b58xprv(parent_fingerprint, private_key, chain, depth, childnr):
""" Private key b58 serialization format. """
raw = (
b'\x04\x88\xad\xe4' +
bytes(chr(depth), 'utf-8') +
parent_fingerprint +
childnr.to_bytes(4, byteorder='big') +
chain +
b'\x00' +
private_key)
return b58encode_check(raw)
示例11: b58xpub
# 需要導入模塊: import base58 [as 別名]
# 或者: from base58 import b58encode_check [as 別名]
def b58xpub(parent_fingerprint, public_key, chain, depth, childnr):
""" Public key b58 serialization format. """
raw = (
b'\x04\x88\xb2\x1e' +
bytes(chr(depth), 'utf-8') +
parent_fingerprint +
childnr.to_bytes(4, byteorder='big') +
chain +
public_key)
return b58encode_check(raw)
示例12: export_to_wif
# 需要導入模塊: import base58 [as 別名]
# 或者: from base58 import b58encode_check [as 別名]
def export_to_wif(self):
"""Export a key to WIF.
See https://en.bitcoin.it/wiki/Wallet_import_format for a full
description.
"""
# Add the network byte, creating the "extended key"
extended_key_hex = self.private_key.get_extended_key()
# BIP32 wallets have a trailing \01 byte
extended_key_bytes = unhexlify(extended_key_hex) + b'\01'
# And return the base58-encoded result with a checksum
return base58.b58encode_check(extended_key_bytes)
示例13: serialize_b58
# 需要導入模塊: import base58 [as 別名]
# 或者: from base58 import b58encode_check [as 別名]
def serialize_b58(self, private=True):
"""Encode the serialized node in base58."""
return ensure_str(
base58.b58encode_check(unhexlify(self.serialize(private))))
示例14: to_address
# 需要導入模塊: import base58 [as 別名]
# 或者: from base58 import b58encode_check [as 別名]
def to_address(self):
"""Create a public address from this Wallet.
Public addresses can accept payments.
https://en.bitcoin.it/wiki/Technical_background_of_Bitcoin_addresses
"""
key = unhexlify(self.get_public_key_hex())
# First get the hash160 of the key
hash160_bytes = hash160(key)
# Prepend the network address byte
network_hash160_bytes = \
chr_py2(self.network.PUBKEY_ADDRESS) + hash160_bytes
# Return a base58 encoded address with a checksum
return ensure_str(base58.b58encode_check(network_hash160_bytes))
示例15: export_to_wif
# 需要導入模塊: import base58 [as 別名]
# 或者: from base58 import b58encode_check [as 別名]
def export_to_wif(self):
"""Export a key to WIF.
See https://en.bitcoin.it/wiki/Wallet_import_format for a full
description.
"""
# Add the network byte, creating the "extended key"
extended_key_hex = self.private_key.get_extended_key()
# BIP32 wallets have a trailing \01 byte
extended_key_bytes = unhexlify(ensure_bytes(extended_key_hex)) + b'\01'
# And return the base58-encoded result with a checksum
return base58.b58encode_check(extended_key_bytes)