def pack(self): assert len(self.outputs) == len(self.amounts), "Outputs count must match amounts count" raw = self.input raw += Serializer.write_u32(self.number) raw += Serializer.write_u8(len(self.outputs)) for output in self.outputs: raw += output for amount in self.amounts: raw += Serializer.write_u32(amount) return raw
def pack(self): raw_block = Serializer.write_u32(self.timestamp) raw_block += Serializer.write_u16(len(self.prev_hashes)) for prev_hash in self.prev_hashes: raw_block += prev_hash raw_block += Serializer.write_u8(len(self.system_txs)) for tx in self.system_txs: raw_block += TransactionParser.pack(tx) raw_block += Serializer.write_u8(len(self.payment_txs)) for tx in self.payment_txs: raw_block += TransactionParser.pack(tx) return raw_block
def pack(self): raw_block = self.block.pack() raw_signed_block = Serializer.write_signature(self.signature) raw_signed_block += Serializer.write_u32(len(raw_block)) raw_signed_block += raw_block return raw_signed_block
def pack(self): raw = self.commit_hash raw += Serializer.write_private_key(self.key) return raw
def get_signing_hash(self, epoch_hash): return sha256(self.rand + Serializer.write_u32(self.pubkey_index) + epoch_hash).digest()
def pack(self): return Serializer.write_encrypted_data(self.rand) + \ Serializer.write_u32(self.pubkey_index) + \ Serializer.write_signature(self.signature)
def pack(self): raw = Serializer.write_u16(self.amount) raw += self.pubkey raw += Serializer.write_signature(self.signature) return raw
def pack(self): raw = Serializer.write_signature(self.signature) raw += Serializer.write_u32(self.pubkey_index) raw += self.pack_pieces() return raw
def pack(self): return self.generated_pubkey + Serializer.write_u32( self.pubkey_index) + Serializer.write_signature(self.signature)
def pack(self): return Serializer.write_signature(self.signature) + \ self.pack_fields()
def pack_fields(self): return self.pubkey + \ Serializer.write_timestamp(self.timestamp) + \ Serializer.write_u32(self.number_of_block)
def pack_conflicts(self): raw = Serializer.write_u8(len(self.conflicts)) for conflict in self.conflicts: raw += conflict return raw
def pack(self): raw = self.pack_conflicts() raw += Serializer.write_signature(self.signature) + \ Serializer.write_timestamp(self.timestamp) return raw
def pack(self): raw = self.pubkey raw += Serializer.write_signature(self.signature) return raw
def pack(self): raw = self.pack_conflicts() raw += Serializer.write_signature(self.signature) return raw
def pack_unsigned(self): raw = self.generated_pubkey raw += Serializer.write_u32(self.pubkey_index) return raw
def pack_fields(self): return self.pubkey + \ Serializer.write_timestamp(self.timestamp) + \ self.block_hash
def pack(self): raw = Serializer.write_private_key(self.key) return raw
def pack(tx): raw = b'' if isinstance(tx, PublicKeyTransaction): raw += Serializer.write_u8(Type.PUBLIC) elif isinstance(tx, SplitRandomTransaction): raw += Serializer.write_u8(Type.RANDOM) elif isinstance(tx, PrivateKeyTransaction): raw += Serializer.write_u8(Type.PRIVATE) elif isinstance(tx, CommitRandomTransaction): raw += Serializer.write_u8(Type.COMMIT) elif isinstance(tx, RevealRandomTransaction): raw += Serializer.write_u8(Type.REVEAL) elif isinstance(tx, StakeHoldTransaction): raw += Serializer.write_u8(Type.STAKEHOLD) elif isinstance(tx, StakeReleaseTransaction): raw += Serializer.write_u8(Type.STAKERELEASE) elif isinstance(tx, PenaltyTransaction): raw += Serializer.write_u8(Type.PENALTY) elif isinstance(tx, NegativeGossipTransaction): raw += Serializer.write_u8(Type.NEGATIVE_GOSSIP) elif isinstance(tx, PositiveGossipTransaction): raw += Serializer.write_u8(Type.POSITIVE_GOSSIP) elif isinstance(tx, PenaltyGossipTransaction): raw += Serializer.write_u8(Type.PENALTY_GOSSIP) elif isinstance(tx, PaymentTransaction): raw += Serializer.write_u8(Type.PAYMENT) else: assert False, "Cannot pack unknown transaction type" raw += tx.pack() return raw
def pack_pieces(self): raw = Serializer.write_u16(len(self.pieces)) for piece in self.pieces: raw += Serializer.write_u8(len(piece)) raw += piece return raw
def get_hash(self): return sha256(Serializer.write_u16(self.amount) + self.pubkey).digest()