aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGregory Maxwell <greg@xiph.org>2012-08-09 05:56:03 -0700
committerGregory Maxwell <greg@xiph.org>2012-08-09 05:56:03 -0700
commit765654dae840630329d0de6760a8216d93b885b2 (patch)
tree66846158ecdf916949b0500d8a9af814e8ebc7cb /src
parent2c006b0b3e6a94fc0fdac80ff2db3af93f768064 (diff)
parent3557f99cf592be352cd2168157121a0cffbd6116 (diff)
Merge pull request #1655 from gmaxwell/signrawtransaction_fix_missing
Correctly handle missing inputs in signrawtransaction. Fixes #1654.
Diffstat (limited to 'src')
-rw-r--r--src/rpcrawtransaction.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp
index 66e4d85f37..57cba15ecf 100644
--- a/src/rpcrawtransaction.cpp
+++ b/src/rpcrawtransaction.cpp
@@ -321,18 +321,23 @@ Value signrawtransaction(const Array& params, bool fHelp)
// Fetch previous transactions (inputs):
map<COutPoint, CScript> mapPrevOut;
+ for (unsigned int i = 0; i < mergedTx.vin.size(); i++)
{
+ CTransaction tempTx;
MapPrevTx mapPrevTx;
CTxDB txdb("r");
map<uint256, CTxIndex> unused;
bool fInvalid;
- mergedTx.FetchInputs(txdb, unused, false, false, mapPrevTx, fInvalid);
+
+ // FetchInputs aborts on failure, so we go one at a time.
+ tempTx.vin.push_back(mergedTx.vin[i]);
+ tempTx.FetchInputs(txdb, unused, false, false, mapPrevTx, fInvalid);
// Copy results into mapPrevOut:
- BOOST_FOREACH(const CTxIn& txin, mergedTx.vin)
+ BOOST_FOREACH(const CTxIn& txin, tempTx.vin)
{
const uint256& prevHash = txin.prevout.hash;
- if (mapPrevTx.count(prevHash))
+ if (mapPrevTx.count(prevHash) && mapPrevTx[prevHash].second.vout.size()>txin.prevout.n)
mapPrevOut[txin.prevout] = mapPrevTx[prevHash].second.vout[txin.prevout.n].scriptPubKey;
}
}