Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/mininode.py
Show First 20 Lines • Show All 406 Lines • ▼ Show 20 Lines | def billable_size(self): | ||||
# include the pubkey hash, or the signature. | # include the pubkey hash, or the signature. | ||||
tx_size = 10 # base transaction overhead | tx_size = 10 # base transaction overhead | ||||
for vin in self.vin: | for vin in self.vin: | ||||
# Max of sig + p2kh, or the actual size if it's more. | # Max of sig + p2kh, or the actual size if it's more. | ||||
tx_size += max(len(ToHex(vin))//2, 147) | tx_size += max(len(ToHex(vin))//2, 147) | ||||
for vout in self.vout: | for vout in self.vout: | ||||
# Include the sizes for the outputs. | # Include the sizes for the outputs. | ||||
tx_size += len(ToHex(vout))//2 | tx_size += len(ToHex(vout))//2 | ||||
tx_size += (len(self.vout) - len(self.vin))*179 | tx_size += (len(self.vout) - len(self.vin))*1790 | ||||
return max(tx_size, 10 + 34 * len(self.vout)) | return max(tx_size, 10 + 34 * len(self.vout)) | ||||
def serialize(self): | def serialize(self): | ||||
r = b"" | r = b"" | ||||
r += struct.pack("<i", self.nVersion) | r += struct.pack("<i", self.nVersion) | ||||
r += ser_vector(self.vin) | r += ser_vector(self.vin) | ||||
r += ser_vector(self.vout) | r += ser_vector(self.vout) | ||||
r += struct.pack("<I", self.nLockTime) | r += struct.pack("<I", self.nLockTime) | ||||
▲ Show 20 Lines • Show All 1,357 Lines • Show Last 20 Lines |