Ejemplo n.º 1
0
print "outpoint    :", outpoint
print "scriptCode  :", scriptCode
print "redeem_amount:", redeem_amount
print "sequence    :", sequence
print "hashOutputs :", hashOutputs
print "n_locktime  :", n_locktime
print "sig_hash_all:", sig_hash_all

amount_satoshi = long(round(float(redeem_amount * __unit)))
redeem_amount = formatamount(amount_satoshi)

signed_tx = n_version + hashPrevouts + hashSequence + outpoint + witness_script + redeem_amount + sequence + hashOutputs + n_locktime + sig_hash_all
#print signed_tx

priv_key_1 = 'cW9fNAfjiAryUkpTyWQRaLWGFVahTyRoiTgH8G259DZig8kJU2VB'
priv_key_1 = wif_2_privkey(priv_key_1)
sk = SigningKey.from_string(binascii.unhexlify(priv_key_1), curve=SECP256k1)
sign_data_hash_d1 = dhash256(signed_tx.decode('hex'))
#print 'sig_hash1:' + sign_data_hash_d1.encode('hex')
signature = sk.sign_digest_deterministic(sign_data_hash_d1,
                                         hashfunc=hashlib.sha256,
                                         sigencode=sigencode_der_canonize)
#print signature.encode('hex')

signature = signature.encode('hex')
sig_hash_type = '01'
signature = signature + sig_hash_type
#print signature

p_len = (len(signature)) / 2
p_len = hex(p_len).lstrip('0x')
Ejemplo n.º 2
0
redeem_public_key_hash = 'ecebae831bbfbd7827542a82da4dc136e1288f71'
#previous txout scriptPubKey
scriptSig = '1976a914' + redeem_public_key_hash + '88ac'
#sequence
sequence = 'ffffffff'

#txouts
n_outputs = '01'
amount = 0.99988480
amount_satoshi = long(round(float(amount * __unit)))
amount = formatamount(amount_satoshi)
#print output_amount
pay_to_hash = '1976a914' + 'ecebae831bbfbd7827542a82da4dc136e1288f71' + '88ac'

priv_key = 'cQuzMWdzbJezujAaAiMNq4Gr6zcFZt7BeD2VGUEN3LYBzZYgipRF'
priv_key = wif_2_privkey(priv_key)
redeem_public_key_hash = 'ecebae831bbfbd7827542a82da4dc136e1288f71'

redeem_amount = 1.00000000
print "n_version   :", n_version
print "n_inputs    :", n_inputs
print "hash_inputs :", hash_inputs
print "nth_inputs  :", nth_inputs
print "scriptSig   :", scriptSig
print "sequence    :", sequence
print "n_outputs   :", n_outputs
print "amount      :", amount
print "scriptPubKey:", pay_to_hash
print "n_locktime  :", n_locktime
print "sig_hash_all:", sig_hash_all