예제 #1
0
class TestMinterSetCandidateOnTx(unittest.TestCase):
    def setUp(self):
        self.PRIVATE_KEY = '05ddcd4e6f7d248ed1388f0091fe345bf9bf4fc2390384e26005e7675c98b3c1'
        self.SIGNED_TX = 'f87c0102018a4d4e54000000000000000aa2e1a00eb98ea04ae466d8d38f490db3c99b3996a90e24243952ce9822c6dc1e2c1a43808001b845f8431ba0095aed433171fe5ac385ccd299507bdcad3dd2269794fd0d14d4f58327ddc87ea046ec7e4f8f9b477a1255485f36e0567e62283723ecc5a0bd1e5d201e53e85245'
        self.TX = MinterSetCandidateOnTx(
            **{
                'nonce':
                1,
                'chain_id':
                MinterTx.TESTNET_CHAIN_ID,
                'gas_coin':
                'MNT',
                'pub_key':
                'Mp0eb98ea04ae466d8d38f490db3c99b3996a90e24243952ce9822c6dc1e2c1a43'
            })

    def test_valid_tx(self):
        """
        Is tx instance of needed TX class.
        """

        self.assertIsInstance(self.TX, MinterSetCandidateOnTx)

    def test_sign_tx(self):
        """
        Sign transaction and check signed transaction
        """
        self.TX.sign(self.PRIVATE_KEY)

        self.assertEqual(self.TX.signed_tx, self.SIGNED_TX)

    def test_from_raw(self):
        tx = MinterTx.from_raw(raw_tx=self.SIGNED_TX)

        self.assertEqual(tx.pub_key, self.TX.pub_key)
예제 #2
0
 def setUp(self):
     self.PRIVATE_KEY = '05ddcd4e6f7d248ed1388f0091fe345bf9bf4fc2390384e26005e7675c98b3c1'
     self.SIGNED_TX = 'f87c0102018a4d4e54000000000000000aa2e1a00eb98ea04ae466d8d38f490db3c99b3996a90e24243952ce9822c6dc1e2c1a43808001b845f8431ba0095aed433171fe5ac385ccd299507bdcad3dd2269794fd0d14d4f58327ddc87ea046ec7e4f8f9b477a1255485f36e0567e62283723ecc5a0bd1e5d201e53e85245'
     self.TX = MinterSetCandidateOnTx(
         **{
             'nonce':
             1,
             'chain_id':
             MinterTx.TESTNET_CHAIN_ID,
             'gas_coin':
             'MNT',
             'pub_key':
             'Mp0eb98ea04ae466d8d38f490db3c99b3996a90e24243952ce9822c6dc1e2c1a43'
         })
예제 #3
0
        # Get nonce from API
        nonce = None
        for minterapi in minterapis:
            try:
                nonce = minterapi.get_nonce(address=wallet['address'])
                break
            except Exception as e:
                print(e.__str__())

        if nonce is None:
            raise

        if action == 'on':
            # Set candidate on tx
            tx = MinterSetCandidateOnTx(pub_key=pub_key,
                                        nonce=nonce,
                                        gas_coin='BIP')
            tx.sign(wallet['private_key'])
            tx_str = 'Set candidate ON tx: {}'.format(tx.signed_tx)
        elif action == 'off':
            # Set candidate off tx
            tx = MinterSetCandidateOffTx(pub_key=pub_key,
                                         nonce=nonce,
                                         gas_coin='BIP',
                                         gas_price=50)
            tx.sign(wallet['private_key'])
            tx_str = 'Set candidate OFF tx: {}'.format(tx.signed_tx)

        # Print collected data for user
        print('Public key: {}'.format(pub_key))
        print('From address: {}'.format(wallet['address']))
예제 #4
0
            try:
                if not multisig:
                    nonce = minterapi.get_nonce(address=wallet['address'])
                else:
                    nonce = minterapi.get_nonce(address=multi_addr)
                break
            except Exception as e:
                print(e.__str__())

        if nonce is None:
            raise

        if action == 'on':
            # Set candidate on tx
            tx = MinterSetCandidateOnTx(pub_key=pub_key,
                                        nonce=nonce,
                                        gas_coin='BIP')
            if multisig:
                tx.sign(private_key=privates_key, ms_address=multi_addr)
            else:
                tx.sign(wallet['private_key'])
            tx_str = 'Set candidate ON tx: {}'.format(tx.signed_tx)
        elif action == 'off':
            # Set candidate off tx
            tx = MinterSetCandidateOffTx(pub_key=pub_key,
                                         nonce=nonce,
                                         gas_coin='BIP',
                                         gas_price=50)
            if multisig:
                tx.sign(private_key=privates_key, ms_address=multi_addr)
            else:
예제 #5
0
        print('Specify correct tx action (on/off)')
        sys.exit(1)

    # Get params from user
    seed = getpass.getpass('Provide seed phrase (password like input): ')

    # When all data seems to be set, create txs
    try:
        # Get API and wallet
        minterapi = MinterAPI(api_url)
        wallet = MinterWallet.create(mnemonic=seed)

        if action == 'on':
            # Set candidate on tx
            tx = MinterSetCandidateOnTx(
                pub_key=pub_key,
                nonce=minterapi.get_nonce(address=wallet['address']),
                gas_coin='BIP')
            tx.sign(wallet['private_key'])
            tx_str = 'Set candidate ON tx: {}'.format(tx.signed_tx)
        elif action == 'off':
            # Set candidate off tx
            tx = MinterSetCandidateOffTx(
                pub_key=pub_key,
                nonce=minterapi.get_nonce(address=wallet['address']),
                gas_coin='BIP')
            tx.sign(wallet['private_key'])
            tx_str = 'Set candidate OFF tx: {}'.format(tx.signed_tx)

        # Print collected data for user
        print('Public key: {}'.format(pub_key))
        print('From address: {}'.format(wallet['address']))