MCPcopy Create free account
hub / github.com/ElementsProject/elements / CTxIn

Class CTxIn

test/functional/test_framework/messages.py:432–487  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

430 return "CAssetIssuance(assetBlindingNonce=%064x assetEntropy=%064x nAmount=%s nInflationKeys=%s)" % (self.assetBlindingNonce, self.assetEntropy, self.nAmount.vchCommitment, self.nInflationKeys.vchCommitment)
431
432class CTxIn:
433 __slots__ = ("nSequence", "prevout", "scriptSig", "m_is_pegin", "assetIssuance")
434
435 def __init__(self, outpoint=None, scriptSig=b"", nSequence=0):
436 if outpoint is None:
437 self.prevout = COutPoint()
438 else:
439 self.prevout = outpoint
440 self.scriptSig = scriptSig
441 self.nSequence = nSequence
442 self.m_is_pegin = False
443 self.assetIssuance = CAssetIssuance()
444
445 def deserialize(self, f):
446 self.prevout = COutPoint()
447 self.prevout.deserialize(f)
448
449 has_asset_issuance = False
450 # Do masking, extract presence of assetIssuance
451 if not self.prevout.isNull(): # ignore coinbase for issuance/pegin
452 if self.prevout.n & OUTPOINT_ISSUANCE_FLAG > 0:
453 has_asset_issuance = True
454 if self.prevout.n & OUTPOINT_PEGIN_FLAG > 0:
455 self.m_is_pegin = True
456 self.prevout.n = self.prevout.n & OUTPOINT_INDEX_MASK
457
458 self.scriptSig = deser_string(f)
459 self.nSequence = struct.unpack("<I", f.read(4))[0]
460
461 if has_asset_issuance:
462 self.assetIssuance = CAssetIssuance()
463 self.assetIssuance.deserialize(f)
464
465 def serialize(self):
466 outpoint = COutPoint()
467 outpoint.hash = self.prevout.hash
468 outpoint.n = self.prevout.n
469 # First apply peg-in and issuance logic to prevout.n, before serializing
470 if self.prevout.n != 4294967295: # ignore coinbase for issuance/pegin
471 if not self.assetIssuance.isNull():
472 outpoint.n |= OUTPOINT_ISSUANCE_FLAG
473 if self.m_is_pegin:
474 outpoint.n |= OUTPOINT_PEGIN_FLAG
475
476 r = b""
477 r += outpoint.serialize()
478 r += ser_string(self.scriptSig)
479 r += struct.pack("<I", self.nSequence)
480 if self.prevout.n != 4294967295 and outpoint.n & OUTPOINT_ISSUANCE_FLAG:
481 r += self.assetIssuance.serialize()
482 return r
483
484 def __repr__(self):
485 return "CTxIn(prevout=%s scriptSig=%s nSequence=%i m_is_pegin=%s assetIssuance=%s)" \
486 % (repr(self.prevout), self.scriptSig.hex(),
487 self.nSequence, self.m_is_pegin, self.assetIssuance)
488
489class CTxOutAsset:

Callers 15

run_testMethod · 0.90
pegin_testMethod · 0.90
issuance_testMethod · 0.90
run_testMethod · 0.90
run_testMethod · 0.90
make_utxosMethod · 0.90
test_disable_flagMethod · 0.90

Calls

no outgoing calls