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

Class CMutableTransaction

bitcoin/core/__init__.py:468–496  ·  view source on GitHub ↗

A mutable transaction

Source from the content-addressed store, hash-verified

466
467@__make_mutable
468class CMutableTransaction(CTransaction):
469 """A mutable transaction"""
470 __slots__ = []
471
472 def __init__(self, vin=None, vout=None, nLockTime=0, nVersion=1, witness=None):
473 if not (0 <= nLockTime <= 0xffffffff):
474 raise ValueError('CTransaction: nLockTime must be in range 0x0 to 0xffffffff; got %x' % nLockTime)
475 self.nLockTime = nLockTime
476
477 if vin is None:
478 vin = []
479 self.vin = vin
480
481 if vout is None:
482 vout = []
483 self.vout = vout
484 self.nVersion = nVersion
485
486 if witness is None:
487 witness = CTxWitness([CTxInWitness() for dummy in range(len(vin))])
488 self.wit = witness
489
490 @classmethod
491 def from_tx(cls, tx):
492 """Create a fully mutable copy of a pre-existing transaction"""
493 vin = [CMutableTxIn.from_txin(txin) for txin in tx.vin]
494 vout = [CMutableTxOut.from_txout(txout) for txout in tx.vout]
495
496 return cls(vin, vout, tx.nLockTime, tx.nVersion, tx.wit)
497
498
499class CBlockHeader(ImmutableSerializable):

Calls

no outgoing calls