From 9291abe32d292f26f52ba88a8aaa3ca69292af53 Mon Sep 17 00:00:00 2001 From: Dakoda Greaves Date: Sun, 23 Oct 2022 03:03:12 -0700 Subject: [PATCH] use AccessCoin instead of GetOutputFor in GetP2SHSigOpCount -altered tests in rest.py (wip) --- qa/rpc-tests/rest.py | 6 +++--- src/validation.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/qa/rpc-tests/rest.py b/qa/rpc-tests/rest.py index a5011701028..0193306271a 100755 --- a/qa/rpc-tests/rest.py +++ b/qa/rpc-tests/rest.py @@ -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) @@ -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) @@ -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') diff --git a/src/validation.cpp b/src/validation.cpp index 4ebb04dd611..200c1198fb7 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -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); } @@ -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; @@ -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()) {