Created
July 18, 2020 05:02
-
-
Save buzzkillb/31ead386998f7b86bfa9b23e3bd44068 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import ecdsa | |
| import hashlib | |
| import base58 | |
| import binascii | |
| import codecs | |
| import struct | |
| #Use Python3 | |
| #Crude Denarius address to scripthash converter for electrumx talking | |
| denariusAddress= "DDD6SzCwXSEcTPHmNwEQX6xbUs2Rf3svNX" | |
| print("D Addy:" + denariusAddress) | |
| #base58decode denarius address | |
| addrToBytes = base58.b58decode(denariusAddress) | |
| print(addrToBytes) | |
| decodedToHex = addrToBytes.hex() | |
| print(decodedToHex) | |
| #remove prefix | |
| removeZeroBytes = 2 | |
| decodedToHexnoPrefix = decodedToHex[removeZeroBytes:] | |
| print(decodedToHexnoPrefix) | |
| #remove checksum | |
| removeChecksum = 40 | |
| decodedNoPrefixnoChecksum = decodedToHexnoPrefix[:removeChecksum] | |
| print(decodedNoPrefixnoChecksum) | |
| #Add OP_DUP OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG | |
| opDup = "76" | |
| opHash160 = "A9" | |
| opsBuffer = "14" | |
| opEqualVerify = "88" | |
| opChecksig = "AC" | |
| preparedtoHash = opDup + opHash160 + opsBuffer + decodedNoPrefixnoChecksum + opEqualVerify + opChecksig | |
| print(preparedtoHash.upper()) | |
| hashedKey = codecs.decode(preparedtoHash.upper(), 'hex') | |
| s = hashlib.new('sha256', hashedKey).digest() | |
| r = hashlib.new('ripemd160', s).digest() | |
| convertBigEndian = (codecs.encode(s, 'hex').decode("utf-8")) | |
| print(convertBigEndian) | |
| scriptHash = codecs.encode(codecs.decode(convertBigEndian, 'hex')[::-1], 'hex').decode() | |
| print("----Scripthash Below----") | |
| print(scriptHash) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment