Fix refund bug

This commit is contained in:
Jay Graber 2017-09-15 11:51:40 -07:00
parent bcb42cc171
commit e6cb6764ae
2 changed files with 7 additions and 2 deletions

View File

@ -208,6 +208,9 @@ class bitcoinProxy():
txout = CMutableTxOut(fundtx['amount'] - FEE, refundPubKey.to_scriptPubKey())
# Create the unsigned raw transaction.
tx = CMutableTransaction([txin], [txout])
# Set nSequence and nLockTime
txin.nSequence = 0
tx.nLockTime = contract.redeemblocknum
sighash = SignatureHash(redeemScript, tx, 0, SIGHASH_ALL)
privkey = self.bitcoind.dumpprivkey(refundPubKey)
sig = privkey.sign(sighash) + bytes([SIGHASH_ALL])

View File

@ -212,14 +212,16 @@ class zcashProxy():
redeemScript = CScript(x(contract.redeemScript))
txin = CMutableTxIn(fundtx['outpoint'])
txout = CMutableTxOut(fundtx['amount'] - FEE, refundPubKey.to_scriptPubKey())
# Create the unsigned raw transaction.
tx = CMutableTransaction([txin], [txout])
# Set nSequence and nLockTime
txin.nSequence = 0
tx.nLockTime = contract.redeemblocknum
# Create the unsigned raw transaction.
sighash = SignatureHash(redeemScript, tx, 0, SIGHASH_ALL)
privkey = self.zcashd.dumpprivkey(refundPubKey)
sig = privkey.sign(sighash) + bytes([SIGHASH_ALL])
# Sign without secret
txin.scriptSig = CScript([sig, privkey.pub, OP_FALSE, redeemScript])
# txin.nSequence = 2185
txin_scriptPubKey = redeemScript.to_p2sh_scriptPubKey()
print('Raw redeem transaction hex: {0}'.format(b2x(tx.serialize())))
res = VerifyScript(txin.scriptSig, txin_scriptPubKey, tx, 0, (SCRIPT_VERIFY_P2SH,))