diff options
author | Hampus Sjöberg <hampus.sjoberg@gmail.com> | 2016-09-06 22:30:30 +0200 |
---|---|---|
committer | Hampus Sjöberg <hampus.sjoberg@gmail.com> | 2016-09-06 22:30:30 +0200 |
commit | fdf82fba3105c3c824e594db8cd7c55c4f692744 (patch) | |
tree | c06d2747fcd2caa329a2ce514da1caa4264110cd /src/primitives | |
parent | cbe9ae8c69b947c8cdff2e0fbf5b57c9aa09b770 (diff) |
Adding method GetTotalSize() to CTransaction
GetTotalSize() returns the total transaction size (including witness) in
bytes.
Diffstat (limited to 'src/primitives')
-rw-r--r-- | src/primitives/transaction.cpp | 5 | ||||
-rw-r--r-- | src/primitives/transaction.h | 7 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/primitives/transaction.cpp b/src/primitives/transaction.cpp index 2fdc59ea07..4afbe99fd3 100644 --- a/src/primitives/transaction.cpp +++ b/src/primitives/transaction.cpp @@ -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; diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h index 5689d15bf7..16c2e5c454 100644 --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -415,6 +415,13 @@ public: // 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 { |