MCPcopy
hub / github.com/petertodd/python-bitcoinlib / CTxWitness

Class CTxWitness

bitcoin/core/__init__.py:307–343  ·  view source on GitHub ↗

Witness data for all inputs to a transaction

Source from the content-addressed store, hash-verified

305 return cls(txinwitness.scriptWitness)
306
307class CTxWitness(ImmutableSerializable):
308 """Witness data for all inputs to a transaction"""
309 __slots__ = ['vtxinwit']
310
311 def __init__(self, vtxinwit=()):
312 object.__setattr__(self, 'vtxinwit', vtxinwit)
313
314 def is_null(self):
315 for n in range(len(self.vtxinwit)):
316 if not self.vtxinwit[n].is_null(): return False
317 return True
318
319 # FIXME this cannot be a @classmethod like the others because we need to
320 # know how many items to deserialize, which comes from len(vin)
321 def stream_deserialize(self, f):
322 vtxinwit = tuple(CTxInWitness.stream_deserialize(f) for dummy in
323 range(len(self.vtxinwit)))
324 return CTxWitness(vtxinwit)
325
326 def stream_serialize(self, f):
327 for i in range(len(self.vtxinwit)):
328 self.vtxinwit[i].stream_serialize(f)
329
330 def __repr__(self):
331 return "CTxWitness(%s)" % (','.join(repr(w) for w in self.vtxinwit))
332
333 @classmethod
334 def from_txwitness(cls, txwitness):
335 """Create an immutable copy of an existing TxWitness
336
337 If txwitness is already immutable (txwitness.__class__ is CTxWitness) it is returned
338 directly.
339 """
340 if txwitness.__class__ is CTxWitness:
341 return txwitness
342 else:
343 return cls(txwitness.vtxinwit)
344
345
346class CTransaction(ImmutableSerializable):

Callers 8

spend-p2wpkh.pyFile · 0.90
stream_deserializeMethod · 0.85
__init__Method · 0.85
stream_deserializeMethod · 0.85
GetTxidMethod · 0.85
__init__Method · 0.85
test_checkblockMethod · 0.85

Calls

no outgoing calls

Tested by 1

test_checkblockMethod · 0.68