def _send_op_return_txt(self, cmd): tx = make_op_return_tx(cmd, self.private_key, self.bitcoind_client, fee=self.fee, format='bin') broadcast_transaction(tx, self.bitcoind_client)
def make_transaction(name, payment_privkey_info, zonefilemanage_client): data = build(name) tx = make_op_return_tx( data, virtualchain.BitcoinPrivateKey(payment_privkey_info), zonefilemanage_client, fee=100000, format='bin') return tx
def sendCertificate(i): if i == 1: ans = raw_input( "Do you want to Create or Update your certificate? [C]reate [U]pdate, default: [C]" ) if ans == "C" or ans == "c" or ans == "" or ans == " ": mode = "CC: " else: mode = "UC: " elif i == 2: mode = "UC: " #Hashing of the certificate f = open("certificate.crt", "rb") #read file in binary mode fr = f.read() cert_hash = hashlib.sha256() #use the SHA256 hashing algorithm cert_hash.update(fr) data = cert_hash.hexdigest() print "\nYour Certificate hash is: ", data data = mode + data print "\nAdding to OP_RETURN..." #Opening Generation private key from pem file if os.path.isfile('./Certificate_Private.pem'): print "\nCertificate Private Key file exists." sk = SigningKey.from_pem(open("Certificate_Private.pem").read()) sk_string = sk.to_string() sk = str(sk_string) sk = sk.encode("hex") elif os.path.isfile('./Certificate_Private.pem.enc'): print "\nCertificate Private Key encoded file exists." decrypt_file(key, "Certificate_Private.pem.enc") print "\nDecrypting Certificate Private Key..." print "Saving to Certificate_Private.pem..." sk = SigningKey.from_pem(open("Certificate_Private.pem").read()) sk_string = sk.to_string() sk = str(sk_string) sk = sk.encode("hex") else: print "\nCertificate Private Key does not exist." print "\nPlease place the file in the script directory or run -i option for a new key pair.\n" sys.exit() try: blockchain_client = BlockchainInfoClient( "dacc6a40-1b8f-4dbb-afc7-bc9657603e83") tx = make_op_return_tx(data, sk, blockchain_client, fee=10000, format='bin') broadcast_transaction(tx, blockchain_client) except Exception: print "\nNo balance in your Certificate address.\n" print "Please first run the -cc or the -u script.\n"
from pybitcoin import BitcoinPrivateKey, BitcoindClient, broadcast_transaction from pybitcoin import make_op_return_tx version_byte_private = 111 """ Test Network requires a diffrent version byte!!!!!!!! """ class BitcoinTestnetPrivateKey(BitcoinPrivateKey): _pubkeyhash_version_byte = version_byte_private private_key_hex = 'cSi82vbDR5NQUJ2eB55C4oz1LxEsA6NePmXM7zNGNSXYbSt6Aop1' msg = "Lubu is great2" private_key = BitcoinTestnetPrivateKey(private_key_hex) print private_key.to_wif() print private_key.to_hex() print private_key.public_key().address() client = BitcoindClient("talos", "talos", port=18332, version_byte=111) tx = make_op_return_tx(msg, private_key, client, fee=10000, format='bin') broadcast_transaction(tx, client)
def certificateRevocation(): print art print "\nCertificate Revocation Script - Block SSL\n" print "In which of your addresses do you still have access? default: [1]\n" print "\t1. All of the addresses. (Generation, Certificate, Revocation)" print "\t2. Only Certificate address.\n" print "\t3. Only Revocation address.\n" print "\t4. Revocation and Generation addresses.\n" ans = raw_input() blockchain_client = BlockchainInfoClient( "dacc6a40-1b8f-4dbb-afc7-bc9657603e83") if ans == "1" or ans == "" or ans == " " or ans == "2": address = open("Cert_Address.txt", "r").read() address = address.strip() url = "https://blockchain.info/balance?format=json&active=" + address r = requests.get(url) try: balance = r.json()[address] balance = str(balance) x = 1 i = 19 final_balance = "" while x == 1: if balance[i] == ",": x += 1 else: final_balance = final_balance + balance[i] i += 1 print " Your Certificate address balance is: " + final_balance #Opening Generation private key from pem file if os.path.isfile('./Certificate_Private.pem'): print "\nCertificate Private Key file exists." sk = SigningKey.from_pem( open("Certificate_Private.pem").read()) sk_string = sk.to_string() sk = str(sk_string) sk = sk.encode("hex") elif os.path.isfile('./Certificate_Private.pem.enc'): print "\nCertificate Private Key encoded file exists." decrypt_file(key, "Certificate_Private.pem.enc") print "\nDecrypting Certificate Private Key..." print "Saving to Certificate_Private.pem..." sk = SigningKey.from_pem( open("Certificate_Private.pem").read()) sk_string = sk.to_string() sk = str(sk_string) sk = sk.encode("hex") else: print "\nCertificate Private Key does not exist." print "\nPlease place the .pem file in the script directory.\n" sys.exit() except ValueError, e: raise Exception('Invalid response from blockchain.info.') if ans == "1" or ans == "" or ans == " ": recepient_address = open("Gen_Address.txt", "rb").read() ans3 = raw_input("Which is your revocation reason?\n") size = len(ans3) while size > 75: print "String too long for OP_RETURN transaction, please repeat.\n" ans3 = raw_input("Which is your revocation reason?\n") size = len(ans3) data = "R1: " + ans3 else: recepient_address = raw_input( "Give the address that you want to sent the certificate balance, for revocation purposes:\n" ) data = "R2: No access to Generation address" #todo - check if the address is correct try: tx = make_op_return_tx(data, sk, blockchain_client, fee=1000, format='bin') broadcast_transaction(tx, blockchain_client) final_balance = final_balance - 1000 send_to_address(recipient_address, final_balance, sk, blockchain_client) except Exception: print "\nNo balance in your Certificate address.\n" print "If the Certificate address has 0 balance, it has been already been revoced.\n"
print "\nCert_Address.txt does not exist." recepient_address = raw_input( "Give the Certificate address of your certificate, for the Extreme revocation transaction:\n" ) if ans == "3": data = "ER1: No Access to Generation and Certificate address" else: data = "ER2: No Access to Certificate address" #send all the balance to given address address print "\nYour revocation reason is: ", data print "\nAdding revocation reason to OP_RETURN..." try: send_to_address(recipient_address, 10000, sk, blockchain_client) tx = make_op_return_tx(data, sk, blockchain_client, fee=1000, format='bin') broadcast_transaction(tx, blockchain_client) except Exception: print "\nNo balance in your Revocation address.\n" print "Please load some bitcoins in order to submit your revocation reason.\n" sys.exit() def createCert(k, cert): # create a self-signed cert country = raw_input("Country Name (2 letter code): ") cert.get_subject().C = country state = raw_input("State or Province Name (full name): ") cert.get_subject().ST = state
def write_data(client, data, private_key): tx = make_op_return_tx(data, private_key, client, fee=10000, format='bin') broadcast_transaction(tx, client)