Browse Source

getaddressbalance fix and hardening

pull/446/head
miketout 2 years ago
parent
commit
e7ab76c34f
  1. 10
      src/rpc/misc.cpp
  2. 34
      src/script/script.cpp

10
src/rpc/misc.cpp

@ -2002,7 +2002,15 @@ UniValue getaddressbalance(const UniValue& params, bool fHelp)
if (it->first.txhash == curTx.GetHash() || myGetTransaction(it->first.txhash, curTx, blockHash))
{
if (it->first.spending) {
reserveBalance -= curTx.vout[it->first.index].ReserveOutValue();
CTransaction priorOutTx;
if (myGetTransaction(curTx.vin[it->first.index].prevout.hash, priorOutTx, blockHash))
{
reserveBalance -= curTx.vout[curTx.vin[it->first.index].prevout.n].ReserveOutValue();
}
else
{
throw JSONRPCError(RPC_DATABASE_ERROR, "Unable to retrieve data for reserve output value");
}
}
else
{

34
src/script/script.cpp

@ -580,21 +580,33 @@ bool CScript::IsPayToCryptoCondition(CScript *pCCSubScript, std::vector<std::vec
vector<unsigned char> firstParam;
vector<unsigned char> data;
opcodetype opcode;
if (this->GetOp(pc, opcode, firstParam))
// Sha256 conditions are <76 bytes
if (opcode > OP_0 && opcode < OP_PUSHDATA1)
if (this->GetOp(pc, opcode, data))
if (opcode == OP_CHECKCRYPTOCONDITION)
try
{
if (this->GetOp(pc, opcode, firstParam))
{
// Sha256 conditions are <76 bytes
if (opcode > OP_0 && opcode < OP_PUSHDATA1)
{
if (this->GetOp(pc, opcode, data))
{
const_iterator pcCCEnd = pc;
if (GetBalancedData(pc, vParams))
if (opcode == OP_CHECKCRYPTOCONDITION)
{
if (pCCSubScript)
*pCCSubScript = CScript(begin(), pcCCEnd);
vParams.push_back(firstParam);
return true;
const_iterator pcCCEnd = pc;
if (GetBalancedData(pc, vParams))
{
if (pCCSubScript)
*pCCSubScript = CScript(begin(), pcCCEnd);
vParams.push_back(firstParam);
return true;
}
}
}
}
}
}
catch(...)
{
}
return false;
}

Loading…
Cancel
Save