Browse Source

Merge remote-tracking branch 'mike/dev' into dev

pull/442/head
Asher Dawes 2 years ago
parent
commit
dc38664d8b
  1. 41
      src/rpc/misc.cpp
  2. 34
      src/script/script.cpp

41
src/rpc/misc.cpp

@ -1571,8 +1571,8 @@ bool timestampSort(std::pair<CMempoolAddressDeltaKey, CMempoolAddressDelta> a,
}
void CurrencyValuesAndNames(UniValue &output, bool spending, const CScript &script, CAmount satoshis, bool friendlyNames=false);
void CurrencyValuesAndNames(UniValue &output, bool spending, const CScript &script, CAmount satoshis, bool friendlyNames)
void CurrencyValuesAndNames(UniValue &output, bool spending, const CScript script, CAmount satoshis, bool friendlyNames=false);
void CurrencyValuesAndNames(UniValue &output, bool spending, const CScript script, CAmount satoshis, bool friendlyNames)
{
if (CConstVerusSolutionVector::GetVersionByHeight(chainActive.Height()) >= CActivationHeight::ACTIVATE_PBAAS)
{
@ -1607,6 +1607,29 @@ void CurrencyValuesAndNames(UniValue &output, bool spending, const CScript &scri
}
}
void CurrencyValuesAndNames(UniValue &output, bool spending, const CTransaction &tx, int index, CAmount satoshis, bool friendlyNames=false);
void CurrencyValuesAndNames(UniValue &output, bool spending, const CTransaction &tx, int index, CAmount satoshis, bool friendlyNames)
{
CScript script;
if (spending) {
CTransaction priorOutTx;
uint256 blockHash;
if (myGetTransaction(tx.vin[index].prevout.hash, priorOutTx, blockHash))
{
script = priorOutTx.vout[tx.vin[index].prevout.n].scriptPubKey;
}
else
{
throw JSONRPCError(RPC_DATABASE_ERROR, "Unable to retrieve data to retrieve spending currency values");
}
}
else
{
script = tx.vout[index].scriptPubKey;
}
return CurrencyValuesAndNames(output, spending, script, satoshis, friendlyNames);
}
UniValue AddressMemPoolUni(const std::vector<std::pair<uint160, int>> &addresses, bool friendlyNames)
{
CTransaction curTx;
@ -1634,7 +1657,7 @@ UniValue AddressMemPoolUni(const std::vector<std::pair<uint160, int>> &addresses
delta.push_back(Pair("txid", it->first.txhash.GetHex()));
delta.push_back(Pair("index", (int)it->first.index));
delta.push_back(Pair("satoshis", it->second.amount));
CurrencyValuesAndNames(delta, it->first.spending, curTx.vout[it->first.index].scriptPubKey, it->second.amount, friendlyNames);
CurrencyValuesAndNames(delta, it->first.spending, curTx, it->first.index, it->second.amount, friendlyNames);
delta.push_back(Pair("timestamp", it->second.time));
if (it->second.amount < 0) {
delta.push_back(Pair("prevtxid", it->second.prevhash.GetHex()));
@ -1909,7 +1932,7 @@ UniValue getaddressdeltas(const UniValue& params, bool fHelp)
uint256 blockHash;
if (verbosity && (it->first.txhash == curTx.GetHash() || myGetTransaction(it->first.txhash, curTx, blockHash)))
{
CurrencyValuesAndNames(delta, it->first.spending, curTx.vout[it->first.index].scriptPubKey, it->second, friendlyNames);
CurrencyValuesAndNames(delta, it->first.spending, curTx, it->first.index, it->second, friendlyNames);
}
deltas.push_back(delta);
@ -2002,7 +2025,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 -= priorOutTx.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