Skip to content

Commit

Permalink
Adding method GetTotalSize() to CTransaction
Browse files Browse the repository at this point in the history
GetTotalSize() returns the total transaction size (including witness) in
bytes.
  • Loading branch information
hsjoberg committed Sep 6, 2016
1 parent cbe9ae8 commit fdf82fb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/primitives/transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ unsigned int CTransaction::CalculateModifiedSize(unsigned int nTxSize) const
return nTxSize;
}

unsigned int CTransaction::GetTotalSize() const
{
return ::GetSerializeSize(*this, SER_NETWORK, PROTOCOL_VERSION);
}

std::string CTransaction::ToString() const
{
std::string str;
Expand Down
7 changes: 7 additions & 0 deletions src/primitives/transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,13 @@ class CTransaction

// Compute modified tx size for priority calculation (optionally given tx size)
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
{
Expand Down

0 comments on commit fdf82fb

Please sign in to comment.