Witness data for all inputs to a transaction
| 305 | return cls(txinwitness.scriptWitness) |
| 306 | |
| 307 | class 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 | |
| 346 | class CTransaction(ImmutableSerializable): |
no outgoing calls