diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -33,13 +33,14 @@ * vout. */ class COutPoint { -public: - uint256 hash; +private: + uint256 txid; uint32_t n; +public: COutPoint() { SetNull(); } - COutPoint(uint256 hashIn, uint32_t nIn) { - hash = hashIn; + COutPoint(uint256 txidIn, uint32_t nIn) { + txid = txidIn; n = nIn; } @@ -47,27 +48,27 @@ template inline void SerializationOp(Stream &s, Operation ser_action) { - READWRITE(hash); + READWRITE(txid); READWRITE(n); } void SetNull() { - hash.SetNull(); + txid.SetNull(); n = uint32_t(-1); } - bool IsNull() const { return hash.IsNull() && n == uint32_t(-1); } + bool IsNull() const { return txid.IsNull() && n == uint32_t(-1); } - TxId GetTxId() const { return TxId(hash); } + TxId GetTxId() const { return TxId(txid); } uint32_t GetN() const { return n; } friend bool operator<(const COutPoint &a, const COutPoint &b) { - int cmp = a.hash.Compare(b.hash); + int cmp = a.txid.Compare(b.txid); return cmp < 0 || (cmp == 0 && a.n < b.n); } friend bool operator==(const COutPoint &a, const COutPoint &b) { - return (a.hash == b.hash && a.n == b.n); + return (a.txid == b.txid && a.n == b.n); } friend bool operator!=(const COutPoint &a, const COutPoint &b) { diff --git a/src/primitives/transaction.cpp b/src/primitives/transaction.cpp --- a/src/primitives/transaction.cpp +++ b/src/primitives/transaction.cpp @@ -10,7 +10,7 @@ #include "utilstrencodings.h" std::string COutPoint::ToString() const { - return strprintf("COutPoint(%s, %u)", hash.ToString().substr(0, 10), n); + return strprintf("COutPoint(%s, %u)", txid.ToString().substr(0, 10), n); } std::string CTxIn::ToString() const { diff --git a/src/test/multisig_tests.cpp b/src/test/multisig_tests.cpp --- a/src/test/multisig_tests.cpp +++ b/src/test/multisig_tests.cpp @@ -38,13 +38,14 @@ } BOOST_AUTO_TEST_CASE(multisig_verify) { - unsigned int flags = SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC; + uint32_t flags = SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC; ScriptError err; CKey key[4]; Amount amount(0); - for (int i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { key[i].MakeNewKey(true); + } CScript a_and_b; a_and_b << OP_2 << ToByteVector(key[0].GetPubKey()) @@ -71,8 +72,7 @@ for (int i = 0; i < 3; i++) { txTo[i].vin.resize(1); txTo[i].vout.resize(1); - txTo[i].vin[0].prevout.n = i; - txTo[i].vin[0].prevout.hash = txFrom.GetId(); + txTo[i].vin[0].prevout = COutPoint(txFrom.GetId(), i); txTo[i].vout[0].nValue = Amount(1); } @@ -345,8 +345,7 @@ for (int i = 0; i < 3; i++) { txTo[i].vin.resize(1); txTo[i].vout.resize(1); - txTo[i].vin[0].prevout.n = i; - txTo[i].vin[0].prevout.hash = txFrom.GetId(); + txTo[i].vin[0].prevout = COutPoint(txFrom.GetId(), i); txTo[i].vout[0].nValue = Amount(1); } diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -300,15 +300,12 @@ CMutableTransaction t1; t1.vin.resize(3); - t1.vin[0].prevout.hash = dummyTransactions[0].GetId(); - t1.vin[0].prevout.n = 1; + t1.vin[0].prevout = COutPoint(dummyTransactions[0].GetId(), 1); t1.vin[0].scriptSig << std::vector(65, 0); - t1.vin[1].prevout.hash = dummyTransactions[1].GetId(); - t1.vin[1].prevout.n = 0; + t1.vin[1].prevout = COutPoint(dummyTransactions[1].GetId(), 0); t1.vin[1].scriptSig << std::vector(65, 0) << std::vector(33, 4); - t1.vin[2].prevout.hash = dummyTransactions[1].GetId(); - t1.vin[2].prevout.n = 1; + t1.vin[2].prevout = COutPoint(dummyTransactions[1].GetId(), 1); t1.vin[2].scriptSig << std::vector(65, 0) << std::vector(33, 4); t1.vout.resize(2); @@ -342,8 +339,7 @@ CMutableTransaction inputm; inputm.nVersion = 1; inputm.vin.resize(1); - inputm.vin[0].prevout.hash = output->GetId(); - inputm.vin[0].prevout.n = 0; + inputm.vin[0].prevout = COutPoint(output->GetId(), 0); inputm.vout.resize(1); inputm.vout[0].nValue = Amount(1); inputm.vout[0].scriptPubKey = CScript(); @@ -463,7 +459,7 @@ for (size_t i = 0; i < mtx.vin.size(); i++) { std::vector vChecks; - CTxOut &out = coins[tx.vin[i].prevout.n].GetTxOut(); + CTxOut &out = coins[tx.vin[i].prevout.GetN()].GetTxOut(); CScriptCheck check(out.scriptPubKey, out.nValue, tx, i, MANDATORY_SCRIPT_VERIFY_FLAGS, false, txdata); vChecks.push_back(CScriptCheck()); @@ -614,8 +610,7 @@ CMutableTransaction t; t.vin.resize(1); - t.vin[0].prevout.hash = dummyTransactions[0].GetId(); - t.vin[0].prevout.n = 1; + t.vin[0].prevout = COutPoint(dummyTransactions[0].GetId(), 1); t.vin[0].scriptSig << std::vector(65, 0); t.vout.resize(1); t.vout[0].nValue = 90 * CENT;