Browse Source

Adding method GetTotalSize() to CTransaction

GetTotalSize() returns the total transaction size (including witness) in
bytes.
0.14
Hampus Sjöberg 8 years ago
parent
commit
fdf82fba31
  1. 5
      src/primitives/transaction.cpp
  2. 7
      src/primitives/transaction.h

5
src/primitives/transaction.cpp

@ -131,6 +131,11 @@ unsigned int CTransaction::CalculateModifiedSize(unsigned int nTxSize) const
return nTxSize; return nTxSize;
} }
unsigned int CTransaction::GetTotalSize() const
{
return ::GetSerializeSize(*this, SER_NETWORK, PROTOCOL_VERSION);
}
std::string CTransaction::ToString() const std::string CTransaction::ToString() const
{ {
std::string str; std::string str;

7
src/primitives/transaction.h

@ -416,6 +416,13 @@ public:
// Compute modified tx size for priority calculation (optionally given tx size) // Compute modified tx size for priority calculation (optionally given tx size)
unsigned int CalculateModifiedSize(unsigned int nTxSize=0) const; unsigned int CalculateModifiedSize(unsigned int nTxSize=0) const;
/**
* Get the total transaction size in bytes, including witness data.
* "Total Size" defined in BIP141 and BIP144.
* @return Total transaction size in bytes
*/
unsigned int GetTotalSize() const;
bool IsCoinBase() const bool IsCoinBase() const
{ {
return (vin.size() == 1 && vin[0].prevout.IsNull()); return (vin.size() == 1 && vin[0].prevout.IsNull());

Loading…
Cancel
Save