예제 #1
0
 def withdrewDelegate(self,
                      staking_blocknum,
                      node_id,
                      amount,
                      pri_key,
                      transaction_cfg=None):
     """
     Reduction/revocation of entrustment (all reductions are revoked)
     :param staking_blocknum: A unique indication of a pledge of a node
     :param node_id: The idled node Id (also called the candidate's node Id)
     :param amount: The amount of the entrusted reduction (unit:von, 1LAT = 10**18 von)
     :param pri_key: Private key for transaction
     :param transaction_cfg: Transaction basic configuration
           type: dict
           example:cfg = {
               "gas":100000000,
               "gasPrice":2000000000000,
               "nonce":1,
           }
     :return: if is need analyze return transaction result dict
               if is not need analyze return transaction hash
     """
     data = rlp.encode([
         rlp.encode(int(1005)),
         rlp.encode(staking_blocknum),
         rlp.encode(bytes.fromhex(node_id)),
         rlp.encode(amount)
     ])
     return send_obj_transaction(self, data, self.web3.stakingAddress,
                                 pri_key, transaction_cfg)
예제 #2
0
 def declareVersion(self,
                    active_node,
                    program_version,
                    version_sign,
                    pri_key,
                    transaction_cfg=None):
     """
     Version statement
     :param active_node: The declared node can only be a verifier/candidate
     :param program_version: The declared version, obtained by rpc's getProgramVersion interface
     :param version_sign: The signed version signature, obtained by rpc's getProgramVersion interface
     :param pri_key: Private key for transaction
     :param transaction_cfg: Transaction basic configuration
           type: dict
           example:cfg = {
               "gas":100000000,
               "gasPrice":2000000000000,
               "nonce":1,
           }
     :return: if is need analyze return transaction result dict
             if is not need analyze return transaction hash
     """
     if version_sign[0:2] == '0x':
         version_sign = version_sign[2:]
     data = rlp.encode([
         rlp.encode(int(2004)),
         rlp.encode(bytes.fromhex(active_node)),
         rlp.encode(int(program_version)),
         rlp.encode(bytes.fromhex(version_sign))
     ])
     return send_obj_transaction(self, data, self.web3.pipAddress, pri_key,
                                 transaction_cfg)
예제 #3
0
 def editCandidate(self, benifit_address, node_id, external_id, node_name, website, details, pri_key, reward_per, transaction_cfg=None):
     """
     Modify staking information
     :param benifit_address: Income account for accepting block rewards and staking rewards
     :param node_id: The idled node Id (also called the candidate's node Id)
     :param external_id: External Id (with length limit, Id for the third party to pull the node description)
     :param node_name: The name of the staking node (with a length limit indicating the name of the node)
     :param website: The third-party home page of the node (with a length limit indicating the home page of the node)
     :param details: Description of the node (with a length limit indicating the description of the node)
     :param pri_key: Private key for transaction
     :param reward_per: Proportion of the reward share obtained from the commission, using BasePoint 1BP = 0.01%
     :param transaction_cfg: Transaction basic configuration
           type: dict
           example:cfg = {
               "gas":100000000,
               "gasPrice":2000000000000,
               "nonce":1,
           }
     :return: if is need analyze return transaction result dict
             if is not need analyze return transaction hash
     """
     # if benifit_address[:2] == '0x':
     #     benifit_address = benifit_address[2:]
     benifit_address = bech32_address_bytes(benifit_address)
     data = HexBytes(rlp.encode([rlp.encode(int(1001)), rlp.encode(benifit_address), rlp.encode(bytes.fromhex(node_id)),
                                 rlp.encode(reward_per),
                                 rlp.encode(external_id), rlp.encode(node_name), rlp.encode(website), rlp.encode(details)])).hex()
     return send_obj_transaction(self, data, self.web3.stakingAddress, pri_key, transaction_cfg)
예제 #4
0
 def delegate(self, typ, node_id, amount, pri_key, transaction_cfg=None):
     """
     Initiate delegate
     :param typ: Indicates whether the account free amount or the account's lock amount is used for delegate, 0: free amount; 1: lock amount
     :param node_id: The idled node Id (also called the candidate's node Id)
     :param amount: Amount of delegate (unit:von, 1LAT = 10**18 von)
     :param pri_key: Private key for transaction
     :param transaction_cfg: Transaction basic configuration
           type: dict
           example:cfg = {
               "gas":100000000,
               "gasPrice":2000000000000,
               "nonce":1,
           }
     :return: if is need analyze return transaction result dict
               if is not need analyze return transaction hash
     """
     data = rlp.encode([
         rlp.encode(int(1004)),
         rlp.encode(typ),
         rlp.encode(bytes.fromhex(node_id)),
         rlp.encode(amount)
     ])
     return send_obj_transaction(self, data, self.web3.stakingAddress,
                                 pri_key, transaction_cfg)
예제 #5
0
 def increaseStaking(self,
                     typ,
                     node_id,
                     amount,
                     pri_key,
                     transaction_cfg=None):
     """
     Increase staking
     :param typ: Indicates whether the account free amount or the account's lock amount is used for staking, 0: free amount; 1: lock amount;
                 2: Give priority to lock amount , use free amount provided that staking amount over lock amount
     :param node_id: The idled node Id (also called the candidate's node Id)
     :param amount: staking von (unit:von, 1LAT = 10**18 von)
     :param pri_key: Private key for transaction
     :param transaction_cfg: Transaction basic configuration
           type: dict
           example:cfg = {
               "gas":100000000,
               "gasPrice":2000000000000,
               "nonce":1,
           }
     :return: if is need analyze return transaction result dict
             if is not need analyze return transaction hash
     """
     data = HexBytes(
         rlp.encode([
             rlp.encode(int(1002)),
             rlp.encode(bytes.fromhex(node_id)),
             rlp.encode(typ),
             rlp.encode(amount)
         ])).hex()
     return send_obj_transaction(self, data, self.stakingAddress, pri_key,
                                 transaction_cfg)
예제 #6
0
 def setValidatorList(self,
                      node_list,
                      pri_key,
                      transaction_cfg={"gas": 210000}):
     data_list = []
     for node_id in node_list:
         data_list.append(bytes.fromhex(node_id))
     data = HexBytes(
         rlp.encode([rlp.encode(int(1900)),
                     rlp.encode(data_list)])).hex()
     return send_obj_transaction(self, data, self.web3.stakingAddress,
                                 pri_key, transaction_cfg)
예제 #7
0
 def withdrewStaking(self, node_id, pri_key, transaction_cfg=None):
     """
     Withdrawal of staking (one-time initiation of all cancellations, multiple arrivals)
     :param node_id: The idled node Id (also called the candidate's node Id)
     :param pri_key: Private key for transaction
     :param transaction_cfg: Transaction basic configuration
           type: dict
           example:cfg = {
               "gas":100000000,
               "gasPrice":2000000000000,
               "nonce":1,
           }
     :return: if is need analyze return transaction result dict
             if is not need analyze return transaction hash
     """
     data = rlp.encode([rlp.encode(int(1003)), rlp.encode(bytes.fromhex(node_id))])
     return send_obj_transaction(self, data, self.web3.stakingAddress, pri_key, transaction_cfg)
예제 #8
0
 def reportDuplicateSign(self, typ, data, pri_key, transaction_cfg=None):
     """
     Report duplicate sign
     :param typ: Represents duplicate sign type, 1:prepareBlock, 2: prepareVote, 3:viewChange
     :param data: Json value of single evidence, format reference RPC interface Evidences
     :param pri_key: Private key for transaction
     :param transaction_cfg: Transaction basic configuration
           type: dict
           example:cfg = {
               "gas":100000000,
               "gasPrice":2000000000000,
               "nonce":1,
           }
     :return: if is need analyze return transaction result dict
             if is not need analyze return transaction hash
     """
     data = rlp.encode([rlp.encode(int(3000)), rlp.encode(typ), rlp.encode(data)])
     return send_obj_transaction(self, data, self.web3.penaltyAddress, pri_key, transaction_cfg)
예제 #9
0
 def createRestrictingPlan(self,
                           account,
                           plan,
                           pri_key,
                           transaction_cfg=None):
     """
     Create a lockout plan
     :param account: Locked account release account
     :param plan:
     An is a list of RestrictingPlan types (array), and RestrictingPlan is defined as follows:
     type RestrictingPlan struct {
         Epoch uint64
         Amount *big.Int
         }
      where Epoch: represents a multiple of the billing period.
      The product of the number of blocks per billing cycle indicates that the locked fund
      s are released at the target block height. Epoch * The number of blocks per cycle is
      at least greater than the maximum irreversible block height.
      Amount: indicates the amount to be released on the target block.
     :param pri_key: Private key for transaction
     :param transaction_cfg: Transaction basic configuration
           type: dict
           example:cfg = {
               "gas":100000000,
               "gasPrice":2000000000000,
               "nonce":1,
           }
     :return: if is need analyze return transaction result dict
             if is not need analyze return transaction hash
     """
     # if account[:2] == '0x':
     #     account = account[2:]
     account = bech32_address_bytes(account)
     plan_list = []
     for dict_ in plan:
         v = [dict_[k] for k in dict_]
         plan_list.append(v)
     rlp_list = rlp.encode(plan_list)
     data = rlp.encode(
         [rlp.encode(int(4000)),
          rlp.encode(account), rlp_list])
     return send_obj_transaction(self, data, self.web3.restrictingAddress,
                                 pri_key, transaction_cfg)
예제 #10
0
 def vote(self,
          verifier,
          proposal_id,
          option,
          program_version,
          version_sign,
          pri_key,
          transaction_cfg=None):
     """
     Vote for proposal
     :param verifier:  The certified submitting the proposal
     :param proposal_id: Proposal ID
     :param option: Voting option
     :param program_version: Node code version, obtained by rpc getProgramVersion interface
     :param version_sign: Code version signature, obtained by rpc getProgramVersion interface
     :param pri_key: Private key for transaction
     :param transaction_cfg: Transaction basic configuration
           type: dict
           example:cfg = {
               "gas":100000000,
               "gasPrice":2000000000000,
               "nonce":1,
           }
     :return: if is need analyze return transaction result dict
             if is not need analyze return transaction hash
     """
     if proposal_id[:2] == '0x':
         proposal_id = proposal_id[2:]
     if version_sign[:2] == '0x':
         version_sign = version_sign[2:]
     data = rlp.encode([
         rlp.encode(int(2003)),
         rlp.encode(bytes.fromhex(verifier)),
         rlp.encode(bytes.fromhex(proposal_id)),
         rlp.encode(option),
         rlp.encode(int(program_version)),
         rlp.encode(bytes.fromhex(version_sign))
     ])
     return send_obj_transaction(self, data, self.web3.pipAddress, pri_key,
                                 transaction_cfg)
예제 #11
0
 def submitVersion(self,
                   verifier,
                   pip_id,
                   new_version,
                   end_voting_rounds,
                   pri_key,
                   transaction_cfg=None):
     """
     Submit an upgrade proposal
     :param verifier:  The certified submitting the proposal
     :param pip_id:  PIPID
     :param new_version: upgraded version
     :param end_voting_rounds: The number of voting consensus rounds.
         Explanation: Assume that the transaction submitted by the proposal is rounded when the consensus round
         number of the package is packed into the block, then the proposal voting block is high,
         which is the 230th block height of the round of the round1 + endVotingRounds
         (assuming a consensus round out of block 250, ppos The list is 20 blocks high in advance,
          250, 20 are configurable), where 0 < endVotingRounds <= 4840 (about 2 weeks, the actual discussion
          can be calculated according to the configuration), and is an integer)
     :param pri_key: Private key for transaction
     :param transaction_cfg: Transaction basic configuration
           type: dict
           example:cfg = {
               "gas":100000000,
               "gasPrice":2000000000000,
               "nonce":1,
           }
     :return: if is need analyze return transaction result dict
             if is not need analyze return transaction hash
     """
     data = rlp.encode([
         rlp.encode(int(2001)),
         rlp.encode(bytes.fromhex(verifier)),
         rlp.encode(pip_id),
         rlp.encode(int(new_version)),
         rlp.encode(int(end_voting_rounds))
     ])
     return send_obj_transaction(self, data, self.web3.pipAddress, pri_key,
                                 transaction_cfg)
예제 #12
0
    def submitCancel(self,
                     verifier,
                     pip_id,
                     end_voting_rounds,
                     tobe_canceled_proposal_id,
                     pri_key,
                     transaction_cfg=None):
        """
        Submit cancellation proposal
        :param verifier: The certified submitting the proposal
        :param pip_id: PIPID
        :param end_voting_rounds:
           The number of voting consensus rounds. Refer to the instructions for submitting the upgrade proposal.
           At the same time, the value of this parameter in this interface
           cannot be greater than the value in the corresponding upgrade proposal.
        :param tobe_canceled_proposal_id: Upgrade proposal ID to be cancelled
        :param pri_key: Private key for transaction
        :param transaction_cfg: Transaction basic configuration
              type: dict
              example:cfg = {
                  "gas":100000000,
                  "gasPrice":2000000000000,
                  "nonce":1,
              }
        :return: if is need analyze return transaction result dict
                if is not need analyze return transaction hash
        """
        if tobe_canceled_proposal_id[:2] == '0x':
            tobe_canceled_proposal_id = tobe_canceled_proposal_id[2:]
        data = rlp.encode([
            rlp.encode(int(2005)),
            rlp.encode(bytes.fromhex(verifier)),
            rlp.encode(pip_id),
            rlp.encode(int(end_voting_rounds)),
            rlp.encode(bytes.fromhex(tobe_canceled_proposal_id))
        ])

        return send_obj_transaction(self, data, self.web3.pipAddress, pri_key,
                                    transaction_cfg)
예제 #13
0
 def createStaking(self, typ, benifit_address, node_id, external_id, node_name, website, details, amount,
                   program_version, program_version_sign, bls_pubkey, bls_proof, pri_key, reward_per, transaction_cfg=None):
     """
     Initiate Staking
     :param typ: Indicates whether the account free amount or the account's lock amount is used for staking, 0: free amount; 1: lock amount
     :param benifit_address: Income account for accepting block rewards and staking rewards
     :param node_id: The idled node Id (also called the candidate's node Id)
     :param external_id: External Id (with length limit, Id for the third party to pull the node description)
     :param node_name: The name of the staking node (with a length limit indicating the name of the node)
     :param website: The third-party home page of the node (with a length limit indicating the home page of the node)
     :param details: Description of the node (with a length limit indicating the description of the node)
     :param amount: staking von (unit:von, 1LAT = 10**18 von)
     :param program_version: The real version of the program, admin_getProgramVersion
     :param program_version_sign: The real version of the program is signed, admin_getProgramVersion
     :param bls_pubkey: Bls public key
     :param bls_proof: Proof of bls, obtained by pulling the proof interface, admin_getSchnorrNIZKProve
     :param pri_key: Private key for transaction
     :param reward_per: Proportion of the reward share obtained from the commission, using BasePoint 1BP = 0.01%
     :param transaction_cfg: Transaction basic configuration
           type: dict
           example:cfg = {
               "gas":100000000,
               "gasPrice":2000000000000,
               "nonce":1,
           }
     :return: if is need analyze return transaction result dict
             if is not need analyze return transaction hash
     """
     benifit_address = bech32_address_bytes(benifit_address)
     if program_version_sign[:2] == '0x':
         program_version_sign = program_version_sign[2:]
     data = HexBytes(rlp.encode([rlp.encode(int(1000)), rlp.encode(typ), rlp.encode(benifit_address),
                                 rlp.encode(bytes.fromhex(node_id)), rlp.encode(external_id), rlp.encode(node_name),
                                 rlp.encode(website), rlp.encode(details),
                                 rlp.encode(amount), rlp.encode(reward_per), rlp.encode(program_version),
                                 rlp.encode(bytes.fromhex(program_version_sign)), rlp.encode(bytes.fromhex(bls_pubkey)),
                                 rlp.encode(bytes.fromhex(bls_proof))])).hex()
     return send_obj_transaction(self, data, self.web3.stakingAddress, pri_key, transaction_cfg)
예제 #14
0
 def submitText(self, verifier, pip_id, pri_key, transaction_cfg=None):
     """
     Submit a text proposal
     :param verifier: The certified submitting the proposal
     :param pip_id: PIPID
     :param pri_key: Private key for transaction
     :param transaction_cfg: Transaction basic configuration
           type: dict
           example:cfg = {
               "gas":100000000,
               "gasPrice":2000000000000,
               "nonce":1,
           }
     :return: if is need analyze return transaction result dict
             if is not need analyze return transaction hash
     """
     data = rlp.encode([
         rlp.encode(int(2000)),
         rlp.encode(bytes.fromhex(verifier)),
         rlp.encode(pip_id)
     ])
     return send_obj_transaction(self, data, self.web3.pipAddress, pri_key,
                                 transaction_cfg)
예제 #15
0
 def submitParam(self,
                 verifier,
                 pip_id,
                 module,
                 name,
                 new_value,
                 pri_key,
                 transaction_cfg=None):
     """
     Submit an param proposal
     :param verifier: The certified submitting the proposal
     :param pip_id: PIPID
     :param module: parameter module
     :param name: parameter name
     :param new_value: New parameter value
     :param pri_key: Private key for transaction
     :param transaction_cfg: Transaction basic configuration
           type: dict
           example:cfg = {
               "gas":100000000,
               "gasPrice":2000000000000,
               "nonce":1,
           }
     :return: if is need analyze return transaction result dict
             if is not need analyze return transaction hash
     """
     data = rlp.encode([
         rlp.encode(int(2002)),
         rlp.encode(bytes.fromhex(verifier)),
         rlp.encode(pip_id),
         rlp.encode(module),
         rlp.encode(name),
         rlp.encode(new_value)
     ])
     return send_obj_transaction(self, data, self.pipAddress, pri_key,
                                 transaction_cfg)
예제 #16
0
 def withdrawDelegateReward(self, pri_key, transaction_cfg=None):
     data = rlp.encode([rlp.encode(int(5000))])
     return send_obj_transaction(self, data, self.web3.delegateRewardAddress, pri_key, transaction_cfg)