add txComments
This commit is contained in:
parent
ba8ed3a93b
commit
8e2d7007f3
@ -54,8 +54,8 @@ std::string CTxOut::ToString() const
|
||||
return strprintf("CTxOut(nValue=%d.%08d, scriptPubKey=%s)", nValue / COIN, nValue % COIN, HexStr(scriptPubKey).substr(0, 30));
|
||||
}
|
||||
|
||||
CMutableTransaction::CMutableTransaction() : nVersion(CTransaction::CURRENT_VERSION), nLockTime(0) {}
|
||||
CMutableTransaction::CMutableTransaction(const CTransaction& tx) : nVersion(tx.nVersion), vin(tx.vin), vout(tx.vout), nLockTime(tx.nLockTime) {}
|
||||
CMutableTransaction::CMutableTransaction() : nVersion(CTransaction::CURRENT_VERSION), nLockTime(0), strTxComment('') {}
|
||||
CMutableTransaction::CMutableTransaction(const CTransaction& tx) : nVersion(tx.nVersion), vin(tx.vin), vout(tx.vout), nLockTime(tx.nLockTime), strTxComment(tx.strTxComment) {}
|
||||
|
||||
uint256 CMutableTransaction::GetHash() const
|
||||
{
|
||||
@ -76,9 +76,9 @@ uint256 CTransaction::GetWitnessHash() const
|
||||
}
|
||||
|
||||
/* For backward compatibility, the hash is initialized to 0. TODO: remove the need for this default constructor entirely. */
|
||||
CTransaction::CTransaction() : nVersion(CTransaction::CURRENT_VERSION), vin(), vout(), nLockTime(0), hash() {}
|
||||
CTransaction::CTransaction(const CMutableTransaction &tx) : nVersion(tx.nVersion), vin(tx.vin), vout(tx.vout), nLockTime(tx.nLockTime), hash(ComputeHash()) {}
|
||||
CTransaction::CTransaction(CMutableTransaction &&tx) : nVersion(tx.nVersion), vin(std::move(tx.vin)), vout(std::move(tx.vout)), nLockTime(tx.nLockTime), hash(ComputeHash()) {}
|
||||
CTransaction::CTransaction() : nVersion(CTransaction::CURRENT_VERSION), vin(), vout(), nLockTime(0), strTxComment(''), hash() {}
|
||||
CTransaction::CTransaction(const CMutableTransaction &tx) : nVersion(tx.nVersion), vin(tx.vin), vout(tx.vout), nLockTime(tx.nLockTime), strTxComment(tx.strTxComment), hash(ComputeHash()) {}
|
||||
CTransaction::CTransaction(CMutableTransaction &&tx) : nVersion(tx.nVersion), vin(std::move(tx.vin)), vout(std::move(tx.vout)), nLockTime(tx.nLockTime), strTxComment(tx.strTxComment), hash(ComputeHash()) {}
|
||||
|
||||
CAmount CTransaction::GetValueOut() const
|
||||
{
|
||||
@ -111,5 +111,8 @@ std::string CTransaction::ToString() const
|
||||
str += " " + tx_in.scriptWitness.ToString() + "\n";
|
||||
for (const auto& tx_out : vout)
|
||||
str += " " + tx_out.ToString() + "\n";
|
||||
if (nVersion >= 2) {
|
||||
str += " txComment: " + tx.strTxComment + "\n";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
@ -226,6 +226,9 @@ inline void UnserializeTransaction(TxType& tx, Stream& s) {
|
||||
throw std::ios_base::failure("Unknown transaction optional data");
|
||||
}
|
||||
s >> tx.nLockTime;
|
||||
if (tx.nVersion >= 2) {
|
||||
s >> tx.strTxComment;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Stream, typename TxType>
|
||||
@ -255,6 +258,9 @@ inline void SerializeTransaction(const TxType& tx, Stream& s) {
|
||||
}
|
||||
}
|
||||
s << tx.nLockTime;
|
||||
if (tx.nVersion >= 2) {
|
||||
s << tx.strTxComment;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -282,6 +288,7 @@ public:
|
||||
const std::vector<CTxIn> vin;
|
||||
const std::vector<CTxOut> vout;
|
||||
const uint32_t nLockTime;
|
||||
const std::string strTxComment;
|
||||
|
||||
private:
|
||||
/** Memory only. */
|
||||
@ -365,6 +372,7 @@ struct CMutableTransaction
|
||||
std::vector<CTxIn> vin;
|
||||
std::vector<CTxOut> vout;
|
||||
uint32_t nLockTime;
|
||||
std::string strTxComment;
|
||||
|
||||
CMutableTransaction();
|
||||
CMutableTransaction(const CTransaction& tx);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user