def test_hashing_name_hashing(): assert hashing.namehash_encode( 'nm', 'welghmolql.test' ) == 'nm_Ziiq3M9ASEHXCV71qUNde6SsomqwZjYPFvnJSvTkpSUDiXqH3' assert hashing.namehash_encode( 'pp', 'welghmolql.test' ) == 'pp_Ziiq3M9ASEHXCV71qUNde6SsomqwZjYPFvnJSvTkpSUDiXqH3' assert hashing.namehash_encode( 'nm', 'abc.test') != 'nm_2KrC4asc6fdv82uhXDwfiqB1TY2htjhnzwzJJKLxidyMymJRUQ'
def transfer_ownership(self, account, recipient_pubkey, fee=defaults.FEE, tx_ttl=defaults.TX_TTL): """ transfer ownership of a name :return: the transaction """ # get the name_id and pointers name_id = hashing.namehash_encode(NAME, self.domain) # get the transaction builder txb = self.client.tx_builder # get the account nonce and ttl nonce, ttl = self.client._get_nonce_ttl(account.get_address(), tx_ttl) # create transaction tx = txb.tx_name_transfer(account.get_address(), name_id, recipient_pubkey, fee, ttl, nonce) # sign the transaction tx_signed = self.client.sign_transaction(account, tx.tx) # post the transaction to the chain self.client.broadcast_transaction(tx_signed.tx, tx_signed.hash) # update the status self.status = NameStatus.TRANSFERRED return tx_signed
def update(self, account, target, name_ttl=defaults.NAME_TTL, client_ttl=defaults.NAME_CLIENT_TTL, fee=defaults.FEE, tx_ttl=defaults.TX_TTL): if not self.check_claimed(): raise NameUpdateError('Must be claimed to update pointer') if isinstance(target, oracles.Oracle): if target.oracle_id is None: raise ValueError( 'You must register the oracle before using it as target') target = target.oracle_id # get the name_id and pointers name_id = hashing.namehash_encode(NAME, self.domain) pointers = self._get_pointers(target) # get the transaction builder txb = self.client.tx_builder # get the account nonce and ttl nonce, ttl = self.client._get_nonce_ttl(account.get_address(), tx_ttl) # create transaction tx = txb.tx_name_update(account.get_address(), name_id, pointers, name_ttl, client_ttl, fee, ttl, nonce) # sign the transaction tx_signed = self.client.sign_transaction(account, tx.tx) # post the transaction to the chain self.client.broadcast_transaction(tx_signed.tx, tx_signed.hash) return tx_signed
def update(self, account, target, name_ttl=DEFAULT_NAME_TTL, client_ttl=NAME_CLIENT_TTL, fee=DEFAULT_FEE, tx_ttl=DEFAULT_TX_TTL): if self.status != NameStatus.CLAIMED: raise NameUpdateError('Must be claimed to update pointer') if isinstance(target, oracle.Oracle): if target.oracle_id is None: raise ValueError( 'You must register the oracle before using it as target') target = target.oracle_id # TODO: check the value for name ttl? # get the name_id and pointers name_id = hashing.namehash_encode("nm", self.domain) pointers = self._get_pointers(target) # get the transaction builder txb = TxBuilder(self.client, account) # create claim transaction tx, sg, tx_hash = txb.tx_name_update(name_id, pointers, name_ttl, client_ttl, fee, tx_ttl) # post the transaction to the chain txb.post_transaction(tx, tx_hash) # ensure tx if self.client.blocking_mode: txb.wait_tx(tx_hash) return tx_hash
def revoke(self, account, fee=DEFAULT_FEE, tx_ttl=DEFAULT_TX_TTL): """ revoke a name :return: the transaction """ # get the name_id and pointers name_id = hashing.namehash_encode("nm", self.domain) # get the transaction builder txb = TxBuilder(self.client, account) # create claim transaction tx, sg, tx_hash = txb.tx_name_revoke(name_id, fee, tx_ttl) # post the transaction to the chain txb.post_transaction(tx, tx_hash) # ensure tx if self.client.blocking_mode: txb.wait_tx(tx_hash) self.status = NameStatus.REVOKED return tx_hash
def transfer_ownership(self, account, recipient_pubkey, fee=DEFAULT_FEE, tx_ttl=DEFAULT_TX_TTL): """ transfer ownership of a name :return: the transaction """ # get the name_id and pointers name_id = hashing.namehash_encode("nm", self.domain) # get the transaction builder txb = TxBuilder(self.client, account) # create claim transaction tx, sg, tx_hash = txb.tx_name_transfer(name_id, recipient_pubkey, fee, tx_ttl) # post the transaction to the chain txb.post_transaction(tx, tx_hash) # update local status self.status = NameStatus.TRANSFERRED # ensure tx if self.client.blocking_mode: txb.wait_tx(tx_hash) return tx_hash