def electrum_sig_hash(message): """ Based on project: https://github.com/chaeplin/dashmnb. """ padded = b"\x19DarkCoin Signed Message:\n" + \ num_to_varint(len(message)) + from_string_to_bytes(message) return bitcoin.dbl_sha256(padded)
def electrum_sig_hash(message): """ Based on project: https://github.com/chaeplin/dashmnb. """ padded = b'\x18DarkNet Signed Message:\n' + num_to_varint( len(message)) + from_string_to_bytes(message) return dbl_sha256(padded)
def wif_to_privkey(wif_key: str, dash_network: str): """ Based on project: https://github.com/chaeplin/dashmnb with some changes related to usage of bitcoin library. """ privkey_encoded = base58.b58decode(wif_key).hex() wif_prefix_cur = privkey_encoded[:2] wif_prefix_network = get_chain_params(dash_network).PREFIX_SECRET_KEY wif_prefix_network_str = wif_prefix_network.to_bytes( 1, byteorder='big').hex() checksum_stored = privkey_encoded[-8:] vs = bytes.fromhex(privkey_encoded[:-8]) checksum_actual = binascii.unhexlify(bitcoin.dbl_sha256(vs))[0:4] checksum_actual_str = checksum_actual.hex() if wif_prefix_cur == wif_prefix_network_str and checksum_stored == checksum_actual_str: privkey = privkey_encoded[2:-8] return privkey else: if wif_prefix_cur != wif_prefix_network_str: logging.warning( 'Private key and network prefixes differ. PK prefix: %s, network prefix: %s', wif_prefix_cur, wif_prefix_network_str) if checksum_stored != checksum_actual_str: logging.warning( 'Invalid private key checksum. PK checksum: %s, required: %s', checksum_stored, checksum_actual_str) return None
def electrum_sig_hash(message): """ Based on project: https://github.com/chaeplin/gewelmnb. First byte refers to magic string length (in hex). Refer to https://bitcointalk.org/index.php?topic=995339.0 """ padded = b"\x16Gewel Signed Message:\n" + \ num_to_varint(len(message)) + from_string_to_bytes(message) return bitcoin.dbl_sha256(padded)
def wif_to_privkey(wif_key: str, dash_network: str): """ Based on project: https://github.com/chaeplin/dashmnb with some changes related to usage of bitcoin library. """ privkey_encoded = base58.b58decode(wif_key).hex() wif_version = privkey_encoded[:2] wif_prefix = get_chain_params(dash_network).PREFIX_SECRET_KEY checksum = privkey_encoded[-8:] vs = bytes.fromhex(privkey_encoded[:-8]) check = binascii.unhexlify(bitcoin.dbl_sha256(vs))[0:4] if wif_version == wif_prefix.to_bytes(1, byteorder='big').hex() and checksum == check.hex(): privkey = privkey_encoded[2:-8] return privkey else: return None
def wif_to_privkey(string): """ Based on project: https://github.com/chaeplin/dashmnb with some changes related to usage of bitcoin library. """ wif_compressed = 52 == len(string) pvkeyencoded = base58.b58decode(string).hex() wifversion = pvkeyencoded[:2] wif_prefix = 204 checksum = pvkeyencoded[-8:] vs = bytes.fromhex(pvkeyencoded[:-8]) check = binascii.unhexlify(bitcoin.dbl_sha256(vs))[0:4] if wifversion == wif_prefix.to_bytes( 1, byteorder='big').hex() and checksum == check.hex(): if wif_compressed: privkey = pvkeyencoded[2:-10] else: privkey = pvkeyencoded[2:-8] return privkey else: return None
def get_wallet_name(self, wallet): return 'joinmarket-wallet-' + btc.dbl_sha256(wallet.keys[0][0])[:6]
def get_wallet_name(wallet): return 'joinmarket-wallet-' + btc.dbl_sha256(wallet.keys[0][0])[:6]