コード例 #1
0
    def test_3_wallet_no_claimable_gas(self):

        wallet = self.GetWallet1()

        result = ClaimGas(wallet, require_password=False)

        self.assertFalse(result)
コード例 #2
0
    def show_wallet(self, arguments):
        if not self.Wallet:
            print("Please open a wallet")
            return

        item = get_arg(arguments)

        if not item:
            print("Wallet %s " % json.dumps(self.Wallet.ToJson(), indent=4))
            return

        if item in ['v', '--v', 'verbose']:
            print("Wallet %s " %
                  json.dumps(self.Wallet.ToJson(verbose=True), indent=4))
            return
        elif item == 'migrate' and self.Wallet is not None:
            self.Wallet.Migrate()
            print("Migrated wallet")
        elif item == 'delete_addr':
            addr_to_delete = get_arg(arguments, 1)
            DeleteAddress(self, self.Wallet, addr_to_delete)
        elif item == 'delete_token':
            token_to_delete = get_arg(arguments, 1)
            DeleteToken(self.Wallet, token_to_delete)
        elif item == 'close':
            self.do_close_wallet()
        elif item == 'claim':
            ClaimGas(self.Wallet, True, arguments[1:])
        elif item == 'rebuild':
            self.Wallet.Rebuild()
            try:
                item2 = int(get_arg(arguments, 1))
                if item2 and item2 > 0:
                    print("Restarting at %s" % item2)
                    self.Wallet._current_height = item2
            except Exception as e:
                pass
        elif item == 'tkn_send':
            token_send(self.Wallet, arguments[1:])
        elif item == 'tkn_send_from':
            token_send_from(self.Wallet, arguments[1:])
        elif item == 'tkn_send_blog':
            token_send_blog(self.Wallet, arguments[1:])
        elif item == 'tkn_approve':
            token_approve_allowance(self.Wallet, arguments[1:])
        elif item == 'tkn_allowance':
            token_get_allowance(self.Wallet, arguments[1:], verbose=True)
        elif item == 'tkn_mint':
            token_mint(self.Wallet, arguments[1:])
        elif item == 'tkn_register':
            token_crowdsale_register(self.Wallet, arguments[1:])
        elif item == 'unspent':
            ShowUnspentCoins(self.Wallet, arguments[1:])
        elif item == 'alias':
            if len(arguments) == 3:
                AddAlias(self.Wallet, arguments[1], arguments[2])
            else:
                print("Please supply an address and title")
        else:
            print("Wallet: '{}' is an invalid parameter".format(item))
コード例 #3
0
    def test_4_wallet_claim_ok(self):

        wallet = self.GetWallet3()

        claim = ClaimGas(wallet, require_password=False)

        self.assertTrue(claim)
コード例 #4
0
    def run(self):
        dbloop = task.LoopingCall(Blockchain.Default().PersistBlocks)
        dbloop.start(.1)
        Blockchain.Default().PersistBlocks()

        while Blockchain.Default().Height < 2:
            print("Waiting for chain to sync...")
            time.sleep(1)

        # Claim initial NEO
        address = "AK2nJJpJr6o664CWJKi1QRXjqeic2zRp8y"
        self.claim_initial_neo(address)

        # Open wallet again
        print("Opening wallet %s" % self.wallet_fn)
        self.wallet = UserWallet.Open(self.wallet_fn, to_aes_key("coz"))
        self.wallet.ProcessBlocks()
        self._walletdb_loop = task.LoopingCall(self.wallet.ProcessBlocks)
        self._walletdb_loop.start(1)
        # self.wallet.Rebuild()
        # print("\nOpened wallet. Rebuilding...")
        # time.sleep(10)

        print("\nWait %s min before claiming GAS." % self.min_wait)
        time.sleep(60 * self.min_wait)

        print("\nSending NEO to own wallet...")
        with patch('neo.Prompt.Commands.Send.prompt', side_effect=["coz"]):
            framework = construct_send_basic(self.wallet,
                                             ["neo", address, "100000000"])
            tx = process_transaction(self.wallet,
                                     contract_tx=framework[0],
                                     scripthash_from=framework[1],
                                     fee=framework[2],
                                     owners=framework[3],
                                     user_tx_attributes=framework[4])

        if not tx:
            print("Something went wrong, no tx.")
            return

        # Wait until transaction is on blockchain
        self.wait_for_tx(tx)

        print("Claiming the GAS...")
        claim_tx, relayed = ClaimGas(self.wallet, require_password=False)
        self.wait_for_tx(claim_tx)

        # Finally, need to rebuild the wallet
        self.wallet.Rebuild()

        print("\nAll done!")
        print("- Wallet file: %s" % self.wallet_fn)
        print("- Wallet pwd: %s" % self.wallet_pwd)

        if self.wif_fn:
            with open(self.wif_fn, "w") as f:
                f.write("KxDgvEKzgSBPPfuVfw67oPQBSjidEiqTHURKSDL1R7yGaGYAeYnr")

        self.quit()
コード例 #5
0
    def test_3_wallet_no_claimable_gas(self):

        wallet = self.GetWallet3()

        claim_tx, relayed = ClaimGas(wallet, require_password=False)

        self.assertFalse(relayed)
コード例 #6
0
    def test_4_wallet_claim_ok(self):

        wallet = self.GetWallet1()

        claim_tx, relayed = ClaimGas(wallet, require_password=False)
        self.assertIsInstance(claim_tx, ClaimTransaction)
        self.assertTrue(relayed)
コード例 #7
0
    def test_5_wallet_claim_ok(self):
        with patch('neo.Prompt.Commands.Wallet.prompt', side_effect=[UserWalletTestCase.wallet_1_pass()]):
            wallet = self.GetWallet1()

            claim_tx, relayed = ClaimGas(wallet)
            self.assertIsInstance(claim_tx, ClaimTransaction)
            self.assertTrue(relayed)
コード例 #8
0
    def run(self):
        dbloop = task.LoopingCall(Blockchain.Default().PersistBlocks)
        dbloop.start(.1)
        Blockchain.Default().PersistBlocks()

        while Blockchain.Default().Height < 2:
            print("Waiting for wallet to sync...")
            time.sleep(1)

        print("Creating Wallet...")
        self.wallet = UserWallet.Create(path=self.wallet_fn, password=self.wallet_pwd)
        self.wallet.ProcessBlocks()

        # Extract infos from wallet
        contract = self.wallet.GetDefaultContract()
        key = self.wallet.GetKey(contract.PublicKeyHash)
        address = key.GetAddress()
        wif = key.Export()
        print("- Address:", address)
        print("- WIF key:", wif)
        self.wallet = None

        # Claim initial NEO
        self.claim_initial_neo(address)

        # Open wallet again
        self.wallet = UserWallet.Open(self.wallet_fn, self.wallet_pwd)
        self._walletdb_loop = task.LoopingCall(self.wallet.ProcessBlocks)
        self._walletdb_loop.start(1)

        print("\nWait %s min before claiming GAS." % self.min_wait)
        time.sleep(60 * self.min_wait)

        print("\nSending NEO to own wallet...")
        tx = construct_and_send(None, self.wallet, ["neo", address, "100000000"], prompt_password=False)
        if not tx:
            print("Something went wrong, no tx.")
            return

        # Wait until transaction is on blockchain
        self.wait_for_tx(tx)

        print("Claiming the GAS...")
        claim_tx, relayed = ClaimGas(self.wallet, require_password=False)
        self.wait_for_tx(claim_tx)

        # Finally, need to rebuild the wallet
        self.wallet.Rebuild()

        print("\nAll done!")
        print("- WIF key: %s" % wif)
        print("- Wallet file: %s" % self.wallet_fn)
        print("- Wallet pwd: %s" % self.wallet_pwd)

        if self.wif_fn:
            with open(self.wif_fn, "w") as f:
                f.write(wif)

        self.quit()
コード例 #9
0
    def show_wallet(self, arguments):

        if not self.Wallet:
            print("please open a wallet")
            return

        item = get_arg(arguments)

        if not item:
            print("Wallet %s " % json.dumps(self.Wallet.ToJson(), indent=4))
            return

        if item in ['v', '--v', 'verbose']:
            print("Wallet %s " %
                  json.dumps(self.Wallet.ToJson(verbose=True), indent=4))
            return
        elif item == 'migrate' and self.Wallet is not None:
            self.Wallet.Migrate()
            print("migrated wallet")
        elif item == 'delete_addr':
            addr_to_delete = get_arg(arguments, 1)
            DeleteAddress(self, self.Wallet, addr_to_delete)
        elif item == 'delete_token':
            token_to_delete = get_arg(arguments, 1)
            DeleteToken(self.Wallet, token_to_delete)
        elif item == 'close':
            self.do_close_wallet()
        elif item == 'claim':
            ClaimGas(self.Wallet)
        elif item == 'rebuild':
            self.Wallet.Rebuild()
            #            self._walletdb_loop = task.LoopingCall(self.Wallet.ProcessBlocks)
            #            self._walletdb_loop.start(1)
            try:
                item2 = int(get_arg(arguments, 1))
                if item2 and item2 > 0:
                    print('restarting at %s ' % item2)
                    self.Wallet._current_height = item2
            except Exception as e:
                pass
        elif item == 'tkn_send':
            token_send(self.Wallet, arguments[1:])
        elif item == 'tkn_send_from':
            token_send_from(self.Wallet, arguments[1:])
        elif item == 'tkn_approve':
            token_approve_allowance(self.Wallet, arguments[1:])
        elif item == 'tkn_allowance':
            token_get_allowance(self.Wallet, arguments[1:], verbose=True)
        elif item == 'tkn_mint':
            token_mint(self.Wallet, arguments[1:])
        elif item == 'tkn_register':
            token_crowdsale_register(self.Wallet, arguments[1:])
        elif item == 'alias':
            if len(arguments) == 3:
                AddAlias(self.Wallet, arguments[1], arguments[2])
            else:
                print("Please supply an address and title")
コード例 #10
0
    def test_4_keyboard_interupt(self):
        with patch('sys.stdout', new=StringIO()) as mock_print:
            with patch('neo.Prompt.Commands.Wallet.prompt', side_effect=[KeyboardInterrupt]):
                wallet = self.GetWallet1()

                claim_tx, relayed = ClaimGas(wallet)
                self.assertEqual(claim_tx, None)
                self.assertFalse(relayed)
                self.assertIn("Claim transaction cancelled", mock_print.getvalue())
コード例 #11
0
    def run(self):
        dbloop = task.LoopingCall(Blockchain.Default().PersistBlocks)
        dbloop.start(.1)
        Blockchain.Default().PersistBlocks()

        while Blockchain.Default().Height < 2:
            print("Waiting for chain to sync...")
            time.sleep(1)

        # Claim initial MFF
        address = "AK2nJJpJr6o664CWJKi1QRXjqeic2zRp8y"
        self.claim_initial_neo(address)

        # Open wallet again
        print("Opening wallet %s" % self.wallet_fn)
        self.wallet = UserWallet.Open(self.wallet_fn, to_aes_key("coz"))
        self.wallet.ProcessBlocks()
        self._walletdb_loop = task.LoopingCall(self.wallet.ProcessBlocks)
        self._walletdb_loop.start(1)
        # self.wallet.Rebuild()
        # print("\nOpened wallet. Rebuilding...")
        # time.sleep(10)

        print("\nWait %s min before claiming GAS." % self.min_wait)
        time.sleep(60 * self.min_wait)

        print("\nSending MFF to own wallet...")
        tx = construct_and_send(None,
                                self.wallet, ["neo", address, "100000000"],
                                prompt_password=False)
        if not tx:
            print("Something went wrong, no tx.")
            return

        # Wait until transaction is on blockchain
        self.wait_for_tx(tx)

        print("Claiming the GAS...")
        claim_tx, relayed = ClaimGas(self.wallet, require_password=False)
        self.wait_for_tx(claim_tx)

        # Finally, need to rebuild the wallet
        self.wallet.Rebuild()

        print("\nAll done!")
        print("- Wallet file: %s" % self.wallet_fn)
        print("- Wallet pwd: %s" % self.wallet_pwd)

        if self.wif_fn:
            with open(self.wif_fn, "w") as f:
                f.write("KxDgvEKzgSBPPfuVfw67oPQBSjidEiqTHURKSDL1R7yGaGYAeYnr")

        self.quit()
コード例 #12
0
    def test_5_wallet_claim_ok(self):

        wallet = self.GetWallet1()
        nodemgr = NodeManager()
        nodemgr.nodes = [NeoNode(object, object)]

        with patch('neo.Network.node.NeoNode.relay',
                   return_value=self.async_return(True)):
            with patch('neo.Prompt.Commands.Wallet.prompt',
                       return_value=self.wallet_1_pass()):
                claim_tx, relayed = ClaimGas(wallet)
                self.assertIsInstance(claim_tx, ClaimTransaction)
                self.assertTrue(relayed)
コード例 #13
0
    def run(self):
        dbloop = task.LoopingCall(Blockchain.Default().PersistBlocks)
        dbloop.start(.1)
        Blockchain.Default().PersistBlocks()

        while Blockchain.Default().Height < 2:
            print("Waiting for chain to sync...")
            time.sleep(1)

        # Open wallet again
        print("Opening wallet %s" % self.wallet_fn)
        self.wallet = UserWallet.Open(self.wallet_fn, to_aes_key("coz"))
        self.wallet.ProcessBlocks()
        self._walletdb_loop = task.LoopingCall(self.wallet.ProcessBlocks)
        self._walletdb_loop.start(1)

        print("\nWait %s min before claiming GAS." % self.min_wait)
        time.sleep(60 * self.min_wait)

        self.wallet.Rebuild()
        print("\nRebuilding wallet...")
        time.sleep(20)

        print("\nSending NEO to own wallet...")
        address = "AK2nJJpJr6o664CWJKi1QRXjqeic2zRp8y"
        with patch('neo.Prompt.Commands.Send.prompt', side_effect=["coz"]):
            framework = construct_send_basic(self.wallet,
                                             ["neo", address, "100000000"])
            tx = process_transaction(self.wallet,
                                     contract_tx=framework[0],
                                     scripthash_from=framework[1],
                                     fee=framework[2],
                                     owners=framework[3],
                                     user_tx_attributes=framework[4])

        if not tx:
            print("Something went wrong, no tx.")
            return

        # Wait until transaction is on blockchain
        self.wait_for_tx(tx)

        print("Claiming the GAS...")
        claim_tx, relayed = ClaimGas(self.wallet, require_password=False)
        self.wait_for_tx(claim_tx)

        # Finally, need to rebuild the wallet
        # self.wallet.Rebuild()
        self.quit()
コード例 #14
0
    def show_wallet(self, arguments):

        if not self.Wallet:
            print("please open a wallet")
            return

        item = get_arg(arguments)

        if not item:
            print("Wallet %s " % json.dumps(self.Wallet.ToJson(), indent=4))
            return

        if item in ['v', '--v', 'verbose']:
            print("Wallet %s " %
                  json.dumps(self.Wallet.ToJson(verbose=True), indent=4))
            return
        elif item == 'migrate' and self.Wallet is not None:
            self.Wallet.Migrate()
            print("migrated wallet")
        elif item == 'delete_addr':
            addr_to_delete = get_arg(arguments, 1)
            DeleteAddress(self, self.Wallet, addr_to_delete)
        elif item == 'delete_token':
            token_to_delete = get_arg(arguments, 1)
            DeleteToken(self.Wallet, token_to_delete)
        elif item == 'close':
            self.do_close_wallet()
        elif item == 'claim':
            ClaimGas(self.Wallet)
        elif item == 'rebuild':
            self.Wallet.Rebuild()
            try:
                item2 = int(get_arg(arguments, 1))
                if item2 and item2 > 0:
                    print('restarting at %s ' % item2)
                    self.Wallet._current_height = item2
            except Exception as e:
                pass
        elif item == 'tkn_send':
            token_send(self.Wallet, arguments[1:])
        elif item == 'tkn_send_from':
            token_send_from(self.Wallet, arguments[1:])
        elif item == 'tkn_approve':
            token_approve_allowance(self.Wallet, arguments[1:])
        elif item == 'tkn_allowance':
            token_get_allowance(self.Wallet, arguments[1:], verbose=True)
コード例 #15
0
    def run(self):
        dbloop = task.LoopingCall(Blockchain.Default().PersistBlocks)
        dbloop.start(.1)
        Blockchain.Default().PersistBlocks()

        while Blockchain.Default().Height < 2:
            print("Waiting for chain to sync...")
            time.sleep(1)

        # Open wallet again
        print("Opening wallet %s" % self.wallet_fn)
        self.wallet = UserWallet.Open(self.wallet_fn, to_aes_key("coz"))
        self.wallet.ProcessBlocks()
        self._walletdb_loop = task.LoopingCall(self.wallet.ProcessBlocks)
        self._walletdb_loop.start(1)

        print("\nWait %s min before claiming GAS." % self.min_wait)
        time.sleep(60 * self.min_wait)

        self.wallet.Rebuild()
        print("\nRebuilding wallet...")
        time.sleep(20)

        print("\nSending MFF to own wallet...")
        address = "AK2nJJpJr6o664CWJKi1QRXjqeic2zRp8y"
        tx = construct_and_send(None,
                                self.wallet, ["neo", address, "100000000"],
                                prompt_password=False)
        if not tx:
            print("Something went wrong, no tx.")
            return

        # Wait until transaction is on blockchain
        self.wait_for_tx(tx)

        print("Claiming the GAS...")
        claim_tx, relayed = ClaimGas(self.wallet, require_password=False)
        self.wait_for_tx(claim_tx)

        # Finally, need to rebuild the wallet
        # self.wallet.Rebuild()
        self.quit()
コード例 #16
0
 def test_5_no_wallet(self):
     claim_tx, relayed = ClaimGas(None, require_password=False)
     self.assertEqual(claim_tx, None)
     self.assertFalse(relayed)
コード例 #17
0
 def test_6_no_wallet(self):
     with patch('neo.Prompt.Commands.Wallet.prompt',
                return_value=self.wallet_1_pass()):
         claim_tx, relayed = ClaimGas(None)
         self.assertEqual(claim_tx, None)
         self.assertFalse(relayed)
コード例 #18
0
 def test_7_no_wallet(self):
     claim_tx, relayed = ClaimGas(None)
     self.assertEqual(claim_tx, None)
     self.assertFalse(relayed)
コード例 #19
0
 def claim_gas(self):
     """ Claim gas from the wallet associated with the API. """
     if self.wallet is None:
         self.open_wallet()
     ClaimGas(self.wallet)
     self.close_wallet()
コード例 #20
0
    def show_wallet(self, arguments):
        if not self.Wallet:
            print("Please open a wallet")
            return

        item = get_arg(arguments)

        if not item:
            print("Wallet %s " % json.dumps(self.Wallet.ToJson(), indent=4))
            return

        if item in ['v', '--v', 'verbose']:
            print("Wallet %s " %
                  json.dumps(self.Wallet.ToJson(verbose=True), indent=4))
            return
        elif item == 'migrate' and self.Wallet is not None:
            self.Wallet.Migrate()
            print("Migrated wallet")
        elif item == 'delete_addr':
            addr_to_delete = get_arg(arguments, 1)
            DeleteAddress(self, self.Wallet, addr_to_delete)
        elif item == 'delete_token':
            token_to_delete = get_arg(arguments, 1)
            DeleteToken(self.Wallet, token_to_delete)
        elif item == 'close':
            self.do_close_wallet()
        elif item == 'claim':
            ClaimGas(self.Wallet, True, arguments[1:])
        elif item == 'rebuild':
            self.Wallet.Rebuild()
            try:
                item2 = int(get_arg(arguments, 1))
                item2 = Blockchain.Default().Height
                if item2 and item2 > 0:
                    print("Restarting at %s" % item2)
                    self.Wallet._current_height = item2

                #TODO - NeoCompiler.io syncing process - BEGINS
                print(
                    "Waiting, at least, 30 seconds, for wallet to sync and rebuild..."
                )
                #time.sleep(30)
                timenow = time.time()
                timebase = time.time()
                while (timenow - timebase < 30):
                    timenow = time.time()
                walletheight = self.Wallet._current_height
                blockchainheight = max(Blockchain.Default().HeaderHeight,
                                       Blockchain.Default().Height)
                while (walletheight < blockchainheight):
                    walletheight = self.Wallet._current_height
                    blockchainheight = max(Blockchain.Default().HeaderHeight,
                                           Blockchain.Default().Height)
                #TODO - NeoCompiler.io syncing process - ENDS
            except Exception as e:
                print("Problems happened when rebuilding %s" % e)
                pass
        elif item == 'tkn_send':
            token_send(self.Wallet, arguments[1:])
        elif item == 'tkn_send_from':
            token_send_from(self.Wallet, arguments[1:])
        elif item == 'tkn_approve':
            token_approve_allowance(self.Wallet, arguments[1:])
        elif item == 'tkn_allowance':
            token_get_allowance(self.Wallet, arguments[1:], verbose=True)
        elif item == 'tkn_mint':
            token_mint(self.Wallet, arguments[1:])
        elif item == 'tkn_register':
            token_crowdsale_register(self.Wallet, arguments[1:])
        elif item == 'unspent':
            ShowUnspentCoins(self.Wallet, arguments[1:])
        elif item == 'alias':
            if len(arguments) == 3:
                AddAlias(self.Wallet, arguments[1], arguments[2])
            else:
                print("Please supply an address and title")
        else:
            print("Wallet: '{}' is an invalid parameter".format(item))