Created
August 15, 2015 19:46
-
-
Save rsmoz/2846eae5588805a72ce0 to your computer and use it in GitHub Desktop.
Uploading a bitcoin transaction with OP_RETURN
This file contains 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
# coding: utf-8 | |
from bitcoin import * | |
import binascii | |
from test import * | |
priv = sha256('brain wallet words go here') | |
pub = privtopub(priv) | |
addr = pubtoaddr(pub) | |
inputs = unspent(addr) | |
message = "HelloWorld" | |
FullLen = format(len(message)+2,'x').rjust(2,'0') | |
MessageLen = format(len(message),'x').rjust(2,'0') | |
ID = binascii.hexlify(str(message)) | |
snd = "6a4c"+MessageLen+ID | |
outputs = [{'value': 10000, 'address': addr}, {'value': 0, 'script': snd}] | |
fee = 10000 | |
tx = mksend(inputs, outputs, addr, fee) | |
dt = deserialize(tx) | |
#qqq(dt) | |
ins = dt['ins'] | |
#print addr | |
print ins | |
for ind, elm in enumerate(ins): | |
# print elm | |
tx = sign(tx, ind, priv) | |
print tx | |
import requests | |
send = requests.post('https://insight.bitpay.com/api/tx/send', data=json.dumps({"rawtx":tx}), headers = {'content-type': 'application/json'}) | |
print send.text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment