Пример #1
0
 def remove_attribute(self, did: str, operator: Account, attrib_key: str,
                      payer: Account, gas_price: int, gas_limit: int):
     """
     This interface is used to send a Transaction object which is used to remove attribute.
     """
     pub_key = operator.get_public_key_bytes()
     b58_payer_address = payer.get_address_base58()
     tx = self.new_remove_attribute_tx(did, pub_key, attrib_key,
                                       b58_payer_address, gas_price,
                                       gas_limit)
     tx.sign_transaction(operator)
     tx.add_sign_transaction(payer)
     return self._sdk.default_network.send_raw_transaction(tx)
Пример #2
0
 async def add_recovery(self, ont_id: str, ctrl_acct: Account,
                        b58_recovery_address: str, payer: Account,
                        gas_price: int, gas_limit: int):
     """
     This interface is used to send a Transaction object which is used to add the recovery.
     """
     b58_payer_address = payer.get_address_base58()
     pub_key = ctrl_acct.get_public_key_bytes()
     tx = self.new_add_recovery_tx(ont_id, pub_key, b58_recovery_address,
                                   b58_payer_address, gas_price, gas_limit)
     tx.sign_transaction(ctrl_acct)
     tx.add_sign_transaction(payer)
     tx_hash = await self._sdk.default_aio_network.send_raw_transaction(tx)
     return tx_hash
Пример #3
0
 def registry_did(self, did: str, ctrl_acct: Account, payer: Account,
                  gas_price: int, gas_limit: int):
     """
     This interface is used to send a Transaction object which is used to registry did.
     """
     if not isinstance(ctrl_acct, Account) or not isinstance(
             payer, Account):
         raise SDKException(ErrorCode.require_acct_params)
     b58_payer_address = payer.get_address_base58()
     bytes_ctrl_pub_key = ctrl_acct.get_public_key_bytes()
     tx = self.new_registry_did_tx(did, bytes_ctrl_pub_key,
                                   b58_payer_address, gas_price, gas_limit)
     tx.sign_transaction(ctrl_acct)
     tx.add_sign_transaction(payer)
     return self._sdk.default_network.send_raw_transaction(tx)
Пример #4
0
 def add_sign_transaction(self, signer: Account):
     """
     This interface is used to add signature into the transaction.
     """
     if self.sig_list is None or len(self.sig_list) == 0:
         self.sig_list = []
     elif len(self.sig_list) >= TX_MAX_SIG_SIZE:
         raise SDKException(
             ErrorCode.param_err(
                 'the number of transaction signatures should not be over 16'
             ))
     tx_hash = self.hash256()
     sig_data = signer.generate_signature(tx_hash)
     sig = Sig([signer.get_public_key_bytes()], 1, [sig_data])
     self.sig_list.append(sig)
Пример #5
0
 async def add_attribute(self, ont_id: str, ctrl_acct: Account,
                         attributes: Attribute, payer: Account,
                         gas_price: int, gas_limit: int) -> str:
     """
     This interface is used to send a Transaction object which is used to add attribute.
     """
     if not isinstance(ctrl_acct, Account) or not isinstance(
             payer, Account):
         raise SDKException(ErrorCode.require_acct_params)
     pub_key = ctrl_acct.get_public_key_bytes()
     b58_payer_address = payer.get_address_base58()
     tx = self.new_add_attribute_tx(ont_id, pub_key, attributes,
                                    b58_payer_address, gas_price, gas_limit)
     tx.sign_transaction(ctrl_acct)
     tx.add_sign_transaction(payer)
     tx_hash = await self._sdk.default_aio_network.send_raw_transaction(tx)
     return tx_hash
Пример #6
0
 async def add_public_key(self,
                          ont_id: str,
                          operator: Account,
                          hex_new_public_key: str,
                          payer: Account,
                          gas_price: int,
                          gas_limit: int,
                          is_recovery: bool = False):
     """
     This interface is used to send a Transaction object which is used to add public key.
     """
     if not isinstance(operator, Account) or not isinstance(payer, Account):
         raise SDKException(ErrorCode.require_acct_params)
     if is_recovery:
         bytes_operator = operator.get_address_bytes()
     else:
         bytes_operator = operator.get_public_key_bytes()
     b58_payer_address = payer.get_address_base58()
     tx = self.new_add_public_key_tx(ont_id, bytes_operator,
                                     hex_new_public_key, b58_payer_address,
                                     gas_price, gas_limit, is_recovery)
     tx.sign_transaction(operator)
     tx.add_sign_transaction(payer)
     return await self._sdk.default_aio_network.send_raw_transaction(tx)
Пример #7
0
 def test_get_public_key_bytes(self):
     hex_private_key = '523c5fcf74823831756f0bcb3634234f10b3beb1c05595058534577752ad2d9f'
     hex_public_key = "03036c12be3726eb283d078dff481175e96224f0b0c632c7a37e10eb40fe6be889"
     account = Account(hex_private_key, SignatureScheme.SHA256withECDSA)
     self.assertEqual(hex_public_key, account.get_public_key_bytes().hex())