Skip to content

Commit

Permalink
use AccessCoin instead of GetOutputFor in GetP2SHSigOpCount
Browse files Browse the repository at this point in the history
-altered tests in rest.py (wip)
  • Loading branch information
xanimo committed Apr 21, 2024
1 parent d4232eb commit 9291abe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions qa/rpc-tests/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def run_test(self):
#################################################
# GETUTXOS: now query an already spent outpoint #
#################################################
json_request = '/'+vintx+'-0'
json_request = '/checkmempool/'+vintx+'-0'
json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+json_request+self.FORMAT_SEPARATOR+'json')
json_obj = json.loads(json_string)

Expand All @@ -127,7 +127,7 @@ def run_test(self):
##################################################
# GETUTXOS: now check both with the same request #
##################################################
json_request = '/'+txid+'-'+str(n)+'/'+vintx+'-0'
json_request = '/checkmempool/'+txid+'-'+str(n)+'/'+vintx+'-0'
json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+json_request+self.FORMAT_SEPARATOR+'json')
json_obj = json.loads(json_string)
assert_equal(len(json_obj['utxos']), 1)
Expand Down Expand Up @@ -183,7 +183,7 @@ def run_test(self):
json_request = '/'+spent
json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+json_request+self.FORMAT_SEPARATOR+'json')
json_obj = json.loads(json_string)
assert_equal(len(json_obj['utxos']), 1) #there should be an outpoint because its spending tx is not confirmed
assert_equal(len(json_obj['utxos']), 0) #there should be an outpoint because its spending tx is not confirmed

json_request = '/checkmempool/'+spent
json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+json_request+self.FORMAT_SEPARATOR+'json')
Expand Down
6 changes: 3 additions & 3 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& in
unsigned int nSigOps = 0;
for (unsigned int i = 0; i < tx.vin.size(); i++)
{
const CTxOut &prevout = inputs.GetOutputFor(tx.vin[i]);
const CTxOut &prevout = inputs.AccessCoin(tx.vin[i].prevout).out;
if (prevout.scriptPubKey.IsPayToScriptHash())
nSigOps += prevout.scriptPubKey.GetSigOpCount(tx.vin[i].scriptSig);
}
Expand All @@ -476,7 +476,7 @@ int64_t GetTransactionSigOpCost(const CTransaction& tx, const CCoinsViewCache& i

for (unsigned int i = 0; i < tx.vin.size(); i++)
{
const CTxOut &prevout = inputs.GetOutputFor(tx.vin[i]);
const CTxOut &prevout = inputs.AccessCoin(tx.vin[i].prevout).out;
nSigOps += CountWitnessSigOps(tx.vin[i].scriptSig, prevout.scriptPubKey, &tx.vin[i].scriptWitness, flags);
}
return nSigOps;
Expand Down Expand Up @@ -1368,7 +1368,7 @@ bool CheckTxInputs(const CChainParams& params, const CTransaction& tx, CValidati
{
const COutPoint &prevout = tx.vin[i].prevout;
const Coin& coin = inputs.AccessCoin(prevout);
assert(!coin.IsPruned());
assert(!coin.IsSpent());

// If prev is coinbase, check that it's matured
if (coin.IsCoinBase()) {
Expand Down

0 comments on commit 9291abe

Please sign in to comment.