I have a vast amount of Ethereum wallets, all packed with Ether. I need to transfer all the Ether to a single account. I don't want to do it manually. Is there a way to script it or use a smart contract or anything else?
There is going to be a level of manual work that will be unavoidable since each wallet will need to be recognized and unlocked via a private key.
You could use web3 and some sort of key/value formatted data and loop through that to unlock and send the ether balance (minus gas) to whatever account you want to send it too.
You can use web3js or web3py, as you do not seem to have the accounts linked to a node with a json file per account, you can use web3 to get the balance of each account then build the transaction locally, sign it with the corresponding private_key and send sendRawTransaction. Then repeat for every account.
You can see how to sign using your private key and send raw transactions here
I also have a similar sort of situation. I have a HD wallet and many of the child address will have ethereum. So my plan is:
Loop through each index (address) in HD wallet and check balance. If balance found create a send transaction with locally signed and keep it in memory. At the end of processing, send all the transaction as batch to an Ethereum node.
Is this the right/best approach?
I am creating a crypto exchange and I am giving each customer a address from my HD wallet (using index) and so I can recover all eth from HD wallet which will have eth from multiple customers. Please suggest, if this is the right approach?