Changeset View
Changeset View
Standalone View
Standalone View
src/primitives/transaction.cpp
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
CMutableTransaction::CMutableTransaction() | CMutableTransaction::CMutableTransaction() | ||||
: nVersion(CTransaction::CURRENT_VERSION), nLockTime(0) {} | : nVersion(CTransaction::CURRENT_VERSION), nLockTime(0) {} | ||||
CMutableTransaction::CMutableTransaction(const CTransaction &tx) | CMutableTransaction::CMutableTransaction(const CTransaction &tx) | ||||
: nVersion(tx.nVersion), vin(tx.vin), vout(tx.vout), | : nVersion(tx.nVersion), vin(tx.vin), vout(tx.vout), | ||||
nLockTime(tx.nLockTime) {} | nLockTime(tx.nLockTime) {} | ||||
TxHash CMutableTransaction::GetId() const { | TxHash CMutableTransaction::GetHash() const { | ||||
return SerializeHash(*this, SER_GETHASH, 0); | return SerializeHash(*this, SER_GETHASH, 0); | ||||
} | } | ||||
TxHash CTransaction::ComputeHash() const { | TxHash CTransaction::ComputeHash() const { | ||||
return SerializeHash(*this, SER_GETHASH, 0); | return SerializeHash(*this, SER_GETHASH, 0); | ||||
} | } | ||||
TxHash CTransaction::GetHash() const { | |||||
return GetId(); | |||||
} | |||||
/** | /** | ||||
* For backward compatibility, the hash is initialized to 0. | * For backward compatibility, the hash is initialized to 0. | ||||
* TODO: remove the need for this default constructor entirely. | * TODO: remove the need for this default constructor entirely. | ||||
*/ | */ | ||||
CTransaction::CTransaction() | CTransaction::CTransaction() | ||||
: nVersion(CTransaction::CURRENT_VERSION), vin(), vout(), nLockTime(0), | : nVersion(CTransaction::CURRENT_VERSION), vin(), vout(), nLockTime(0), | ||||
hash() {} | hash() {} | ||||
CTransaction::CTransaction(const CMutableTransaction &tx) | CTransaction::CTransaction(const CMutableTransaction &tx) | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | |||||
unsigned int CTransaction::GetTotalSize() const { | unsigned int CTransaction::GetTotalSize() const { | ||||
return ::GetSerializeSize(*this, SER_NETWORK, PROTOCOL_VERSION); | return ::GetSerializeSize(*this, SER_NETWORK, PROTOCOL_VERSION); | ||||
} | } | ||||
std::string CTransaction::ToString() const { | std::string CTransaction::ToString() const { | ||||
std::string str; | std::string str; | ||||
str += strprintf("CTransaction(txid=%s, ver=%d, vin.size=%u, vout.size=%u, " | str += strprintf("CTransaction(txid=%s, ver=%d, vin.size=%u, vout.size=%u, " | ||||
"nLockTime=%u)\n", | "nLockTime=%u)\n", | ||||
GetId().ToString().substr(0, 10), nVersion, vin.size(), | GetHash().ToString().substr(0, 10), nVersion, vin.size(), | ||||
vout.size(), nLockTime); | vout.size(), nLockTime); | ||||
for (unsigned int i = 0; i < vin.size(); i++) | for (unsigned int i = 0; i < vin.size(); i++) | ||||
str += " " + vin[i].ToString() + "\n"; | str += " " + vin[i].ToString() + "\n"; | ||||
for (unsigned int i = 0; i < vout.size(); i++) | for (unsigned int i = 0; i < vout.size(); i++) | ||||
str += " " + vout[i].ToString() + "\n"; | str += " " + vout[i].ToString() + "\n"; | ||||
return str; | return str; | ||||
} | } | ||||
int64_t GetTransactionSize(const CTransaction &tx) { | int64_t GetTransactionSize(const CTransaction &tx) { | ||||
return ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); | return ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); | ||||
} | } |