示例#1
0
    def register(self, save=False):
        client = get_client()
        keys = [str(self.ident), self.material.ident]
        txid = client.publishfrom(
            self.licensor.address,
            settings.STREAM_SMART_LICENSE,
            keys,
            self.to_primitive()
        )

        # Create token if tokenize transaction model
        if self.transaction_model.ident == ActivationMode.TOKEN:
            client.issue(
                address=self.licensor.address,
                asset_name_or_asset_params={
                    'name': self.ident.bytes.hex(),
                    'open': True
                },
                quantity=1000,
                smallest_unit=1,
                native_amount=0.1,
                custom_fields={
                    'info': self.info,
                    'type': 'smart-license'
                }
            )
        if save:
            self.txid = txid
            self.save()
        return txid
示例#2
0
def validate_address(value):
    client = get_client()
    result = client.validateaddress(value)
    if result.get('isvalid') is False:
        raise ValidationError(
            _('%(value)s is not a valid address'),
            params={'value': value},
        )
示例#3
0
 def register(self):
     client = get_client()
     token_name = self.smart_license.ident.bytes.hex()
     txid = client.sendasset(
         address=self.recipient,
         asset_identifier=token_name,
         asset_qty=1,
         native_amount=0.1
     )
     return txid
示例#4
0
    def handle(self, *args, **options):
        client = get_client()

        user_obj = User.objects.get(username='******')
        addrs = client.getaddresses()
        for addr in addrs:
            print('Import WalletID:', addr)
            wid, created = WalletID.objects.get_or_create(
                owner=user_obj,
                address=addr,
                memo='Demo User Wallet'
            )
            if created:
                print('Imported WalletID:', wid)
            else:
                print(wid, 'already exists.')
示例#5
0
 def register(self, save=False):
     client = get_client()
     smart_license_id = str(self.smart_license.ident)
     licensor = self.smart_license.licensor.address
     licensee = self.licensee
     data = {
         'json': {'licensee': licensee}
     }
     txid = client.publishfrom(
         from_address=licensor,
         stream_identifier=settings.STREAM_SMART_LICENSE,
         key_or_keys=['ATT', smart_license_id],
         data_hex_or_data_obj=data
     )
     if save:
         self.txid = txid
         self.save()
     return txid
示例#6
0
    def register(self):
        # Register ISCC
        data = {
            'json': {
                'title': self.title,
                'tophash': self.tophash,
            }
        }
        if self.extra:
            data['json']['extra'] = self.extra

        client = get_client()
        txid = client.publish(
            settings.STREAM_ISCC,
            key_or_keys=list(self.ident.split('-')),
            data_hex_or_data_obj=data
        )
        return txid