def make_payload(self, message, signer_keypair=None): """Make a payload for the given message type""" self.validate(message=message, signer=signer_keypair) message_type = self.message_type inputs, outputs = self.make_addresses(message=message, signer_keypair=signer_keypair) if has_duplicates(inputs): raise ValueError("{} inputs duplicated addresses {}".format( self.message_type_name, addresser.parse_addresses(duplicates(inputs)), )) if has_duplicates(outputs): raise ValueError("{} outputs duplicated addresses {}".format( self.message_type_name, addresser.parse_addresses(duplicates(outputs)), )) if not set(outputs).issubset(set(inputs)): raise ValueError( "{} output addresses {} not contained in inputs".format( self.message_type_name, addresser.parse_addresses( set(outputs).difference(set(inputs))), )) return batcher.make_payload(message=message, message_type=message_type, inputs=inputs, outputs=outputs)
def make_payload(self, message, signer_keypair=None): """Make a payload for the given message type""" self.validate(message=message, signer=signer_keypair) message_type = self.message_type inputs, outputs = self.make_addresses( message=message, signer_keypair=signer_keypair ) inputs = set(inputs) outputs = set(outputs) if signer_keypair: inputs.add(addresser.user.address(object_id=signer_keypair.public_key)) if not outputs.issubset(inputs): raise ValueError( "{} output addresses {} not contained in inputs".format( self.message_type_name, addresser.parse_addresses(outputs.difference(inputs)), ) ) return batcher.make_payload( message=message, message_type=message_type, inputs=inputs, outputs=outputs )
def make_payload(self, message, signer_user_id, signer_keypair): """Make a payload for the given message type""" if not signer_keypair: raise ValueError( "{} signer_keypair is required".format(self.message_type_name) ) if not signer_user_id: raise ValueError( "{} signer_user_id is required".format(self.message_type_name) ) self.validate( message=message, signer=Signer(user_id=signer_user_id, public_key=signer_keypair.public_key), ) message_type = self.message_type inputs, outputs = self.make_addresses( message=message, signer_user_id=signer_user_id ) inputs = set(inputs) outputs = set(outputs) inputs.add(addresser.key.address(object_id=signer_keypair.public_key)) inputs.add(addresser.user.address(object_id=signer_user_id)) inputs.add( addresser.user.key.address( object_id=signer_user_id, related_id=signer_keypair.public_key ) ) if not outputs.issubset(inputs): raise ValueError( "{} output addresses {} not contained in inputs".format( self.message_type_name, addresser.parse_addresses(outputs.difference(inputs)), ) ) return batcher.make_payload( message=message, message_type=message_type, inputs=inputs, outputs=outputs, signer_user_id=signer_user_id, signer_public_key=signer_keypair.public_key, )