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

Class CTxInWitness

test/functional/test_framework/messages.py:679–727  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

677
678
679class CTxInWitness:
680 __slots__ = ("scriptWitness", "vchIssuanceAmountRangeproof",
681 "vchInflationKeysRangeproof", "peginWitness")
682
683 def __init__(self):
684 self.vchIssuanceAmountRangeproof = b''
685 self.vchInflationKeysRangeproof = b''
686 self.scriptWitness = CScriptWitness()
687 self.peginWitness = CScriptWitness()
688
689 def deserialize(self, f):
690 self.vchIssuanceAmountRangeproof = deser_string(f)
691 self.vchInflationKeysRangeproof = deser_string(f)
692 self.scriptWitness.stack = deser_string_vector(f)
693 self.peginWitness.stack = deser_string_vector(f)
694
695 def serialize(self):
696 r = b''
697 r += ser_string(self.vchIssuanceAmountRangeproof)
698 r += ser_string(self.vchInflationKeysRangeproof)
699 r += ser_string_vector(self.scriptWitness.stack)
700 r += ser_string_vector(self.peginWitness.stack)
701 return r
702
703 # Used in taproot sighash calculation
704 def serialize_issuance_proofs(self):
705 r = b''
706 r += ser_string(self.vchIssuanceAmountRangeproof)
707 r += ser_string(self.vchInflationKeysRangeproof)
708 return r
709
710 def calc_witness_hash(self):
711 leaves = [
712 hash256(ser_string(self.vchIssuanceAmountRangeproof))[::-1].hex(),
713 hash256(ser_string(self.vchInflationKeysRangeproof))[::-1].hex(),
714 hash256(ser_string_vector(self.scriptWitness.stack))[::-1].hex(),
715 hash256(ser_string_vector(self.peginWitness.stack))[::-1].hex()
716 ]
717 return calcfastmerkleroot(leaves)
718
719 def __repr__(self):
720 return "CTxInWitness (%s, %s, %s %s)" % (self.vchIssuanceAmountRangeproof,
721 self.vchInflationKeysRangeproof, self.scriptWitness, self.peginWitness)
722
723 def is_null(self):
724 return len(self.vchIssuanceAmountRangeproof) == 0 \
725 and len(self.vchInflationKeysRangeproof) == 0 \
726 and self.peginWitness.is_null() \
727 and self.scriptWitness.is_null()
728
729
730class CTxOutWitness:

Calls

no outgoing calls