diff --git a/xcat/bitcoinRPC.py b/xcat/bitcoinRPC.py index 338d8e3..0a3c73f 100644 --- a/xcat/bitcoinRPC.py +++ b/xcat/bitcoinRPC.py @@ -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]) diff --git a/xcat/zcashRPC.py b/xcat/zcashRPC.py index b2cafd0..0aa38fd 100644 --- a/xcat/zcashRPC.py +++ b/xcat/zcashRPC.py @@ -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,))