diff --git a/src/test/blockcheck_tests.cpp b/src/test/blockcheck_tests.cpp --- a/src/test/blockcheck_tests.cpp +++ b/src/test/blockcheck_tests.cpp @@ -63,8 +63,7 @@ RunCheckOnBlock(config, block); // No coinbase - tx.vin[0].prevout.hash = InsecureRand256(); - tx.vin[0].prevout.n = 0; + tx.vin[0].prevout = COutPoint(InsecureRand256(), 0); block.vtx[0] = MakeTransactionRef(tx); RunCheckOnBlock(config, block, "bad-cb-missing"); @@ -79,12 +78,11 @@ // Oversize block. tx = CMutableTransaction(coinbaseTx); block.vtx[0] = MakeTransactionRef(tx); - tx.vin[0].prevout.n = 0; auto txSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); auto maxTxCount = ((DEFAULT_MAX_BLOCK_SIZE - 1) / txSize) - 1; for (size_t i = 1; i < maxTxCount; i++) { - tx.vin[0].prevout.hash = InsecureRand256(); + tx.vin[0].prevout = COutPoint(InsecureRand256(), 0); block.vtx.push_back(MakeTransactionRef(tx)); } @@ -93,7 +91,7 @@ // But reject it with one more transaction as it goes over the maximum // allowed block size. - tx.vin[0].prevout.hash = InsecureRand256(); + tx.vin[0].prevout = COutPoint(InsecureRand256(), 0); block.vtx.push_back(MakeTransactionRef(tx)); RunCheckOnBlock(config, block, "bad-blk-length"); } diff --git a/src/test/txvalidationcache_tests.cpp b/src/test/txvalidationcache_tests.cpp --- a/src/test/txvalidationcache_tests.cpp +++ b/src/test/txvalidationcache_tests.cpp @@ -45,8 +45,7 @@ for (int i = 0; i < 2; i++) { spends[i].nVersion = 1; spends[i].vin.resize(1); - spends[i].vin[0].prevout.hash = coinbaseTxns[0].GetId(); - spends[i].vin[0].prevout.n = 0; + spends[i].vin[0].prevout = COutPoint(coinbaseTxns[0].GetId(), 0); spends[i].vout.resize(1); spends[i].vout[0].nValue = 11 * CENT; spends[i].vout[0].scriptPubKey = scriptPubKey; @@ -173,8 +172,7 @@ mutableSpend_tx.nVersion = 1; mutableSpend_tx.vin.resize(1); - mutableSpend_tx.vin[0].prevout.hash = coinbaseTxns[0].GetId(); - mutableSpend_tx.vin[0].prevout.n = 0; + mutableSpend_tx.vin[0].prevout = COutPoint(coinbaseTxns[0].GetId(), 0); mutableSpend_tx.vout.resize(4); mutableSpend_tx.vout[0].nValue = 11 * CENT; mutableSpend_tx.vout[0].scriptPubKey = p2sh_scriptPubKey; @@ -248,8 +246,7 @@ CMutableTransaction invalid_under_p2sh_tx; invalid_under_p2sh_tx.nVersion = 1; invalid_under_p2sh_tx.vin.resize(1); - invalid_under_p2sh_tx.vin[0].prevout.hash = spend_tx.GetId(); - invalid_under_p2sh_tx.vin[0].prevout.n = 0; + invalid_under_p2sh_tx.vin[0].prevout = COutPoint(spend_tx.GetId(), 0); invalid_under_p2sh_tx.vout.resize(1); invalid_under_p2sh_tx.vout[0].nValue = 11 * CENT; invalid_under_p2sh_tx.vout[0].scriptPubKey = p2pk_scriptPubKey; @@ -267,8 +264,7 @@ invalid_with_cltv_tx.nVersion = 1; invalid_with_cltv_tx.nLockTime = 100; invalid_with_cltv_tx.vin.resize(1); - invalid_with_cltv_tx.vin[0].prevout.hash = spend_tx.GetId(); - invalid_with_cltv_tx.vin[0].prevout.n = 1; + invalid_with_cltv_tx.vin[0].prevout = COutPoint(spend_tx.GetId(), 1); invalid_with_cltv_tx.vin[0].nSequence = 0; invalid_with_cltv_tx.vout.resize(1); invalid_with_cltv_tx.vout[0].nValue = 11 * CENT; @@ -305,8 +301,7 @@ CMutableTransaction invalid_with_csv_tx; invalid_with_csv_tx.nVersion = 2; invalid_with_csv_tx.vin.resize(1); - invalid_with_csv_tx.vin[0].prevout.hash = spend_tx.GetId(); - invalid_with_csv_tx.vin[0].prevout.n = 2; + invalid_with_csv_tx.vin[0].prevout = COutPoint(spend_tx.GetId(), 2); invalid_with_csv_tx.vin[0].nSequence = 100; invalid_with_csv_tx.vout.resize(1); invalid_with_csv_tx.vout[0].nValue = 11 * CENT; @@ -345,10 +340,8 @@ tx.nVersion = 1; tx.vin.resize(2); - tx.vin[0].prevout.hash = spend_tx.GetId(); - tx.vin[0].prevout.n = 0; - tx.vin[1].prevout.hash = spend_tx.GetId(); - tx.vin[1].prevout.n = 3; + tx.vin[0].prevout = COutPoint(spend_tx.GetId(), 0); + tx.vin[1].prevout = COutPoint(spend_tx.GetId(), 3); tx.vout.resize(1); tx.vout[0].nValue = 22 * CENT; tx.vout[0].scriptPubKey = p2pk_scriptPubKey; diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -718,11 +718,11 @@ return false; } - const CTransactionRef &txFrom = pool.get(txin.prevout.hash); + const CTransactionRef &txFrom = pool.get(txin.prevout.GetTxId()); if (txFrom) { - assert(txFrom->GetHash() == txin.prevout.hash); - assert(txFrom->vout.size() > txin.prevout.n); - assert(txFrom->vout[txin.prevout.n] == coin.GetTxOut()); + assert(txFrom->GetHash() == txin.prevout.GetTxId()); + assert(txFrom->vout.size() > txin.prevout.GetN()); + assert(txFrom->vout[txin.prevout.GetN()] == coin.GetTxOut()); } else { const Coin &coinFromDisk = pcoinsTip->AccessCoin(txin.prevout); assert(!coinFromDisk.IsSpent()); @@ -1706,7 +1706,7 @@ // this information only in undo records for the last spend of a // transactions' outputs. This implies that it must be present for some // other output of the same tx. - const Coin &alternate = AccessByTxid(view, out.hash); + const Coin &alternate = AccessByTxid(view, out.GetTxId()); if (alternate.IsSpent()) { // Adding output for transaction without known metadata return DISCONNECT_FAILED;