{
vector<valtype> vSolutions;
txnouttype whichType;
- const CTxOut& txout = IsProofOfStake()? vtx[1].vout[1] : vtx[0].vout[0];
+ int nVouts = nTime < 1361664000 ? 1 : vtx[0].vout.size();
- if (!Solver(txout.scriptPubKey, whichType, vSolutions))
- return false;
- if (whichType == TX_PUBKEY)
+ if(!IsProofOfStake())
{
- // Sign
- const valtype& vchPubKey = vSolutions[0];
- CKey key;
- if (!keystore.GetKey(Hash160(vchPubKey), key))
- return false;
- if (key.GetPubKey() != vchPubKey)
+ for(int i = 0; i < nVouts; i++)
+ {
+ const CTxOut& txout = vtx[0].vout[i];
+
+ if (!Solver(txout.scriptPubKey, whichType, vSolutions))
+ continue;
+
+ if (whichType == TX_PUBKEY)
+ {
+ // Sign
+ valtype& vchPubKey = vSolutions[0];
+ CKey key;
+
+ if (!keystore.GetKey(Hash160(vchPubKey), key))
+ continue;
+ if (key.GetPubKey() != vchPubKey)
+ continue;
+ if(!key.Sign(GetHash(), vchBlockSig))
+ continue;
+
+ return true;
+ }
+ }
+ }
+ else
+ {
+ const CTxOut& txout = vtx[1].vout[1];
+
+ if (!Solver(txout.scriptPubKey, whichType, vSolutions))
return false;
- return key.Sign(GetHash(), vchBlockSig);
+
+ if (whichType == TX_PUBKEY)
+ {
+ // Sign
+ valtype& vchPubKey = vSolutions[0];
+ CKey key;
+
+ if (!keystore.GetKey(Hash160(vchPubKey), key))
+ return false;
+ if (key.GetPubKey() != vchPubKey)
+ return false;
+
+ return key.Sign(GetHash(), vchBlockSig);
+ }
}
+
+ printf("Sign failed\n");
return false;
}
vector<valtype> vSolutions;
txnouttype whichType;
- const CTxOut& txout = IsProofOfStake()? vtx[1].vout[1] : vtx[0].vout[0];
+ int nVouts = nTime < 1361664000 ? 1 : vtx[0].vout.size();
- if (!Solver(txout.scriptPubKey, whichType, vSolutions))
- return false;
- if (whichType == TX_PUBKEY)
+ if(IsProofOfStake())
{
- const valtype& vchPubKey = vSolutions[0];
- CKey key;
- if (!key.SetPubKey(vchPubKey))
- return false;
- if (vchBlockSig.empty())
+ const CTxOut& txout = vtx[1].vout[1];
+
+ if (!Solver(txout.scriptPubKey, whichType, vSolutions))
return false;
- return key.Verify(GetHash(), vchBlockSig);
+ if (whichType == TX_PUBKEY)
+ {
+ valtype& vchPubKey = vSolutions[0];
+ CKey key;
+ if (!key.SetPubKey(vchPubKey))
+ return false;
+ if (vchBlockSig.empty())
+ return false;
+ return key.Verify(GetHash(), vchBlockSig);
+ }
}
- return false;
-}
-
+ else
+ {
+ for(int i = 0; i < nVouts; i++)
+ {
+ const CTxOut& txout = vtx[0].vout[i];
+ if (!Solver(txout.scriptPubKey, whichType, vSolutions))
+ return false;
+ if (whichType == TX_PUBKEY)
+ {
+ // Verify
+ valtype& vchPubKey = vSolutions[0];
+ CKey key;
+ if (!key.SetPubKey(vchPubKey))
+ continue;
+ if (vchBlockSig.empty())
+ continue;
+ if(!key.Verify(GetHash(), vchBlockSig))
+ continue;
+ return true;
+ }
+ }
+ }
+ return false;
+}
bool CheckDiskSpace(uint64 nAdditionalBytes)