mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-01-11 15:27:57 +00:00
Merge pull request #1689 from gavinandresen/rawtx_singlefix
When using SIGHASH_SINGLE, only sign inputs that have corresponding outputs
This commit is contained in:
commit
b86da2abe8
@ -428,6 +428,8 @@ Value signrawtransaction(const Array& params, bool fHelp)
|
|||||||
throw JSONRPCError(-8, "Invalid sighash param");
|
throw JSONRPCError(-8, "Invalid sighash param");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool fHashSingle = ((nHashType & ~SIGHASH_ANYONECANPAY) == SIGHASH_SINGLE);
|
||||||
|
|
||||||
// Sign what we can:
|
// Sign what we can:
|
||||||
for (unsigned int i = 0; i < mergedTx.vin.size(); i++)
|
for (unsigned int i = 0; i < mergedTx.vin.size(); i++)
|
||||||
{
|
{
|
||||||
@ -440,6 +442,8 @@ Value signrawtransaction(const Array& params, bool fHelp)
|
|||||||
const CScript& prevPubKey = mapPrevOut[txin.prevout];
|
const CScript& prevPubKey = mapPrevOut[txin.prevout];
|
||||||
|
|
||||||
txin.scriptSig.clear();
|
txin.scriptSig.clear();
|
||||||
|
// Only sign SIGHASH_SINGLE if there's a corresponding output:
|
||||||
|
if (!fHashSingle || (i < mergedTx.vout.size()))
|
||||||
SignSignature(keystore, prevPubKey, mergedTx, i, nHashType);
|
SignSignature(keystore, prevPubKey, mergedTx, i, nHashType);
|
||||||
|
|
||||||
// ... and merge in other signatures:
|
// ... and merge in other signatures:
|
||||||
|
Loading…
Reference in New Issue
Block a user