#!/usr/bin/env python import binascii from bitcoin.core import COutPoint, CTxIn, CTxOut, CTransaction, CBlock coinbase = "04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73" scriptPubKeyHex = "4104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac" # construct previous out point previousOut = COutPoint() previousOut.hash = 0 previousOut.n = 4294967295 # construct txin txin = CTxIn() txin.coinbase = binascii.unhexlify(coinbase) txin.scriptSig = binascii.unhexlify(coinbase) txin.prevout = previousOut # construct txout txout = CTxOut() txout.nValue = 5000000000 txout.scriptPubKey = binascii.unhexlify(scriptPubKeyHex) # create transaction tx = CTransaction() tx.vin.append(txin) tx.vout.append(txout) tx.calc_sha256()
v_hex = hex(v) if int(v_hex[:4], 16) > 127: v_hex = v_hex[:2] + "00" + v_hex[2:] nbytes = 0xFF & ((len(v_hex) - 3) // 2) nbytes = (nbytes << 8) | (int(v_hex[2:4], 16) & 0xFF) nbytes = (nbytes << 8) | (int(v_hex[4:6], 16) & 0xFF) nbytes = (nbytes << 8) | (int(v_hex[6:8], 16) & 0xFF) return nbytes coinbase = "04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73" scriptPubKeyHex = "4104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac" # construct previous out point previousOut = COutPoint() previousOut.hash = 0 previousOut.n = 4294967295 # construct txin txin = CTxIn() txin.coinbase = binascii.unhexlify(coinbase) txin.scriptSig = binascii.unhexlify(coinbase) txin.prevout = previousOut # construct txout txout = CTxOut() txout.nValue = 5000000000 txout.scriptPubKey = binascii.unhexlify(scriptPubKeyHex) # create transaction tx = CTransaction()
from bitcoin.core import COutPoint, CTxIn, CTxOut, CTransaction # from utils def myhash(s): return hashlib.sha256(hashlib.sha256(s).digest()).digest() previous = COutPoint() txin = CTxIn() txout = CTxOut() tx = CTransaction() # get the outpoint from which we want to spend previous.hash = 0xeccf7e3034189b851985d871f91384b8ee357cd47c3024736e5676eb2debb3f2 previous.n = 0x01000000 txin.prevout = previous txin.scriptSig = binascii.unhexlify( "76a914010966776006953d5567439e5e39f86a0d273bee88ac") # create output transaction txout.nValue = 0x605af40500000000 txout.scriptPubKey = binascii.unhexlify( "76a914097072524438d003d23a2f23edb65aae1bb3e46988ac") # set inputs and outputs tx.vin.append(txin) tx.vout.append(txout) sertx = tx.serialize() + binascii.unhexlify("01000000") """
from bitcoin.key import CKey from bitcoin.core import COutPoint, CTxIn, CTxOut, CTransaction # from utils def myhash(s): return hashlib.sha256(hashlib.sha256(s).digest()).digest() previous = COutPoint() txin = CTxIn() txout = CTxOut() tx = CTransaction() # get the outpoint from which we want to spend previous.hash = 0xeccf7e3034189b851985d871f91384b8ee357cd47c3024736e5676eb2debb3f2 previous.n = 0x01000000 txin.prevout = previous txin.scriptSig = binascii.unhexlify("76a914010966776006953d5567439e5e39f86a0d273bee88ac") # create output transaction txout.nValue = 0x605af40500000000 txout.scriptPubKey = binascii.unhexlify("76a914097072524438d003d23a2f23edb65aae1bb3e46988ac") # set inputs and outputs tx.vin.append(txin) tx.vout.append(txout) sertx = tx.serialize() + binascii.unhexlify("01000000") """ print sertx[:76]