mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-05 21:24:47 +02:00
test: introduce get_weight()
helper for CTransaction
This commit is contained in:
@ -590,12 +590,15 @@ class CTransaction:
|
||||
return False
|
||||
return True
|
||||
|
||||
# Calculate the virtual transaction size using witness and non-witness
|
||||
# Calculate the transaction weight using witness and non-witness
|
||||
# serialization size (does NOT use sigops).
|
||||
def get_vsize(self):
|
||||
def get_weight(self):
|
||||
with_witness_size = len(self.serialize_with_witness())
|
||||
without_witness_size = len(self.serialize_without_witness())
|
||||
return math.ceil(((WITNESS_SCALE_FACTOR - 1) * without_witness_size + with_witness_size) / WITNESS_SCALE_FACTOR)
|
||||
return (WITNESS_SCALE_FACTOR - 1) * without_witness_size + with_witness_size
|
||||
|
||||
def get_vsize(self):
|
||||
return math.ceil(self.get_weight() / WITNESS_SCALE_FACTOR)
|
||||
|
||||
def __repr__(self):
|
||||
return "CTransaction(nVersion=%i vin=%s vout=%s wit=%s nLockTime=%i)" \
|
||||
|
Reference in New Issue
Block a user