You're not grabbing a valid blockhash:
tx.recentBlockhash = Keypair.generate().publicKey.toString();
Try replacing it with a recent blockhashhblockhash:
let latestBlockhash = await connection.getLatestBlockhash('finalized');
tx.recentBlockhash = latestBlockhash.blockhash;